Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/nfs nfs_unmount(): No need to take a second reference fo...



details:   https://anonhg.NetBSD.org/src/rev/49c8d39d5af0
branches:  trunk
changeset: 756235:49c8d39d5af0
user:      hannken <hannken%NetBSD.org@localhost>
date:      Fri Jul 09 08:25:57 2010 +0000

description:
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.

diffstat:

 sys/nfs/nfs_vfsops.c |  26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diffs (74 lines):

diff -r a10f7d365024 -r 49c8d39d5af0 sys/nfs/nfs_vfsops.c
--- a/sys/nfs/nfs_vfsops.c      Fri Jul 09 08:22:04 2010 +0000
+++ b/sys/nfs/nfs_vfsops.c      Fri Jul 09 08:25:57 2010 +0000
@@ -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);
 }



Home | Main Index | Thread Index | Old Index