Grow: add check that there are enough devices.

The check for 'enough spares' doesn't apply to RAID0 as we don't
mind it going degraded.  But add a test that there are enough spares
to actually produce a working array.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2011-03-09 18:37:00 +11:00
parent 83732c285b
commit e06c4e59b3
1 changed files with 15 additions and 0 deletions

15
Grow.c
View File

@ -1675,6 +1675,7 @@ static int reshape_array(char *container, int fd, char *devname,
* freeze_array and freeze_container.
*/
sysfs_freeze_array(info);
/* Check we have enough spares to not be degraded */
spares_needed = max(reshape.before.data_disks,
reshape.after.data_disks)
+ reshape.parity - array.raid_disks;
@ -1691,6 +1692,20 @@ static int reshape_array(char *container, int fd, char *devname,
info->array.spare_disks);
goto release;
}
/* Check we have enough spares to not fail */
spares_needed = max(reshape.before.data_disks,
reshape.after.data_disks)
- array.raid_disks;
if ((info->new_level > 1 || info->new_level == 0) &&
spares_needed > info->array.spare_disks) {
fprintf(stderr,
Name ": Need %d spare%s to create working array,"
" and only have %d.\n",
spares_needed,
spares_needed == 1 ? "" : "s",
info->array.spare_disks);
goto release;
}
if (reshape.level != info->array.level) {
char *c = map_num(pers, reshape.level);