From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:28 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 63DEC56FADD; Thu, 25 Feb 2021 20:52:28 +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 4DmlN95Q9xz3P0W; Thu, 25 Feb 2021 20:52:23 +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 EFB551E54B; Thu, 25 Feb 2021 20:52:22 +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 11PKqMni079320; Thu, 25 Feb 2021 20:52:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqMV5079319; Thu, 25 Feb 2021 20:52:22 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:22 GMT Message-Id: <202102252052.11PKqMV5079319@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: 0c3cdbf4293a - releng/13.0 - ffs_vput_pair(): try harder to recover from the vnode reclaim 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/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 0c3cdbf4293afa1f6faa50e368e47327957ceb85 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Feb 2021 20:52:28 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0c3cdbf4293afa1f6faa50e368e47327957ceb85 commit 0c3cdbf4293afa1f6faa50e368e47327957ceb85 Author: Konstantin Belousov AuthorDate: 2021-01-27 18:10:51 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:49:04 +0000 ffs_vput_pair(): try harder to recover from the vnode reclaim Approved by: re (delphij, gjb) (cherry picked from commit 30bfb2fa0fad8e5bbcce369df46dcaa2e08324f3) --- sys/ufs/ffs/ffs_vnops.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 623b13790ce0..2ac67adad5f2 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1924,8 +1924,11 @@ ffs_getpages_async(struct vop_getpages_async_args *ap) static int ffs_vput_pair(struct vop_vput_pair_args *ap) { - struct vnode *dvp, *vp, **vpp; - struct inode *dp; + struct mount *mp; + struct vnode *dvp, *vp, *vp1, **vpp; + struct inode *dp, *ip; + ino_t ip_ino; + u_int64_t ip_gen; int error, vp_locked; dvp = ap->a_dvp; @@ -1940,12 +1943,17 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) return (0); } + mp = NULL; if (vp != NULL) { if (ap->a_unlock_vp) { vput(vp); } else { MPASS(vp->v_type != VNON); vp_locked = VOP_ISLOCKED(vp); + ip = VTOI(vp); + ip_ino = ip->i_number; + ip_gen = ip->i_gen; + mp = vp->v_mount; VOP_UNLOCK(vp); } } @@ -1957,6 +1965,7 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) if (vp == NULL || ap->a_unlock_vp) return (0); + MPASS(mp != NULL); /* * It is possible that vp is reclaimed at this point. Only @@ -1970,5 +1979,29 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) * and respond to dead vnodes by returning ESTALE. */ VOP_LOCK(vp, vp_locked | LK_RETRY); - return (0); + if (!VN_IS_DOOMED(vp)) + return (0); + + /* + * Try harder to recover from reclaimed vp if reclaim was not + * because underlying inode was cleared. We saved inode + * number and inode generation, so we can try to reinstantiate + * exactly same version of inode. If this fails, return + * original doomed vnode and let caller to handle + * consequences. + * + * Note that callers must keep write started around + * VOP_VPUT_PAIR() calls, so it is safe to use mp without + * busying it. + */ + VOP_UNLOCK(vp); + error = ffs_inotovp(mp, ip_ino, ip_gen, LK_EXCLUSIVE, &vp1, + FFSV_REPLACE_DOOMED); + if (error != 0) { + VOP_LOCK(vp, vp_locked | LK_RETRY); + } else { + vrele(vp); + *vpp = vp1; + } + return (error); }