Module Name:    src
Committed By:   hannken
Date:           Fri Jul  9 08:25:57 UTC 2010

Modified Files:
        src/sys/nfs: nfs_vfsops.c

Log Message:
nfs_unmount(): No need to take a second reference for the root node.

nfs_root():    Replace vget() with vref()/vn_lock(), this node already
               has a reference.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.214 src/sys/nfs/nfs_vfsops.c:1.215
--- src/sys/nfs/nfs_vfsops.c:1.214	Thu Jun 24 13:03:17 2010
+++ src/sys/nfs/nfs_vfsops.c	Fri Jul  9 08:25:57 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.214 2010/06/24 13:03:17 hannken Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.215 2010/07/09 08:25:57 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.214 2010/06/24 13:03:17 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.215 2010/07/09 08:25:57 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -864,22 +864,21 @@
 	 */
 	/*
 	 * We need to decrement the ref. count on the nfsnode representing
-	 * the remote root.  See comment in mountnfs().  The VFS unmount()
-	 * has done vput on this vnode, otherwise we would get deadlock!
+	 * the remote root.  See comment in mountnfs().
 	 */
 	vp = nmp->nm_vnode;
-	error = vget(vp, LK_EXCLUSIVE | LK_RETRY);
+	error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	if (error != 0)
 		return error;
 
-	if ((mntflags & MNT_FORCE) == 0 && vp->v_usecount > 2) {
-		vput(vp);
+	if ((mntflags & MNT_FORCE) == 0 && vp->v_usecount > 1) {
+		VOP_UNLOCK(vp);
 		return (EBUSY);
 	}
 
 	error = vflush(mp, vp, flags);
 	if (error) {
-		vput(vp);
+		VOP_UNLOCK(vp);
 		return (error);
 	}
 
@@ -898,10 +897,10 @@
 	iostat_free(nmp->nm_stats);
 
 	/*
-	 * There are two reference counts to get rid of here
+	 * There is one reference count to get rid of here
 	 * (see comment in mountnfs()).
 	 */
-	vput(vp);
+	VOP_UNLOCK(vp);
 	vgone(vp);
 	nfs_disconnect(nmp);
 	m_freem(nmp->nm_nam);
@@ -929,9 +928,12 @@
 
 	nmp = VFSTONFS(mp);
 	vp = nmp->nm_vnode;
-	error = vget(vp, LK_EXCLUSIVE | LK_RETRY);
-	if (error != 0)
+	vref(vp);
+	error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+	if (error != 0) {
+		vrele(vp);
 		return error;
+	}
 	*vpp = vp;
 	return (0);
 }

Reply via email to