xref: /netbsd-src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/bptree.h (revision 3227e6cf668bd374971740bd6660f43cee4417ac)
1*3227e6cfSchs /*
2*3227e6cfSchs  * CDDL HEADER START
3*3227e6cfSchs  *
4*3227e6cfSchs  * The contents of this file are subject to the terms of the
5*3227e6cfSchs  * Common Development and Distribution License (the "License").
6*3227e6cfSchs  * You may not use this file except in compliance with the License.
7*3227e6cfSchs  *
8*3227e6cfSchs  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*3227e6cfSchs  * or http://www.opensolaris.org/os/licensing.
10*3227e6cfSchs  * See the License for the specific language governing permissions
11*3227e6cfSchs  * and limitations under the License.
12*3227e6cfSchs  *
13*3227e6cfSchs  * When distributing Covered Code, include this CDDL HEADER in each
14*3227e6cfSchs  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*3227e6cfSchs  * If applicable, add the following below this CDDL HEADER, with the
16*3227e6cfSchs  * fields enclosed by brackets "[]" replaced with your own identifying
17*3227e6cfSchs  * information: Portions Copyright [yyyy] [name of copyright owner]
18*3227e6cfSchs  *
19*3227e6cfSchs  * CDDL HEADER END
20*3227e6cfSchs  */
21*3227e6cfSchs /*
22*3227e6cfSchs  * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
23*3227e6cfSchs  */
24*3227e6cfSchs 
25*3227e6cfSchs #ifndef	_SYS_BPTREE_H
26*3227e6cfSchs #define	_SYS_BPTREE_H
27*3227e6cfSchs 
28*3227e6cfSchs #include <sys/spa.h>
29*3227e6cfSchs #include <sys/zio.h>
30*3227e6cfSchs 
31*3227e6cfSchs #ifdef	__cplusplus
32*3227e6cfSchs extern "C" {
33*3227e6cfSchs #endif
34*3227e6cfSchs 
35*3227e6cfSchs typedef struct bptree_phys {
36*3227e6cfSchs 	uint64_t bt_begin;
37*3227e6cfSchs 	uint64_t bt_end;
38*3227e6cfSchs 	uint64_t bt_bytes;
39*3227e6cfSchs 	uint64_t bt_comp;
40*3227e6cfSchs 	uint64_t bt_uncomp;
41*3227e6cfSchs } bptree_phys_t;
42*3227e6cfSchs 
43*3227e6cfSchs typedef struct bptree_entry_phys {
44*3227e6cfSchs 	blkptr_t be_bp;
45*3227e6cfSchs 	uint64_t be_birth_txg; /* only delete blocks born after this txg */
46*3227e6cfSchs 	zbookmark_phys_t be_zb; /* holds traversal resume point if needed */
47*3227e6cfSchs } bptree_entry_phys_t;
48*3227e6cfSchs 
49*3227e6cfSchs typedef int bptree_itor_t(void *arg, const blkptr_t *bp, dmu_tx_t *tx);
50*3227e6cfSchs 
51*3227e6cfSchs uint64_t bptree_alloc(objset_t *os, dmu_tx_t *tx);
52*3227e6cfSchs int bptree_free(objset_t *os, uint64_t obj, dmu_tx_t *tx);
53*3227e6cfSchs boolean_t bptree_is_empty(objset_t *os, uint64_t obj);
54*3227e6cfSchs 
55*3227e6cfSchs void bptree_add(objset_t *os, uint64_t obj, blkptr_t *bp, uint64_t birth_txg,
56*3227e6cfSchs     uint64_t bytes, uint64_t comp, uint64_t uncomp, dmu_tx_t *tx);
57*3227e6cfSchs 
58*3227e6cfSchs int bptree_iterate(objset_t *os, uint64_t obj, boolean_t free,
59*3227e6cfSchs     bptree_itor_t func, void *arg, dmu_tx_t *tx);
60*3227e6cfSchs 
61*3227e6cfSchs #ifdef	__cplusplus
62*3227e6cfSchs }
63*3227e6cfSchs #endif
64*3227e6cfSchs 
65*3227e6cfSchs #endif	/* _SYS_BPTREE_H */
66