]>
Commit | Line | Data |
---|---|---|
34dc7c2f 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 | |
9 | * or http://www.opensolaris.org/os/licensing. | |
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 | /* | |
428870ff | 22 | * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
83017311 | 23 | * Copyright (c) 2013 by Delphix. All rights reserved. |
34dc7c2f BB |
24 | */ |
25 | ||
26 | #ifndef _SYS_ZAP_H | |
27 | #define _SYS_ZAP_H | |
28 | ||
34dc7c2f BB |
29 | /* |
30 | * ZAP - ZFS Attribute Processor | |
31 | * | |
32 | * The ZAP is a module which sits on top of the DMU (Data Management | |
33 | * Unit) and implements a higher-level storage primitive using DMU | |
34 | * objects. Its primary consumer is the ZPL (ZFS Posix Layer). | |
35 | * | |
36 | * A "zapobj" is a DMU object which the ZAP uses to stores attributes. | |
37 | * Users should use only zap routines to access a zapobj - they should | |
38 | * not access the DMU object directly using DMU routines. | |
39 | * | |
40 | * The attributes stored in a zapobj are name-value pairs. The name is | |
41 | * a zero-terminated string of up to ZAP_MAXNAMELEN bytes (including | |
42 | * terminating NULL). The value is an array of integers, which may be | |
43 | * 1, 2, 4, or 8 bytes long. The total space used by the array (number | |
44 | * of integers * integer length) can be up to ZAP_MAXVALUELEN bytes. | |
45 | * Note that an 8-byte integer value can be used to store the location | |
46 | * (object number) of another dmu object (which may be itself a zapobj). | |
47 | * Note that you can use a zero-length attribute to store a single bit | |
48 | * of information - the attribute is present or not. | |
49 | * | |
50 | * The ZAP routines are thread-safe. However, you must observe the | |
51 | * DMU's restriction that a transaction may not be operated on | |
52 | * concurrently. | |
53 | * | |
54 | * Any of the routines that return an int may return an I/O error (EIO | |
55 | * or ECHECKSUM). | |
56 | * | |
57 | * | |
58 | * Implementation / Performance Notes: | |
59 | * | |
60 | * The ZAP is intended to operate most efficiently on attributes with | |
61 | * short (49 bytes or less) names and single 8-byte values, for which | |
62 | * the microzap will be used. The ZAP should be efficient enough so | |
63 | * that the user does not need to cache these attributes. | |
64 | * | |
65 | * The ZAP's locking scheme makes its routines thread-safe. Operations | |
66 | * on different zapobjs will be processed concurrently. Operations on | |
67 | * the same zapobj which only read data will be processed concurrently. | |
68 | * Operations on the same zapobj which modify data will be processed | |
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 | ||
34dc7c2f | 88 | /* |
d3cc8b15 | 89 | * Specifies matching criteria for ZAP lookups. |
34dc7c2f BB |
90 | */ |
91 | typedef enum matchtype | |
92 | { | |
d3cc8b15 | 93 | /* Only find an exact match (non-normalized) */ |
34dc7c2f | 94 | MT_EXACT, |
d3cc8b15 WA |
95 | /* |
96 | * If there is an exact match, find that, otherwise find the | |
97 | * first normalized match. | |
98 | */ | |
34dc7c2f | 99 | MT_BEST, |
d3cc8b15 WA |
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 | */ | |
34dc7c2f BB |
105 | MT_FIRST |
106 | } matchtype_t; | |
107 | ||
428870ff BB |
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 | ||
34dc7c2f BB |
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 | * | |
125 | * normflags specifies what normalization will be done. values are: | |
126 | * 0: no normalization (legacy on-disk format, supports MT_EXACT matching | |
127 | * only) | |
128 | * U8_TEXTPREP_TOLOWER: case normalization will be performed. | |
129 | * MT_FIRST/MT_BEST matching will find entries that match without | |
130 | * regard to case (eg. looking for "foo" can find an entry "Foo"). | |
131 | * Eventually, other flags will permit unicode normalization as well. | |
50c957f7 NB |
132 | * |
133 | * dnodesize specifies the on-disk size of the dnode for the new zapobj. | |
134 | * Valid values are multiples of 512 up to DNODE_MAX_SIZE. | |
34dc7c2f BB |
135 | */ |
136 | uint64_t zap_create(objset_t *ds, dmu_object_type_t ot, | |
137 | dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx); | |
50c957f7 NB |
138 | uint64_t zap_create_dnsize(objset_t *ds, dmu_object_type_t ot, |
139 | dmu_object_type_t bonustype, int bonuslen, int dnodesize, dmu_tx_t *tx); | |
34dc7c2f BB |
140 | uint64_t zap_create_norm(objset_t *ds, int normflags, dmu_object_type_t ot, |
141 | dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx); | |
50c957f7 NB |
142 | uint64_t zap_create_norm_dnsize(objset_t *ds, int normflags, |
143 | dmu_object_type_t ot, dmu_object_type_t bonustype, int bonuslen, | |
144 | int dnodesize, dmu_tx_t *tx); | |
428870ff BB |
145 | uint64_t zap_create_flags(objset_t *os, int normflags, zap_flags_t flags, |
146 | dmu_object_type_t ot, int leaf_blockshift, int indirect_blockshift, | |
147 | dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx); | |
50c957f7 NB |
148 | uint64_t zap_create_flags_dnsize(objset_t *os, int normflags, |
149 | zap_flags_t flags, dmu_object_type_t ot, int leaf_blockshift, | |
150 | int indirect_blockshift, dmu_object_type_t bonustype, int bonuslen, | |
151 | int dnodesize, dmu_tx_t *tx); | |
9ae529ec CS |
152 | uint64_t zap_create_link(objset_t *os, dmu_object_type_t ot, |
153 | uint64_t parent_obj, const char *name, dmu_tx_t *tx); | |
50c957f7 NB |
154 | uint64_t zap_create_link_dnsize(objset_t *os, dmu_object_type_t ot, |
155 | uint64_t parent_obj, const char *name, int dnodesize, dmu_tx_t *tx); | |
34dc7c2f | 156 | |
fa86b5db MA |
157 | /* |
158 | * Initialize an already-allocated object. | |
159 | */ | |
160 | void mzap_create_impl(objset_t *os, uint64_t obj, int normflags, | |
161 | zap_flags_t flags, dmu_tx_t *tx); | |
162 | ||
34dc7c2f BB |
163 | /* |
164 | * Create a new zapobj with no attributes from the given (unallocated) | |
165 | * object number. | |
166 | */ | |
167 | int zap_create_claim(objset_t *ds, uint64_t obj, dmu_object_type_t ot, | |
168 | dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx); | |
50c957f7 NB |
169 | int zap_create_claim_dnsize(objset_t *ds, uint64_t obj, dmu_object_type_t ot, |
170 | dmu_object_type_t bonustype, int bonuslen, int dnodesize, dmu_tx_t *tx); | |
34dc7c2f BB |
171 | int zap_create_claim_norm(objset_t *ds, uint64_t obj, |
172 | int normflags, dmu_object_type_t ot, | |
173 | dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx); | |
50c957f7 NB |
174 | int zap_create_claim_norm_dnsize(objset_t *ds, uint64_t obj, |
175 | int normflags, dmu_object_type_t ot, | |
176 | dmu_object_type_t bonustype, int bonuslen, int dnodesize, dmu_tx_t *tx); | |
34dc7c2f BB |
177 | |
178 | /* | |
179 | * The zapobj passed in must be a valid ZAP object for all of the | |
180 | * following routines. | |
181 | */ | |
182 | ||
183 | /* | |
184 | * Destroy this zapobj and all its attributes. | |
185 | * | |
186 | * Frees the object number using dmu_object_free. | |
187 | */ | |
188 | int zap_destroy(objset_t *ds, uint64_t zapobj, dmu_tx_t *tx); | |
189 | ||
190 | /* | |
191 | * Manipulate attributes. | |
192 | * | |
193 | * 'integer_size' is in bytes, and must be 1, 2, 4, or 8. | |
194 | */ | |
195 | ||
196 | /* | |
197 | * Retrieve the contents of the attribute with the given name. | |
198 | * | |
199 | * If the requested attribute does not exist, the call will fail and | |
200 | * return ENOENT. | |
201 | * | |
202 | * If 'integer_size' is smaller than the attribute's integer size, the | |
203 | * call will fail and return EINVAL. | |
204 | * | |
205 | * If 'integer_size' is equal to or larger than the attribute's integer | |
d3cc8b15 WA |
206 | * size, the call will succeed and return 0. |
207 | * | |
208 | * When converting to a larger integer size, the integers will be treated as | |
209 | * unsigned (ie. no sign-extension will be performed). | |
34dc7c2f BB |
210 | * |
211 | * 'num_integers' is the length (in integers) of 'buf'. | |
212 | * | |
213 | * If the attribute is longer than the buffer, as many integers as will | |
214 | * fit will be transferred to 'buf'. If the entire attribute was not | |
215 | * transferred, the call will return EOVERFLOW. | |
d3cc8b15 WA |
216 | */ |
217 | int zap_lookup(objset_t *ds, uint64_t zapobj, const char *name, | |
218 | uint64_t integer_size, uint64_t num_integers, void *buf); | |
219 | ||
220 | /* | |
34dc7c2f BB |
221 | * If rn_len is nonzero, realname will be set to the name of the found |
222 | * entry (which may be different from the requested name if matchtype is | |
223 | * not MT_EXACT). | |
224 | * | |
225 | * If normalization_conflictp is not NULL, it will be set if there is | |
226 | * another name with the same case/unicode normalized form. | |
227 | */ | |
34dc7c2f BB |
228 | int zap_lookup_norm(objset_t *ds, uint64_t zapobj, const char *name, |
229 | uint64_t integer_size, uint64_t num_integers, void *buf, | |
230 | matchtype_t mt, char *realname, int rn_len, | |
231 | boolean_t *normalization_conflictp); | |
428870ff BB |
232 | int zap_lookup_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key, |
233 | int key_numints, uint64_t integer_size, uint64_t num_integers, void *buf); | |
234 | int zap_contains(objset_t *ds, uint64_t zapobj, const char *name); | |
07248450 | 235 | int zap_prefetch(objset_t *os, uint64_t zapobj, const char *name); |
428870ff BB |
236 | int zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key, |
237 | int key_numints); | |
34dc7c2f | 238 | |
9babb374 | 239 | int zap_count_write(objset_t *os, uint64_t zapobj, const char *name, |
45d1cae3 | 240 | int add, uint64_t *towrite, uint64_t *tooverwrite); |
9babb374 | 241 | |
34dc7c2f BB |
242 | /* |
243 | * Create an attribute with the given name and value. | |
244 | * | |
245 | * If an attribute with the given name already exists, the call will | |
246 | * fail and return EEXIST. | |
247 | */ | |
428870ff | 248 | int zap_add(objset_t *ds, uint64_t zapobj, const char *key, |
34dc7c2f BB |
249 | int integer_size, uint64_t num_integers, |
250 | const void *val, dmu_tx_t *tx); | |
428870ff BB |
251 | int zap_add_uint64(objset_t *ds, uint64_t zapobj, const uint64_t *key, |
252 | int key_numints, int integer_size, uint64_t num_integers, | |
253 | const void *val, dmu_tx_t *tx); | |
34dc7c2f BB |
254 | |
255 | /* | |
256 | * Set the attribute with the given name to the given value. If an | |
257 | * attribute with the given name does not exist, it will be created. If | |
258 | * an attribute with the given name already exists, the previous value | |
259 | * will be overwritten. The integer_size may be different from the | |
260 | * existing attribute's integer size, in which case the attribute's | |
261 | * integer size will be updated to the new value. | |
262 | */ | |
263 | int zap_update(objset_t *ds, uint64_t zapobj, const char *name, | |
264 | int integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx); | |
428870ff BB |
265 | int zap_update_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key, |
266 | int key_numints, | |
267 | int integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx); | |
34dc7c2f BB |
268 | |
269 | /* | |
270 | * Get the length (in integers) and the integer size of the specified | |
271 | * attribute. | |
272 | * | |
273 | * If the requested attribute does not exist, the call will fail and | |
274 | * return ENOENT. | |
275 | */ | |
276 | int zap_length(objset_t *ds, uint64_t zapobj, const char *name, | |
277 | uint64_t *integer_size, uint64_t *num_integers); | |
428870ff BB |
278 | int zap_length_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key, |
279 | int key_numints, uint64_t *integer_size, uint64_t *num_integers); | |
34dc7c2f BB |
280 | |
281 | /* | |
282 | * Remove the specified attribute. | |
283 | * | |
284 | * If the specified attribute does not exist, the call will fail and | |
285 | * return ENOENT. | |
286 | */ | |
287 | int zap_remove(objset_t *ds, uint64_t zapobj, const char *name, dmu_tx_t *tx); | |
288 | int zap_remove_norm(objset_t *ds, uint64_t zapobj, const char *name, | |
289 | matchtype_t mt, dmu_tx_t *tx); | |
428870ff BB |
290 | int zap_remove_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key, |
291 | int key_numints, dmu_tx_t *tx); | |
34dc7c2f BB |
292 | |
293 | /* | |
294 | * Returns (in *count) the number of attributes in the specified zap | |
295 | * object. | |
296 | */ | |
297 | int zap_count(objset_t *ds, uint64_t zapobj, uint64_t *count); | |
298 | ||
34dc7c2f BB |
299 | /* |
300 | * Returns (in name) the name of the entry whose (value & mask) | |
301 | * (za_first_integer) is value, or ENOENT if not found. The string | |
302 | * pointed to by name must be at least 256 bytes long. If mask==0, the | |
303 | * match must be exact (ie, same as mask=-1ULL). | |
304 | */ | |
305 | int zap_value_search(objset_t *os, uint64_t zapobj, | |
306 | uint64_t value, uint64_t mask, char *name); | |
307 | ||
b128c09f BB |
308 | /* |
309 | * Transfer all the entries from fromobj into intoobj. Only works on | |
310 | * int_size=8 num_integers=1 values. Fails if there are any duplicated | |
311 | * entries. | |
312 | */ | |
313 | int zap_join(objset_t *os, uint64_t fromobj, uint64_t intoobj, dmu_tx_t *tx); | |
314 | ||
428870ff BB |
315 | /* Same as zap_join, but set the values to 'value'. */ |
316 | int zap_join_key(objset_t *os, uint64_t fromobj, uint64_t intoobj, | |
317 | uint64_t value, dmu_tx_t *tx); | |
318 | ||
319 | /* Same as zap_join, but add together any duplicated entries. */ | |
320 | int zap_join_increment(objset_t *os, uint64_t fromobj, uint64_t intoobj, | |
321 | dmu_tx_t *tx); | |
322 | ||
b128c09f BB |
323 | /* |
324 | * Manipulate entries where the name + value are the "same" (the name is | |
325 | * a stringified version of the value). | |
326 | */ | |
327 | int zap_add_int(objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx); | |
328 | int zap_remove_int(objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx); | |
329 | int zap_lookup_int(objset_t *os, uint64_t obj, uint64_t value); | |
428870ff BB |
330 | int zap_increment_int(objset_t *os, uint64_t obj, uint64_t key, int64_t delta, |
331 | dmu_tx_t *tx); | |
332 | ||
333 | /* Here the key is an int and the value is a different int. */ | |
334 | int zap_add_int_key(objset_t *os, uint64_t obj, | |
335 | uint64_t key, uint64_t value, dmu_tx_t *tx); | |
753c3839 MA |
336 | int zap_update_int_key(objset_t *os, uint64_t obj, |
337 | uint64_t key, uint64_t value, dmu_tx_t *tx); | |
428870ff BB |
338 | int zap_lookup_int_key(objset_t *os, uint64_t obj, |
339 | uint64_t key, uint64_t *valuep); | |
340 | ||
428870ff BB |
341 | int zap_increment(objset_t *os, uint64_t obj, const char *name, int64_t delta, |
342 | dmu_tx_t *tx); | |
b128c09f | 343 | |
34dc7c2f BB |
344 | struct zap; |
345 | struct zap_leaf; | |
346 | typedef struct zap_cursor { | |
347 | /* This structure is opaque! */ | |
348 | objset_t *zc_objset; | |
349 | struct zap *zc_zap; | |
350 | struct zap_leaf *zc_leaf; | |
351 | uint64_t zc_zapobj; | |
428870ff | 352 | uint64_t zc_serialized; |
34dc7c2f BB |
353 | uint64_t zc_hash; |
354 | uint32_t zc_cd; | |
355 | } zap_cursor_t; | |
356 | ||
357 | typedef struct { | |
358 | int za_integer_length; | |
359 | /* | |
360 | * za_normalization_conflict will be set if there are additional | |
361 | * entries with this normalized form (eg, "foo" and "Foo"). | |
362 | */ | |
363 | boolean_t za_normalization_conflict; | |
364 | uint64_t za_num_integers; | |
365 | uint64_t za_first_integer; /* no sign extension for <8byte ints */ | |
366 | char za_name[MAXNAMELEN]; | |
367 | } zap_attribute_t; | |
368 | ||
369 | /* | |
370 | * The interface for listing all the attributes of a zapobj can be | |
371 | * thought of as cursor moving down a list of the attributes one by | |
372 | * one. The cookie returned by the zap_cursor_serialize routine is | |
373 | * persistent across system calls (and across reboot, even). | |
374 | */ | |
375 | ||
376 | /* | |
377 | * Initialize a zap cursor, pointing to the "first" attribute of the | |
378 | * zapobj. You must _fini the cursor when you are done with it. | |
379 | */ | |
380 | void zap_cursor_init(zap_cursor_t *zc, objset_t *ds, uint64_t zapobj); | |
381 | void zap_cursor_fini(zap_cursor_t *zc); | |
382 | ||
383 | /* | |
384 | * Get the attribute currently pointed to by the cursor. Returns | |
385 | * ENOENT if at the end of the attributes. | |
386 | */ | |
387 | int zap_cursor_retrieve(zap_cursor_t *zc, zap_attribute_t *za); | |
388 | ||
389 | /* | |
390 | * Advance the cursor to the next attribute. | |
391 | */ | |
392 | void zap_cursor_advance(zap_cursor_t *zc); | |
393 | ||
394 | /* | |
395 | * Get a persistent cookie pointing to the current position of the zap | |
396 | * cursor. The low 4 bits in the cookie are always zero, and thus can | |
397 | * be used as to differentiate a serialized cookie from a different type | |
398 | * of value. The cookie will be less than 2^32 as long as there are | |
399 | * fewer than 2^22 (4.2 million) entries in the zap object. | |
400 | */ | |
401 | uint64_t zap_cursor_serialize(zap_cursor_t *zc); | |
402 | ||
403 | /* | |
404 | * Initialize a zap cursor pointing to the position recorded by | |
405 | * zap_cursor_serialize (in the "serialized" argument). You can also | |
406 | * use a "serialized" argument of 0 to start at the beginning of the | |
407 | * zapobj (ie. zap_cursor_init_serialized(..., 0) is equivalent to | |
408 | * zap_cursor_init(...).) | |
409 | */ | |
410 | void zap_cursor_init_serialized(zap_cursor_t *zc, objset_t *ds, | |
411 | uint64_t zapobj, uint64_t serialized); | |
412 | ||
413 | ||
414 | #define ZAP_HISTOGRAM_SIZE 10 | |
415 | ||
416 | typedef struct zap_stats { | |
417 | /* | |
418 | * Size of the pointer table (in number of entries). | |
419 | * This is always a power of 2, or zero if it's a microzap. | |
420 | * In general, it should be considerably greater than zs_num_leafs. | |
421 | */ | |
422 | uint64_t zs_ptrtbl_len; | |
423 | ||
424 | uint64_t zs_blocksize; /* size of zap blocks */ | |
425 | ||
426 | /* | |
427 | * The number of blocks used. Note that some blocks may be | |
428 | * wasted because old ptrtbl's and large name/value blocks are | |
429 | * not reused. (Although their space is reclaimed, we don't | |
430 | * reuse those offsets in the object.) | |
431 | */ | |
432 | uint64_t zs_num_blocks; | |
433 | ||
434 | /* | |
435 | * Pointer table values from zap_ptrtbl in the zap_phys_t | |
436 | */ | |
437 | uint64_t zs_ptrtbl_nextblk; /* next (larger) copy start block */ | |
438 | uint64_t zs_ptrtbl_blks_copied; /* number source blocks copied */ | |
439 | uint64_t zs_ptrtbl_zt_blk; /* starting block number */ | |
440 | uint64_t zs_ptrtbl_zt_numblks; /* number of blocks */ | |
441 | uint64_t zs_ptrtbl_zt_shift; /* bits to index it */ | |
442 | ||
443 | /* | |
444 | * Values of the other members of the zap_phys_t | |
445 | */ | |
446 | uint64_t zs_block_type; /* ZBT_HEADER */ | |
447 | uint64_t zs_magic; /* ZAP_MAGIC */ | |
448 | uint64_t zs_num_leafs; /* The number of leaf blocks */ | |
449 | uint64_t zs_num_entries; /* The number of zap entries */ | |
450 | uint64_t zs_salt; /* salt to stir into hash function */ | |
451 | ||
452 | /* | |
453 | * Histograms. For all histograms, the last index | |
454 | * (ZAP_HISTOGRAM_SIZE-1) includes any values which are greater | |
455 | * than what can be represented. For example | |
456 | * zs_leafs_with_n5_entries[ZAP_HISTOGRAM_SIZE-1] is the number | |
457 | * of leafs with more than 45 entries. | |
458 | */ | |
459 | ||
460 | /* | |
461 | * zs_leafs_with_n_pointers[n] is the number of leafs with | |
462 | * 2^n pointers to it. | |
463 | */ | |
464 | uint64_t zs_leafs_with_2n_pointers[ZAP_HISTOGRAM_SIZE]; | |
465 | ||
466 | /* | |
467 | * zs_leafs_with_n_entries[n] is the number of leafs with | |
468 | * [n*5, (n+1)*5) entries. In the current implementation, there | |
469 | * can be at most 55 entries in any block, but there may be | |
470 | * fewer if the name or value is large, or the block is not | |
471 | * completely full. | |
472 | */ | |
473 | uint64_t zs_blocks_with_n5_entries[ZAP_HISTOGRAM_SIZE]; | |
474 | ||
475 | /* | |
476 | * zs_leafs_n_tenths_full[n] is the number of leafs whose | |
477 | * fullness is in the range [n/10, (n+1)/10). | |
478 | */ | |
479 | uint64_t zs_blocks_n_tenths_full[ZAP_HISTOGRAM_SIZE]; | |
480 | ||
481 | /* | |
482 | * zs_entries_using_n_chunks[n] is the number of entries which | |
483 | * consume n 24-byte chunks. (Note, large names/values only use | |
484 | * one chunk, but contribute to zs_num_blocks_large.) | |
485 | */ | |
486 | uint64_t zs_entries_using_n_chunks[ZAP_HISTOGRAM_SIZE]; | |
487 | ||
488 | /* | |
489 | * zs_buckets_with_n_entries[n] is the number of buckets (each | |
490 | * leaf has 64 buckets) with n entries. | |
491 | * zs_buckets_with_n_entries[1] should be very close to | |
492 | * zs_num_entries. | |
493 | */ | |
494 | uint64_t zs_buckets_with_n_entries[ZAP_HISTOGRAM_SIZE]; | |
495 | } zap_stats_t; | |
496 | ||
497 | /* | |
498 | * Get statistics about a ZAP object. Note: you need to be aware of the | |
499 | * internal implementation of the ZAP to correctly interpret some of the | |
500 | * statistics. This interface shouldn't be relied on unless you really | |
501 | * know what you're doing. | |
502 | */ | |
503 | int zap_get_stats(objset_t *ds, uint64_t zapobj, zap_stats_t *zs); | |
504 | ||
505 | #ifdef __cplusplus | |
506 | } | |
507 | #endif | |
508 | ||
509 | #endif /* _SYS_ZAP_H */ |