10713e232SGeorge Wilson /*
20713e232SGeorge Wilson  * CDDL HEADER START
30713e232SGeorge Wilson  *
40713e232SGeorge Wilson  * The contents of this file are subject to the terms of the
50713e232SGeorge Wilson  * Common Development and Distribution License (the "License").
60713e232SGeorge Wilson  * You may not use this file except in compliance with the License.
70713e232SGeorge Wilson  *
80713e232SGeorge Wilson  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90713e232SGeorge Wilson  * or http://www.opensolaris.org/os/licensing.
100713e232SGeorge Wilson  * See the License for the specific language governing permissions
110713e232SGeorge Wilson  * and limitations under the License.
120713e232SGeorge Wilson  *
130713e232SGeorge Wilson  * When distributing Covered Code, include this CDDL HEADER in each
140713e232SGeorge Wilson  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150713e232SGeorge Wilson  * If applicable, add the following below this CDDL HEADER, with the
160713e232SGeorge Wilson  * fields enclosed by brackets "[]" replaced with your own identifying
170713e232SGeorge Wilson  * information: Portions Copyright [yyyy] [name of copyright owner]
180713e232SGeorge Wilson  *
190713e232SGeorge Wilson  * CDDL HEADER END
200713e232SGeorge Wilson  */
210713e232SGeorge Wilson /*
220713e232SGeorge Wilson  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230713e232SGeorge Wilson  * Use is subject to license terms.
240713e232SGeorge Wilson  */
250713e232SGeorge Wilson 
260713e232SGeorge Wilson /*
270713e232SGeorge Wilson  * Copyright (c) 2013 by Delphix. All rights reserved.
280713e232SGeorge Wilson  */
290713e232SGeorge Wilson 
300713e232SGeorge Wilson #ifndef _SYS_SPACE_REFTREE_H
310713e232SGeorge Wilson #define	_SYS_SPACE_REFTREE_H
320713e232SGeorge Wilson 
330713e232SGeorge Wilson #include <sys/range_tree.h>
34*4d7988d6SPaul Dagnelie #include <sys/avl.h>
350713e232SGeorge Wilson #ifdef	__cplusplus
360713e232SGeorge Wilson extern "C" {
370713e232SGeorge Wilson #endif
380713e232SGeorge Wilson 
390713e232SGeorge Wilson typedef struct space_ref {
400713e232SGeorge Wilson 	avl_node_t	sr_node;	/* AVL node */
410713e232SGeorge Wilson 	uint64_t	sr_offset;	/* range offset (start or end) */
420713e232SGeorge Wilson 	int64_t		sr_refcnt;	/* associated reference count */
430713e232SGeorge Wilson } space_ref_t;
440713e232SGeorge Wilson 
450713e232SGeorge Wilson void space_reftree_create(avl_tree_t *t);
460713e232SGeorge Wilson void space_reftree_destroy(avl_tree_t *t);
470713e232SGeorge Wilson void space_reftree_add_seg(avl_tree_t *t, uint64_t start, uint64_t end,
480713e232SGeorge Wilson     int64_t refcnt);
490713e232SGeorge Wilson void space_reftree_add_map(avl_tree_t *t, range_tree_t *rt, int64_t refcnt);
500713e232SGeorge Wilson void space_reftree_generate_map(avl_tree_t *t, range_tree_t *rt,
510713e232SGeorge Wilson     int64_t minref);
520713e232SGeorge Wilson 
530713e232SGeorge Wilson #ifdef	__cplusplus
540713e232SGeorge Wilson }
550713e232SGeorge Wilson #endif
560713e232SGeorge Wilson 
570713e232SGeorge Wilson #endif	/* _SYS_SPACE_REFTREE_H */