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:
parent
83732c285b
commit
e06c4e59b3
15
Grow.c
15
Grow.c
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue