From 19efd8a5a834ffd7af7ed6cddab389ae8417181a Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 11 Jul 2016 14:19:09 +0000 Subject: [PATCH] In vgonel(), postpone setting BO_DEAD until VOP_RECLAIM() is called, if vnode is VMIO. For VMIO vnodes, set BO_DEAD in vm_object_terminate(). The vnode_destroy_object(), when calling into vm_object_terminate(), must be able to flush buffers. BO_DEAD purpose is to quickly destroy buffers on write when the underlying vnode is not operable any more (one example is the devfs node after geom is gone). Setting BO_DEAD for reclaiming vnode before object is terminated is premature, and results in unability to flush buffers with live SU dependencies from vinvalbuf() in vm_object_terminate(). Reported by: David Cross Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks --- sys/kern/vfs_subr.c | 8 +++++++- sys/vm/vm_object.c | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 5b4c8a7d38e6..58e430db7c62 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3232,7 +3232,13 @@ vgonel(struct vnode *vp) TAILQ_EMPTY(&vp->v_bufobj.bo_clean.bv_hd) && vp->v_bufobj.bo_clean.bv_cnt == 0, ("vp %p bufobj not invalidated", vp)); - vp->v_bufobj.bo_flag |= BO_DEAD; + + /* + * For VMIO bufobj, BO_DEAD is set in vm_object_terminate() + * after the object' page queue is flushed. + */ + if (vp->v_bufobj.bo_object == NULL) + vp->v_bufobj.bo_flag |= BO_DEAD; BO_UNLOCK(&vp->v_bufobj); /* diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 2af4b79c08ee..297b1171423a 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -741,6 +741,10 @@ vm_object_terminate(vm_object_t object) vinvalbuf(vp, V_SAVE, 0, 0); + BO_LOCK(&vp->v_bufobj); + vp->v_bufobj.bo_flag |= BO_DEAD; + BO_UNLOCK(&vp->v_bufobj); + VM_OBJECT_WLOCK(object); }