diff options
author | Dan Williams <dan.j.williams@intel.com> | 2009-03-17 18:10:40 -0700 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-03-31 14:57:49 +1100 |
commit | 80c3a6ce4ba4470379b9e6a4d9bcd9d2ee26ae03 (patch) | |
tree | de88622f05a7e681ac7bff7714e8f2d8953b66ac /drivers/md/raid5.c | |
parent | 93ed05e2a56b5ee06c0100a169433b11c4aa5d0b (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/raid5.c')
-rw-r--r-- | drivers/md/raid5.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 70b50af2bcd7..2cd619ff0761 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -4166,6 +4166,20 @@ static struct attribute_group raid5_attrs_group = { .attrs = raid5_attrs, }; +static sector_t +raid5_size(mddev_t *mddev, sector_t sectors, int raid_disks) +{ + raid5_conf_t *conf = mddev_to_conf(mddev); + + if (!sectors) + sectors = mddev->dev_sectors; + if (!raid_disks) + raid_disks = conf->previous_raid_disks; + + sectors &= ~((sector_t)mddev->chunk_size/512 - 1); + return sectors * (raid_disks - conf->max_degraded); +} + static raid5_conf_t *setup_conf(mddev_t *mddev) { raid5_conf_t *conf; @@ -4460,8 +4474,7 @@ static int run(mddev_t *mddev) mddev->queue->backing_dev_info.congested_data = mddev; mddev->queue->backing_dev_info.congested_fn = raid5_congested; - mddev->array_sectors = mddev->dev_sectors * - (conf->previous_raid_disks - conf->max_degraded); + mddev->array_sectors = raid5_size(mddev, 0, 0); blk_queue_merge_bvec(mddev->queue, raid5_mergeable_bvec); @@ -4684,11 +4697,8 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors) * any io in the removed space completes, but it hardly seems * worth it. */ - raid5_conf_t *conf = mddev_to_conf(mddev); - sectors &= ~((sector_t)mddev->chunk_size/512 - 1); - mddev->array_sectors = sectors * (mddev->raid_disks - - conf->max_degraded); + mddev->array_sectors = raid5_size(mddev, sectors, mddev->raid_disks); set_capacity(mddev->gendisk, mddev->array_sectors); mddev->changed = 1; if (sectors > mddev->dev_sectors && mddev->recovery_cp == MaxSector) { @@ -4824,10 +4834,12 @@ static void end_reshape(raid5_conf_t *conf) struct block_device *bdev; if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) { - conf->mddev->array_sectors = conf->mddev->dev_sectors * - (conf->raid_disks - conf->max_degraded); - set_capacity(conf->mddev->gendisk, conf->mddev->array_sectors); - conf->mddev->changed = 1; + mddev_t *mddev = conf->mddev; + + mddev->array_sectors = raid5_size(mddev, 0, conf->raid_disks); + set_capacity(mddev->gendisk, mddev->array_sectors); + mddev->changed = 1; + conf->previous_raid_disks = conf->raid_disks; bdev = bdget_disk(conf->mddev->gendisk, 0); if (bdev) { @@ -5076,6 +5088,7 @@ static struct mdk_personality raid6_personality = .spare_active = raid5_spare_active, .sync_request = sync_request, .resize = raid5_resize, + .size = raid5_size, #ifdef CONFIG_MD_RAID5_RESHAPE .check_reshape = raid5_check_reshape, .start_reshape = raid5_start_reshape, @@ -5098,6 +5111,7 @@ static struct mdk_personality raid5_personality = .spare_active = raid5_spare_active, .sync_request = sync_request, .resize = raid5_resize, + .size = raid5_size, #ifdef CONFIG_MD_RAID5_RESHAPE .check_reshape = raid5_check_reshape, .start_reshape = raid5_start_reshape, @@ -5122,6 +5136,7 @@ static struct mdk_personality raid4_personality = .spare_active = raid5_spare_active, .sync_request = sync_request, .resize = raid5_resize, + .size = raid5_size, #ifdef CONFIG_MD_RAID5_RESHAPE .check_reshape = raid5_check_reshape, .start_reshape = raid5_start_reshape, |