FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
/*
 * This function *must* return indices evenly distributed between all
 * sublists of the multilist. This is needed due to how the ARC eviction
 * code is laid out; arc_evict_state() assumes ARC buffers are evenly
 * distributed between all sublists and uses this assumption when
 * deciding which sublist to evict from and how much to evict from it.
 */
This function *must* return indices evenly distributed between all
sublists of the multilist. This is needed due to how the ARC eviction
code is laid out; arc_evict_state() assumes ARC buffers are evenly
distributed between all sublists and uses this assumption when
deciding which sublist to evict from and how much to evict from it.
This function * must * return indices evenly distributed between all sublists of the multilist . This is needed due to how the ARC eviction code is laid out ; arc_evict_state () assumes ARC buffers are evenly distributed between all sublists and uses this assumption when deciding which sublist to evict from and how much to evict from it .
unsigned int
arc_state_multilist_index_func(multilist_t *ml, void *obj)
{
	arc_buf_hdr_t *hdr = obj;
	ASSERT(!BUF_EMPTY(hdr));
	return (buf_hash(hdr->b_spa, &hdr->b_dva, hdr->b_birth) %
	    multilist_get_num_sublists(ml));
}
unsigned int arc_state_multilist_index_func ( multilist_t * ml , void * obj ) { arc_buf_hdr_t * hdr = obj ; ASSERT ( ! BUF_EMPTY ( hdr ) ) ; return ( buf_hash ( hdr -> b_spa , & hdr -> b_dva , hdr -> b_birth ) % multilist_get_num_sublists ( ml ) ) ; }
This function *must* return indices evenly distributed between all
 sublists of the multilist.
This function * must * return indices evenly distributed between all sublists of the multilist .
/*
	 * We rely on b_dva to generate evenly distributed index
	 * numbers using buf_hash below. So, as an added precaution,
	 * let's make sure we never add empty buffers to the arc lists.
	 */ /*
	 * The assumption here, is the hash value for a given
	 * arc_buf_hdr_t will remain constant throughout it's lifetime
	 * (i.e. it's b_spa, b_dva, and b_birth fields don't change).
	 * Thus, we don't need to store the header's sublist index
	 * on insertion, as this index can be recalculated on removal.
	 *
	 * Also, the low order bits of the hash value are thought to be
	 * distributed evenly. Otherwise, in the case that the multilist
	 * has a power of two number of sublists, each sublists' usage
	 * would not be evenly distributed.
	 */