1258717Savg/*
2258717Savg * CDDL HEADER START
3258717Savg *
4258717Savg * The contents of this file are subject to the terms of the
5258717Savg * Common Development and Distribution License (the "License").
6258717Savg * You may not use this file except in compliance with the License.
7258717Savg *
8258717Savg * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9258717Savg * or http://www.opensolaris.org/os/licensing.
10258717Savg * See the License for the specific language governing permissions
11258717Savg * and limitations under the License.
12258717Savg *
13258717Savg * When distributing Covered Code, include this CDDL HEADER in each
14258717Savg * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15258717Savg * If applicable, add the following below this CDDL HEADER, with the
16258717Savg * fields enclosed by brackets "[]" replaced with your own identifying
17258717Savg * information: Portions Copyright [yyyy] [name of copyright owner]
18258717Savg *
19258717Savg * CDDL HEADER END
20258717Savg */
21258717Savg/*
22258717Savg * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23258717Savg * Use is subject to license terms.
24258717Savg */
25258717Savg
26258717Savg/*
27258717Savg * Copyright (c) 2013 by Delphix. All rights reserved.
28258717Savg */
29258717Savg
30258717Savg#ifndef _SYS_SPACE_REFTREE_H
31258717Savg#define	_SYS_SPACE_REFTREE_H
32258717Savg
33258717Savg#include <sys/range_tree.h>
34258717Savg
35258717Savg#ifdef	__cplusplus
36258717Savgextern "C" {
37258717Savg#endif
38258717Savg
39258717Savgtypedef struct space_ref {
40258717Savg	avl_node_t	sr_node;	/* AVL node */
41258717Savg	uint64_t	sr_offset;	/* range offset (start or end) */
42258717Savg	int64_t		sr_refcnt;	/* associated reference count */
43258717Savg} space_ref_t;
44258717Savg
45258717Savgvoid space_reftree_create(avl_tree_t *t);
46258717Savgvoid space_reftree_destroy(avl_tree_t *t);
47258717Savgvoid space_reftree_add_seg(avl_tree_t *t, uint64_t start, uint64_t end,
48258717Savg    int64_t refcnt);
49258717Savgvoid space_reftree_add_map(avl_tree_t *t, range_tree_t *rt, int64_t refcnt);
50258717Savgvoid space_reftree_generate_map(avl_tree_t *t, range_tree_t *rt,
51258717Savg    int64_t minref);
52258717Savg
53258717Savg#ifdef	__cplusplus
54258717Savg}
55258717Savg#endif
56258717Savg
57258717Savg#endif	/* _SYS_SPACE_REFTREE_H */
58