aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid5.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/raid5.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/raid5.c')
-rw-r--r--drivers/md/raid5.c35
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 = {
4166 .attrs = raid5_attrs, 4166 .attrs = raid5_attrs,
4167}; 4167};
4168 4168
4169static sector_t
4170raid5_size(mddev_t *mddev, sector_t sectors, int raid_disks)
4171{
4172 raid5_conf_t *conf = mddev_to_conf(mddev);
4173
4174 if (!sectors)
4175 sectors = mddev->dev_sectors;
4176 if (!raid_disks)
4177 raid_disks = conf->previous_raid_disks;
4178
4179 sectors &= ~((sector_t)mddev->chunk_size/512 - 1);
4180 return sectors * (raid_disks - conf->max_degraded);
4181}
4182
4169static raid5_conf_t *setup_conf(mddev_t *mddev) 4183static raid5_conf_t *setup_conf(mddev_t *mddev)
4170{ 4184{
4171 raid5_conf_t *conf; 4185 raid5_conf_t *conf;
@@ -4460,8 +4474,7 @@ static int run(mddev_t *mddev)
4460 mddev->queue->backing_dev_info.congested_data = mddev; 4474 mddev->queue->backing_dev_info.congested_data = mddev;
4461 mddev->queue->backing_dev_info.congested_fn = raid5_congested; 4475 mddev->queue->backing_dev_info.congested_fn = raid5_congested;
4462 4476
4463 mddev->array_sectors = mddev->dev_sectors * 4477 mddev->array_sectors = raid5_size(mddev, 0, 0);
4464 (conf->previous_raid_disks - conf->max_degraded);
4465 4478
4466 blk_queue_merge_bvec(mddev->queue, raid5_mergeable_bvec); 4479 blk_queue_merge_bvec(mddev->queue, raid5_mergeable_bvec);
4467 4480
@@ -4684,11 +4697,8 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors)
4684 * any io in the removed space completes, but it hardly seems 4697 * any io in the removed space completes, but it hardly seems
4685 * worth it. 4698 * worth it.
4686 */ 4699 */
4687 raid5_conf_t *conf = mddev_to_conf(mddev);
4688
4689 sectors &= ~((sector_t)mddev->chunk_size/512 - 1); 4700 sectors &= ~((sector_t)mddev->chunk_size/512 - 1);
4690 mddev->array_sectors = sectors * (mddev->raid_disks 4701 mddev->array_sectors = raid5_size(mddev, sectors, mddev->raid_disks);
4691 - conf->max_degraded);
4692 set_capacity(mddev->gendisk, mddev->array_sectors); 4702 set_capacity(mddev->gendisk, mddev->array_sectors);
4693 mddev->changed = 1; 4703 mddev->changed = 1;
4694 if (sectors > mddev->dev_sectors && mddev->recovery_cp == MaxSector) { 4704 if (sectors > mddev->dev_sectors && mddev->recovery_cp == MaxSector) {
@@ -4824,10 +4834,12 @@ static void end_reshape(raid5_conf_t *conf)
4824 struct block_device *bdev; 4834 struct block_device *bdev;
4825 4835
4826 if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) { 4836 if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) {
4827 conf->mddev->array_sectors = conf->mddev->dev_sectors * 4837 mddev_t *mddev = conf->mddev;
4828 (conf->raid_disks - conf->max_degraded); 4838
4829 set_capacity(conf->mddev->gendisk, conf->mddev->array_sectors); 4839 mddev->array_sectors = raid5_size(mddev, 0, conf->raid_disks);
4830 conf->mddev->changed = 1; 4840 set_capacity(mddev->gendisk, mddev->array_sectors);
4841 mddev->changed = 1;
4842 conf->previous_raid_disks = conf->raid_disks;
4831 4843
4832 bdev = bdget_disk(conf->mddev->gendisk, 0); 4844 bdev = bdget_disk(conf->mddev->gendisk, 0);
4833 if (bdev) { 4845 if (bdev) {
@@ -5076,6 +5088,7 @@ static struct mdk_personality raid6_personality =
5076 .spare_active = raid5_spare_active, 5088 .spare_active = raid5_spare_active,
5077 .sync_request = sync_request, 5089 .sync_request = sync_request,
5078 .resize = raid5_resize, 5090 .resize = raid5_resize,
5091 .size = raid5_size,
5079#ifdef CONFIG_MD_RAID5_RESHAPE 5092#ifdef CONFIG_MD_RAID5_RESHAPE
5080 .check_reshape = raid5_check_reshape, 5093 .check_reshape = raid5_check_reshape,
5081 .start_reshape = raid5_start_reshape, 5094 .start_reshape = raid5_start_reshape,
@@ -5098,6 +5111,7 @@ static struct mdk_personality raid5_personality =
5098 .spare_active = raid5_spare_active, 5111 .spare_active = raid5_spare_active,
5099 .sync_request = sync_request, 5112 .sync_request = sync_request,
5100 .resize = raid5_resize, 5113 .resize = raid5_resize,
5114 .size = raid5_size,
5101#ifdef CONFIG_MD_RAID5_RESHAPE 5115#ifdef CONFIG_MD_RAID5_RESHAPE
5102 .check_reshape = raid5_check_reshape, 5116 .check_reshape = raid5_check_reshape,
5103 .start_reshape = raid5_start_reshape, 5117 .start_reshape = raid5_start_reshape,
@@ -5122,6 +5136,7 @@ static struct mdk_personality raid4_personality =
5122 .spare_active = raid5_spare_active, 5136 .spare_active = raid5_spare_active,
5123 .sync_request = sync_request, 5137 .sync_request = sync_request,
5124 .resize = raid5_resize, 5138 .resize = raid5_resize,
5139 .size = raid5_size,
5125#ifdef CONFIG_MD_RAID5_RESHAPE 5140#ifdef CONFIG_MD_RAID5_RESHAPE
5126 .check_reshape = raid5_check_reshape, 5141 .check_reshape = raid5_check_reshape,
5127 .start_reshape = raid5_start_reshape, 5142 .start_reshape = raid5_start_reshape,