Index: sys/vm/swap_pager.c =================================================================== --- sys/vm/swap_pager.c +++ sys/vm/swap_pager.c @@ -2263,12 +2263,8 @@ sp->sw_close = close; sp->sw_flags = flags; - sp->sw_blist = blist_create(nblks, M_WAITOK); - /* - * Do not free the first two block in order to avoid overwriting - * any bsd label at the front of the partition - */ - blist_free(sp->sw_blist, 2, nblks - 2); + sp->sw_blist = blist_create(sp->sw_nblks, M_WAITOK); + blist_free(sp->sw_blist, 0, sp->sw_nblks); dvbase = 0; mtx_lock(&sw_dev_mtx); @@ -2286,8 +2282,8 @@ sp->sw_end = dvbase + nblks; TAILQ_INSERT_TAIL(&swtailq, sp, sw_list); nswapdev++; - swap_pager_avail += nblks - 2; - swap_total += nblks; + swap_pager_avail += sp->sw_nblks; + swap_total += sp->sw_nblks; swapon_check_swzone(); swp_sizecheck(); mtx_unlock(&sw_dev_mtx); @@ -2354,7 +2350,6 @@ static int swapoff_one(struct swdevt *sp, struct ucred *cred) { - u_long nblks; #ifdef MAC int error; #endif @@ -2367,7 +2362,6 @@ if (error != 0) return (error); #endif - nblks = sp->sw_nblks; /* * We can turn off this swap device safely only if the @@ -2375,7 +2369,7 @@ * of data we will have to page back in, plus an epsilon so * the system doesn't become critically low on swap space. */ - if (vm_free_count() + swap_pager_avail < nblks + nswap_lowat) + if (vm_free_count() + swap_pager_avail < sp->sw_nblks + nswap_lowat) return (ENOMEM); /* @@ -2383,8 +2377,8 @@ */ mtx_lock(&sw_dev_mtx); sp->sw_flags |= SW_CLOSING; - swap_pager_avail -= blist_fill(sp->sw_blist, 0, nblks); - swap_total -= nblks; + swap_pager_avail -= blist_fill(sp->sw_blist, 0, sp->sw_nblks); + swap_total -= sp->sw_nblks; mtx_unlock(&sw_dev_mtx); /*