Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Jan 2011 00:59:04 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r217493 - stable/8/sys/fs/nfsserver
Message-ID:  <201101170059.p0H0x4LP083041@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Mon Jan 17 00:59:04 2011
New Revision: 217493
URL: http://svn.freebsd.org/changeset/base/217493

Log:
  MFC: r216897
  Modify the experimental NFSv4 server so that the lookup
  ops return a locked vnode. This ensures that the associated mount
  point will always be valid for the code that follows the operation.
  Also add a couple of additional checks
  for non-error to the other functions that create file objects.

Modified:
  stable/8/sys/fs/nfsserver/nfs_nfsdserv.c
  stable/8/sys/fs/nfsserver/nfs_nfsdsocket.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- stable/8/sys/fs/nfsserver/nfs_nfsdserv.c	Mon Jan 17 00:15:01 2011	(r217492)
+++ stable/8/sys/fs/nfsserver/nfs_nfsdserv.c	Mon Jan 17 00:59:04 2011	(r217493)
@@ -470,12 +470,10 @@ nfsrvd_lookup(struct nfsrv_descript *nd,
 	nd->nd_repstat = nfsvno_getfh(vp, fhp, p);
 	if (!(nd->nd_flag & ND_NFSV4) && !nd->nd_repstat)
 		nd->nd_repstat = nfsvno_getattr(vp, &nva, nd->nd_cred, p, 1);
-	if (vpp) {
-		NFSVOPUNLOCK(vp, 0, p);
+	if (vpp != NULL && nd->nd_repstat == 0)
 		*vpp = vp;
-	} else {
+	else
 		vput(vp);
-	}
 	if (dirp) {
 		if (nd->nd_flag & ND_NFSV3)
 			dattr_ret = nfsvno_getattr(dirp, &dattr, nd->nd_cred,
@@ -1218,12 +1216,11 @@ nfsrvd_mknod(struct nfsrv_descript *nd, 
 		if ((nd->nd_flag & ND_NFSV3) && !nd->nd_repstat)
 			nd->nd_repstat = nfsvno_getattr(vp, &nva, nd->nd_cred,
 			    p, 1);
-		if (vpp) {
-			NFSVOPUNLOCK(vp, 0, p);
+		if (vpp != NULL && nd->nd_repstat == 0) {
+			VOP_UNLOCK(vp, 0);
 			*vpp = vp;
-		} else {
+		} else
 			vput(vp);
-		}
 	}
 
 	diraft_ret = nfsvno_getattr(dirp, &diraft, nd->nd_cred, p, 0);
@@ -1706,12 +1703,11 @@ nfsrvd_symlinksub(struct nfsrv_descript 
 				nd->nd_repstat = nfsvno_getattr(ndp->ni_vp,
 				    nvap, nd->nd_cred, p, 1);
 		}
-		if (vpp) {
-			NFSVOPUNLOCK(ndp->ni_vp, 0, p);
+		if (vpp != NULL && nd->nd_repstat == 0) {
+			VOP_UNLOCK(ndp->ni_vp, 0);
 			*vpp = ndp->ni_vp;
-		} else {
+		} else
 			vput(ndp->ni_vp);
-		}
 	}
 	if (dirp) {
 		*diraft_retp = nfsvno_getattr(dirp, diraftp, nd->nd_cred, p, 0);

Modified: stable/8/sys/fs/nfsserver/nfs_nfsdsocket.c
==============================================================================
--- stable/8/sys/fs/nfsserver/nfs_nfsdsocket.c	Mon Jan 17 00:15:01 2011	(r217492)
+++ stable/8/sys/fs/nfsserver/nfs_nfsdsocket.c	Mon Jan 17 00:59:04 2011	(r217493)
@@ -861,10 +861,14 @@ nfsrvd_compound(struct nfsrv_descript *n
 					    nfsvno_lockvfs(mp);
 				    }
 			    }
+			    if (op == NFSV4OP_LOOKUP || op == NFSV4OP_LOOKUPP)
+				    /* Lookup ops return a locked vnode */
+				    VOP_UNLOCK(nvp, 0);
 			    if (!nd->nd_repstat) {
 				    vrele(vp);
 				    vp = nvp;
-			    }
+			    } else
+				    vrele(nvp);
 			}
 			if (nfsv4_opflag[op].modifyfs)
 				NFS_ENDWRITE(mp);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101170059.p0H0x4LP083041>