Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/swap_pager.c
Show First 20 Lines • Show All 2,322 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static void | static void | ||||
swaponsomething(struct vnode *vp, void *id, u_long nblks, | swaponsomething(struct vnode *vp, void *id, u_long nblks, | ||||
sw_strategy_t *strategy, sw_close_t *close, dev_t dev, int flags) | sw_strategy_t *strategy, sw_close_t *close, dev_t dev, int flags) | ||||
{ | { | ||||
struct swdevt *sp, *tsp; | struct swdevt *sp, *tsp; | ||||
daddr_t dvbase; | daddr_t dvbase; | ||||
u_long mblocks; | |||||
/* | /* | ||||
* nblks is in DEV_BSIZE'd chunks, convert to PAGE_SIZE'd chunks. | * nblks is in DEV_BSIZE'd chunks, convert to PAGE_SIZE'd chunks. | ||||
* First chop nblks off to page-align it, then convert. | * First chop nblks off to page-align it, then convert. | ||||
* | * | ||||
* sw->sw_nblks is in page-sized chunks now too. | * sw->sw_nblks is in page-sized chunks now too. | ||||
*/ | */ | ||||
nblks &= ~(ctodb(1) - 1); | nblks &= ~(ctodb(1) - 1); | ||||
nblks = dbtoc(nblks); | nblks = dbtoc(nblks); | ||||
/* | |||||
* If we go beyond this, we get overflows in the radix | |||||
* tree bitmap code. | |||||
*/ | |||||
mblocks = 0x40000000 / BLIST_META_RADIX; | |||||
if (nblks > mblocks) { | |||||
printf( | |||||
"WARNING: reducing swap size to maximum of %luMB per unit\n", | |||||
mblocks / 1024 / 1024 * PAGE_SIZE); | |||||
nblks = mblocks; | |||||
} | |||||
sp = malloc(sizeof *sp, M_VMPGDATA, M_WAITOK | M_ZERO); | sp = malloc(sizeof *sp, M_VMPGDATA, M_WAITOK | M_ZERO); | ||||
sp->sw_blist = blist_create(nblks, M_WAITOK); | |||||
sp->sw_vp = vp; | sp->sw_vp = vp; | ||||
sp->sw_id = id; | sp->sw_id = id; | ||||
sp->sw_dev = dev; | sp->sw_dev = dev; | ||||
sp->sw_nblks = nblks; | sp->sw_nblks = nblks; | ||||
sp->sw_used = 0; | sp->sw_used = 0; | ||||
sp->sw_strategy = strategy; | sp->sw_strategy = strategy; | ||||
sp->sw_close = close; | sp->sw_close = close; | ||||
sp->sw_flags = flags; | sp->sw_flags = flags; | ||||
sp->sw_blist = blist_create(nblks, M_WAITOK); | |||||
/* | /* | ||||
* Do not free the first blocks in order to avoid overwriting | * Do not free the first blocks in order to avoid overwriting | ||||
* any bsd label at the front of the partition | * any bsd label at the front of the partition | ||||
*/ | */ | ||||
blist_free(sp->sw_blist, howmany(BBSIZE, PAGE_SIZE), | blist_free(sp->sw_blist, howmany(BBSIZE, PAGE_SIZE), | ||||
nblks - howmany(BBSIZE, PAGE_SIZE)); | nblks - howmany(BBSIZE, PAGE_SIZE)); | ||||
dvbase = 0; | dvbase = 0; | ||||
▲ Show 20 Lines • Show All 703 Lines • Show Last 20 Lines |