Date: Sat, 22 May 2021 18:24:00 GMT From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: e9757b0c94c0 - stable/13 - vfs: refactor vdrop Message-ID: <202105221824.14MIO0wc005947@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e9757b0c94c02db1a2a154089af3ec0e4e8b3b1a commit e9757b0c94c02db1a2a154089af3ec0e4e8b3b1a Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2021-05-14 19:01:32 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> 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); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105221824.14MIO0wc005947>