4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2018, 2019 by Delphix. All rights reserved.
26 #ifndef _SYS_DSL_DEADLIST_H
27 #define _SYS_DSL_DEADLIST_H
29 #include <sys/bpobj.h>
30 #include <sys/zfs_context.h>
41 typedef struct dsl_deadlist_phys
{
45 uint64_t dl_pad
[37]; /* pad out to 320b for future expansion */
46 } dsl_deadlist_phys_t
;
48 typedef struct dsl_deadlist
{
51 avl_tree_t dl_tree
; /* contains dsl_deadlist_entry_t */
52 avl_tree_t dl_cache
; /* contains dsl_deadlist_cache_entry_t */
53 boolean_t dl_havetree
;
54 boolean_t dl_havecache
;
55 struct dmu_buf
*dl_dbuf
;
56 dsl_deadlist_phys_t
*dl_phys
;
59 /* if it's the old on-disk format: */
64 typedef struct dsl_deadlist_cache_entry
{
71 } dsl_deadlist_cache_entry_t
;
73 typedef struct dsl_deadlist_entry
{
77 } dsl_deadlist_entry_t
;
79 typedef struct livelist_condense_entry
{
80 struct dsl_dataset
*ds
;
81 dsl_deadlist_entry_t
*first
;
82 dsl_deadlist_entry_t
*next
;
85 } livelist_condense_entry_t
;
87 extern uint64_t zfs_livelist_max_entries
;
88 extern int zfs_livelist_min_percent_shared
;
90 typedef int deadlist_iter_t(void *args
, dsl_deadlist_entry_t
*dle
);
92 int dsl_deadlist_open(dsl_deadlist_t
*dl
, objset_t
*os
, uint64_t object
);
93 void dsl_deadlist_close(dsl_deadlist_t
*dl
);
94 void dsl_deadlist_iterate(dsl_deadlist_t
*dl
, deadlist_iter_t func
, void *arg
);
95 uint64_t dsl_deadlist_alloc(objset_t
*os
, dmu_tx_t
*tx
);
96 void dsl_deadlist_free(objset_t
*os
, uint64_t dlobj
, dmu_tx_t
*tx
);
97 void dsl_deadlist_insert(dsl_deadlist_t
*dl
, const blkptr_t
*bp
,
98 boolean_t free
, dmu_tx_t
*tx
);
99 int dsl_deadlist_insert_alloc_cb(void *arg
, const blkptr_t
*bp
, dmu_tx_t
*tx
);
100 int dsl_deadlist_insert_free_cb(void *arg
, const blkptr_t
*bp
, dmu_tx_t
*tx
);
101 void dsl_deadlist_add_key(dsl_deadlist_t
*dl
, uint64_t mintxg
, dmu_tx_t
*tx
);
102 void dsl_deadlist_remove_key(dsl_deadlist_t
*dl
, uint64_t mintxg
, dmu_tx_t
*tx
);
103 void dsl_deadlist_remove_entry(dsl_deadlist_t
*dl
, uint64_t mintxg
,
105 dsl_deadlist_entry_t
*dsl_deadlist_first(dsl_deadlist_t
*dl
);
106 dsl_deadlist_entry_t
*dsl_deadlist_last(dsl_deadlist_t
*dl
);
107 uint64_t dsl_deadlist_clone(dsl_deadlist_t
*dl
, uint64_t maxtxg
,
108 uint64_t mrs_obj
, dmu_tx_t
*tx
);
109 void dsl_deadlist_space(dsl_deadlist_t
*dl
,
110 uint64_t *usedp
, uint64_t *compp
, uint64_t *uncompp
);
111 void dsl_deadlist_space_range(dsl_deadlist_t
*dl
,
112 uint64_t mintxg
, uint64_t maxtxg
,
113 uint64_t *usedp
, uint64_t *compp
, uint64_t *uncompp
);
114 void dsl_deadlist_merge(dsl_deadlist_t
*dl
, uint64_t obj
, dmu_tx_t
*tx
);
115 void dsl_deadlist_move_bpobj(dsl_deadlist_t
*dl
, bpobj_t
*bpo
, uint64_t mintxg
,
117 boolean_t
dsl_deadlist_is_open(dsl_deadlist_t
*dl
);
118 int dsl_process_sub_livelist(bpobj_t
*bpobj
, struct bplist
*to_free
,
119 zthr_t
*t
, uint64_t *size
);
120 void dsl_deadlist_clear_entry(dsl_deadlist_entry_t
*dle
, dsl_deadlist_t
*dl
,
122 void dsl_deadlist_discard_tree(dsl_deadlist_t
*dl
);
128 #endif /* _SYS_DSL_DEADLIST_H */