Fix invalid pointer access in trace_dbuf.h
[zfs.git] / include / sys / dsl_bookmark.h
blob353c5c2d260f1ff334a00a2ba2f430ed3a1b562f
1 /*
2 * CDDL HEADER START
4 * This file and its contents are supplied under the terms of the
5 * Common Development and Distribution License ("CDDL"), version 1.0.
6 * You may only use this file in accordance with the terms of version
7 * 1.0 of the CDDL.
9 * A full copy of the text of the CDDL should have accompanied this
10 * source. A copy of the CDDL is also available via the Internet at
11 * http://www.illumos.org/license/CDDL.
13 * CDDL HEADER END
16 * Copyright (c) 2013, 2018 by Delphix. All rights reserved.
19 #ifndef _SYS_DSL_BOOKMARK_H
20 #define _SYS_DSL_BOOKMARK_H
22 #include <sys/zfs_context.h>
23 #include <sys/zfs_refcount.h>
24 #include <sys/dsl_dataset.h>
25 #include <sys/dsl_pool.h>
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
32 * On disk zap object.
34 typedef struct zfs_bookmark_phys {
35 uint64_t zbm_guid; /* guid of bookmarked dataset */
36 uint64_t zbm_creation_txg; /* birth transaction group */
37 uint64_t zbm_creation_time; /* bookmark creation time */
39 /* fields used for redacted send / recv */
40 uint64_t zbm_redaction_obj; /* redaction list object */
41 uint64_t zbm_flags; /* ZBM_FLAG_* */
43 /* fields used for bookmark written size */
44 uint64_t zbm_referenced_bytes_refd;
45 uint64_t zbm_compressed_bytes_refd;
46 uint64_t zbm_uncompressed_bytes_refd;
47 uint64_t zbm_referenced_freed_before_next_snap;
48 uint64_t zbm_compressed_freed_before_next_snap;
49 uint64_t zbm_uncompressed_freed_before_next_snap;
51 /* fields used for raw sends */
52 uint64_t zbm_ivset_guid;
53 } zfs_bookmark_phys_t;
56 #define BOOKMARK_PHYS_SIZE_V1 (3 * sizeof (uint64_t))
57 #define BOOKMARK_PHYS_SIZE_V2 (12 * sizeof (uint64_t))
59 typedef enum zbm_flags {
60 ZBM_FLAG_HAS_FBN = (1 << 0),
61 ZBM_FLAG_SNAPSHOT_EXISTS = (1 << 1),
62 } zbm_flags_t;
64 typedef struct redaction_list_phys {
65 uint64_t rlp_last_object;
66 uint64_t rlp_last_blkid;
67 uint64_t rlp_num_entries;
68 uint64_t rlp_num_snaps;
69 uint64_t rlp_snaps[]; /* variable length */
70 } redaction_list_phys_t;
72 typedef struct redaction_list {
73 dmu_buf_user_t rl_dbu;
74 redaction_list_phys_t *rl_phys;
75 dmu_buf_t *rl_dbuf;
76 uint64_t rl_object;
77 zfs_refcount_t rl_longholds;
78 objset_t *rl_mos;
79 } redaction_list_t;
81 /* node in ds_bookmarks */
82 typedef struct dsl_bookmark_node {
83 char *dbn_name; /* free with strfree() */
84 kmutex_t dbn_lock; /* protects dirty/phys in block_killed */
85 boolean_t dbn_dirty; /* in currently syncing txg */
86 zfs_bookmark_phys_t dbn_phys;
87 avl_node_t dbn_node;
88 } dsl_bookmark_node_t;
90 typedef struct redact_block_phys {
91 uint64_t rbp_object;
92 uint64_t rbp_blkid;
94 * The top 16 bits of this field represent the block size in sectors of
95 * the blocks in question; the bottom 48 bits are used to store the
96 * number of consecutive blocks that are in the redaction list. They
97 * should be accessed using the inline functions below.
99 uint64_t rbp_size_count;
100 uint64_t rbp_padding;
101 } redact_block_phys_t;
103 typedef int (*rl_traverse_callback_t)(redact_block_phys_t *, void *);
106 typedef struct dsl_bookmark_create_arg {
107 nvlist_t *dbca_bmarks;
108 nvlist_t *dbca_errors;
109 } dsl_bookmark_create_arg_t;
111 typedef struct dsl_bookmark_create_redacted_arg {
112 const char *dbcra_bmark;
113 const char *dbcra_snap;
114 redaction_list_t **dbcra_rl;
115 uint64_t dbcra_numsnaps;
116 uint64_t *dbcra_snaps;
117 const void *dbcra_tag;
118 } dsl_bookmark_create_redacted_arg_t;
120 int dsl_bookmark_create(nvlist_t *, nvlist_t *);
121 int dsl_bookmark_create_nvl_validate(nvlist_t *);
122 int dsl_bookmark_create_check(void *arg, dmu_tx_t *tx);
123 void dsl_bookmark_create_sync(void *arg, dmu_tx_t *tx);
124 int dsl_bookmark_create_redacted(const char *, const char *, uint64_t,
125 uint64_t *, const void *, redaction_list_t **);
126 int dsl_get_bookmarks(const char *, nvlist_t *, nvlist_t *);
127 int dsl_get_bookmarks_impl(dsl_dataset_t *, nvlist_t *, nvlist_t *);
128 int dsl_get_bookmark_props(const char *, const char *, nvlist_t *);
129 int dsl_bookmark_destroy(nvlist_t *, nvlist_t *);
130 int dsl_bookmark_lookup(struct dsl_pool *, const char *,
131 struct dsl_dataset *, zfs_bookmark_phys_t *);
132 int dsl_bookmark_lookup_impl(dsl_dataset_t *, const char *,
133 zfs_bookmark_phys_t *);
134 int dsl_redaction_list_hold_obj(struct dsl_pool *, uint64_t, const void *,
135 redaction_list_t **);
136 void dsl_redaction_list_rele(redaction_list_t *, const void *);
137 void dsl_redaction_list_long_hold(struct dsl_pool *, redaction_list_t *,
138 const void *);
139 void dsl_redaction_list_long_rele(redaction_list_t *, const void *);
140 boolean_t dsl_redaction_list_long_held(redaction_list_t *);
141 int dsl_bookmark_init_ds(dsl_dataset_t *);
142 void dsl_bookmark_fini_ds(dsl_dataset_t *);
143 boolean_t dsl_bookmark_ds_destroyed(dsl_dataset_t *, dmu_tx_t *);
144 void dsl_bookmark_snapshotted(dsl_dataset_t *, dmu_tx_t *);
145 void dsl_bookmark_block_killed(dsl_dataset_t *, const blkptr_t *, dmu_tx_t *);
146 void dsl_bookmark_sync_done(dsl_dataset_t *, dmu_tx_t *);
147 void dsl_bookmark_node_add(dsl_dataset_t *, dsl_bookmark_node_t *, dmu_tx_t *);
148 uint64_t dsl_bookmark_latest_txg(dsl_dataset_t *);
149 int dsl_redaction_list_traverse(redaction_list_t *, zbookmark_phys_t *,
150 rl_traverse_callback_t, void *);
151 void dsl_bookmark_next_changed(dsl_dataset_t *, dsl_dataset_t *, dmu_tx_t *);
153 #ifdef __cplusplus
155 #endif
157 #endif /* _SYS_DSL_BOOKMARK_H */