FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
/*
 * ==========================================================================
 * The first-fit block allocator
 * ==========================================================================
 */
The first-fit block allocator
The first - fit block allocator
static uint64_t
metaslab_ff_alloc(metaslab_t *msp, uint64_t size)
{
	uint64_t align = size & -size;
	uint64_t *cursor = &msp->ms_lbas[highbit64(align) - 1];
	avl_tree_t *t = &msp->ms_tree->rt_root;
	return (metaslab_block_picker(t, cursor, size, align));
}
static uint64_t metaslab_ff_alloc ( metaslab_t * msp , uint64_t size ) { uint64_t align = size & - size ; uint64_t * cursor = & msp -> ms_lbas [ highbit64 ( align ) - 1 ] ; avl_tree_t * t = & msp -> ms_tree -> rt_root ; return ( metaslab_block_picker ( t , cursor , size , align ) ) ; }
The first-fit block allocator
The first - fit block allocator
/*
	 * Find the largest power of 2 block size that evenly divides the
	 * requested size. This is used to try to allocate blocks with similar
	 * alignment from the same area of the metaslab (i.e. same cursor
	 * bucket) but it does not guarantee that other allocations sizes
	 * may exist in the same region.
	 */