* vm_object_terminate_pages removes any remaining pageable pages * from the object and resets the object to an empty state. */
| 877 | * from the object and resets the object to an empty state. |
| 878 | */ |
| 879 | static void |
| 880 | vm_object_terminate_pages(vm_object_t object) |
| 881 | { |
| 882 | vm_page_t p, p_next; |
| 883 | |
| 884 | VM_OBJECT_ASSERT_WLOCKED(object); |
| 885 | |
| 886 | /* |
| 887 | * Free any remaining pageable pages. This also removes them from the |
| 888 | * paging queues. However, don't free wired pages, just remove them |
| 889 | * from the object. Rather than incrementally removing each page from |
| 890 | * the object, the page and object are reset to any empty state. |
| 891 | */ |
| 892 | TAILQ_FOREACH_SAFE(p, &object->memq, listq, p_next) { |
| 893 | vm_page_assert_unbusied(p); |
| 894 | KASSERT(p->object == object && |
| 895 | (p->ref_count & VPRC_OBJREF) != 0, |
| 896 | ("vm_object_terminate_pages: page %p is inconsistent", p)); |
| 897 | |
| 898 | p->object = NULL; |
| 899 | if (vm_page_drop(p, VPRC_OBJREF) == VPRC_OBJREF) { |
| 900 | VM_CNT_INC(v_pfree); |
| 901 | vm_page_free(p); |
| 902 | } |
| 903 | } |
| 904 | |
| 905 | /* |
| 906 | * If the object contained any pages, then reset it to an empty state. |
| 907 | * None of the object's fields, including "resident_page_count", were |
| 908 | * modified by the preceding loop. |
| 909 | */ |
| 910 | if (object->resident_page_count != 0) { |
| 911 | vm_radix_reclaim_allnodes(&object->rtree); |
| 912 | TAILQ_INIT(&object->memq); |
| 913 | object->resident_page_count = 0; |
| 914 | if (object->type == OBJT_VNODE) |
| 915 | vdrop(object->handle); |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | /* |
| 920 | * vm_object_terminate actually destroys the specified object, freeing |
no test coverage detected