diff options
author | NeilBrown <neilb@suse.de> | 2012-03-19 12:46:40 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-03-19 12:46:40 +1100 |
commit | 006a09a0ae0a494473a8cd82c8d1d653e37e6663 (patch) | |
tree | 169c59f77ef89e1c7cfb727249d60de88370fe79 /drivers/md | |
parent | 6b740b8d79252f13bcb7e5d3c1d43157e78a81e7 (diff) | |
download | talos-op-linux-006a09a0ae0a494473a8cd82c8d1d653e37e6663.tar.gz talos-op-linux-006a09a0ae0a494473a8cd82c8d1d653e37e6663.zip |
md/raid10 - support resizing some RAID10 arrays.
'resizing' an array in this context means making use of extra
space that has become available in component devices, not adding new
devices.
It also includes shrinking the array to take up less space of
component devices.
This is not supported for array with a 'far' layout. However
for 'near' and 'offset' layout arrays, adding and removing space at
the end of the devices is easy to support, and this patch provides
that support.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/raid10.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index e4a66ab6b0fb..3540316886f2 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3436,6 +3436,43 @@ static void raid10_quiesce(struct mddev *mddev, int state) } } +static int raid10_resize(struct mddev *mddev, sector_t sectors) +{ + /* Resize of 'far' arrays is not supported. + * For 'near' and 'offset' arrays we can set the + * number of sectors used to be an appropriate multiple + * of the chunk size. + * For 'offset', this is far_copies*chunksize. + * For 'near' the multiplier is the LCM of + * near_copies and raid_disks. + * So if far_copies > 1 && !far_offset, fail. + * Else find LCM(raid_disks, near_copy)*far_copies and + * multiply by chunk_size. Then round to this number. + * This is mostly done by raid10_size() + */ + struct r10conf *conf = mddev->private; + sector_t oldsize, size; + + if (conf->far_copies > 1 && !conf->far_offset) + return -EINVAL; + + oldsize = raid10_size(mddev, 0, 0); + size = raid10_size(mddev, sectors, 0); + md_set_array_sectors(mddev, size); + if (mddev->array_sectors > size) + return -EINVAL; + set_capacity(mddev->gendisk, mddev->array_sectors); + revalidate_disk(mddev->gendisk); + if (sectors > mddev->dev_sectors && + mddev->recovery_cp > oldsize) { + mddev->recovery_cp = oldsize; + set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); + } + mddev->dev_sectors = sectors; + mddev->resync_max_sectors = size; + return 0; +} + static void *raid10_takeover_raid0(struct mddev *mddev) { struct md_rdev *rdev; @@ -3505,6 +3542,7 @@ static struct md_personality raid10_personality = .sync_request = sync_request, .quiesce = raid10_quiesce, .size = raid10_size, + .resize = raid10_resize, .takeover = raid10_takeover, }; |