Date: Sun, 23 Aug 2020 21:04:35 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364538 - head/sys/kern Message-ID: <202008232104.07NL4ZqD047481@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Sun Aug 23 21:04:35 2020 New Revision: 364538 URL: https://svnweb.freebsd.org/changeset/base/364538 Log: vfs: factor away doomed vnode handling into vdropl_final Modified: head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Sun Aug 23 21:04:22 2020 (r364537) +++ head/sys/kern/vfs_subr.c Sun Aug 23 21:04:35 2020 (r364538) @@ -3437,6 +3437,33 @@ vdrop_deactivate(struct vnode *vp) vdbatch_enqueue(vp); } +static void __noinline +vdropl_final(struct vnode *vp) +{ + + ASSERT_VI_LOCKED(vp, __func__); + VNPASS(VN_IS_DOOMED(vp), vp); + /* + * Set the VHOLD_NO_SMR flag. + * + * We may be racing against vhold_smr. If they win we can just pretend + * we never got this far, they will vdrop later. + */ + if (__predict_false(!atomic_cmpset_int(&vp->v_holdcnt, 0, VHOLD_NO_SMR))) { + vn_freevnodes_inc(); + VI_UNLOCK(vp); + /* + * We lost the aforementioned race. Any subsequent access is + * invalid as they might have managed to vdropl on their own. + */ + return; + } + /* + * Don't bump freevnodes as this one is going away. + */ + freevnode(vp); +} + void vdrop(struct vnode *vp) { @@ -3469,25 +3496,7 @@ vdropl(struct vnode *vp) */ return; } - /* - * Set the VHOLD_NO_SMR flag. - * - * We may be racing against vhold_smr. If they win we can just pretend - * we never got this far, they will vdrop later. - */ - if (__predict_false(!atomic_cmpset_int(&vp->v_holdcnt, 0, VHOLD_NO_SMR))) { - vn_freevnodes_inc(); - VI_UNLOCK(vp); - /* - * We lost the aforementioned race. Any subsequent access is - * invalid as they might have managed to vdropl on their own. - */ - return; - } - /* - * Don't bump freevnodes as this one is going away. - */ - freevnode(vp); + vdropl_final(vp); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008232104.07NL4ZqD047481>