Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/swap_pager.c
Show First 20 Lines • Show All 1,120 Lines • ▼ Show 20 Lines | swap_pager_getpages(vm_object_t object, vm_page_t *m, int count, int *rbehind, | ||||
/* | /* | ||||
* Allocate readahead and readbehind pages. | * Allocate readahead and readbehind pages. | ||||
*/ | */ | ||||
shift = rbehind != NULL ? *rbehind : 0; | shift = rbehind != NULL ? *rbehind : 0; | ||||
if (shift != 0) { | if (shift != 0) { | ||||
for (i = 1; i <= shift; i++) { | for (i = 1; i <= shift; i++) { | ||||
p = vm_page_alloc(object, m[0]->pindex - i, | p = vm_page_alloc(object, m[0]->pindex - i, | ||||
VM_ALLOC_NORMAL | VM_ALLOC_IFNOTCACHED); | VM_ALLOC_NORMAL); | ||||
if (p == NULL) { | if (p == NULL) { | ||||
/* Shift allocated pages to the left. */ | /* Shift allocated pages to the left. */ | ||||
for (j = 0; j < i - 1; j++) | for (j = 0; j < i - 1; j++) | ||||
bp->b_pages[j] = | bp->b_pages[j] = | ||||
bp->b_pages[j + shift - i + 1]; | bp->b_pages[j + shift - i + 1]; | ||||
break; | break; | ||||
} | } | ||||
bp->b_pages[shift - i] = p; | bp->b_pages[shift - i] = p; | ||||
} | } | ||||
shift = i - 1; | shift = i - 1; | ||||
*rbehind = shift; | *rbehind = shift; | ||||
} | } | ||||
for (i = 0; i < reqcount; i++) | for (i = 0; i < reqcount; i++) | ||||
bp->b_pages[i + shift] = m[i]; | bp->b_pages[i + shift] = m[i]; | ||||
if (rahead != NULL) { | if (rahead != NULL) { | ||||
for (i = 0; i < *rahead; i++) { | for (i = 0; i < *rahead; i++) { | ||||
p = vm_page_alloc(object, | p = vm_page_alloc(object, | ||||
m[reqcount - 1]->pindex + i + 1, | m[reqcount - 1]->pindex + i + 1, VM_ALLOC_NORMAL); | ||||
VM_ALLOC_NORMAL | VM_ALLOC_IFNOTCACHED); | |||||
if (p == NULL) | if (p == NULL) | ||||
break; | break; | ||||
bp->b_pages[shift + reqcount + i] = p; | bp->b_pages[shift + reqcount + i] = p; | ||||
} | } | ||||
*rahead = i; | *rahead = i; | ||||
} | } | ||||
if (rbehind != NULL) | if (rbehind != NULL) | ||||
count += *rbehind; | count += *rbehind; | ||||
▲ Show 20 Lines • Show All 1,625 Lines • Show Last 20 Lines |