Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Feb 2021 20:52:20 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 2b2c2c7128ea - releng/13.0 - nfsserver: use VOP_VPUT_PAIR().
Message-ID:  <202102252052.11PKqKSk079279@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/13.0 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=2b2c2c7128ea1ee9ed049e9bca939772ed8d6ce1

commit 2b2c2c7128ea1ee9ed049e9bca939772ed8d6ce1
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-01-24 13:02:27 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-02-25 20:48:52 +0000

    nfsserver: use VOP_VPUT_PAIR().
    
    Approved by:    re (delphij, gjb)
    
    (cherry picked from commit 4a21bcb24174438e0944d6e4d6633290a067b7a8)
---
 sys/fs/nfsserver/nfs_nfsdport.c | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c
index b781503a6815..4d19c73dfa06 100644
--- a/sys/fs/nfsserver/nfs_nfsdport.c
+++ b/sys/fs/nfsserver/nfs_nfsdport.c
@@ -1105,7 +1105,8 @@ nfsvno_createsub(struct nfsrv_descript *nd, struct nameidata *ndp,
 				nfsrv_pnfscreate(ndp->ni_vp, &nvap->na_vattr,
 				    nd->nd_cred, p);
 			}
-			vput(ndp->ni_dvp);
+			VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp :
+			    NULL, false);
 			nfsvno_relpathbuf(ndp);
 			if (!error) {
 				if (*exclusive_flagp) {
@@ -1140,7 +1141,8 @@ nfsvno_createsub(struct nfsrv_descript *nd, struct nameidata *ndp,
 			nvap->na_rdev = rdev;
 			error = VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp,
 			    &ndp->ni_cnd, &nvap->na_vattr);
-			vput(ndp->ni_dvp);
+			VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp :
+			    NULL, false);
 			nfsvno_relpathbuf(ndp);
 			vrele(ndp->ni_startdir);
 			if (error)
@@ -1221,7 +1223,8 @@ nfsvno_mknod(struct nameidata *ndp, struct nfsvattr *nvap, struct ucred *cred,
 		vrele(ndp->ni_startdir);
 		error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
 		    &ndp->ni_cnd, &nvap->na_vattr);
-		vput(ndp->ni_dvp);
+		VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL,
+		    false);
 		nfsvno_relpathbuf(ndp);
 	} else {
 		if (nvap->na_type != VFIFO &&
@@ -1233,7 +1236,8 @@ nfsvno_mknod(struct nameidata *ndp, struct nfsvattr *nvap, struct ucred *cred,
 		}
 		error = VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp,
 		    &ndp->ni_cnd, &nvap->na_vattr);
-		vput(ndp->ni_dvp);
+		VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL,
+		    false);
 		nfsvno_relpathbuf(ndp);
 		vrele(ndp->ni_startdir);
 		/*
@@ -1268,7 +1272,7 @@ nfsvno_mkdir(struct nameidata *ndp, struct nfsvattr *nvap, uid_t saved_uid,
 	}
 	error = VOP_MKDIR(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd,
 	    &nvap->na_vattr);
-	vput(ndp->ni_dvp);
+	VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL, false);
 	nfsvno_relpathbuf(ndp);
 
 out:
@@ -1300,17 +1304,15 @@ nfsvno_symlink(struct nameidata *ndp, struct nfsvattr *nvap, char *pathcp,
 
 	error = VOP_SYMLINK(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd,
 	    &nvap->na_vattr, pathcp);
-	vput(ndp->ni_dvp);
-	vrele(ndp->ni_startdir);
-	nfsvno_relpathbuf(ndp);
 	/*
 	 * Although FreeBSD still had the lookup code in
 	 * it for 7/current, there doesn't seem to be any
 	 * point, since VOP_SYMLINK() returns the ni_vp.
 	 * Just vput it for v2.
 	 */
-	if (!not_v2 && !error)
-		vput(ndp->ni_vp);
+	VOP_VPUT_PAIR(ndp->ni_dvp, &ndp->ni_vp, !not_v2 && error == 0);
+	vrele(ndp->ni_startdir);
+	nfsvno_relpathbuf(ndp);
 
 out:
 	NFSEXITCODE(error);
@@ -1595,11 +1597,13 @@ nfsvno_link(struct nameidata *ndp, struct vnode *vp, struct ucred *cred,
 			error = VOP_LINK(ndp->ni_dvp, vp, &ndp->ni_cnd);
 		else
 			error = EPERM;
-		if (ndp->ni_dvp == vp)
+		if (ndp->ni_dvp == vp) {
 			vrele(ndp->ni_dvp);
-		else
-			vput(ndp->ni_dvp);
-		NFSVOPUNLOCK(vp);
+			NFSVOPUNLOCK(vp);
+		} else {
+			vref(vp);
+			VOP_VPUT_PAIR(ndp->ni_dvp, &vp, true);
+		}
 	} else {
 		if (ndp->ni_dvp == ndp->ni_vp)
 			vrele(ndp->ni_dvp);
@@ -1793,7 +1797,8 @@ nfsvno_open(struct nfsrv_descript *nd, struct nameidata *ndp,
 				nfsrv_pnfscreate(ndp->ni_vp, &nvap->na_vattr,
 				    cred, p);
 			}
-			vput(ndp->ni_dvp);
+			VOP_VPUT_PAIR(ndp->ni_dvp, nd->nd_repstat == 0 ?
+			    &ndp->ni_vp : NULL, false);
 			nfsvno_relpathbuf(ndp);
 			if (!nd->nd_repstat) {
 				if (*exclusive_flagp) {
@@ -4106,7 +4111,8 @@ nfsrv_dscreate(struct vnode *dvp, struct vattr *vap, struct vattr *nvap,
 	error = NFSVOPLOCK(dvp, LK_EXCLUSIVE);
 	if (error == 0) {
 		error = VOP_CREATE(dvp, &nvp, &named.ni_cnd, vap);
-		NFSVOPUNLOCK(dvp);
+		vref(dvp);
+		VOP_VPUT_PAIR(dvp, error == 0 ? &nvp : NULL, false);
 		if (error == 0) {
 			/* Set the ownership of the file. */
 			error = VOP_SETATTR(nvp, nvap, tcred);



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