vm: object: implement object cleanup
This commit is contained in:
@@ -15,10 +15,30 @@
|
|||||||
(p) += VM_PAGE_SIZE; \
|
(p) += VM_PAGE_SIZE; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static kern_status_t vm_object_cleanup(struct object *obj, struct queue *q)
|
||||||
|
{
|
||||||
|
struct vm_object *vmo = vm_object_cast(obj);
|
||||||
|
struct btree_node *cur = btree_first(&vmo->vo_pages);
|
||||||
|
while (cur) {
|
||||||
|
struct vm_page *pg
|
||||||
|
= BTREE_CONTAINER(struct vm_page, p_bnode, cur);
|
||||||
|
struct btree_node *next = btree_next(cur);
|
||||||
|
btree_delete(&vmo->vo_pages, cur);
|
||||||
|
|
||||||
|
vm_page_free(pg);
|
||||||
|
cur = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return KERN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static struct object_type vm_object_type = {
|
static struct object_type vm_object_type = {
|
||||||
.ob_name = "vm-object",
|
.ob_name = "vm-object",
|
||||||
.ob_size = sizeof(struct vm_object),
|
.ob_size = sizeof(struct vm_object),
|
||||||
.ob_header_offset = offsetof(struct vm_object, vo_base),
|
.ob_header_offset = offsetof(struct vm_object, vo_base),
|
||||||
|
.ob_ops = {
|
||||||
|
.destroy = vm_object_cleanup,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
struct object_iterator {
|
struct object_iterator {
|
||||||
|
|||||||
Reference in New Issue
Block a user