Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/swap_pager.c
Show First 20 Lines • Show All 2,270 Lines • ▼ Show 20 Lines | swp_pager_meta_lookup(vm_object_t object, vm_pindex_t pindex) | ||||||||
if (sb == NULL) | if (sb == NULL) | ||||||||
return (SWAPBLK_NONE); | return (SWAPBLK_NONE); | ||||||||
return (sb->d[pindex % SWAP_META_PAGES]); | return (sb->d[pindex % SWAP_META_PAGES]); | ||||||||
} | } | ||||||||
/* | /* | ||||||||
* Returns the least page index which is greater than or equal to the | * Returns the least page index which is greater than or equal to the | ||||||||
* parameter pindex and for which there is a swap block allocated. | * parameter pindex and for which there is a swap block allocated. | ||||||||
* Returns object's size if the object's type is not swap or if there | * Returns object's size if the object's type is not swap or if there | ||||||||
kibUnsubmitted Not Done Inline Actions
kib: | |||||||||
* are no allocated swap blocks for the object after the requested | * are no allocated swap blocks for the object after the requested | ||||||||
* pindex. | * pindex. | ||||||||
*/ | */ | ||||||||
vm_pindex_t | vm_pindex_t | ||||||||
swap_pager_find_least(vm_object_t object, vm_pindex_t pindex) | swap_pager_find_least(vm_object_t object, vm_pindex_t pindex) | ||||||||
{ | { | ||||||||
struct swblk *sb; | struct swblk *sb; | ||||||||
int i; | int i; | ||||||||
VM_OBJECT_ASSERT_LOCKED(object); | VM_OBJECT_ASSERT_LOCKED(object); | ||||||||
MPASS((object->flags & OBJ_SWAP) != 0); | MPASS((object->flags & OBJ_SWAP) != 0); | ||||||||
if (pctrie_is_empty(&object->un_pager.swp.swp_blks)) | |||||||||
return (object->size); | |||||||||
sb = SWAP_PCTRIE_LOOKUP_GE(&object->un_pager.swp.swp_blks, | sb = SWAP_PCTRIE_LOOKUP_GE(&object->un_pager.swp.swp_blks, | ||||||||
rounddown(pindex, SWAP_META_PAGES)); | rounddown(pindex, SWAP_META_PAGES)); | ||||||||
if (sb == NULL) | if (sb == NULL) | ||||||||
return (object->size); | return (object->size); | ||||||||
if (sb->p < pindex) { | for (i = pindex - sb->p; i < SWAP_META_PAGES; i++) { | ||||||||
for (i = pindex % SWAP_META_PAGES; i < SWAP_META_PAGES; i++) { | |||||||||
if (sb->d[i] != SWAPBLK_NONE) | if (sb->d[i] != SWAPBLK_NONE) | ||||||||
return (sb->p + i); | return (sb->p + i); | ||||||||
} | } | ||||||||
sb = SWAP_PCTRIE_LOOKUP_GE(&object->un_pager.swp.swp_blks, | sb = SWAP_PCTRIE_LOOKUP_GE(&object->un_pager.swp.swp_blks, pindex); | ||||||||
roundup(pindex, SWAP_META_PAGES)); | |||||||||
if (sb == NULL) | if (sb == NULL) | ||||||||
return (object->size); | return (object->size); | ||||||||
} | |||||||||
for (i = 0; i < SWAP_META_PAGES; i++) { | for (i = 0; i < SWAP_META_PAGES; i++) { | ||||||||
if (sb->d[i] != SWAPBLK_NONE) | if (sb->d[i] != SWAPBLK_NONE) | ||||||||
return (sb->p + i); | return (sb->p + i); | ||||||||
} | } | ||||||||
/* | /* | ||||||||
* We get here if a swblk is present in the trie but it | * We get here if a swblk is present in the trie but it | ||||||||
* doesn't map any blocks. | * doesn't map any blocks. | ||||||||
*/ | */ | ||||||||
MPASS(0); | __unreachable(); | ||||||||
Not Done Inline ActionsPerhaps it is the time to change these two lines into __unreachable(). kib: Perhaps it is the time to change these two lines into __unreachable(). | |||||||||
return (object->size); | return (object->size); | ||||||||
} | } | ||||||||
/* | /* | ||||||||
* System call swapon(name) enables swapping on device name, | * System call swapon(name) enables swapping on device name, | ||||||||
* which must be in the swdevsw. Return EBUSY | * which must be in the swdevsw. Return EBUSY | ||||||||
* if already swapping on this device. | * if already swapping on this device. | ||||||||
*/ | */ | ||||||||
▲ Show 20 Lines • Show All 842 Lines • Show Last 20 Lines |