Allow dsl_deadlist_open() return errors
[zfs.git] / include / sys / dsl_deadlist.h
blob798f9e3f6245e2228ec7c6aa7b347a2e7b83af6b
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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>
31 #include <sys/zthr.h>
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 struct dmu_buf;
38 struct dsl_pool;
39 struct dsl_dataset;
41 typedef struct dsl_deadlist_phys {
42 uint64_t dl_used;
43 uint64_t dl_comp;
44 uint64_t dl_uncomp;
45 uint64_t dl_pad[37]; /* pad out to 320b for future expansion */
46 } dsl_deadlist_phys_t;
48 typedef struct dsl_deadlist {
49 objset_t *dl_os;
50 uint64_t dl_object;
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;
57 kmutex_t dl_lock;
59 /* if it's the old on-disk format: */
60 bpobj_t dl_bpobj;
61 boolean_t dl_oldfmt;
62 } dsl_deadlist_t;
64 typedef struct dsl_deadlist_cache_entry {
65 avl_node_t dlce_node;
66 uint64_t dlce_mintxg;
67 uint64_t dlce_bpobj;
68 uint64_t dlce_bytes;
69 uint64_t dlce_comp;
70 uint64_t dlce_uncomp;
71 } dsl_deadlist_cache_entry_t;
73 typedef struct dsl_deadlist_entry {
74 avl_node_t dle_node;
75 uint64_t dle_mintxg;
76 bpobj_t dle_bpobj;
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;
83 boolean_t syncing;
84 boolean_t cancelled;
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,
104 dmu_tx_t *tx);
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,
116 dmu_tx_t *tx);
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,
121 dmu_tx_t *tx);
122 void dsl_deadlist_discard_tree(dsl_deadlist_t *dl);
124 #ifdef __cplusplus
126 #endif
128 #endif /* _SYS_DSL_DEADLIST_H */