Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/swap_pager.c
Show First 20 Lines • Show All 418 Lines • ▼ Show 20 Lines | |||||
static void swp_pager_async_iodone(struct buf *bp); | static void swp_pager_async_iodone(struct buf *bp); | ||||
static bool swp_pager_swblk_empty(struct swblk *sb, int start, int limit); | static bool swp_pager_swblk_empty(struct swblk *sb, int start, int limit); | ||||
static void swp_pager_free_empty_swblk(vm_object_t, struct swblk *sb); | static void swp_pager_free_empty_swblk(vm_object_t, struct swblk *sb); | ||||
static int swapongeom(struct vnode *); | static int swapongeom(struct vnode *); | ||||
static int swaponvp(struct thread *, struct vnode *, u_long); | static int swaponvp(struct thread *, struct vnode *, u_long); | ||||
static int swapoff_one(struct swdevt *sp, struct ucred *cred); | static int swapoff_one(struct swdevt *sp, struct ucred *cred); | ||||
/* | /* | ||||
* Swap swblk functions | |||||
*/ | |||||
static bool swp_swblk_available(struct swdevt *sp, int npages); | |||||
/* | |||||
* Swap bitmap functions | * Swap bitmap functions | ||||
*/ | */ | ||||
static void swp_pager_freeswapspace(daddr_t blk, daddr_t npages); | static void swp_pager_freeswapspace(daddr_t blk, daddr_t npages); | ||||
static daddr_t swp_pager_getswapspace(int *npages, int limit); | static daddr_t swp_pager_getswapspace(int *npages, int limit); | ||||
/* | /* | ||||
* Metadata functions | * Metadata functions | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | swap_pager_dealloc(vm_object_t object) | ||||
* associated with vm_page_t's for this object. We do not care | * associated with vm_page_t's for this object. We do not care | ||||
* if paging is still in progress on some objects. | * if paging is still in progress on some objects. | ||||
*/ | */ | ||||
swp_pager_meta_free_all(object); | swp_pager_meta_free_all(object); | ||||
object->handle = NULL; | object->handle = NULL; | ||||
object->type = OBJT_DEAD; | object->type = OBJT_DEAD; | ||||
} | } | ||||
static bool | |||||
swp_swblk_available(struct swdevt *sp, int npages) | |||||
{ | |||||
if (sp->sw_flags & SW_CLOSING) | |||||
return (false); | |||||
return (sp->sw_nblks - howmany(BBSIZE, PAGE_SIZE) - sp->sw_used >= | |||||
npages ); | |||||
} | |||||
/************************************************************************ | /************************************************************************ | ||||
* SWAP PAGER BITMAP ROUTINES * | * SWAP PAGER BITMAP ROUTINES * | ||||
************************************************************************/ | ************************************************************************/ | ||||
/* | /* | ||||
* SWP_PAGER_GETSWAPSPACE() - allocate raw swap space | * SWP_PAGER_GETSWAPSPACE() - allocate raw swap space | ||||
* | * | ||||
* Allocate swap for up to the requested number of pages, and at | * Allocate swap for up to the requested number of pages, and at | ||||
Show All 18 Lines | swp_pager_getswapspace(int *io_npages, int limit) | ||||
blk = SWAPBLK_NONE; | blk = SWAPBLK_NONE; | ||||
mpages = *io_npages; | mpages = *io_npages; | ||||
npages = imin(BLIST_MAX_ALLOC, mpages); | npages = imin(BLIST_MAX_ALLOC, mpages); | ||||
mtx_lock(&sw_dev_mtx); | mtx_lock(&sw_dev_mtx); | ||||
sp = swdevhd; | sp = swdevhd; | ||||
while (!TAILQ_EMPTY(&swtailq)) { | while (!TAILQ_EMPTY(&swtailq)) { | ||||
if (sp == NULL) | if (sp == NULL) | ||||
sp = TAILQ_FIRST(&swtailq); | sp = TAILQ_FIRST(&swtailq); | ||||
if ((sp->sw_flags & SW_CLOSING) == 0) | if (swp_swblk_available(sp, npages)) | ||||
blk = blist_alloc(sp->sw_blist, &npages, mpages); | blk = blist_alloc(sp->sw_blist, &npages, mpages); | ||||
if (blk != SWAPBLK_NONE) | if (blk != SWAPBLK_NONE) | ||||
break; | break; | ||||
sp = TAILQ_NEXT(sp, sw_list); | sp = TAILQ_NEXT(sp, sw_list); | ||||
if (swdevhd == sp) { | if (swdevhd == sp) { | ||||
if (npages <= limit) | if (npages <= limit) | ||||
break; | break; | ||||
mpages = npages - 1; | mpages = npages - 1; | ||||
▲ Show 20 Lines • Show All 2,325 Lines • Show Last 20 Lines |