From 5a22c9582c7a2d53f4e158a83dbba2b5e34dc46c Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Thu, 6 Oct 2016 18:09:22 +0000 Subject: [PATCH] Add vrecyclel() to vrecycle() a vnode with the interlock already held. Obtained from: OneFS Sponsored by: Dell EMC Isilon MFC after: 2 weeks --- sys/kern/vfs_subr.c | 19 ++++++++++++++++--- sys/sys/vnode.h | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 6fbb3ff9af7..12364bf8c23 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3160,15 +3160,28 @@ vrecycle(struct vnode *vp) { int recycled; - ASSERT_VOP_ELOCKED(vp, "vrecycle"); + VI_LOCK(vp); + recycled = vrecyclel(vp); + VI_UNLOCK(vp); + return (recycled); +} + +/* + * vrecycle, with the vp interlock held. + */ +int +vrecyclel(struct vnode *vp) +{ + int recycled; + + ASSERT_VOP_ELOCKED(vp, __func__); + ASSERT_VI_LOCKED(vp, __func__); CTR2(KTR_VFS, "%s: vp %p", __func__, vp); recycled = 0; - VI_LOCK(vp); if (vp->v_usecount == 0) { recycled = 1; vgonel(vp); } - VI_UNLOCK(vp); return (recycled); } diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 4d2a8427cae..9f1b8d9c3a0 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -659,6 +659,7 @@ int vtruncbuf(struct vnode *vp, struct ucred *cred, off_t length, void vunref(struct vnode *); void vn_printf(struct vnode *vp, const char *fmt, ...) __printflike(2,3); int vrecycle(struct vnode *vp); +int vrecyclel(struct vnode *vp); int vn_bmap_seekhole(struct vnode *vp, u_long cmd, off_t *off, struct ucred *cred); int vn_close(struct vnode *vp,