Print this page
3748 zfs headers should be C++ compatible
Submitted by: Justin Gibbs <justing@spectralogic.com>
Submitted by: Will Andrews <willa@spectralogic.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/zfs/sys/ddt.h
+++ new/usr/src/uts/common/fs/zfs/sys/ddt.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24
25 25 #ifndef _SYS_DDT_H
26 26 #define _SYS_DDT_H
27 27
28 28 #include <sys/sysmacros.h>
29 29 #include <sys/types.h>
30 30 #include <sys/fs/zfs.h>
31 31 #include <sys/zio.h>
32 32 #include <sys/dmu.h>
33 33
34 34 #ifdef __cplusplus
35 35 extern "C" {
36 36 #endif
37 37
38 38 /*
39 39 * On-disk DDT formats, in the desired search order (newest version first).
40 40 */
41 41 enum ddt_type {
42 42 DDT_TYPE_ZAP = 0,
43 43 DDT_TYPES
44 44 };
45 45
46 46 /*
47 47 * DDT classes, in the desired search order (highest replication level first).
48 48 */
49 49 enum ddt_class {
50 50 DDT_CLASS_DITTO = 0,
51 51 DDT_CLASS_DUPLICATE,
52 52 DDT_CLASS_UNIQUE,
53 53 DDT_CLASSES
54 54 };
55 55
56 56 #define DDT_TYPE_CURRENT 0
57 57
58 58 #define DDT_COMPRESS_BYTEORDER_MASK 0x80
59 59 #define DDT_COMPRESS_FUNCTION_MASK 0x7f
60 60
61 61 /*
62 62 * On-disk ddt entry: key (name) and physical storage (value).
63 63 */
64 64 typedef struct ddt_key {
65 65 zio_cksum_t ddk_cksum; /* 256-bit block checksum */
66 66 uint64_t ddk_prop; /* LSIZE, PSIZE, compression */
67 67 } ddt_key_t;
68 68
69 69 /*
70 70 * ddk_prop layout:
71 71 *
72 72 * +-------+-------+-------+-------+-------+-------+-------+-------+
73 73 * | 0 | 0 | 0 | comp | PSIZE | LSIZE |
74 74 * +-------+-------+-------+-------+-------+-------+-------+-------+
75 75 */
76 76 #define DDK_GET_LSIZE(ddk) \
77 77 BF64_GET_SB((ddk)->ddk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)
78 78 #define DDK_SET_LSIZE(ddk, x) \
79 79 BF64_SET_SB((ddk)->ddk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x)
80 80
81 81 #define DDK_GET_PSIZE(ddk) \
82 82 BF64_GET_SB((ddk)->ddk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1)
83 83 #define DDK_SET_PSIZE(ddk, x) \
84 84 BF64_SET_SB((ddk)->ddk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1, x)
85 85
86 86 #define DDK_GET_COMPRESS(ddk) BF64_GET((ddk)->ddk_prop, 32, 8)
87 87 #define DDK_SET_COMPRESS(ddk, x) BF64_SET((ddk)->ddk_prop, 32, 8, x)
88 88
89 89 #define DDT_KEY_WORDS (sizeof (ddt_key_t) / sizeof (uint64_t))
90 90
91 91 typedef struct ddt_phys {
92 92 dva_t ddp_dva[SPA_DVAS_PER_BP];
93 93 uint64_t ddp_refcnt;
94 94 uint64_t ddp_phys_birth;
95 95 } ddt_phys_t;
96 96
97 97 enum ddt_phys_type {
98 98 DDT_PHYS_DITTO = 0,
99 99 DDT_PHYS_SINGLE = 1,
100 100 DDT_PHYS_DOUBLE = 2,
101 101 DDT_PHYS_TRIPLE = 3,
102 102 DDT_PHYS_TYPES
103 103 };
104 104
105 105 /*
106 106 * In-core ddt entry
107 107 */
108 108 struct ddt_entry {
109 109 ddt_key_t dde_key;
110 110 ddt_phys_t dde_phys[DDT_PHYS_TYPES];
111 111 zio_t *dde_lead_zio[DDT_PHYS_TYPES];
112 112 void *dde_repair_data;
113 113 enum ddt_type dde_type;
114 114 enum ddt_class dde_class;
115 115 uint8_t dde_loading;
116 116 uint8_t dde_loaded;
117 117 kcondvar_t dde_cv;
118 118 avl_node_t dde_node;
119 119 };
120 120
121 121 /*
122 122 * In-core ddt
123 123 */
124 124 struct ddt {
125 125 kmutex_t ddt_lock;
126 126 avl_tree_t ddt_tree;
127 127 avl_tree_t ddt_repair_tree;
128 128 enum zio_checksum ddt_checksum;
129 129 spa_t *ddt_spa;
130 130 objset_t *ddt_os;
131 131 uint64_t ddt_stat_object;
132 132 uint64_t ddt_object[DDT_TYPES][DDT_CLASSES];
133 133 ddt_histogram_t ddt_histogram[DDT_TYPES][DDT_CLASSES];
134 134 ddt_histogram_t ddt_histogram_cache[DDT_TYPES][DDT_CLASSES];
135 135 ddt_object_t ddt_object_stats[DDT_TYPES][DDT_CLASSES];
136 136 avl_node_t ddt_node;
137 137 };
138 138
139 139 /*
140 140 * In-core and on-disk bookmark for DDT walks
141 141 */
142 142 typedef struct ddt_bookmark {
143 143 uint64_t ddb_class;
144 144 uint64_t ddb_type;
145 145 uint64_t ddb_checksum;
146 146 uint64_t ddb_cursor;
147 147 } ddt_bookmark_t;
148 148
149 149 /*
150 150 * Ops vector to access a specific DDT object type.
151 151 */
152 152 typedef struct ddt_ops {
153 153 char ddt_op_name[32];
154 154 int (*ddt_op_create)(objset_t *os, uint64_t *object, dmu_tx_t *tx,
155 155 boolean_t prehash);
156 156 int (*ddt_op_destroy)(objset_t *os, uint64_t object, dmu_tx_t *tx);
157 157 int (*ddt_op_lookup)(objset_t *os, uint64_t object, ddt_entry_t *dde);
158 158 void (*ddt_op_prefetch)(objset_t *os, uint64_t object,
159 159 ddt_entry_t *dde);
160 160 int (*ddt_op_update)(objset_t *os, uint64_t object, ddt_entry_t *dde,
161 161 dmu_tx_t *tx);
↓ open down ↓ |
161 lines elided |
↑ open up ↑ |
162 162 int (*ddt_op_remove)(objset_t *os, uint64_t object, ddt_entry_t *dde,
163 163 dmu_tx_t *tx);
164 164 int (*ddt_op_walk)(objset_t *os, uint64_t object, ddt_entry_t *dde,
165 165 uint64_t *walk);
166 166 uint64_t (*ddt_op_count)(objset_t *os, uint64_t object);
167 167 } ddt_ops_t;
168 168
169 169 #define DDT_NAMELEN 80
170 170
171 171 extern void ddt_object_name(ddt_t *ddt, enum ddt_type type,
172 - enum ddt_class class, char *name);
172 + enum ddt_class /*class*/, char *name);
173 173 extern int ddt_object_walk(ddt_t *ddt, enum ddt_type type,
174 - enum ddt_class class, uint64_t *walk, ddt_entry_t *dde);
174 + enum ddt_class /*class*/, uint64_t *walk, ddt_entry_t *dde);
175 175 extern uint64_t ddt_object_count(ddt_t *ddt, enum ddt_type type,
176 - enum ddt_class class);
176 + enum ddt_class /*class*/);
177 177 extern int ddt_object_info(ddt_t *ddt, enum ddt_type type,
178 - enum ddt_class class, dmu_object_info_t *);
178 + enum ddt_class /*class*/, dmu_object_info_t *);
179 179 extern boolean_t ddt_object_exists(ddt_t *ddt, enum ddt_type type,
180 - enum ddt_class class);
180 + enum ddt_class /*class*/);
181 181
182 182 extern void ddt_bp_fill(const ddt_phys_t *ddp, blkptr_t *bp,
183 183 uint64_t txg);
184 184 extern void ddt_bp_create(enum zio_checksum checksum, const ddt_key_t *ddk,
185 185 const ddt_phys_t *ddp, blkptr_t *bp);
186 186
187 187 extern void ddt_key_fill(ddt_key_t *ddk, const blkptr_t *bp);
188 188
189 189 extern void ddt_phys_fill(ddt_phys_t *ddp, const blkptr_t *bp);
190 190 extern void ddt_phys_clear(ddt_phys_t *ddp);
191 191 extern void ddt_phys_addref(ddt_phys_t *ddp);
192 192 extern void ddt_phys_decref(ddt_phys_t *ddp);
193 193 extern void ddt_phys_free(ddt_t *ddt, ddt_key_t *ddk, ddt_phys_t *ddp,
194 194 uint64_t txg);
195 195 extern ddt_phys_t *ddt_phys_select(const ddt_entry_t *dde, const blkptr_t *bp);
196 196 extern uint64_t ddt_phys_total_refcnt(const ddt_entry_t *dde);
197 197
198 198 extern void ddt_stat_add(ddt_stat_t *dst, const ddt_stat_t *src, uint64_t neg);
199 199
200 200 extern void ddt_histogram_add(ddt_histogram_t *dst, const ddt_histogram_t *src);
201 201 extern void ddt_histogram_stat(ddt_stat_t *dds, const ddt_histogram_t *ddh);
202 202 extern boolean_t ddt_histogram_empty(const ddt_histogram_t *ddh);
203 203 extern void ddt_get_dedup_object_stats(spa_t *spa, ddt_object_t *ddo);
204 204 extern void ddt_get_dedup_histogram(spa_t *spa, ddt_histogram_t *ddh);
205 205 extern void ddt_get_dedup_stats(spa_t *spa, ddt_stat_t *dds_total);
206 206
207 207 extern uint64_t ddt_get_dedup_dspace(spa_t *spa);
208 208 extern uint64_t ddt_get_pool_dedup_ratio(spa_t *spa);
209 209
210 210 extern int ddt_ditto_copies_needed(ddt_t *ddt, ddt_entry_t *dde,
211 211 ddt_phys_t *ddp_willref);
212 212 extern int ddt_ditto_copies_present(ddt_entry_t *dde);
213 213
214 214 extern size_t ddt_compress(void *src, uchar_t *dst, size_t s_len, size_t d_len);
215 215 extern void ddt_decompress(uchar_t *src, void *dst, size_t s_len, size_t d_len);
216 216
217 217 extern ddt_t *ddt_select(spa_t *spa, const blkptr_t *bp);
218 218 extern void ddt_enter(ddt_t *ddt);
219 219 extern void ddt_exit(ddt_t *ddt);
220 220 extern ddt_entry_t *ddt_lookup(ddt_t *ddt, const blkptr_t *bp, boolean_t add);
221 221 extern void ddt_prefetch(spa_t *spa, const blkptr_t *bp);
222 222 extern void ddt_remove(ddt_t *ddt, ddt_entry_t *dde);
223 223
224 224 extern boolean_t ddt_class_contains(spa_t *spa, enum ddt_class max_class,
225 225 const blkptr_t *bp);
226 226
227 227 extern ddt_entry_t *ddt_repair_start(ddt_t *ddt, const blkptr_t *bp);
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
228 228 extern void ddt_repair_done(ddt_t *ddt, ddt_entry_t *dde);
229 229
230 230 extern int ddt_entry_compare(const void *x1, const void *x2);
231 231
232 232 extern void ddt_create(spa_t *spa);
233 233 extern int ddt_load(spa_t *spa);
234 234 extern void ddt_unload(spa_t *spa);
235 235 extern void ddt_sync(spa_t *spa, uint64_t txg);
236 236 extern int ddt_walk(spa_t *spa, ddt_bookmark_t *ddb, ddt_entry_t *dde);
237 237 extern int ddt_object_update(ddt_t *ddt, enum ddt_type type,
238 - enum ddt_class class, ddt_entry_t *dde, dmu_tx_t *tx);
238 + enum ddt_class /*class*/, ddt_entry_t *dde, dmu_tx_t *tx);
239 239
240 240 extern const ddt_ops_t ddt_zap_ops;
241 241
242 242 #ifdef __cplusplus
243 243 }
244 244 #endif
245 245
246 246 #endif /* _SYS_DDT_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX