Page MenuHomeFreeBSD

D49224.id151827.diff
No OneTemporary

D49224.id151827.diff

Index: sys/vm/swap_pager.c
===================================================================
--- sys/vm/swap_pager.c
+++ sys/vm/swap_pager.c
@@ -1359,7 +1359,7 @@
vm_page_t *ma, int count, int *rbehind, int *rahead)
{
struct buf *bp;
- vm_page_t bm, mpred, msucc, p;
+ vm_page_t mpred, msucc, p;
vm_pindex_t pindex;
daddr_t blk;
int i, maxahead, maxbehind, reqcount;
@@ -1393,60 +1393,65 @@
* Clip the readahead and readbehind ranges to exclude resident pages.
*/
if (rahead != NULL) {
- *rahead = imin(*rahead, maxahead - (reqcount - 1));
+ maxahead = imin(*rahead, maxahead - (reqcount - 1));
pindex = ma[reqcount - 1]->pindex;
msucc = TAILQ_NEXT(ma[reqcount - 1], listq);
- if (msucc != NULL && msucc->pindex - pindex - 1 < *rahead)
- *rahead = msucc->pindex - pindex - 1;
+ if (msucc != NULL)
+ maxahead = MIN(maxahead, msucc->pindex - pindex - 1);
+ count += maxahead;
}
if (rbehind != NULL) {
- *rbehind = imin(*rbehind, maxbehind);
+ maxbehind = imin(*rbehind, maxbehind);
pindex = ma[0]->pindex;
mpred = TAILQ_PREV(ma[0], pglist, listq);
- if (mpred != NULL && pindex - mpred->pindex - 1 < *rbehind)
- *rbehind = pindex - mpred->pindex - 1;
- }
+ if (mpred != NULL)
+ maxbehind = MIN(maxbehind, pindex - mpred->pindex - 1);
+ count += maxbehind;
+ } else
+ maxbehind = 0;
- bm = ma[0];
- for (i = 0; i < count; i++)
+ vm_page_t b_pages[count];
+ for (i = 0; i < reqcount; i++) {
ma[i]->oflags |= VPO_SWAPINPROG;
+ b_pages[i + maxbehind] = ma[i];
+ }
/*
* Allocate readahead and readbehind pages.
*/
+ if (rahead != NULL) {
+ p = ma[reqcount - 1];
+ pindex = p->pindex;
+ for (i = 1; i <= maxahead; i++) {
+ p = vm_page_alloc_after(object, pindex + i,
+ VM_ALLOC_NORMAL, p);
+ if (p == NULL)
+ break;
+ p->oflags |= VPO_SWAPINPROG;
+ b_pages[count - maxahead + i - 1] = p;
+ }
+ *rahead = i - 1;
+ count -= maxahead - *rahead;
+ }
if (rbehind != NULL) {
pindex = ma[0]->pindex;
/* Stepping backward from pindex, mpred doesn't change. */
- for (i = 1; i <= *rbehind; i++) {
+ for (i = 1; i <= maxbehind; i++) {
p = vm_page_alloc_after(object, pindex - i,
VM_ALLOC_NORMAL, mpred);
if (p == NULL)
break;
p->oflags |= VPO_SWAPINPROG;
- bm = p;
+ b_pages[maxbehind - i] = p;
}
*rbehind = i - 1;
+ count -= maxbehind - *rbehind;
+ maxbehind -= *rbehind;
}
- if (rahead != NULL) {
- p = ma[reqcount - 1];
- pindex = p->pindex;
- for (i = 0; i < *rahead; i++) {
- p = vm_page_alloc_after(object, pindex + i + 1,
- VM_ALLOC_NORMAL, p);
- if (p == NULL)
- break;
- p->oflags |= VPO_SWAPINPROG;
- }
- *rahead = i;
- }
- if (rbehind != NULL)
- count += *rbehind;
- if (rahead != NULL)
- count += *rahead;
vm_object_pip_add(object, count);
- pindex = bm->pindex;
+ pindex = b_pages[maxbehind]->pindex;
blk = swp_pager_meta_lookup(blks, pindex);
KASSERT(blk != SWAPBLK_NONE,
("no swap blocking containing %p(%jx)", object, (uintmax_t)pindex));
@@ -1455,10 +1460,8 @@
bp = uma_zalloc(swrbuf_zone, M_WAITOK);
MPASS((bp->b_flags & B_MAXPHYS) != 0);
/* Pages cannot leave the object while busy. */
- for (i = 0, p = bm; i < count; i++, p = TAILQ_NEXT(p, listq)) {
- MPASS(p->pindex == bm->pindex + i);
- bp->b_pages[i] = p;
- }
+ for (i = 0; i < count; i++)
+ bp->b_pages[i] = b_pages[i + maxbehind];
bp->b_flags |= B_PAGING;
bp->b_iocmd = BIO_READ;

File Metadata

Mime Type
text/plain
Expires
Wed, Jun 24, 5:13 PM (21 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34289491
Default Alt Text
D49224.id151827.diff (3 KB)

Event Timeline