FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_reftree.c
/*
 * Convert a reference tree into a range tree.  The range tree will contain
 * all members of the reference tree for which refcnt >= minref.
 */
Convert a reference tree into a range tree.  The range tree will contain
all members of the reference tree for which refcnt >= minref.
Convert a reference tree into a range tree . The range tree will contain all members of the reference tree for which refcnt > = minref .
void
space_reftree_generate_map(avl_tree_t *t, range_tree_t *rt, int64_t minref)
{
	uint64_t start = -1ULL;
	int64_t refcnt = 0;
	space_ref_t *sr;
	ASSERT(MUTEX_HELD(rt->rt_lock));
	range_tree_vacate(rt, NULL, NULL);
	for (sr = avl_first(t); sr != NULL; sr = AVL_NEXT(t, sr)) {
		refcnt += sr->sr_refcnt;
		if (refcnt >= minref) {
			if (start == -1ULL) {
				start = sr->sr_offset;
			}
		} else {
			if (start != -1ULL) {
				uint64_t end = sr->sr_offset;
				ASSERT(start <= end);
				if (end > start)
					range_tree_add(rt, start, end - start);
				start = -1ULL;
			}
		}
	}
	ASSERT(refcnt == 0);
	ASSERT(start == -1ULL);
}
void space_reftree_generate_map ( avl_tree_t * t , range_tree_t * rt , int64_t minref ) { uint64_t start = -1ULL ; int64_t refcnt = 0 ; space_ref_t * sr ; ASSERT ( MUTEX_HELD ( rt -> rt_lock ) ) ; range_tree_vacate ( rt , NULL , NULL ) ; for ( sr = avl_first ( t ) ; sr != NULL ; sr = AVL_NEXT ( t , sr ) ) { refcnt += sr -> sr_refcnt ; if ( refcnt >= minref ) { if ( start == -1ULL ) { start = sr -> sr_offset ; } } else { if ( start != -1ULL ) { uint64_t end = sr -> sr_offset ; ASSERT ( start <= end ) ; if ( end > start ) range_tree_add ( rt , start , end - start ) ; start = -1ULL ; } } } ASSERT ( refcnt == 0 ) ; ASSERT ( start == -1ULL ) ; }
Convert a reference tree into a range tree.
Convert a reference tree into a range tree .