Index: sys/kern/subr_blist.c =================================================================== --- sys/kern/subr_blist.c +++ sys/kern/subr_blist.c @@ -134,9 +134,6 @@ u_daddr_t radix); static void blst_copy(blmeta_t *scan, daddr_t blk, daddr_t radix, blist_t dest, daddr_t count); -static daddr_t blst_leaf_fill(blmeta_t *scan, daddr_t blk, int count); -static daddr_t blst_meta_fill(blmeta_t *scan, daddr_t allocBlk, daddr_t count, - u_daddr_t radix); static daddr_t blst_radix_init(blmeta_t *scan, daddr_t radix, daddr_t count); #ifndef _KERNEL static void blst_radix_print(blmeta_t *scan, daddr_t blk, daddr_t radix, @@ -321,16 +318,16 @@ } /* - * blist_fill() - mark a region in the block bitmap as off-limits - * to the allocator (i.e. allocate it), ignoring any - * existing allocations. Return the number of blocks - * actually filled that were free before the call. + * blist_alloc_all() - mark all blocks allocated. */ -daddr_t -blist_fill(blist_t bl, daddr_t blkno, daddr_t count) +void +blist_alloc_all(blist_t bl) { - return (blst_meta_fill(bl->bl_root, blkno, count, bl->bl_radix)); + if (bl->bl_radix == BLIST_BMAP_RADIX) + bl->bl_root->u.bmu_bitmap = 0; + else + bl->bl_root->u.bmu_avail = 0; } /* @@ -970,109 +967,6 @@ } /* - * BLST_LEAF_FILL() - allocate specific blocks in leaf bitmap - * - * This routine allocates all blocks in the specified range - * regardless of any existing allocations in that range. Returns - * the number of blocks allocated by the call. - */ -static daddr_t -blst_leaf_fill(blmeta_t *scan, daddr_t blk, int count) -{ - daddr_t nblks; - u_daddr_t mask; - int n; - - n = blk & BLIST_BMAP_MASK; - mask = ((u_daddr_t)-1 << n) & - ((u_daddr_t)-1 >> (BLIST_BMAP_RADIX - count - n)); - - /* Count the number of blocks that we are allocating. */ - nblks = bitcount64(scan->u.bmu_bitmap & mask); - - scan->u.bmu_bitmap &= ~mask; - return (nblks); -} - -/* - * BLIST_META_FILL() - allocate specific blocks at a meta node - * - * This routine allocates the specified range of blocks, - * regardless of any existing allocations in the range. The - * range must be within the extent of this node. Returns the - * number of blocks allocated by the call. - */ -static daddr_t -blst_meta_fill(blmeta_t *scan, daddr_t allocBlk, daddr_t count, u_daddr_t radix) -{ - daddr_t blk, i, nblks, next_skip, skip, v; - int child; - - if (scan->bm_bighint == (daddr_t)-1) - panic("filling invalid range"); - if (count > radix) { - /* - * The allocation exceeds the number of blocks that are - * managed by this node. - */ - panic("fill too large"); - } - if (radix == BLIST_BMAP_RADIX) - return (blst_leaf_fill(scan, allocBlk, count)); - if (count == radix || scan->u.bmu_avail == 0) { - /* - * ALL-ALLOCATED special case - */ - nblks = scan->u.bmu_avail; - scan->u.bmu_avail = 0; - scan->bm_bighint = 0; - return (nblks); - } - skip = radix_to_skip(radix); - next_skip = skip / BLIST_META_RADIX; - blk = allocBlk & -radix; - - /* - * An ALL-FREE meta node requires special handling before allocating - * any of its blocks. - */ - if (scan->u.bmu_avail == radix) { - radix /= BLIST_META_RADIX; - - /* - * Reinitialize each of the meta node's children. An ALL-FREE - * meta node cannot have a terminator in any subtree. - */ - for (i = 1; i < skip; i += next_skip) { - if (next_skip == 1) - scan[i].u.bmu_bitmap = (u_daddr_t)-1; - else - scan[i].u.bmu_avail = radix; - scan[i].bm_bighint = radix; - } - } else { - radix /= BLIST_META_RADIX; - } - - nblks = 0; - child = (allocBlk - blk) / radix; - blk += child * radix; - i = 1 + child * next_skip; - while (i < skip && blk < allocBlk + count) { - v = blk + radix - allocBlk; - if (v > count) - v = count; - nblks += blst_meta_fill(&scan[i], allocBlk, v, radix); - count -= v; - allocBlk += v; - blk += radix; - i += next_skip; - } - scan->u.bmu_avail -= nblks; - return (nblks); -} - -/* * BLST_RADIX_INIT() - initialize radix tree * * Initialize our meta structures and bitmaps and calculate the exact @@ -1280,6 +1174,9 @@ printf("?\n"); } break; + case 'A': + blist_alloc_all(bl); + break; case 'f': if (sscanf(buf + 1, "%llx %lld", &da, &count) == 2) { blist_free(bl, da, count); @@ -1287,22 +1184,14 @@ printf("?\n"); } break; - case 'l': - if (sscanf(buf + 1, "%llx %lld", &da, &count) == 2) { - printf(" n=%jd\n", - (intmax_t)blist_fill(bl, da, count)); - } else { - printf("?\n"); - } - break; case '?': case 'h': puts( "p -print\n" "s -stats\n" "a %d -allocate\n" + "A -allocate all\n" "f %x %d -free\n" - "l %x %d -fill\n" "r %d -resize\n" "h/? -help" ); Index: sys/sys/blist.h =================================================================== --- sys/sys/blist.h +++ sys/sys/blist.h @@ -33,7 +33,7 @@ * (void) blist_destroy(blist) * blkno = blist_alloc(blist, count) * (void) blist_free(blist, blkno, count) - * nblks = blist_fill(blist, blkno, count) + * (void) blist_alloc_all(blist) * (void) blist_resize(&blist, count, freeextra, flags) * * @@ -96,7 +96,7 @@ daddr_t blist_avail(blist_t blist); blist_t blist_create(daddr_t blocks, int flags); void blist_destroy(blist_t blist); -daddr_t blist_fill(blist_t bl, daddr_t blkno, daddr_t count); +void blist_alloc_all(blist_t bl); void blist_free(blist_t blist, daddr_t blkno, daddr_t count); void blist_print(blist_t blist); void blist_resize(blist_t *pblist, daddr_t count, int freenew, int flags); Index: sys/vm/swap_pager.c =================================================================== --- sys/vm/swap_pager.c +++ sys/vm/swap_pager.c @@ -2308,7 +2308,8 @@ */ mtx_lock(&sw_dev_mtx); sp->sw_flags |= SW_CLOSING; - swap_pager_avail -= blist_fill(sp->sw_blist, 0, nblks); + swap_pager_avail -= blist_avail(sp->sw_blist); + blist_alloc_all(sp->sw_blist); swap_total -= (vm_ooffset_t)nblks * PAGE_SIZE; mtx_unlock(&sw_dev_mtx);