When the function blist_fill() was added to the kernel in r107913, the swap
pager used a different scheme for striping the allocation of swap space across multiple devices. And, although blist_fill() was intended to support fill operations with large counts, the old striping scheme never performed a fill larger than the stripe size. Consequently, the misplacement of a sanity check in blst_meta_fill() went undetected. Now, moving forward in time to r118390, a new scheme for striping was introduced that maintained a blist allocator per device, but as noted in r318995, swapoff_one() was not fully and correctly converted to the new scheme. This change completes what was started in r318995 by fixing the underlying bug in blst_meta_fill() that stops swapoff_one() from simply performing a single blist_fill() operation. Reviewed by: kib MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D11043
This commit is contained in:
@@ -769,6 +769,8 @@ blst_meta_fill(
|
|||||||
int next_skip = ((u_int)skip / BLIST_META_RADIX);
|
int next_skip = ((u_int)skip / BLIST_META_RADIX);
|
||||||
int nblks = 0;
|
int nblks = 0;
|
||||||
|
|
||||||
|
if (count > radix)
|
||||||
|
panic("blist_meta_fill: allocation too large");
|
||||||
if (count == radix || scan->u.bmu_avail == 0) {
|
if (count == radix || scan->u.bmu_avail == 0) {
|
||||||
/*
|
/*
|
||||||
* ALL-ALLOCATED special case
|
* ALL-ALLOCATED special case
|
||||||
@@ -800,9 +802,6 @@ blst_meta_fill(
|
|||||||
radix /= BLIST_META_RADIX;
|
radix /= BLIST_META_RADIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > radix)
|
|
||||||
panic("blist_meta_fill: allocation too large");
|
|
||||||
|
|
||||||
i = (allocBlk - blk) / radix;
|
i = (allocBlk - blk) / radix;
|
||||||
blk += i * radix;
|
blk += i * radix;
|
||||||
i = i * next_skip + 1;
|
i = i * next_skip + 1;
|
||||||
|
|||||||
+2
-9
@@ -2271,7 +2271,7 @@ sys_swapoff(struct thread *td, struct swapoff_args *uap)
|
|||||||
static int
|
static int
|
||||||
swapoff_one(struct swdevt *sp, struct ucred *cred)
|
swapoff_one(struct swdevt *sp, struct ucred *cred)
|
||||||
{
|
{
|
||||||
u_long nblks, dvbase;
|
u_long nblks;
|
||||||
#ifdef MAC
|
#ifdef MAC
|
||||||
int error;
|
int error;
|
||||||
#endif
|
#endif
|
||||||
@@ -2300,14 +2300,7 @@ swapoff_one(struct swdevt *sp, struct ucred *cred)
|
|||||||
*/
|
*/
|
||||||
mtx_lock(&sw_dev_mtx);
|
mtx_lock(&sw_dev_mtx);
|
||||||
sp->sw_flags |= SW_CLOSING;
|
sp->sw_flags |= SW_CLOSING;
|
||||||
for (dvbase = 0; dvbase < nblks; dvbase += BLIST_BMAP_RADIX) {
|
swap_pager_avail -= blist_fill(sp->sw_blist, 0, nblks);
|
||||||
/*
|
|
||||||
* blist_fill() cannot allocate more than BLIST_BMAP_RADIX
|
|
||||||
* blocks per call.
|
|
||||||
*/
|
|
||||||
swap_pager_avail -= blist_fill(sp->sw_blist,
|
|
||||||
dvbase, ulmin(nblks - dvbase, BLIST_BMAP_RADIX));
|
|
||||||
}
|
|
||||||
swap_total -= (vm_ooffset_t)nblks * PAGE_SIZE;
|
swap_total -= (vm_ooffset_t)nblks * PAGE_SIZE;
|
||||||
mtx_unlock(&sw_dev_mtx);
|
mtx_unlock(&sw_dev_mtx);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user