summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2007-04-09 19:23:52 +0000
committernjl <njl@FreeBSD.org>2007-04-09 19:23:52 +0000
commitd6c7a51b9ab961a72961f8af5af88283249f720c (patch)
treee07406f9ba32ff7b175485e566f86cc230b7c590 /sys/kern
parent8222e16eeafd3f727c4a849150f58cdd8868e6ec (diff)
downloadFreeBSD-src-d6c7a51b9ab961a72961f8af5af88283249f720c.zip
FreeBSD-src-d6c7a51b9ab961a72961f8af5af88283249f720c.tar.gz
Clean up the root mount and mount wait code. No mutexes are needed here
since a spurious wakeup() is the only possible outcome and this is fine in the BSD programming model.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_mount.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index b7dec78..c6ddedb 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -1312,7 +1312,7 @@ struct root_hold_token {
static LIST_HEAD(, root_hold_token) root_holds =
LIST_HEAD_INITIALIZER(&root_holds);
-static int root_mount_complete = 0;
+static int root_mount_complete;
/*
* Hold root mount.
@@ -1377,24 +1377,23 @@ static void
root_mount_done(void)
{
- mtx_lock(&mountlist_mtx);
+ /*
+ * 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.
+ */
root_mount_complete = 1;
wakeup(&root_mount_complete);
- mtx_unlock(&mountlist_mtx);
}
- /*
+/*
* Return true if root is already mounted.
*/
int
root_mounted(void)
{
- int mounted;
- mtx_lock(&mountlist_mtx);
- mounted = root_mount_complete;
- mtx_unlock(&mountlist_mtx);
- return (mounted);
+ return (root_mount_complete);
}
/*
@@ -1410,12 +1409,8 @@ root_mount_wait(void)
*/
KASSERT(curthread->td_proc->p_pid != 0,
("root_mount_wait: cannot be called from the swapper thread"));
- mtx_lock(&mountlist_mtx);
- while (!root_mount_complete) {
- msleep(&root_mount_complete, &mountlist_mtx, PZERO, "rootwait",
- hz);
- }
- mtx_unlock(&mountlist_mtx);
+ while (!root_mount_complete)
+ tsleep(&root_mount_complete, PZERO, "rootwait", hz);
}
static void
OpenPOWER on IntegriCloud