From: Neil Brown Date: Sat, 12 Jul 2008 10:27:42 +0000 (+1000) Subject: Improve shutdown for container-based arrays. X-Git-Tag: mdadm-3.0-devel1~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48561b014292e5052da3dc3df629c10d8531d7fd;p=thirdparty%2Fmdadm.git Improve shutdown for container-based arrays. 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. --- diff --git a/managemon.c b/managemon.c index 03de9a89..9b93ce4e 100644 --- a/managemon.c +++ b/managemon.c @@ -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 8b4b5dff..6fe6b99f 100644 --- 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 {