]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow: be extra careful about races when freezing an array
authorNeilBrown <neilb@suse.de>
Wed, 15 Dec 2010 22:07:51 +0000 (09:07 +1100)
committerNeilBrown <neilb@suse.de>
Wed, 15 Dec 2010 22:07:51 +0000 (09:07 +1100)
If any subarray has any spare devices, then something raced,
and we should abort the reshape.

Signed-off-by: NeilBrown <neilb@suse.de>
msg.c

diff --git a/msg.c b/msg.c
index 5511ecdb75af3b752ebc79aeedadedefc155ad45..7bd85f8154477a6d009ab2bcd9fec9833fa11ab6 100644 (file)
--- a/msg.c
+++ b/msg.c
@@ -348,8 +348,19 @@ int block_monitor(char *container, const int freeze)
                     sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0 &&
                     strcmp(buf, "frozen\n") == 0))
                        /* pass */;
-               else
+               else {
+                       unblock_subarray(sra, 0);
                        break;
+               }
+               /* Double check against races - there should be no spares
+                * or part-spares
+                */
+               sysfs_free(sra);
+               sra = sysfs_read(-1, e->devnum, GET_DEVS | GET_STATE);
+               if (sra && sra->array.spare_disks > 0) {
+                       unblock_subarray(sra, freeze);
+                       break;
+               }
        }
 
        if (e) {