16 * fields enclosed by brackets "[]" replaced with your own identifying |
16 * fields enclosed by brackets "[]" replaced with your own identifying |
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
18 * |
18 * |
19 * CDDL HEADER END |
19 * CDDL HEADER END |
20 */ |
20 */ |
|
21 |
21 /* |
22 /* |
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2011 by Delphix. All rights reserved. |
24 * Copyright (c) 2012 by Delphix. All rights reserved. |
24 */ |
|
25 /* |
|
26 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. |
25 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. |
27 * Copyright (c) 2012, Joyent, Inc. All rights reserved. |
26 * Copyright (c) 2012, Joyent, Inc. All rights reserved. |
28 */ |
27 */ |
29 |
28 |
30 /* Portions Copyright 2010 Robert Milkowski */ |
29 /* Portions Copyright 2010 Robert Milkowski */ |
72 struct sa_handle; |
71 struct sa_handle; |
73 |
72 |
74 typedef struct objset objset_t; |
73 typedef struct objset objset_t; |
75 typedef struct dmu_tx dmu_tx_t; |
74 typedef struct dmu_tx dmu_tx_t; |
76 typedef struct dsl_dir dsl_dir_t; |
75 typedef struct dsl_dir dsl_dir_t; |
|
76 |
|
77 typedef enum dmu_object_byteswap { |
|
78 DMU_BSWAP_UINT8, |
|
79 DMU_BSWAP_UINT16, |
|
80 DMU_BSWAP_UINT32, |
|
81 DMU_BSWAP_UINT64, |
|
82 DMU_BSWAP_ZAP, |
|
83 DMU_BSWAP_DNODE, |
|
84 DMU_BSWAP_OBJSET, |
|
85 DMU_BSWAP_ZNODE, |
|
86 DMU_BSWAP_OLDACL, |
|
87 DMU_BSWAP_ACL, |
|
88 /* |
|
89 * Allocating a new byteswap type number makes the on-disk format |
|
90 * incompatible with any other format that uses the same number. |
|
91 * |
|
92 * Data can usually be structured to work with one of the |
|
93 * DMU_BSWAP_UINT* or DMU_BSWAP_ZAP types. |
|
94 */ |
|
95 DMU_BSWAP_NUMFUNCS |
|
96 } dmu_object_byteswap_t; |
|
97 |
|
98 #define DMU_OT_NEWTYPE 0x80 |
|
99 #define DMU_OT_METADATA 0x40 |
|
100 #define DMU_OT_BYTESWAP_MASK 0x3f |
|
101 |
|
102 /* |
|
103 * Defines a uint8_t object type. Object types specify if the data |
|
104 * in the object is metadata (boolean) and how to byteswap the data |
|
105 * (dmu_object_byteswap_t). |
|
106 */ |
|
107 #define DMU_OT(byteswap, metadata) \ |
|
108 (DMU_OT_NEWTYPE | \ |
|
109 ((metadata) ? DMU_OT_METADATA : 0) | \ |
|
110 ((byteswap) & DMU_OT_BYTESWAP_MASK)) |
|
111 |
|
112 #define DMU_OT_IS_VALID(ot) (((ot) & DMU_OT_NEWTYPE) ? \ |
|
113 ((ot) & DMU_OT_BYTESWAP_MASK) < DMU_BSWAP_NUMFUNCS : \ |
|
114 (ot) < DMU_OT_NUMTYPES) |
|
115 |
|
116 #define DMU_OT_IS_METADATA(ot) (((ot) & DMU_OT_NEWTYPE) ? \ |
|
117 ((ot) & DMU_OT_METADATA) : \ |
|
118 dmu_ot[(ot)].ot_metadata) |
|
119 |
|
120 #define DMU_OT_BYTESWAP(ot) (((ot) & DMU_OT_NEWTYPE) ? \ |
|
121 ((ot) & DMU_OT_BYTESWAP_MASK) : \ |
|
122 dmu_ot[(ot)].ot_byteswap) |
77 |
123 |
78 typedef enum dmu_object_type { |
124 typedef enum dmu_object_type { |
79 DMU_OT_NONE, |
125 DMU_OT_NONE, |
80 /* general: */ |
126 /* general: */ |
81 DMU_OT_OBJECT_DIRECTORY, /* ZAP */ |
127 DMU_OT_OBJECT_DIRECTORY, /* ZAP */ |
137 DMU_OT_DEDUP, /* fake dedup BP from ddt_bp_create() */ |
183 DMU_OT_DEDUP, /* fake dedup BP from ddt_bp_create() */ |
138 DMU_OT_DEADLIST, /* ZAP */ |
184 DMU_OT_DEADLIST, /* ZAP */ |
139 DMU_OT_DEADLIST_HDR, /* UINT64 */ |
185 DMU_OT_DEADLIST_HDR, /* UINT64 */ |
140 DMU_OT_DSL_CLONES, /* ZAP */ |
186 DMU_OT_DSL_CLONES, /* ZAP */ |
141 DMU_OT_BPOBJ_SUBOBJ, /* UINT64 */ |
187 DMU_OT_BPOBJ_SUBOBJ, /* UINT64 */ |
142 DMU_OT_NUMTYPES |
188 /* |
|
189 * Do not allocate new object types here. Doing so makes the on-disk |
|
190 * format incompatible with any other format that uses the same object |
|
191 * type number. |
|
192 * |
|
193 * When creating an object which does not have one of the above types |
|
194 * use the DMU_OTN_* type with the correct byteswap and metadata |
|
195 * values. |
|
196 * |
|
197 * The DMU_OTN_* types do not have entries in the dmu_ot table, |
|
198 * use the DMU_OT_IS_METDATA() and DMU_OT_BYTESWAP() macros instead |
|
199 * of indexing into dmu_ot directly (this works for both DMU_OT_* types |
|
200 * and DMU_OTN_* types). |
|
201 */ |
|
202 DMU_OT_NUMTYPES, |
|
203 |
|
204 /* |
|
205 * Names for valid types declared with DMU_OT(). |
|
206 */ |
|
207 DMU_OTN_UINT8_DATA = DMU_OT(DMU_BSWAP_UINT8, B_FALSE), |
|
208 DMU_OTN_UINT8_METADATA = DMU_OT(DMU_BSWAP_UINT8, B_TRUE), |
|
209 DMU_OTN_UINT16_DATA = DMU_OT(DMU_BSWAP_UINT16, B_FALSE), |
|
210 DMU_OTN_UINT16_METADATA = DMU_OT(DMU_BSWAP_UINT16, B_TRUE), |
|
211 DMU_OTN_UINT32_DATA = DMU_OT(DMU_BSWAP_UINT32, B_FALSE), |
|
212 DMU_OTN_UINT32_METADATA = DMU_OT(DMU_BSWAP_UINT32, B_TRUE), |
|
213 DMU_OTN_UINT64_DATA = DMU_OT(DMU_BSWAP_UINT64, B_FALSE), |
|
214 DMU_OTN_UINT64_METADATA = DMU_OT(DMU_BSWAP_UINT64, B_TRUE), |
|
215 DMU_OTN_ZAP_DATA = DMU_OT(DMU_BSWAP_ZAP, B_FALSE), |
|
216 DMU_OTN_ZAP_METADATA = DMU_OT(DMU_BSWAP_ZAP, B_TRUE), |
143 } dmu_object_type_t; |
217 } dmu_object_type_t; |
144 |
218 |
145 typedef enum dmu_objset_type { |
219 typedef enum dmu_objset_type { |
146 DMU_OST_NONE, |
220 DMU_OST_NONE, |
147 DMU_OST_META, |
221 DMU_OST_META, |
217 /* |
291 /* |
218 * The names of zap entries in the DIRECTORY_OBJECT of the MOS. |
292 * The names of zap entries in the DIRECTORY_OBJECT of the MOS. |
219 */ |
293 */ |
220 #define DMU_POOL_DIRECTORY_OBJECT 1 |
294 #define DMU_POOL_DIRECTORY_OBJECT 1 |
221 #define DMU_POOL_CONFIG "config" |
295 #define DMU_POOL_CONFIG "config" |
|
296 #define DMU_POOL_FEATURES_FOR_WRITE "features_for_write" |
|
297 #define DMU_POOL_FEATURES_FOR_READ "features_for_read" |
|
298 #define DMU_POOL_FEATURE_DESCRIPTIONS "feature_descriptions" |
222 #define DMU_POOL_ROOT_DATASET "root_dataset" |
299 #define DMU_POOL_ROOT_DATASET "root_dataset" |
223 #define DMU_POOL_SYNC_BPOBJ "sync_bplist" |
300 #define DMU_POOL_SYNC_BPOBJ "sync_bplist" |
224 #define DMU_POOL_ERRLOG_SCRUB "errlog_scrub" |
301 #define DMU_POOL_ERRLOG_SCRUB "errlog_scrub" |
225 #define DMU_POOL_ERRLOG_LAST "errlog_last" |
302 #define DMU_POOL_ERRLOG_LAST "errlog_last" |
226 #define DMU_POOL_SPARES "spares" |
303 #define DMU_POOL_SPARES "spares" |
232 #define DMU_POOL_DDT "DDT-%s-%s-%s" |
309 #define DMU_POOL_DDT "DDT-%s-%s-%s" |
233 #define DMU_POOL_DDT_STATS "DDT-statistics" |
310 #define DMU_POOL_DDT_STATS "DDT-statistics" |
234 #define DMU_POOL_CREATION_VERSION "creation_version" |
311 #define DMU_POOL_CREATION_VERSION "creation_version" |
235 #define DMU_POOL_SCAN "scan" |
312 #define DMU_POOL_SCAN "scan" |
236 #define DMU_POOL_FREE_BPOBJ "free_bpobj" |
313 #define DMU_POOL_FREE_BPOBJ "free_bpobj" |
|
314 #define DMU_POOL_BPTREE_OBJ "bptree_obj" |
237 |
315 |
238 /* |
316 /* |
239 * Allocate an object from this objset. The range of object numbers |
317 * Allocate an object from this objset. The range of object numbers |
240 * available is (0, DN_MAX_OBJECT). Object 0 is the meta-dnode. |
318 * available is (0, DN_MAX_OBJECT). Object 0 is the meta-dnode. |
241 * |
319 * |
492 void dmu_tx_callback_register(dmu_tx_t *tx, dmu_tx_callback_func_t *dcb_func, |
570 void dmu_tx_callback_register(dmu_tx_t *tx, dmu_tx_callback_func_t *dcb_func, |
493 void *dcb_data); |
571 void *dcb_data); |
494 |
572 |
495 /* |
573 /* |
496 * Free up the data blocks for a defined range of a file. If size is |
574 * Free up the data blocks for a defined range of a file. If size is |
497 * zero, the range from offset to end-of-file is freed. |
575 * -1, the range from offset to end-of-file is freed. |
498 */ |
576 */ |
499 int dmu_free_range(objset_t *os, uint64_t object, uint64_t offset, |
577 int dmu_free_range(objset_t *os, uint64_t object, uint64_t offset, |
500 uint64_t size, dmu_tx_t *tx); |
578 uint64_t size, dmu_tx_t *tx); |
501 int dmu_free_long_range(objset_t *os, uint64_t object, uint64_t offset, |
579 int dmu_free_long_range(objset_t *os, uint64_t object, uint64_t offset, |
502 uint64_t size); |
580 uint64_t size); |
562 } dmu_object_info_t; |
640 } dmu_object_info_t; |
563 |
641 |
564 typedef void arc_byteswap_func_t(void *buf, size_t size); |
642 typedef void arc_byteswap_func_t(void *buf, size_t size); |
565 |
643 |
566 typedef struct dmu_object_type_info { |
644 typedef struct dmu_object_type_info { |
567 arc_byteswap_func_t *ot_byteswap; |
645 dmu_object_byteswap_t ot_byteswap; |
568 boolean_t ot_metadata; |
646 boolean_t ot_metadata; |
569 char *ot_name; |
647 char *ot_name; |
570 } dmu_object_type_info_t; |
648 } dmu_object_type_info_t; |
571 |
649 |
|
650 typedef struct dmu_object_byteswap_info { |
|
651 arc_byteswap_func_t *ob_func; |
|
652 char *ob_name; |
|
653 } dmu_object_byteswap_info_t; |
|
654 |
572 extern const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES]; |
655 extern const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES]; |
|
656 extern const dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS]; |
573 |
657 |
574 /* |
658 /* |
575 * Get information on a DMU object. |
659 * Get information on a DMU object. |
576 * |
660 * |
577 * Return 0 on success or ENOENT if object is not allocated. |
661 * Return 0 on success or ENOENT if object is not allocated. |