From fe71561af2c99e6eb2e9fbaa0896e124c5f340ea Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 27 May 2017 16:40:00 +0000 Subject: [PATCH] In r118390, the swap pager's approach to striping swap allocation over multiple devices was changed. However, swapoff_one() was not fully and correctly converted. In particular, with r118390's introduction of a per- device blist, the maximum swap block size, "dmmax", became irrelevant to swapoff_one()'s operation. Moreover, swapoff_one() was performing out-of- range operations on the per-device blist that were silently ignored by blist_fill(). This change corrects both of these problems with swapoff_one(), which will allow us to potentially increase MAX_PAGEOUT_CLUSTER. Previously, swapoff_one() would panic inside of blist_fill() if you increased MAX_PAGEOUT_CLUSTER. Reviewed by: kib, markj MFC after: 3 days --- sys/vm/swap_pager.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 2a73acaad66..16881368ddc 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -2310,9 +2310,13 @@ swapoff_one(struct swdevt *sp, struct ucred *cred) */ mtx_lock(&sw_dev_mtx); sp->sw_flags |= SW_CLOSING; - for (dvbase = 0; dvbase < sp->sw_end; dvbase += dmmax) { + for (dvbase = 0; dvbase < nblks; dvbase += BLIST_BMAP_RADIX) { + /* + * blist_fill() cannot allocate more than BLIST_BMAP_RADIX + * blocks per call. + */ swap_pager_avail -= blist_fill(sp->sw_blist, - dvbase, dmmax); + dvbase, ulmin(nblks - dvbase, BLIST_BMAP_RADIX)); } swap_total -= (vm_ooffset_t)nblks * PAGE_SIZE; mtx_unlock(&sw_dev_mtx);