From d779d4431349f73339594a3bba8cf1797a4471ba Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Thu, 18 Feb 2010 22:22:45 +0000 Subject: [PATCH] - Reduce scope of vnode lock. vfs_mount_alloc() doesn't need vnode to be locked. - Remove code duplication. --- sys/kern/vfs_mount.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index b443152af084..088d93973bd7 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -959,12 +959,12 @@ vfs_domount( } vp->v_iflag |= VI_MOUNT; VI_UNLOCK(vp); + VOP_UNLOCK(vp, 0); /* * Allocate and initialize the filesystem. */ mp = vfs_mount_alloc(vp, vfsp, fspath, td->td_ucred); - VOP_UNLOCK(vp, 0); /* XXXMAC: pass to vfs_mount_alloc? */ mp->mnt_optnew = fsdata; @@ -1060,12 +1060,12 @@ vfs_domount( * Put the new filesystem on the mount list after root. */ cache_purge(vp); + VI_LOCK(vp); + vp->v_iflag &= ~VI_MOUNT; + VI_UNLOCK(vp); if (!error) { struct vnode *newdp; - VI_LOCK(vp); - vp->v_iflag &= ~VI_MOUNT; - VI_UNLOCK(vp); vp->v_mountedhere = mp; mtx_lock(&mountlist_mtx); TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); @@ -1083,9 +1083,6 @@ vfs_domount( if (error) vrele(vp); } else { - VI_LOCK(vp); - vp->v_iflag &= ~VI_MOUNT; - VI_UNLOCK(vp); vfs_unbusy(mp); vfs_mount_destroy(mp); vput(vp);