mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
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.
This commit is contained in:
parent
d5ec19ea68
commit
6b1e469ea5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=168547
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user