Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sendfile.c
Show First 20 Lines • Show All 879 Lines • ▼ Show 20 Lines | #endif | ||||
npages = howmany(space + (off & PAGE_MASK), PAGE_SIZE); | npages = howmany(space + (off & PAGE_MASK), PAGE_SIZE); | ||||
/* | /* | ||||
* Calculate maximum allowed number of pages for readahead | * Calculate maximum allowed number of pages for readahead | ||||
* at this iteration. If SF_USER_READAHEAD was set, we don't | * at this iteration. If SF_USER_READAHEAD was set, we don't | ||||
* do any heuristics and use exactly the value supplied by | * do any heuristics and use exactly the value supplied by | ||||
* application. Otherwise, we allow readahead up to "rem". | * application. Otherwise, we allow readahead up to "rem". | ||||
* If application wants more, let it be, but there is no | * If application wants more, let it be, but there is no | ||||
* reason to go above MAXPHYS. Also check against "obj_size", | * reason to go above maxphys. Also check against "obj_size", | ||||
* since vm_pager_has_page() can hint beyond EOF. | * since vm_pager_has_page() can hint beyond EOF. | ||||
*/ | */ | ||||
if (flags & SF_USER_READAHEAD) { | if (flags & SF_USER_READAHEAD) { | ||||
rhpages = SF_READAHEAD(flags); | rhpages = SF_READAHEAD(flags); | ||||
} else { | } else { | ||||
rhpages = howmany(rem + (off & PAGE_MASK), PAGE_SIZE) - | rhpages = howmany(rem + (off & PAGE_MASK), PAGE_SIZE) - | ||||
npages; | npages; | ||||
rhpages += SF_READAHEAD(flags); | rhpages += SF_READAHEAD(flags); | ||||
} | } | ||||
rhpages = min(howmany(MAXPHYS, PAGE_SIZE), rhpages); | rhpages = min(howmany(maxphys, PAGE_SIZE), rhpages); | ||||
rhpages = min(howmany(obj_size - trunc_page(off), PAGE_SIZE) - | rhpages = min(howmany(obj_size - trunc_page(off), PAGE_SIZE) - | ||||
npages, rhpages); | npages, rhpages); | ||||
sfio = malloc(sizeof(struct sf_io) + | sfio = malloc(sizeof(struct sf_io) + | ||||
npages * sizeof(vm_page_t), M_SENDFILE, M_WAITOK); | npages * sizeof(vm_page_t), M_SENDFILE, M_WAITOK); | ||||
refcount_init(&sfio->nios, 1); | refcount_init(&sfio->nios, 1); | ||||
sfio->obj = obj; | sfio->obj = obj; | ||||
sfio->error = 0; | sfio->error = 0; | ||||
▲ Show 20 Lines • Show All 430 Lines • Show Last 20 Lines |