]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Improve shutdown for container-based arrays.
authorNeil Brown <neilb@suse.de>
Sat, 12 Jul 2008 10:27:42 +0000 (20:27 +1000)
committerNeil Brown <neilb@suse.de>
Sat, 12 Jul 2008 10:27:42 +0000 (20:27 +1000)
1/ close a race where multiple arrays disappear at once
   and monitor isn't woken up to find out that the last one
   has gone.
2/ "mdadm -Ss" needs to pause briefly for mdmon to exit.

managemon.c
mdadm.c

index 03de9a89f7ba6784c3642aa15b00894372f5dffe..9b93ce4ea72c5ca08135938c23eb7bb2e131cb3a 100644 (file)
@@ -159,6 +159,7 @@ static void remove_old(void)
                if (pending_discard == discard_this)
                        pending_discard = NULL;
                discard_this = NULL;
+               wakeup_monitor();
        }
 }
 
@@ -174,7 +175,6 @@ static void replace_array(struct supertype *container,
         */
        remove_old();
        while (pending_discard) {
-               wakeup_monitor();
                while (discard_this == NULL)
                        sleep(1);
                remove_old();
diff --git a/mdadm.c b/mdadm.c
index 8b4b5dffbacceb81dbb05fb7e438ead3052abecc..6fe6b99f3024bd88c7a569c5c59e5b4c32f2ee8b 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1257,6 +1257,16 @@ int main(int argc, char *argv[])
 
                                                        put_md_name(name);
                                                }
+                                               /* This is a bit of a hack.
+                                                * When we stop an array in a container, it
+                                                * takes a moment for mdmon to let go.
+                                                * So just pause briefly incase that is
+                                                * happening.  Maybe we should do something
+                                                * more deterministic via the socket.
+                                                */
+                                               if (progress && err)
+                                                       usleep(50000);
+
                                        } while (!last && err);
                                        if (err) rv |= 1;
                                } else {