Grow: fix reshape-array for shrinking reshapes.

The value in info->array.raid_disks is the total number of
devices, which is the 'after' number when the number is increasing,
and the 'before' number when the number is decreasing.

The code currently assumes it is always the 'after' number - so fix
that.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2011-12-23 06:59:48 +11:00
parent 27a1e5b5a4
commit ce4783d3d6
1 changed files with 5 additions and 3 deletions

8
Grow.c
View File

@ -1891,10 +1891,12 @@ static int reshape_array(char *container, int fd, char *devname,
if (info->reshape_active) {
int new_level = info->new_level;
info->new_level = UnSet;
info->array.raid_disks -= info->delta_disks;
if (info->delta_disks > 0)
info->array.raid_disks -= info->delta_disks;
msg = analyse_change(info, &reshape);
info->new_level = new_level;
info->array.raid_disks += info->delta_disks;
if (info->delta_disks > 0)
info->array.raid_disks += info->delta_disks;
if (!restart)
/* Make sure the array isn't read-only */
ioctl(fd, RESTART_ARRAY_RW, 0);
@ -1908,7 +1910,7 @@ static int reshape_array(char *container, int fd, char *devname,
(reshape.level != info->array.level ||
reshape.before.layout != info->array.layout ||
reshape.before.data_disks + reshape.parity
!= info->array.raid_disks - info->delta_disks)) {
!= info->array.raid_disks - max(0, info->delta_disks))) {
fprintf(stderr, Name ": reshape info is not in native format -"
" cannot continue.\n");
goto release;