53089ab7c84db6fb76c16ca50076c147cda11757eschrock/*
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * CDDL HEADER START
53089ab7c84db6fb76c16ca50076c147cda11757eschrock *
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * The contents of this file are subject to the terms of the
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * Common Development and Distribution License (the "License").
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * You may not use this file except in compliance with the License.
53089ab7c84db6fb76c16ca50076c147cda11757eschrock *
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * or http://www.opensolaris.org/os/licensing.
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * See the License for the specific language governing permissions
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * and limitations under the License.
53089ab7c84db6fb76c16ca50076c147cda11757eschrock *
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * When distributing Covered Code, include this CDDL HEADER in each
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * If applicable, add the following below this CDDL HEADER, with the
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * fields enclosed by brackets "[]" replaced with your own identifying
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * information: Portions Copyright [yyyy] [name of copyright owner]
53089ab7c84db6fb76c16ca50076c147cda11757eschrock *
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * CDDL HEADER END
53089ab7c84db6fb76c16ca50076c147cda11757eschrock */
53089ab7c84db6fb76c16ca50076c147cda11757eschrock/*
7802d7bf98dec568dadf72286893b1fe5abd8602Matthew Ahrens * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
53089ab7c84db6fb76c16ca50076c147cda11757eschrock */
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#ifndef _SYS_BPTREE_H
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#define _SYS_BPTREE_H
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#include <sys/spa.h>
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#include <sys/zio.h>
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#ifdef __cplusplus
53089ab7c84db6fb76c16ca50076c147cda11757eschrockextern "C" {
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#endif
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrocktypedef struct bptree_phys {
53089ab7c84db6fb76c16ca50076c147cda11757eschrock uint64_t bt_begin;
53089ab7c84db6fb76c16ca50076c147cda11757eschrock uint64_t bt_end;
53089ab7c84db6fb76c16ca50076c147cda11757eschrock uint64_t bt_bytes;
53089ab7c84db6fb76c16ca50076c147cda11757eschrock uint64_t bt_comp;
53089ab7c84db6fb76c16ca50076c147cda11757eschrock uint64_t bt_uncomp;
53089ab7c84db6fb76c16ca50076c147cda11757eschrock} bptree_phys_t;
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrocktypedef struct bptree_entry_phys {
53089ab7c84db6fb76c16ca50076c147cda11757eschrock blkptr_t be_bp;
53089ab7c84db6fb76c16ca50076c147cda11757eschrock uint64_t be_birth_txg; /* only delete blocks born after this txg */
7802d7bf98dec568dadf72286893b1fe5abd8602Matthew Ahrens zbookmark_phys_t be_zb; /* holds traversal resume point if needed */
53089ab7c84db6fb76c16ca50076c147cda11757eschrock} bptree_entry_phys_t;
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrocktypedef int bptree_itor_t(void *arg, const blkptr_t *bp, dmu_tx_t *tx);
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrockuint64_t bptree_alloc(objset_t *os, dmu_tx_t *tx);
53089ab7c84db6fb76c16ca50076c147cda11757eschrockint bptree_free(objset_t *os, uint64_t obj, dmu_tx_t *tx);
7fd05ac4dec0c343d2f68f310d3718b715ecfbafMatthew Ahrensboolean_t bptree_is_empty(objset_t *os, uint64_t obj);
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrockvoid bptree_add(objset_t *os, uint64_t obj, blkptr_t *bp, uint64_t birth_txg,
53089ab7c84db6fb76c16ca50076c147cda11757eschrock uint64_t bytes, uint64_t comp, uint64_t uncomp, dmu_tx_t *tx);
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrockint bptree_iterate(objset_t *os, uint64_t obj, boolean_t free,
53089ab7c84db6fb76c16ca50076c147cda11757eschrock bptree_itor_t func, void *arg, dmu_tx_t *tx);
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#ifdef __cplusplus
53089ab7c84db6fb76c16ca50076c147cda11757eschrock}
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#endif
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#endif /* _SYS_BPTREE_H */