Move the check for the MD_SHUTDOWN flag to before the tsleep() call

in the per-device kthread. This ensures that synchronisation with
mddestroy() succeeds even if the kthread was not waiting in tsleep()
at the time of the wakeup(). Among other things, this fixes the
problem of mdconfig getting stuck when an attempt is made to use a
zero-length file as a vnode-type backing store.

Approved by:	re
This commit is contained in:
iedowse 2002-11-30 22:03:53 +00:00
parent 001b8247ff
commit 947ff5e0c7

View File

@ -577,12 +577,12 @@ md_kthread(void *arg)
bioq_remove(&sc->bio_queue, bp);
/* XXX: UNLOCK(unique unit numbers) */
if (!bp) {
tsleep(sc, PRIBIO, "mdwait", 0);
if (sc->flags & MD_SHUTDOWN) {
sc->procp = NULL;
wakeup(&sc->procp);
kthread_exit(0);
}
tsleep(sc, PRIBIO, "mdwait", 0);
continue;
}