From owner-dev-commits-src-all@freebsd.org Wed Feb 24 07:58:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67006553C31; Wed, 24 Feb 2021 07:58:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlpG60qvlz4ZgM; Wed, 24 Feb 2021 07:58:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9BCF1288C2; Wed, 24 Feb 2021 07:58:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7wolc046566; Wed, 24 Feb 2021 07:58:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wolM046565; Wed, 24 Feb 2021 07:58:50 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:50 GMT Message-Id: <202102240758.11O7wolM046565@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 1de6eb52fdbf - stable/13 - FFS: implement special VOP_VPUT_PAIR(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1de6eb52fdbfca2df545cf4860b8f18c1f140f70 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Feb 2021 07:58:58 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1de6eb52fdbfca2df545cf4860b8f18c1f140f70 commit 1de6eb52fdbfca2df545cf4860b8f18c1f140f70 Author: Konstantin Belousov AuthorDate: 2021-01-27 18:09:53 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:44:41 +0000 FFS: implement special VOP_VPUT_PAIR(). (cherry picked from commit f2c9d038bdee547be07c8b0404547617b71f2232) --- sys/ufs/ffs/ffs_vnops.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index be2653e32adc..623b13790ce0 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -130,6 +130,7 @@ static vop_listextattr_t ffs_listextattr; static vop_openextattr_t ffs_openextattr; static vop_setextattr_t ffs_setextattr; static vop_vptofh_t ffs_vptofh; +static vop_vput_pair_t ffs_vput_pair; /* Global vfs data structures for ufs. */ struct vop_vector ffs_vnodeops1 = { @@ -146,6 +147,7 @@ struct vop_vector ffs_vnodeops1 = { .vop_reallocblks = ffs_reallocblks, .vop_write = ffs_write, .vop_vptofh = ffs_vptofh, + .vop_vput_pair = ffs_vput_pair, }; VFS_VOP_VECTOR_REGISTER(ffs_vnodeops1); @@ -182,6 +184,7 @@ struct vop_vector ffs_vnodeops2 = { .vop_openextattr = ffs_openextattr, .vop_setextattr = ffs_setextattr, .vop_vptofh = ffs_vptofh, + .vop_vput_pair = ffs_vput_pair, }; VFS_VOP_VECTOR_REGISTER(ffs_vnodeops2); @@ -1917,3 +1920,55 @@ ffs_getpages_async(struct vop_getpages_async_args *ap) return (error); } + +static int +ffs_vput_pair(struct vop_vput_pair_args *ap) +{ + struct vnode *dvp, *vp, **vpp; + struct inode *dp; + int error, vp_locked; + + dvp = ap->a_dvp; + dp = VTOI(dvp); + vpp = ap->a_vpp; + vp = vpp != NULL ? *vpp : NULL; + + if ((dp->i_flag & IN_NEEDSYNC) == 0) { + vput(dvp); + if (vp != NULL && ap->a_unlock_vp) + vput(vp); + return (0); + } + + if (vp != NULL) { + if (ap->a_unlock_vp) { + vput(vp); + } else { + MPASS(vp->v_type != VNON); + vp_locked = VOP_ISLOCKED(vp); + VOP_UNLOCK(vp); + } + } + + do { + error = ffs_syncvnode(dvp, MNT_WAIT, 0); + } while (error == ERELOOKUP); + vput(dvp); + + if (vp == NULL || ap->a_unlock_vp) + return (0); + + /* + * It is possible that vp is reclaimed at this point. Only + * routines that call us with a_unlock_vp == false can find + * that their vp has been reclaimed. There are three areas + * that are affected: + * 1) vn_open_cred() - later VOPs could fail, but + * dead_open() returns 0 to simulate successful open. + * 2) ffs_snapshot() - creation of snapshot fails with EBADF. + * 3) NFS server (several places) - code is prepared to detect + * and respond to dead vnodes by returning ESTALE. + */ + VOP_LOCK(vp, vp_locked | LK_RETRY); + return (0); +}