]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow: fix reshape-array for shrinking reshapes.
authorNeilBrown <neilb@suse.de>
Thu, 22 Dec 2011 19:59:48 +0000 (06:59 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 22 Dec 2011 19:59:48 +0000 (06:59 +1100)
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>
Grow.c

diff --git a/Grow.c b/Grow.c
index cda780285cc99c63abd7016d84861ffac3cce163..e9867c8c80e8d4872b853fb27ae08bb6cdeeea06 100644 (file)
--- 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;