FreeBSD/sys/kern/subr_blist.c
/*
 * 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.
 */
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.
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 int
blst_meta_fill(
	blmeta_t *scan,
	daddr_t allocBlk,
	daddr_t count,
	daddr_t radix, 
	int skip,
	daddr_t blk
) {
	int i;
	int next_skip = ((u_int)skip / BLIST_META_RADIX);
	int nblks = 0;
	if (count == radix || scan->u.bmu_avail == 0)  {
		nblks = scan->u.bmu_avail;
		scan->u.bmu_avail = 0;
		scan->bm_bighint = count;
		return nblks;
	}
	if (scan->u.bmu_avail == radix) {
		radix /= BLIST_META_RADIX;
		for (i = 1; i <= skip; i += next_skip) {
			if (scan[i].bm_bighint == (daddr_t)-1)
				break;
			if (next_skip == 1) {
				scan[i].u.bmu_bitmap = (u_daddr_t)-1;
				scan[i].bm_bighint = BLIST_BMAP_RADIX;
			} else {
				scan[i].bm_bighint = radix;
				scan[i].u.bmu_avail = radix;
			}
		}
	} else {
		radix /= BLIST_META_RADIX;
	}
	if (count > radix)
		panic("blist_meta_fill: allocation too large");
	i = (allocBlk - blk) / radix;
	blk += i * radix;
	i = i * next_skip + 1;
	while (i <= skip && blk < allocBlk + count) {
		daddr_t v;
		v = blk + radix - allocBlk;
		if (v > count)
			v = count;
		if (scan->bm_bighint == (daddr_t)-1)
			panic("blst_meta_fill: filling unexpected range");
		if (next_skip == 1) {
			nblks += blst_leaf_fill(&scan[i], allocBlk, v);
		} else {
			nblks += blst_meta_fill(&scan[i], allocBlk, v,
			    radix, next_skip - 1, blk);
		}
		count -= v;
		allocBlk += v;
		blk += radix;
		i += next_skip;
	}
	scan->u.bmu_avail -= nblks;
	return nblks;
}
static int blst_meta_fill ( blmeta_t * scan , daddr_t allocBlk , daddr_t count , daddr_t radix , int skip , daddr_t blk ) { int i ; int next_skip = ( ( u_int ) skip / BLIST_META_RADIX ) ; int nblks = 0 ; if ( count == radix || scan -> u . bmu_avail == 0 ) { nblks = scan -> u . bmu_avail ; scan -> u . bmu_avail = 0 ; scan -> bm_bighint = count ; return nblks ; } if ( scan -> u . bmu_avail == radix ) { radix /= BLIST_META_RADIX ; for ( i = 1 ; i <= skip ; i += next_skip ) { if ( scan [ i ] . bm_bighint == ( daddr_t ) - 1 ) break ; if ( next_skip == 1 ) { scan [ i ] . u . bmu_bitmap = ( u_daddr_t ) - 1 ; scan [ i ] . bm_bighint = BLIST_BMAP_RADIX ; } else { scan [ i ] . bm_bighint = radix ; scan [ i ] . u . bmu_avail = radix ; } } } else { radix /= BLIST_META_RADIX ; } if ( count > radix ) panic ( " " ) ; i = ( allocBlk - blk ) / radix ; blk += i * radix ; i = i * next_skip + 1 ; while ( i <= skip && blk < allocBlk + count ) { daddr_t v ; v = blk + radix - allocBlk ; if ( v > count ) v = count ; if ( scan -> bm_bighint == ( daddr_t ) - 1 ) panic ( " " ) ; if ( next_skip == 1 ) { nblks += blst_leaf_fill ( & scan [ i ] , allocBlk , v ) ; } else { nblks += blst_meta_fill ( & scan [ i ] , allocBlk , v , radix , next_skip - 1 , blk ) ; } count -= v ; allocBlk += v ; blk += radix ; i += next_skip ; } scan -> u . bmu_avail -= nblks ; 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.
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 .
/*
		 * ALL-ALLOCATED special case
		 */ /*
		 * ALL-FREE special case, initialize sublevel
		 */