]> git.proxmox.com Git - mirror_zfs.git/blame - include/sys/dsl_deadlist.h
FreeBSD: Add zfs_link_create() error handling
[mirror_zfs.git] / include / sys / dsl_deadlist.h
CommitLineData
428870ff
BB
1/*
2 * CDDL HEADER START
3 *
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.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1d3ba0bf 9 * or https://opensource.org/licenses/CDDL-1.0.
428870ff
BB
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
37f03da8 23 * Copyright (c) 2018, 2019 by Delphix. All rights reserved.
428870ff
BB
24 */
25
26#ifndef _SYS_DSL_DEADLIST_H
27#define _SYS_DSL_DEADLIST_H
28
29#include <sys/bpobj.h>
30#include <sys/zfs_context.h>
37f03da8 31#include <sys/zthr.h>
428870ff
BB
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37struct dmu_buf;
37f03da8 38struct dsl_pool;
428870ff
BB
39struct dsl_dataset;
40
41typedef 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;
47
48typedef struct dsl_deadlist {
49 objset_t *dl_os;
50 uint64_t dl_object;
325d288c
MA
51 avl_tree_t dl_tree; /* contains dsl_deadlist_entry_t */
52 avl_tree_t dl_cache; /* contains dsl_deadlist_cache_entry_t */
428870ff 53 boolean_t dl_havetree;
325d288c 54 boolean_t dl_havecache;
428870ff
BB
55 struct dmu_buf *dl_dbuf;
56 dsl_deadlist_phys_t *dl_phys;
57 kmutex_t dl_lock;
58
59 /* if it's the old on-disk format: */
60 bpobj_t dl_bpobj;
61 boolean_t dl_oldfmt;
62} dsl_deadlist_t;
63
325d288c
MA
64typedef 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;
72
428870ff
BB
73typedef 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;
78
37f03da8
SH
79typedef 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;
86
ab8d9c17 87extern uint64_t zfs_livelist_max_entries;
37f03da8
SH
88extern int zfs_livelist_min_percent_shared;
89
90typedef int deadlist_iter_t(void *args, dsl_deadlist_entry_t *dle);
91
428870ff
BB
92void dsl_deadlist_open(dsl_deadlist_t *dl, objset_t *os, uint64_t object);
93void dsl_deadlist_close(dsl_deadlist_t *dl);
37f03da8 94void dsl_deadlist_iterate(dsl_deadlist_t *dl, deadlist_iter_t func, void *arg);
428870ff
BB
95uint64_t dsl_deadlist_alloc(objset_t *os, dmu_tx_t *tx);
96void dsl_deadlist_free(objset_t *os, uint64_t dlobj, dmu_tx_t *tx);
37f03da8
SH
97void dsl_deadlist_insert(dsl_deadlist_t *dl, const blkptr_t *bp,
98 boolean_t free, dmu_tx_t *tx);
99int dsl_deadlist_insert_alloc_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx);
100int dsl_deadlist_insert_free_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx);
428870ff
BB
101void dsl_deadlist_add_key(dsl_deadlist_t *dl, uint64_t mintxg, dmu_tx_t *tx);
102void dsl_deadlist_remove_key(dsl_deadlist_t *dl, uint64_t mintxg, dmu_tx_t *tx);
37f03da8
SH
103void dsl_deadlist_remove_entry(dsl_deadlist_t *dl, uint64_t mintxg,
104dmu_tx_t *tx);
105dsl_deadlist_entry_t *dsl_deadlist_first(dsl_deadlist_t *dl);
106dsl_deadlist_entry_t *dsl_deadlist_last(dsl_deadlist_t *dl);
428870ff
BB
107uint64_t dsl_deadlist_clone(dsl_deadlist_t *dl, uint64_t maxtxg,
108 uint64_t mrs_obj, dmu_tx_t *tx);
109void dsl_deadlist_space(dsl_deadlist_t *dl,
110 uint64_t *usedp, uint64_t *compp, uint64_t *uncompp);
111void 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);
114void dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx);
115void dsl_deadlist_move_bpobj(dsl_deadlist_t *dl, bpobj_t *bpo, uint64_t mintxg,
116 dmu_tx_t *tx);
a1d477c2 117boolean_t dsl_deadlist_is_open(dsl_deadlist_t *dl);
37f03da8
SH
118int dsl_process_sub_livelist(bpobj_t *bpobj, struct bplist *to_free,
119 zthr_t *t, uint64_t *size);
120void dsl_deadlist_clear_entry(dsl_deadlist_entry_t *dle, dsl_deadlist_t *dl,
121 dmu_tx_t *tx);
325d288c 122void dsl_deadlist_discard_tree(dsl_deadlist_t *dl);
428870ff
BB
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif /* _SYS_DSL_DEADLIST_H */