1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * This file and its contents are supplied under the terms of the 4 * Common Development and Distribution License ("CDDL"), version 1.0. 5 * You may only use this file in accordance with the terms of version 6 * 1.0 of the CDDL. 7 * 8 * A full copy of the text of the CDDL should have accompanied this 9 * source. A copy of the CDDL is also available via the Internet at 10 * https://opensource.org/license/CDDL-1.0. 11 */ 12 /* 13 * Copyright (c) 2012, 2014 by Delphix. All rights reserved. 14 */ 15 16 #ifndef _SYS_BPTREE_H 17 #define _SYS_BPTREE_H 18 19 #include <sys/spa.h> 20 #include <sys/zio.h> 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 typedef struct bptree_phys { 27 uint64_t bt_begin; 28 uint64_t bt_end; 29 uint64_t bt_bytes; 30 uint64_t bt_comp; 31 uint64_t bt_uncomp; 32 } bptree_phys_t; 33 34 typedef struct bptree_entry_phys { 35 blkptr_t be_bp; 36 uint64_t be_birth_txg; /* only delete blocks born after this txg */ 37 zbookmark_phys_t be_zb; /* holds traversal resume point if needed */ 38 } bptree_entry_phys_t; 39 40 typedef int bptree_itor_t(void *arg, const blkptr_t *bp, dmu_tx_t *tx); 41 42 uint64_t bptree_alloc(objset_t *os, dmu_tx_t *tx); 43 int bptree_free(objset_t *os, uint64_t obj, dmu_tx_t *tx); 44 boolean_t bptree_is_empty(objset_t *os, uint64_t obj); 45 46 void bptree_add(objset_t *os, uint64_t obj, blkptr_t *bp, uint64_t birth_txg, 47 uint64_t bytes, uint64_t comp, uint64_t uncomp, dmu_tx_t *tx); 48 49 int bptree_iterate(objset_t *os, uint64_t obj, boolean_t free, 50 bptree_itor_t func, void *arg, dmu_tx_t *tx); 51 52 #ifdef __cplusplus 53 } 54 #endif 55 56 #endif /* _SYS_BPTREE_H */ 57