From: NeilBrown Date: Thu, 22 Dec 2011 19:59:48 +0000 (+1100) Subject: Grow: fix reshape-array for shrinking reshapes. X-Git-Tag: mdadm-3.2.3~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce4783d3d60af3b89e4d06a6948a972d3e1c87cd;p=thirdparty%2Fmdadm.git 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 --- diff --git a/Grow.c b/Grow.c index cda78028..e9867c8c 100644 --- a/Grow.c +++ b/Grow.c @@ -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;