mirror of
https://github.com/opnsense/src.git
synced 2026-06-06 23:32:52 -04:00
vnode_pager: simplify loop, avoid overflow
Filling in read-behind pages in vnode_pager_generic_getpages() is made very slightly simpler here, by avoiding overflowing the startpindex variable and then avoiding an extra test in the allocation loop that handles the overflow case. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D49200
This commit is contained in:
parent
23da585dd4
commit
420e2f8a74
1 changed files with 6 additions and 11 deletions
|
|
@ -1045,18 +1045,13 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int count,
|
|||
vm_page_t mpred, p;
|
||||
|
||||
VM_OBJECT_WLOCK(object);
|
||||
startpindex = m[0]->pindex - rbehind;
|
||||
if ((mpred = TAILQ_PREV(m[0], pglist, listq)) != NULL &&
|
||||
mpred->pindex >= startpindex)
|
||||
startpindex = mpred->pindex + 1;
|
||||
tpindex = m[0]->pindex;
|
||||
startpindex = MAX(tpindex, rbehind) - rbehind;
|
||||
if ((mpred = TAILQ_PREV(m[0], pglist, listq)) != NULL)
|
||||
startpindex = MAX(startpindex, mpred->pindex + 1);
|
||||
|
||||
/*
|
||||
* tpindex is unsigned; beware of numeric underflow.
|
||||
* Stepping backward from pindex, mpred doesn't change.
|
||||
*/
|
||||
for (tpindex = m[0]->pindex - 1;
|
||||
tpindex >= startpindex && tpindex < m[0]->pindex;
|
||||
tpindex--, i++) {
|
||||
/* Stepping backward from pindex, mpred doesn't change. */
|
||||
for (; tpindex-- > startpindex; i++) {
|
||||
p = vm_page_alloc_after(object, tpindex,
|
||||
VM_ALLOC_NORMAL, mpred);
|
||||
if (p == NULL) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue