aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2019-08-25 13:26:06 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2019-08-25 13:26:06 +0000
commit783a68aa336ca538534bbe520335a94f921d0e45 (patch)
tree92f988a9b5a25d521fefd79f98266e99494677a0 /sys
parent4e8671dd78cc77b31c598e83354fa6722acd4e3f (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/vm_object.c35
-rw-r--r--sys/vm/vnode_pager.c15
2 files changed, 20 insertions, 30 deletions
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 37fcfff775a5..20e3a562af91 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -653,9 +653,10 @@ doterm:
* recursion due to the terminate having to sync data
* to disk.
*/
- if ((object->flags & OBJ_DEAD) == 0)
+ if ((object->flags & OBJ_DEAD) == 0) {
+ vm_object_set_flag(object, OBJ_DEAD);
vm_object_terminate(object);
- else
+ } else
VM_OBJECT_WUNLOCK(object);
object = temp;
}
@@ -746,35 +747,9 @@ vm_object_terminate_pages(vm_object_t object)
void
vm_object_terminate(vm_object_t object)
{
-
VM_OBJECT_ASSERT_WLOCKED(object);
-
- /*
- * Make sure no one uses us.
- */
- vm_object_set_flag(object, OBJ_DEAD);
-
- /*
- * Clean and free the pages, as appropriate. All references to the
- * object are gone, so we don't need to lock it.
- */
- if (object->type == OBJT_VNODE) {
- struct vnode *vp = (struct vnode *)object->handle;
-
- /*
- * Clean pages and flush buffers.
- */
- vm_object_page_clean(object, 0, 0, OBJPC_SYNC);
- VM_OBJECT_WUNLOCK(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);
- }
+ KASSERT((object->flags & OBJ_DEAD) != 0,
+ ("terminating non-dead obj %p", object));
/*
* wait for the pageout daemon to be done with the object
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c
index 70c919d9134e..ed286e0024cd 100644
--- a/sys/vm/vnode_pager.c
+++ b/sys/vm/vnode_pager.c
@@ -200,6 +200,21 @@ vnode_destroy_vobject(struct vnode *vp)
* don't double-terminate the object
*/
if ((obj->flags & OBJ_DEAD) == 0) {
+ vm_object_set_flag(obj, OBJ_DEAD);
+
+ /*
+ * Clean pages and flush buffers.
+ */
+ vm_object_page_clean(obj, 0, 0, OBJPC_SYNC);
+ VM_OBJECT_WUNLOCK(obj);
+
+ 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(obj);
vm_object_terminate(obj);
} else {
/*