69 * concurrently when there are many attributes in the zapobj (because
70 * the ZAP uses per-block locking - more than 128 * (number of cpus)
71 * small attributes will suffice).
72 */
73
74 /*
75 * We're using zero-terminated byte strings (ie. ASCII or UTF-8 C
76 * strings) for the names of attributes, rather than a byte string
77 * bounded by an explicit length. If some day we want to support names
78 * in character sets which have embedded zeros (eg. UTF-16, UTF-32),
79 * we'll have to add routines for using length-bounded strings.
80 */
81
82 #include <sys/dmu.h>
83
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87
88 /*
89 * The matchtype specifies which entry will be accessed.
90 * MT_EXACT: only find an exact match (non-normalized)
91 * MT_FIRST: find the "first" normalized (case and Unicode
92 * form) match; the designated "first" match will not change as long
93 * as the set of entries with this normalization doesn't change
94 * MT_BEST: if there is an exact match, find that, otherwise find the
95 * first normalized match
96 */
97 typedef enum matchtype
98 {
99 MT_EXACT,
100 MT_BEST,
101 MT_FIRST
102 } matchtype_t;
103
104 typedef enum zap_flags {
105 /* Use 64-bit hash value (serialized cursors will always use 64-bits) */
106 ZAP_FLAG_HASH64 = 1 << 0,
107 /* Key is binary, not string (zap_add_uint64() can be used) */
108 ZAP_FLAG_UINT64_KEY = 1 << 1,
109 /*
110 * First word of key (which must be an array of uint64) is
111 * already randomly distributed.
112 */
113 ZAP_FLAG_PRE_HASHED_KEY = 1 << 2,
114 } zap_flags_t;
115
116 /*
117 * Create a new zapobj with no attributes and return its object number.
118 * MT_EXACT will cause the zap object to only support MT_EXACT lookups,
119 * otherwise any matchtype can be used for lookups.
120 *
157 * Frees the object number using dmu_object_free.
158 */
159 int zap_destroy(objset_t *ds, uint64_t zapobj, dmu_tx_t *tx);
160
161 /*
162 * Manipulate attributes.
163 *
164 * 'integer_size' is in bytes, and must be 1, 2, 4, or 8.
165 */
166
167 /*
168 * Retrieve the contents of the attribute with the given name.
169 *
170 * If the requested attribute does not exist, the call will fail and
171 * return ENOENT.
172 *
173 * If 'integer_size' is smaller than the attribute's integer size, the
174 * call will fail and return EINVAL.
175 *
176 * If 'integer_size' is equal to or larger than the attribute's integer
177 * size, the call will succeed and return 0. * When converting to a
178 * larger integer size, the integers will be treated as unsigned (ie. no
179 * sign-extension will be performed).
180 *
181 * 'num_integers' is the length (in integers) of 'buf'.
182 *
183 * If the attribute is longer than the buffer, as many integers as will
184 * fit will be transferred to 'buf'. If the entire attribute was not
185 * transferred, the call will return EOVERFLOW.
186 *
187 * If rn_len is nonzero, realname will be set to the name of the found
188 * entry (which may be different from the requested name if matchtype is
189 * not MT_EXACT).
190 *
191 * If normalization_conflictp is not NULL, it will be set if there is
192 * another name with the same case/unicode normalized form.
193 */
194 int zap_lookup(objset_t *ds, uint64_t zapobj, const char *name,
195 uint64_t integer_size, uint64_t num_integers, void *buf);
196 int zap_lookup_norm(objset_t *ds, uint64_t zapobj, const char *name,
197 uint64_t integer_size, uint64_t num_integers, void *buf,
198 matchtype_t mt, char *realname, int rn_len,
199 boolean_t *normalization_conflictp);
200 int zap_lookup_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
201 int key_numints, uint64_t integer_size, uint64_t num_integers, void *buf);
202 int zap_contains(objset_t *ds, uint64_t zapobj, const char *name);
203 int zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
204 int key_numints);
205
206 int zap_count_write(objset_t *os, uint64_t zapobj, const char *name,
207 int add, uint64_t *towrite, uint64_t *tooverwrite);
208
209 /*
210 * Create an attribute with the given name and value.
211 *
212 * If an attribute with the given name already exists, the call will
213 * fail and return EEXIST.
214 */
215 int zap_add(objset_t *ds, uint64_t zapobj, const char *key,
|
69 * concurrently when there are many attributes in the zapobj (because
70 * the ZAP uses per-block locking - more than 128 * (number of cpus)
71 * small attributes will suffice).
72 */
73
74 /*
75 * We're using zero-terminated byte strings (ie. ASCII or UTF-8 C
76 * strings) for the names of attributes, rather than a byte string
77 * bounded by an explicit length. If some day we want to support names
78 * in character sets which have embedded zeros (eg. UTF-16, UTF-32),
79 * we'll have to add routines for using length-bounded strings.
80 */
81
82 #include <sys/dmu.h>
83
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87
88 /*
89 * Specifies matching criteria for ZAP lookups.
90 */
91 typedef enum matchtype
92 {
93 /* Only find an exact match (non-normalized) */
94 MT_EXACT,
95 /*
96 * If there is an exact match, find that, otherwise find the
97 * first normalized match.
98 */
99 MT_BEST,
100 /*
101 * Find the "first" normalized (case and Unicode form) match;
102 * the designated "first" match will not change as long as the
103 * set of entries with this normalization doesn't change.
104 */
105 MT_FIRST
106 } matchtype_t;
107
108 typedef enum zap_flags {
109 /* Use 64-bit hash value (serialized cursors will always use 64-bits) */
110 ZAP_FLAG_HASH64 = 1 << 0,
111 /* Key is binary, not string (zap_add_uint64() can be used) */
112 ZAP_FLAG_UINT64_KEY = 1 << 1,
113 /*
114 * First word of key (which must be an array of uint64) is
115 * already randomly distributed.
116 */
117 ZAP_FLAG_PRE_HASHED_KEY = 1 << 2,
118 } zap_flags_t;
119
120 /*
121 * Create a new zapobj with no attributes and return its object number.
122 * MT_EXACT will cause the zap object to only support MT_EXACT lookups,
123 * otherwise any matchtype can be used for lookups.
124 *
161 * Frees the object number using dmu_object_free.
162 */
163 int zap_destroy(objset_t *ds, uint64_t zapobj, dmu_tx_t *tx);
164
165 /*
166 * Manipulate attributes.
167 *
168 * 'integer_size' is in bytes, and must be 1, 2, 4, or 8.
169 */
170
171 /*
172 * Retrieve the contents of the attribute with the given name.
173 *
174 * If the requested attribute does not exist, the call will fail and
175 * return ENOENT.
176 *
177 * If 'integer_size' is smaller than the attribute's integer size, the
178 * call will fail and return EINVAL.
179 *
180 * If 'integer_size' is equal to or larger than the attribute's integer
181 * size, the call will succeed and return 0.
182 *
183 * When converting to a larger integer size, the integers will be treated as
184 * unsigned (ie. no sign-extension will be performed).
185 *
186 * 'num_integers' is the length (in integers) of 'buf'.
187 *
188 * If the attribute is longer than the buffer, as many integers as will
189 * fit will be transferred to 'buf'. If the entire attribute was not
190 * transferred, the call will return EOVERFLOW.
191 */
192 int zap_lookup(objset_t *ds, uint64_t zapobj, const char *name,
193 uint64_t integer_size, uint64_t num_integers, void *buf);
194
195 /*
196 * If rn_len is nonzero, realname will be set to the name of the found
197 * entry (which may be different from the requested name if matchtype is
198 * not MT_EXACT).
199 *
200 * If normalization_conflictp is not NULL, it will be set if there is
201 * another name with the same case/unicode normalized form.
202 */
203 int zap_lookup_norm(objset_t *ds, uint64_t zapobj, const char *name,
204 uint64_t integer_size, uint64_t num_integers, void *buf,
205 matchtype_t mt, char *realname, int rn_len,
206 boolean_t *normalization_conflictp);
207 int zap_lookup_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
208 int key_numints, uint64_t integer_size, uint64_t num_integers, void *buf);
209 int zap_contains(objset_t *ds, uint64_t zapobj, const char *name);
210 int zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
211 int key_numints);
212
213 int zap_count_write(objset_t *os, uint64_t zapobj, const char *name,
214 int add, uint64_t *towrite, uint64_t *tooverwrite);
215
216 /*
217 * Create an attribute with the given name and value.
218 *
219 * If an attribute with the given name already exists, the call will
220 * fail and return EEXIST.
221 */
222 int zap_add(objset_t *ds, uint64_t zapobj, const char *key,
|