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