xref: /titanic_52/usr/src/uts/common/fs/zfs/sys/bptree.h (revision 7802d7bf98dec568dadf72286893b1fe5abd8602)
153089ab7Seschrock /*
253089ab7Seschrock  * CDDL HEADER START
353089ab7Seschrock  *
453089ab7Seschrock  * The contents of this file are subject to the terms of the
553089ab7Seschrock  * Common Development and Distribution License (the "License").
653089ab7Seschrock  * You may not use this file except in compliance with the License.
753089ab7Seschrock  *
853089ab7Seschrock  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
953089ab7Seschrock  * or http://www.opensolaris.org/os/licensing.
1053089ab7Seschrock  * See the License for the specific language governing permissions
1153089ab7Seschrock  * and limitations under the License.
1253089ab7Seschrock  *
1353089ab7Seschrock  * When distributing Covered Code, include this CDDL HEADER in each
1453089ab7Seschrock  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1553089ab7Seschrock  * If applicable, add the following below this CDDL HEADER, with the
1653089ab7Seschrock  * fields enclosed by brackets "[]" replaced with your own identifying
1753089ab7Seschrock  * information: Portions Copyright [yyyy] [name of copyright owner]
1853089ab7Seschrock  *
1953089ab7Seschrock  * CDDL HEADER END
2053089ab7Seschrock  */
2153089ab7Seschrock /*
22*7802d7bfSMatthew Ahrens  * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
2353089ab7Seschrock  */
2453089ab7Seschrock 
2553089ab7Seschrock #ifndef	_SYS_BPTREE_H
2653089ab7Seschrock #define	_SYS_BPTREE_H
2753089ab7Seschrock 
2853089ab7Seschrock #include <sys/spa.h>
2953089ab7Seschrock #include <sys/zio.h>
3053089ab7Seschrock 
3153089ab7Seschrock #ifdef	__cplusplus
3253089ab7Seschrock extern "C" {
3353089ab7Seschrock #endif
3453089ab7Seschrock 
3553089ab7Seschrock typedef struct bptree_phys {
3653089ab7Seschrock 	uint64_t bt_begin;
3753089ab7Seschrock 	uint64_t bt_end;
3853089ab7Seschrock 	uint64_t bt_bytes;
3953089ab7Seschrock 	uint64_t bt_comp;
4053089ab7Seschrock 	uint64_t bt_uncomp;
4153089ab7Seschrock } bptree_phys_t;
4253089ab7Seschrock 
4353089ab7Seschrock typedef struct bptree_entry_phys {
4453089ab7Seschrock 	blkptr_t be_bp;
4553089ab7Seschrock 	uint64_t be_birth_txg; /* only delete blocks born after this txg */
46*7802d7bfSMatthew Ahrens 	zbookmark_phys_t be_zb; /* holds traversal resume point if needed */
4753089ab7Seschrock } bptree_entry_phys_t;
4853089ab7Seschrock 
4953089ab7Seschrock typedef int bptree_itor_t(void *arg, const blkptr_t *bp, dmu_tx_t *tx);
5053089ab7Seschrock 
5153089ab7Seschrock uint64_t bptree_alloc(objset_t *os, dmu_tx_t *tx);
5253089ab7Seschrock int bptree_free(objset_t *os, uint64_t obj, dmu_tx_t *tx);
537fd05ac4SMatthew Ahrens boolean_t bptree_is_empty(objset_t *os, uint64_t obj);
5453089ab7Seschrock 
5553089ab7Seschrock void bptree_add(objset_t *os, uint64_t obj, blkptr_t *bp, uint64_t birth_txg,
5653089ab7Seschrock     uint64_t bytes, uint64_t comp, uint64_t uncomp, dmu_tx_t *tx);
5753089ab7Seschrock 
5853089ab7Seschrock int bptree_iterate(objset_t *os, uint64_t obj, boolean_t free,
5953089ab7Seschrock     bptree_itor_t func, void *arg, dmu_tx_t *tx);
6053089ab7Seschrock 
6153089ab7Seschrock #ifdef	__cplusplus
6253089ab7Seschrock }
6353089ab7Seschrock #endif
6453089ab7Seschrock 
6553089ab7Seschrock #endif	/* _SYS_BPTREE_H */
66