Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/swap_pager.c
Show First 20 Lines • Show All 1,543 Lines • ▼ Show 20 Lines | if (bp->b_ioflags & BIO_ERROR) { | ||||
if (i < bp->b_pgbefore || | if (i < bp->b_pgbefore || | ||||
i >= bp->b_npages - bp->b_pgafter) | i >= bp->b_npages - bp->b_pgafter) | ||||
vm_page_readahead_finish(m); | vm_page_readahead_finish(m); | ||||
} else { | } else { | ||||
/* | /* | ||||
* For write success, clear the dirty | * For write success, clear the dirty | ||||
* status, then finish the I/O ( which decrements the | * status, then finish the I/O ( which decrements the | ||||
* busy count and possibly wakes waiter's up ). | * busy count and possibly wakes waiter's up ). | ||||
* A page is only written to swap after a period of | |||||
* inactivity. Therefore, we do not expect it to be | |||||
* reused. | |||||
*/ | */ | ||||
KASSERT(!pmap_page_is_write_mapped(m), | KASSERT(!pmap_page_is_write_mapped(m), | ||||
("swp_pager_async_iodone: page %p is not write" | ("swp_pager_async_iodone: page %p is not write" | ||||
" protected", m)); | " protected", m)); | ||||
vm_page_undirty(m); | vm_page_undirty(m); | ||||
vm_page_sunbusy(m); | |||||
if (vm_page_count_severe()) { | |||||
vm_page_lock(m); | vm_page_lock(m); | ||||
vm_page_try_to_cache(m); | vm_page_deactivate_noreuse(m); | ||||
vm_page_unlock(m); | vm_page_unlock(m); | ||||
vm_page_sunbusy(m); | |||||
} | } | ||||
} | } | ||||
} | |||||
/* | /* | ||||
* adjust pip. NOTE: the original parent may still have its own | * adjust pip. NOTE: the original parent may still have its own | ||||
* pip refs on the object. | * pip refs on the object. | ||||
*/ | */ | ||||
if (object != NULL) { | if (object != NULL) { | ||||
vm_object_pip_wakeupn(object, bp->b_npages); | vm_object_pip_wakeupn(object, bp->b_npages); | ||||
VM_OBJECT_WUNLOCK(object); | VM_OBJECT_WUNLOCK(object); | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | swap_pager_isswapped(vm_object_t object, struct swdevt *sp) | ||||
} | } | ||||
mtx_unlock(&swhash_mtx); | mtx_unlock(&swhash_mtx); | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* SWP_PAGER_FORCE_PAGEIN() - force a swap block to be paged in | * SWP_PAGER_FORCE_PAGEIN() - force a swap block to be paged in | ||||
* | * | ||||
* This routine dissociates the page at the given index within a | * This routine dissociates the page at the given index within an object | ||||
* swap block from its backing store, paging it in if necessary. | * from its backing store, paging it in if it does not reside in memory. | ||||
* If the page is paged in, it is placed in the inactive queue, | * If the page is paged in, it is marked dirty and placed in the laundry | ||||
* since it had its backing store ripped out from under it. | * queue. The page is marked dirty because it no longer has backing | ||||
* We also attempt to swap in all other pages in the swap block, | * store. It is placed in the laundry queue because it has not been | ||||
* we only guarantee that the one at the specified index is | * accessed recently. Otherwise, it would already reside in memory. | ||||
* | |||||
* We also attempt to swap in all other pages in the swap block. | |||||
* However, we only guarantee that the one at the specified index is | |||||
* paged in. | * paged in. | ||||
* | * | ||||
* XXX - The code to page the whole block in doesn't work, so we | * XXX - The code to page the whole block in doesn't work, so we | ||||
* revert to the one-by-one behavior for now. Sigh. | * revert to the one-by-one behavior for now. Sigh. | ||||
*/ | */ | ||||
static inline void | static inline void | ||||
swp_pager_force_pagein(vm_object_t object, vm_pindex_t pindex) | swp_pager_force_pagein(vm_object_t object, vm_pindex_t pindex) | ||||
{ | { | ||||
Show All 12 Lines | if (m->valid == VM_PAGE_BITS_ALL) { | ||||
return; | return; | ||||
} | } | ||||
if (swap_pager_getpages(object, &m, 1, NULL, NULL) != VM_PAGER_OK) | if (swap_pager_getpages(object, &m, 1, NULL, NULL) != VM_PAGER_OK) | ||||
panic("swap_pager_force_pagein: read from swap failed");/*XXX*/ | panic("swap_pager_force_pagein: read from swap failed");/*XXX*/ | ||||
vm_object_pip_wakeup(object); | vm_object_pip_wakeup(object); | ||||
vm_page_dirty(m); | vm_page_dirty(m); | ||||
vm_page_lock(m); | vm_page_lock(m); | ||||
vm_page_deactivate(m); | vm_page_launder(m); | ||||
vm_page_unlock(m); | vm_page_unlock(m); | ||||
vm_page_xunbusy(m); | vm_page_xunbusy(m); | ||||
vm_pager_page_unswapped(m); | vm_pager_page_unswapped(m); | ||||
} | } | ||||
/* | /* | ||||
* swap_pager_swapoff: | * swap_pager_swapoff: | ||||
* | * | ||||
▲ Show 20 Lines • Show All 1,097 Lines • Show Last 20 Lines |