From owner-dev-commits-src-all@freebsd.org Sat May 22 18:24:01 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 439106340B1; Sat, 22 May 2021 18:24:01 +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 4FnX1D6yQkz4TtB; Sat, 22 May 2021 18:24:00 +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 BB20DF6B; Sat, 22 May 2021 18:24:00 +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 14MIO08e005948; Sat, 22 May 2021 18:24:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MIO0wc005947; Sat, 22 May 2021 18:24:00 GMT (envelope-from git) Date: Sat, 22 May 2021 18:24:00 GMT Message-Id: <202105221824.14MIO0wc005947@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: e9757b0c94c0 - stable/13 - vfs: refactor vdrop MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e9757b0c94c02db1a2a154089af3ec0e4e8b3b1a 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: Sat, 22 May 2021 18:24:01 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e9757b0c94c02db1a2a154089af3ec0e4e8b3b1a commit e9757b0c94c02db1a2a154089af3ec0e4e8b3b1a Author: Mateusz Guzik AuthorDate: 2021-05-14 19:01:32 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-22 18:22:30 +0000 vfs: refactor vdrop In particular move vunlazy into its own routine. (cherry picked from commit cc6f46ac2fd5d910e632fced3f21d0b0f53030d8) --- sys/kern/vfs_subr.c | 85 +++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 53c9c12be34c..270dab02bf39 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3059,6 +3059,31 @@ vlazy(struct vnode *vp) mtx_unlock(&mp->mnt_listmtx); } +static void +vunlazy(struct vnode *vp) +{ + struct mount *mp; + + ASSERT_VI_LOCKED(vp, __func__); + VNPASS(!VN_IS_DOOMED(vp), vp); + + mp = vp->v_mount; + mtx_lock(&mp->mnt_listmtx); + VNPASS(vp->v_mflag & VMP_LAZYLIST, vp); + /* + * Don't remove the vnode from the lazy list if another thread + * has increased the hold count. It may have re-enqueued the + * vnode to the lazy list and is now responsible for its + * removal. + */ + if (vp->v_holdcnt == 0) { + vp->v_mflag &= ~VMP_LAZYLIST; + TAILQ_REMOVE(&mp->mnt_lazyvnodelist, vp, v_lazylist); + mp->mnt_lazyvnodelistsize--; + } + mtx_unlock(&mp->mnt_listmtx); +} + /* * This routine is only meant to be called from vgonel prior to dooming * the vnode. @@ -3514,42 +3539,6 @@ vdbatch_dequeue(struct vnode *vp) * there is at least one resident non-cached page, the vnode cannot * leave the active list without the page cleanup done. */ -static void -vdrop_deactivate(struct vnode *vp) -{ - struct mount *mp; - - ASSERT_VI_LOCKED(vp, __func__); - /* - * Mark a vnode as free: remove it from its active list - * and put it up for recycling on the freelist. - */ - VNASSERT(!VN_IS_DOOMED(vp), vp, - ("vdrop: returning doomed vnode")); - VNASSERT((vp->v_iflag & VI_OWEINACT) == 0, vp, - ("vnode with VI_OWEINACT set")); - VNASSERT((vp->v_iflag & VI_DEFINACT) == 0, vp, - ("vnode with VI_DEFINACT set")); - if (vp->v_mflag & VMP_LAZYLIST) { - mp = vp->v_mount; - mtx_lock(&mp->mnt_listmtx); - VNASSERT(vp->v_mflag & VMP_LAZYLIST, vp, ("lost VMP_LAZYLIST")); - /* - * Don't remove the vnode from the lazy list if another thread - * has increased the hold count. It may have re-enqueued the - * vnode to the lazy list and is now responsible for its - * removal. - */ - if (vp->v_holdcnt == 0) { - vp->v_mflag &= ~VMP_LAZYLIST; - TAILQ_REMOVE(&mp->mnt_lazyvnodelist, vp, v_lazylist); - mp->mnt_lazyvnodelistsize--; - } - mtx_unlock(&mp->mnt_listmtx); - } - vdbatch_enqueue(vp); -} - static void __noinline vdropl_final(struct vnode *vp) { @@ -3599,17 +3588,23 @@ vdropl(struct vnode *vp) VI_UNLOCK(vp); return; } - if (!VN_IS_DOOMED(vp)) { - vfs_freevnodes_inc(); - vdrop_deactivate(vp); - /* - * Also unlocks the interlock. We can't assert on it as we - * released our hold and by now the vnode might have been - * freed. - */ + VNPASS((vp->v_iflag & VI_OWEINACT) == 0, vp); + VNPASS((vp->v_iflag & VI_DEFINACT) == 0, vp); + if (VN_IS_DOOMED(vp)) { + vdropl_final(vp); return; } - vdropl_final(vp); + + vfs_freevnodes_inc(); + if (vp->v_mflag & VMP_LAZYLIST) { + vunlazy(vp); + } + /* + * Also unlocks the interlock. We can't assert on it as we + * released our hold and by now the vnode might have been + * freed. + */ + vdbatch_enqueue(vp); } /*