Push down Giant in the vlnru kproc main loop so that it is only acquired

around calls to vlrureclaim() on non-MPSAFE filesystems.  Specifically,
vnlru no longer needs Giant for the common case of waking up and deciding
there is nothing for it to do.

MFC after:	2 weeks
This commit is contained in:
John Baldwin 2009-01-23 22:08:54 +00:00
parent aac35298e6
commit 645f1f4ea3

View File

@ -755,14 +755,12 @@ static void
vnlru_proc(void)
{
struct mount *mp, *nmp;
int done;
int done, vfslocked;
struct proc *p = vnlruproc;
EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_shutdown, p,
SHUTDOWN_PRI_FIRST);
mtx_lock(&Giant);
for (;;) {
kproc_suspend_check(p);
mtx_lock(&vnode_free_list_mtx);
@ -779,19 +777,13 @@ vnlru_proc(void)
done = 0;
mtx_lock(&mountlist_mtx);
for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
int vfsunlocked;
if (vfs_busy(mp, MBF_NOWAIT | MBF_MNTLSTLOCK)) {
nmp = TAILQ_NEXT(mp, mnt_list);
continue;
}
if (!VFS_NEEDSGIANT(mp)) {
mtx_unlock(&Giant);
vfsunlocked = 1;
} else
vfsunlocked = 0;
vfslocked = VFS_LOCK_GIANT(mp);
done += vlrureclaim(mp);
if (vfsunlocked)
mtx_lock(&Giant);
VFS_UNLOCK_GIANT(vfslocked);
mtx_lock(&mountlist_mtx);
nmp = TAILQ_NEXT(mp, mnt_list);
vfs_unbusy(mp);