Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_object.c
Show First 20 Lines • Show All 647 Lines • ▼ Show 20 Lines | if (temp != NULL) { | ||||
VM_OBJECT_WUNLOCK(temp); | VM_OBJECT_WUNLOCK(temp); | ||||
object->backing_object = NULL; | object->backing_object = NULL; | ||||
} | } | ||||
/* | /* | ||||
* Don't double-terminate, we could be in a termination | * Don't double-terminate, we could be in a termination | ||||
* recursion due to the terminate having to sync data | * recursion due to the terminate having to sync data | ||||
* to disk. | * 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); | vm_object_terminate(object); | ||||
else | } else | ||||
VM_OBJECT_WUNLOCK(object); | VM_OBJECT_WUNLOCK(object); | ||||
object = temp; | object = temp; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* vm_object_destroy removes the object from the global object list | * vm_object_destroy removes the object from the global object list | ||||
* and frees the space for the object. | * and frees the space for the object. | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
* up all previously used resources. | * up all previously used resources. | ||||
* | * | ||||
* The object must be locked. | * The object must be locked. | ||||
* This routine may block. | * This routine may block. | ||||
*/ | */ | ||||
void | void | ||||
vm_object_terminate(vm_object_t object) | vm_object_terminate(vm_object_t object) | ||||
{ | { | ||||
VM_OBJECT_ASSERT_WLOCKED(object); | VM_OBJECT_ASSERT_WLOCKED(object); | ||||
KASSERT((object->flags & OBJ_DEAD) != 0, | |||||
/* | ("terminating non-dead obj %p", 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); | |||||
} | |||||
/* | /* | ||||
* wait for the pageout daemon to be done with the object | * wait for the pageout daemon to be done with the object | ||||
*/ | */ | ||||
vm_object_pip_wait(object, "objtrm"); | vm_object_pip_wait(object, "objtrm"); | ||||
KASSERT(!object->paging_in_progress, | KASSERT(!object->paging_in_progress, | ||||
("vm_object_terminate: pageout in progress")); | ("vm_object_terminate: pageout in progress")); | ||||
▲ Show 20 Lines • Show All 1,896 Lines • Show Last 20 Lines |