Date: Wed, 24 Feb 2021 07:58:47 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: b7a3af0b9f01 - stable/13 - Use VOP_VPUT_PAIR() for eligible VFS syscalls. Message-ID: <202102240758.11O7wlJT046503@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b7a3af0b9f010afa9cc0e29d87827f349ab2db9a commit b7a3af0b9f010afa9cc0e29d87827f349ab2db9a Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-01-28 22:31:30 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2021-02-24 07:43:40 +0000 Use VOP_VPUT_PAIR() for eligible VFS syscalls. (cherry picked from commit 3b2aa36024abcb2d8fdbf3a6ecc7438b073b04e4) --- sys/kern/uipc_usrreq.c | 5 +++-- sys/kern/vfs_syscalls.c | 29 ++++++++++++----------------- sys/kern/vfs_vnops.c | 5 +++-- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 0809f5180cc1..ca23ccbdb05e 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -669,8 +669,8 @@ restart: if (error == 0) error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); if (error) { + VOP_VPUT_PAIR(nd.ni_dvp, NULL, true); vn_finished_write(mp); if (error == ERELOOKUP) goto restart; @@ -686,7 +686,8 @@ restart: unp->unp_addr = soun; unp->unp_flags &= ~UNP_BINDING; UNP_PCB_UNLOCK(unp); - VOP_UNLOCK(vp); + vref(vp); + VOP_VPUT_PAIR(nd.ni_dvp, &vp, true); vn_finished_write(mp); free(buf, M_TEMP); return (0); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 35a56510e9ef..aba3d62936bb 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1370,13 +1370,12 @@ restart: else { error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); - if (error == 0) - vput(nd.ni_vp); } } - NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 && !whiteout ? &nd.ni_vp : NULL, + true); vn_finished_write(mp); + NDFREE(&nd, NDF_ONLY_PNBUF); if (error == ERELOOKUP) goto restart; return (error); @@ -1457,12 +1456,10 @@ restart: goto out; #endif error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); - if (error == 0) - vput(nd.ni_vp); #ifdef MAC out: #endif - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true); vn_finished_write(mp); NDFREE(&nd, NDF_ONLY_PNBUF); if (error == ERELOOKUP) @@ -1629,10 +1626,10 @@ kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, const char *path, return (EAGAIN); } error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); - VOP_UNLOCK(vp); - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, &vp, true); vn_finished_write(mp); NDFREE(&nd, NDF_ONLY_PNBUF); + vp = NULL; } else { vput(nd.ni_dvp); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1640,7 +1637,8 @@ kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, const char *path, return (EAGAIN); } } - vrele(vp); + if (vp != NULL) + vrele(vp); return (error); } @@ -1710,6 +1708,7 @@ restart: else vput(nd.ni_dvp); vrele(nd.ni_vp); + nd.ni_vp = NULL; error = EEXIST; goto out; } @@ -1730,14 +1729,12 @@ restart: goto out2; #endif error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, syspath); - if (error == 0) - vput(nd.ni_vp); #ifdef MAC out2: #endif - NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true); vn_finished_write(mp); + NDFREE(&nd, NDF_ONLY_PNBUF); if (error == ERELOOKUP) goto restart; out: @@ -3794,9 +3791,7 @@ restart: out: #endif NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); - if (error == 0) - vput(nd.ni_vp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true); vn_finished_write(mp); if (error == ERELOOKUP) goto restart; diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 3ec2662dfcd8..71dd379558cb 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -274,8 +274,9 @@ restart: if (error == 0) #endif error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp, - &ndp->ni_cnd, vap); - vput(ndp->ni_dvp); + &ndp->ni_cnd, vap); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : + NULL, false); vn_finished_write(mp); if (error) { NDFREE(ndp, NDF_ONLY_PNBUF);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202102240758.11O7wlJT046503>