summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_mountroot.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2014-06-11 08:14:08 +0000
committermav <mav@FreeBSD.org>2014-06-11 08:14:08 +0000
commit1be587d5055cd66a4a8f82edf3a84f9db6721f69 (patch)
treec1afc7b79520c172c1e5e7b96ce028207bf137b1 /sys/kern/vfs_mountroot.c
parentba5ebd0f6ed78af0290bbe8f350beb6a51f96984 (diff)
downloadFreeBSD-src-1be587d5055cd66a4a8f82edf3a84f9db6721f69.zip
FreeBSD-src-1be587d5055cd66a4a8f82edf3a84f9db6721f69.tar.gz
Move root_mount_hold() functionality to separate mutex.
It has nothing to share with mutex protecting list of mounted file systems.
Diffstat (limited to 'sys/kern/vfs_mountroot.c')
-rw-r--r--sys/kern/vfs_mountroot.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c
index 5647840..9ec7340 100644
--- a/sys/kern/vfs_mountroot.c
+++ b/sys/kern/vfs_mountroot.c
@@ -97,6 +97,9 @@ struct vnode *rootvnode;
char *rootdevnames[2] = {NULL, NULL};
+struct mtx root_holds_mtx;
+MTX_SYSINIT(root_holds, &root_holds_mtx, "root_holds", MTX_DEF);
+
struct root_hold_token {
const char *who;
LIST_ENTRY(root_hold_token) list;
@@ -131,9 +134,9 @@ root_mount_hold(const char *identifier)
h = malloc(sizeof *h, M_DEVBUF, M_ZERO | M_WAITOK);
h->who = identifier;
- mtx_lock(&mountlist_mtx);
+ mtx_lock(&root_holds_mtx);
LIST_INSERT_HEAD(&root_holds, h, list);
- mtx_unlock(&mountlist_mtx);
+ mtx_unlock(&root_holds_mtx);
return (h);
}
@@ -143,10 +146,10 @@ root_mount_rel(struct root_hold_token *h)
if (h == NULL)
return;
- mtx_lock(&mountlist_mtx);
+ mtx_lock(&root_holds_mtx);
LIST_REMOVE(h, list);
wakeup(&root_holds);
- mtx_unlock(&mountlist_mtx);
+ mtx_unlock(&root_holds_mtx);
free(h, M_DEVBUF);
}
@@ -168,12 +171,12 @@ 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);
+ mtx_lock(&root_holds_mtx);
while (!root_mount_complete) {
- msleep(&root_mount_complete, &mountlist_mtx, PZERO, "rootwait",
+ msleep(&root_mount_complete, &root_holds_mtx, PZERO, "rootwait",
hz);
}
- mtx_unlock(&mountlist_mtx);
+ mtx_unlock(&root_holds_mtx);
}
static void
@@ -908,9 +911,9 @@ vfs_mountroot_wait(void)
DROP_GIANT();
g_waitidle();
PICKUP_GIANT();
- mtx_lock(&mountlist_mtx);
+ mtx_lock(&root_holds_mtx);
if (LIST_EMPTY(&root_holds)) {
- mtx_unlock(&mountlist_mtx);
+ mtx_unlock(&root_holds_mtx);
break;
}
if (ppsratecheck(&lastfail, &curfail, 1)) {
@@ -919,7 +922,7 @@ vfs_mountroot_wait(void)
printf(" %s", h->who);
printf("\n");
}
- msleep(&root_holds, &mountlist_mtx, PZERO | PDROP, "roothold",
+ msleep(&root_holds, &root_holds_mtx, PZERO | PDROP, "roothold",
hz);
}
}
@@ -979,10 +982,10 @@ vfs_mountroot(void)
vref(prison0.pr_root);
mtx_unlock(&prison0.pr_mtx);
- mtx_lock(&mountlist_mtx);
+ mtx_lock(&root_holds_mtx);
atomic_store_rel_int(&root_mount_complete, 1);
wakeup(&root_mount_complete);
- mtx_unlock(&mountlist_mtx);
+ mtx_unlock(&root_holds_mtx);
EVENTHANDLER_INVOKE(mountroot);
}
OpenPOWER on IntegriCloud