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.
This commit is contained in:
Neil Brown 2008-07-12 20:27:42 +10:00
parent c7c149300b
commit 48561b0142
2 changed files with 11 additions and 1 deletions

View 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();

10
mdadm.c
View File

@ -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 {