aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid10.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-03-17 21:10:40 -0400
committerDan Williams <dan.j.williams@intel.com>2009-03-30 23:57:49 -0400
commit80c3a6ce4ba4470379b9e6a4d9bcd9d2ee26ae03 (patch)
treede88622f05a7e681ac7bff7714e8f2d8953b66ac /drivers/md/raid10.c
parent93ed05e2a56b5ee06c0100a169433b11c4aa5d0b (diff)
md: add 'size' as a personality method
In preparation for giving userspace control over ->array_sectors we need to be able to retrieve the 'default' size, and the 'anticipated' size when a reshape is requested. For personalities that do not reshape emit a warning if anything but the default size is requested. In the raid5 case we need to update ->previous_raid_disks to make the new 'default' size available. Reviewed-by: Andre Noll <maan@systemlinux.org> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/md/raid10.c')
-rw-r--r--drivers/md/raid10.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index c2059e25d03f..5bf1b24ae802 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2023,6 +2023,25 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
2023 goto skipped; 2023 goto skipped;
2024} 2024}
2025 2025
2026static sector_t
2027raid10_size(mddev_t *mddev, sector_t sectors, int raid_disks)
2028{
2029 sector_t size;
2030 conf_t *conf = mddev_to_conf(mddev);
2031
2032 if (!raid_disks)
2033 raid_disks = mddev->raid_disks;
2034 if (!sectors)
2035 sectors = mddev->dev_sectors;
2036
2037 size = sectors >> conf->chunk_shift;
2038 sector_div(size, conf->far_copies);
2039 size = size * raid_disks;
2040 sector_div(size, conf->near_copies);
2041
2042 return size << conf->chunk_shift;
2043}
2044
2026static int run(mddev_t *mddev) 2045static int run(mddev_t *mddev)
2027{ 2046{
2028 conf_t *conf; 2047 conf_t *conf;
@@ -2174,8 +2193,8 @@ static int run(mddev_t *mddev)
2174 /* 2193 /*
2175 * Ok, everything is just fine now 2194 * Ok, everything is just fine now
2176 */ 2195 */
2177 mddev->array_sectors = size << conf->chunk_shift; 2196 mddev->array_sectors = raid10_size(mddev, 0, 0);
2178 mddev->resync_max_sectors = size << conf->chunk_shift; 2197 mddev->resync_max_sectors = mddev->array_sectors;
2179 2198
2180 mddev->queue->unplug_fn = raid10_unplug; 2199 mddev->queue->unplug_fn = raid10_unplug;
2181 mddev->queue->backing_dev_info.congested_fn = raid10_congested; 2200 mddev->queue->backing_dev_info.congested_fn = raid10_congested;
@@ -2261,6 +2280,7 @@ static struct mdk_personality raid10_personality =
2261 .spare_active = raid10_spare_active, 2280 .spare_active = raid10_spare_active,
2262 .sync_request = sync_request, 2281 .sync_request = sync_request,
2263 .quiesce = raid10_quiesce, 2282 .quiesce = raid10_quiesce,
2283 .size = raid10_size,
2264}; 2284};
2265 2285
2266static int __init raid_init(void) 2286static int __init raid_init(void)