diff options
author | NeilBrown <neilb@suse.de> | 2009-03-31 00:10:36 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-03-31 00:10:36 -0400 |
commit | 7ec0547838976d088dfb9cb0adb073e6e8a15aa3 (patch) | |
tree | 32f2d5aa5d112e99bebbfb9bfde49ba82b66809d | |
parent | 34e04e87fb8b2c62c9e8868f41c8179d0e15f51a (diff) |
md/raid5: enhance raid5_size to work correctly with negative delta_disks
This is the first of four patches which combine to allow md/raid5 to
reduce the number of devices in the array by restriping the data over
a subset of the devices.
If the number of disks in a raid4/5/6 is being reduced, then the
default size must be based on the new number, not the old number
of devices.
In general, it should be based on the smaller of new and old.
Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r-- | drivers/md/raid5.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 3930b3e9aa04..5694eb8941b6 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -4169,8 +4169,13 @@ raid5_size(mddev_t *mddev, sector_t sectors, int raid_disks) | |||
4169 | 4169 | ||
4170 | if (!sectors) | 4170 | if (!sectors) |
4171 | sectors = mddev->dev_sectors; | 4171 | sectors = mddev->dev_sectors; |
4172 | if (!raid_disks) | 4172 | if (!raid_disks) { |
4173 | raid_disks = conf->previous_raid_disks; | 4173 | /* size is defined by the smallest of previous and new size */ |
4174 | if (conf->raid_disks < conf->previous_raid_disks) | ||
4175 | raid_disks = conf->raid_disks; | ||
4176 | else | ||
4177 | raid_disks = conf->previous_raid_disks; | ||
4178 | } | ||
4174 | 4179 | ||
4175 | sectors &= ~((sector_t)mddev->chunk_size/512 - 1); | 4180 | sectors &= ~((sector_t)mddev->chunk_size/512 - 1); |
4176 | return sectors * (raid_disks - conf->max_degraded); | 4181 | return sectors * (raid_disks - conf->max_degraded); |