summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2007-04-09 21:10:04 +0000
committernjl <njl@FreeBSD.org>2007-04-09 21:10:04 +0000
commit7d4003b184bf3b809fb0e23f949a1aa30ae6a802 (patch)
treed8224a8bb4a3a36e2a564a151320355840ce02dc /sys/kern
parentaa9104eb0c11249b672be4ef2c50e7293f0d19a4 (diff)
downloadFreeBSD-src-7d4003b184bf3b809fb0e23f949a1aa30ae6a802.zip
FreeBSD-src-7d4003b184bf3b809fb0e23f949a1aa30ae6a802.tar.gz
Restore the locking for the sleep/wakeup to avoid waiting an extra 1 sec
if a race was lost. We're still single-threaded at this point, but just be safe for the future.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_mount.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index c6ddedb..5182249 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -1378,12 +1378,13 @@ root_mount_done(void)
{
/*
- * No mutex is acquired here because int stores are atomic. If a
- * thread is polling root_mount_complete, it may get a spurious
- * wakeup() but that is fine in the tsleep()/wakeup() model.
+ * Use a mutex to prevent the wakeup being missed and waiting for
+ * an extra 1 second sleep.
*/
+ mtx_lock(&mountlist_mtx);
root_mount_complete = 1;
wakeup(&root_mount_complete);
+ mtx_unlock(&mountlist_mtx);
}
/*
@@ -1393,6 +1394,7 @@ int
root_mounted(void)
{
+ /* No mutex is acquired here because int stores are atomic. */
return (root_mount_complete);
}
@@ -1409,8 +1411,12 @@ root_mount_wait(void)
*/
KASSERT(curthread->td_proc->p_pid != 0,
("root_mount_wait: cannot be called from the swapper thread"));
- while (!root_mount_complete)
- tsleep(&root_mount_complete, PZERO, "rootwait", hz);
+ mtx_lock(&mountlist_mtx);
+ while (!root_mount_complete) {
+ msleep(&root_mount_complete, &mountlist_mtx, PZERO, "rootwait",
+ hz);
+ }
+ mtx_unlock(&mountlist_mtx);
}
static void
OpenPOWER on IntegriCloud