* SWAP_PAGER_ALLOC() - allocate a new OBJT_SWAP VM object and instantiate * its metadata structures. * * This routine is called from the mmap and fork code to create a new * OBJT_SWAP object. * * This routine must ensure that no live duplicate is created for * the named object request, which is protected against by * holding the sw_alloc_sx lock in case handle != NULL. */
| 695 | * holding the sw_alloc_sx lock in case handle != NULL. |
| 696 | */ |
| 697 | static vm_object_t |
| 698 | swap_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, |
| 699 | vm_ooffset_t offset, struct ucred *cred) |
| 700 | { |
| 701 | vm_object_t object; |
| 702 | |
| 703 | if (handle != NULL) { |
| 704 | /* |
| 705 | * Reference existing named region or allocate new one. There |
| 706 | * should not be a race here against swp_pager_meta_build() |
| 707 | * as called from vm_page_remove() in regards to the lookup |
| 708 | * of the handle. |
| 709 | */ |
| 710 | sx_xlock(&sw_alloc_sx); |
| 711 | object = vm_pager_object_lookup(NOBJLIST(handle), handle); |
| 712 | if (object == NULL) { |
| 713 | object = swap_pager_alloc_init(handle, cred, size, |
| 714 | offset); |
| 715 | if (object != NULL) { |
| 716 | TAILQ_INSERT_TAIL(NOBJLIST(object->handle), |
| 717 | object, pager_object_list); |
| 718 | } |
| 719 | } |
| 720 | sx_xunlock(&sw_alloc_sx); |
| 721 | } else { |
| 722 | object = swap_pager_alloc_init(handle, cred, size, offset); |
| 723 | } |
| 724 | return (object); |
| 725 | } |
| 726 | |
| 727 | /* |
| 728 | * SWAP_PAGER_DEALLOC() - remove swap metadata from object |
nothing calls this directly
no test coverage detected