]> git.proxmox.com Git - mirror_zfs.git/blob - include/sys/fs/zfs.h
Introduce read/write kstats per dataset
[mirror_zfs.git] / include / sys / fs / zfs.h
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
22 /*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
25 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 * Copyright (c) 2013, 2017 Joyent, Inc. All rights reserved.
27 * Copyright (c) 2014 Integros [integros.com]
28 * Copyright (c) 2017 Datto Inc.
29 */
30
31 /* Portions Copyright 2010 Robert Milkowski */
32
33 #ifndef _SYS_FS_ZFS_H
34 #define _SYS_FS_ZFS_H
35
36 #include <sys/time.h>
37 #include <sys/zio_priority.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /*
44 * Types and constants shared between userland and the kernel.
45 */
46
47 /*
48 * Each dataset can be one of the following types. These constants can be
49 * combined into masks that can be passed to various functions.
50 */
51 typedef enum {
52 ZFS_TYPE_FILESYSTEM = (1 << 0),
53 ZFS_TYPE_SNAPSHOT = (1 << 1),
54 ZFS_TYPE_VOLUME = (1 << 2),
55 ZFS_TYPE_POOL = (1 << 3),
56 ZFS_TYPE_BOOKMARK = (1 << 4)
57 } zfs_type_t;
58
59 /*
60 * NB: lzc_dataset_type should be updated whenever a new objset type is added,
61 * if it represents a real type of a dataset that can be created from userland.
62 */
63 typedef enum dmu_objset_type {
64 DMU_OST_NONE,
65 DMU_OST_META,
66 DMU_OST_ZFS,
67 DMU_OST_ZVOL,
68 DMU_OST_OTHER, /* For testing only! */
69 DMU_OST_ANY, /* Be careful! */
70 DMU_OST_NUMTYPES
71 } dmu_objset_type_t;
72
73 #define ZFS_TYPE_DATASET \
74 (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
75
76 /*
77 * All of these include the terminating NUL byte.
78 */
79 #define ZAP_MAXNAMELEN 256
80 #define ZAP_MAXVALUELEN (1024 * 8)
81 #define ZAP_OLDMAXVALUELEN 1024
82 #define ZFS_MAX_DATASET_NAME_LEN 256
83
84 /*
85 * Dataset properties are identified by these constants and must be added to
86 * the end of this list to ensure that external consumers are not affected
87 * by the change. If you make any changes to this list, be sure to update
88 * the property table in module/zcommon/zfs_prop.c.
89 */
90 typedef enum {
91 ZPROP_CONT = -2,
92 ZPROP_INVAL = -1,
93 ZFS_PROP_TYPE = 0,
94 ZFS_PROP_CREATION,
95 ZFS_PROP_USED,
96 ZFS_PROP_AVAILABLE,
97 ZFS_PROP_REFERENCED,
98 ZFS_PROP_COMPRESSRATIO,
99 ZFS_PROP_MOUNTED,
100 ZFS_PROP_ORIGIN,
101 ZFS_PROP_QUOTA,
102 ZFS_PROP_RESERVATION,
103 ZFS_PROP_VOLSIZE,
104 ZFS_PROP_VOLBLOCKSIZE,
105 ZFS_PROP_RECORDSIZE,
106 ZFS_PROP_MOUNTPOINT,
107 ZFS_PROP_SHARENFS,
108 ZFS_PROP_CHECKSUM,
109 ZFS_PROP_COMPRESSION,
110 ZFS_PROP_ATIME,
111 ZFS_PROP_DEVICES,
112 ZFS_PROP_EXEC,
113 ZFS_PROP_SETUID,
114 ZFS_PROP_READONLY,
115 ZFS_PROP_ZONED,
116 ZFS_PROP_SNAPDIR,
117 ZFS_PROP_PRIVATE, /* not exposed to user, temporary */
118 ZFS_PROP_ACLINHERIT,
119 ZFS_PROP_CREATETXG,
120 ZFS_PROP_NAME, /* not exposed to the user */
121 ZFS_PROP_CANMOUNT,
122 ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */
123 ZFS_PROP_XATTR,
124 ZFS_PROP_NUMCLONES, /* not exposed to the user */
125 ZFS_PROP_COPIES,
126 ZFS_PROP_VERSION,
127 ZFS_PROP_UTF8ONLY,
128 ZFS_PROP_NORMALIZE,
129 ZFS_PROP_CASE,
130 ZFS_PROP_VSCAN,
131 ZFS_PROP_NBMAND,
132 ZFS_PROP_SHARESMB,
133 ZFS_PROP_REFQUOTA,
134 ZFS_PROP_REFRESERVATION,
135 ZFS_PROP_GUID,
136 ZFS_PROP_PRIMARYCACHE,
137 ZFS_PROP_SECONDARYCACHE,
138 ZFS_PROP_USEDSNAP,
139 ZFS_PROP_USEDDS,
140 ZFS_PROP_USEDCHILD,
141 ZFS_PROP_USEDREFRESERV,
142 ZFS_PROP_USERACCOUNTING, /* not exposed to the user */
143 ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */
144 ZFS_PROP_DEFER_DESTROY,
145 ZFS_PROP_USERREFS,
146 ZFS_PROP_LOGBIAS,
147 ZFS_PROP_UNIQUE, /* not exposed to the user */
148 ZFS_PROP_OBJSETID,
149 ZFS_PROP_DEDUP,
150 ZFS_PROP_MLSLABEL,
151 ZFS_PROP_SYNC,
152 ZFS_PROP_DNODESIZE,
153 ZFS_PROP_REFRATIO,
154 ZFS_PROP_WRITTEN,
155 ZFS_PROP_CLONES,
156 ZFS_PROP_LOGICALUSED,
157 ZFS_PROP_LOGICALREFERENCED,
158 ZFS_PROP_INCONSISTENT, /* not exposed to the user */
159 ZFS_PROP_VOLMODE,
160 ZFS_PROP_FILESYSTEM_LIMIT,
161 ZFS_PROP_SNAPSHOT_LIMIT,
162 ZFS_PROP_FILESYSTEM_COUNT,
163 ZFS_PROP_SNAPSHOT_COUNT,
164 ZFS_PROP_SNAPDEV,
165 ZFS_PROP_ACLTYPE,
166 ZFS_PROP_SELINUX_CONTEXT,
167 ZFS_PROP_SELINUX_FSCONTEXT,
168 ZFS_PROP_SELINUX_DEFCONTEXT,
169 ZFS_PROP_SELINUX_ROOTCONTEXT,
170 ZFS_PROP_RELATIME,
171 ZFS_PROP_REDUNDANT_METADATA,
172 ZFS_PROP_OVERLAY,
173 ZFS_PROP_PREV_SNAP,
174 ZFS_PROP_RECEIVE_RESUME_TOKEN,
175 ZFS_PROP_ENCRYPTION,
176 ZFS_PROP_KEYLOCATION,
177 ZFS_PROP_KEYFORMAT,
178 ZFS_PROP_PBKDF2_SALT,
179 ZFS_PROP_PBKDF2_ITERS,
180 ZFS_PROP_ENCRYPTION_ROOT,
181 ZFS_PROP_KEY_GUID,
182 ZFS_PROP_KEYSTATUS,
183 ZFS_PROP_REMAPTXG, /* not exposed to the user */
184 ZFS_NUM_PROPS
185 } zfs_prop_t;
186
187 typedef enum {
188 ZFS_PROP_USERUSED,
189 ZFS_PROP_USERQUOTA,
190 ZFS_PROP_GROUPUSED,
191 ZFS_PROP_GROUPQUOTA,
192 ZFS_PROP_USEROBJUSED,
193 ZFS_PROP_USEROBJQUOTA,
194 ZFS_PROP_GROUPOBJUSED,
195 ZFS_PROP_GROUPOBJQUOTA,
196 ZFS_PROP_PROJECTUSED,
197 ZFS_PROP_PROJECTQUOTA,
198 ZFS_PROP_PROJECTOBJUSED,
199 ZFS_PROP_PROJECTOBJQUOTA,
200 ZFS_NUM_USERQUOTA_PROPS
201 } zfs_userquota_prop_t;
202
203 extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
204
205 /*
206 * Pool properties are identified by these constants and must be added to the
207 * end of this list to ensure that external consumers are not affected
208 * by the change. If you make any changes to this list, be sure to update
209 * the property table in module/zcommon/zpool_prop.c.
210 */
211 typedef enum {
212 ZPOOL_PROP_INVAL = -1,
213 ZPOOL_PROP_NAME,
214 ZPOOL_PROP_SIZE,
215 ZPOOL_PROP_CAPACITY,
216 ZPOOL_PROP_ALTROOT,
217 ZPOOL_PROP_HEALTH,
218 ZPOOL_PROP_GUID,
219 ZPOOL_PROP_VERSION,
220 ZPOOL_PROP_BOOTFS,
221 ZPOOL_PROP_DELEGATION,
222 ZPOOL_PROP_AUTOREPLACE,
223 ZPOOL_PROP_CACHEFILE,
224 ZPOOL_PROP_FAILUREMODE,
225 ZPOOL_PROP_LISTSNAPS,
226 ZPOOL_PROP_AUTOEXPAND,
227 ZPOOL_PROP_DEDUPDITTO,
228 ZPOOL_PROP_DEDUPRATIO,
229 ZPOOL_PROP_FREE,
230 ZPOOL_PROP_ALLOCATED,
231 ZPOOL_PROP_READONLY,
232 ZPOOL_PROP_ASHIFT,
233 ZPOOL_PROP_COMMENT,
234 ZPOOL_PROP_EXPANDSZ,
235 ZPOOL_PROP_FREEING,
236 ZPOOL_PROP_FRAGMENTATION,
237 ZPOOL_PROP_LEAKED,
238 ZPOOL_PROP_MAXBLOCKSIZE,
239 ZPOOL_PROP_TNAME,
240 ZPOOL_PROP_MAXDNODESIZE,
241 ZPOOL_PROP_MULTIHOST,
242 ZPOOL_PROP_CHECKPOINT,
243 ZPOOL_PROP_LOAD_GUID,
244 ZPOOL_NUM_PROPS
245 } zpool_prop_t;
246
247 /* Small enough to not hog a whole line of printout in zpool(1M). */
248 #define ZPROP_MAX_COMMENT 32
249
250 #define ZPROP_VALUE "value"
251 #define ZPROP_SOURCE "source"
252
253 typedef enum {
254 ZPROP_SRC_NONE = 0x1,
255 ZPROP_SRC_DEFAULT = 0x2,
256 ZPROP_SRC_TEMPORARY = 0x4,
257 ZPROP_SRC_LOCAL = 0x8,
258 ZPROP_SRC_INHERITED = 0x10,
259 ZPROP_SRC_RECEIVED = 0x20
260 } zprop_source_t;
261
262 #define ZPROP_SRC_ALL 0x3f
263
264 #define ZPROP_SOURCE_VAL_RECVD "$recvd"
265 #define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS"
266
267 /*
268 * Dataset flag implemented as a special entry in the props zap object
269 * indicating that the dataset has received properties on or after
270 * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
271 * just as it did in earlier versions, and thereafter, local properties are
272 * preserved.
273 */
274 #define ZPROP_HAS_RECVD "$hasrecvd"
275
276 typedef enum {
277 ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
278 ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
279 } zprop_errflags_t;
280
281 typedef int (*zprop_func)(int, void *);
282
283 /*
284 * Properties to be set on the root file system of a new pool
285 * are stuffed into their own nvlist, which is then included in
286 * the properties nvlist with the pool properties.
287 */
288 #define ZPOOL_ROOTFS_PROPS "root-props-nvl"
289
290 /*
291 * Length of 'written@' and 'written#'
292 */
293 #define ZFS_WRITTEN_PROP_PREFIX_LEN 8
294
295 /*
296 * Dataset property functions shared between libzfs and kernel.
297 */
298 const char *zfs_prop_default_string(zfs_prop_t);
299 uint64_t zfs_prop_default_numeric(zfs_prop_t);
300 boolean_t zfs_prop_readonly(zfs_prop_t);
301 boolean_t zfs_prop_visible(zfs_prop_t prop);
302 boolean_t zfs_prop_inheritable(zfs_prop_t);
303 boolean_t zfs_prop_setonce(zfs_prop_t);
304 boolean_t zfs_prop_encryption_key_param(zfs_prop_t);
305 boolean_t zfs_prop_valid_keylocation(const char *, boolean_t);
306 const char *zfs_prop_to_name(zfs_prop_t);
307 zfs_prop_t zfs_name_to_prop(const char *);
308 boolean_t zfs_prop_user(const char *);
309 boolean_t zfs_prop_userquota(const char *);
310 boolean_t zfs_prop_written(const char *);
311 int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
312 int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
313 uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
314 boolean_t zfs_prop_valid_for_type(int, zfs_type_t, boolean_t);
315
316 /*
317 * Pool property functions shared between libzfs and kernel.
318 */
319 zpool_prop_t zpool_name_to_prop(const char *);
320 const char *zpool_prop_to_name(zpool_prop_t);
321 const char *zpool_prop_default_string(zpool_prop_t);
322 uint64_t zpool_prop_default_numeric(zpool_prop_t);
323 boolean_t zpool_prop_readonly(zpool_prop_t);
324 boolean_t zpool_prop_setonce(zpool_prop_t);
325 boolean_t zpool_prop_feature(const char *);
326 boolean_t zpool_prop_unsupported(const char *);
327 int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
328 int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
329 uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
330
331 /*
332 * Definitions for the Delegation.
333 */
334 typedef enum {
335 ZFS_DELEG_WHO_UNKNOWN = 0,
336 ZFS_DELEG_USER = 'u',
337 ZFS_DELEG_USER_SETS = 'U',
338 ZFS_DELEG_GROUP = 'g',
339 ZFS_DELEG_GROUP_SETS = 'G',
340 ZFS_DELEG_EVERYONE = 'e',
341 ZFS_DELEG_EVERYONE_SETS = 'E',
342 ZFS_DELEG_CREATE = 'c',
343 ZFS_DELEG_CREATE_SETS = 'C',
344 ZFS_DELEG_NAMED_SET = 's',
345 ZFS_DELEG_NAMED_SET_SETS = 'S'
346 } zfs_deleg_who_type_t;
347
348 typedef enum {
349 ZFS_DELEG_NONE = 0,
350 ZFS_DELEG_PERM_LOCAL = 1,
351 ZFS_DELEG_PERM_DESCENDENT = 2,
352 ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
353 ZFS_DELEG_PERM_CREATE = 4
354 } zfs_deleg_inherit_t;
355
356 #define ZFS_DELEG_PERM_UID "uid"
357 #define ZFS_DELEG_PERM_GID "gid"
358 #define ZFS_DELEG_PERM_GROUPS "groups"
359
360 #define ZFS_MLSLABEL_DEFAULT "none"
361
362 #define ZFS_SMB_ACL_SRC "src"
363 #define ZFS_SMB_ACL_TARGET "target"
364
365 typedef enum {
366 ZFS_CANMOUNT_OFF = 0,
367 ZFS_CANMOUNT_ON = 1,
368 ZFS_CANMOUNT_NOAUTO = 2
369 } zfs_canmount_type_t;
370
371 typedef enum {
372 ZFS_LOGBIAS_LATENCY = 0,
373 ZFS_LOGBIAS_THROUGHPUT = 1
374 } zfs_logbias_op_t;
375
376 typedef enum zfs_share_op {
377 ZFS_SHARE_NFS = 0,
378 ZFS_UNSHARE_NFS = 1,
379 ZFS_SHARE_SMB = 2,
380 ZFS_UNSHARE_SMB = 3
381 } zfs_share_op_t;
382
383 typedef enum zfs_smb_acl_op {
384 ZFS_SMB_ACL_ADD,
385 ZFS_SMB_ACL_REMOVE,
386 ZFS_SMB_ACL_RENAME,
387 ZFS_SMB_ACL_PURGE
388 } zfs_smb_acl_op_t;
389
390 typedef enum zfs_cache_type {
391 ZFS_CACHE_NONE = 0,
392 ZFS_CACHE_METADATA = 1,
393 ZFS_CACHE_ALL = 2
394 } zfs_cache_type_t;
395
396 typedef enum {
397 ZFS_SYNC_STANDARD = 0,
398 ZFS_SYNC_ALWAYS = 1,
399 ZFS_SYNC_DISABLED = 2
400 } zfs_sync_type_t;
401
402 typedef enum {
403 ZFS_XATTR_OFF = 0,
404 ZFS_XATTR_DIR = 1,
405 ZFS_XATTR_SA = 2
406 } zfs_xattr_type_t;
407
408 typedef enum {
409 ZFS_DNSIZE_LEGACY = 0,
410 ZFS_DNSIZE_AUTO = 1,
411 ZFS_DNSIZE_1K = 1024,
412 ZFS_DNSIZE_2K = 2048,
413 ZFS_DNSIZE_4K = 4096,
414 ZFS_DNSIZE_8K = 8192,
415 ZFS_DNSIZE_16K = 16384
416 } zfs_dnsize_type_t;
417
418 typedef enum {
419 ZFS_REDUNDANT_METADATA_ALL,
420 ZFS_REDUNDANT_METADATA_MOST
421 } zfs_redundant_metadata_type_t;
422
423 typedef enum {
424 ZFS_VOLMODE_DEFAULT = 0,
425 ZFS_VOLMODE_GEOM = 1,
426 ZFS_VOLMODE_DEV = 2,
427 ZFS_VOLMODE_NONE = 3
428 } zfs_volmode_t;
429
430 typedef enum zfs_keystatus {
431 ZFS_KEYSTATUS_NONE = 0,
432 ZFS_KEYSTATUS_UNAVAILABLE,
433 ZFS_KEYSTATUS_AVAILABLE,
434 } zfs_keystatus_t;
435
436 typedef enum zfs_keyformat {
437 ZFS_KEYFORMAT_NONE = 0,
438 ZFS_KEYFORMAT_RAW,
439 ZFS_KEYFORMAT_HEX,
440 ZFS_KEYFORMAT_PASSPHRASE,
441 ZFS_KEYFORMAT_FORMATS
442 } zfs_keyformat_t;
443
444 typedef enum zfs_key_location {
445 ZFS_KEYLOCATION_NONE = 0,
446 ZFS_KEYLOCATION_PROMPT,
447 ZFS_KEYLOCATION_URI,
448 ZFS_KEYLOCATION_LOCATIONS
449 } zfs_keylocation_t;
450
451 #define DEFAULT_PBKDF2_ITERATIONS 350000
452 #define MIN_PBKDF2_ITERATIONS 100000
453
454 /*
455 * On-disk version number.
456 */
457 #define SPA_VERSION_1 1ULL
458 #define SPA_VERSION_2 2ULL
459 #define SPA_VERSION_3 3ULL
460 #define SPA_VERSION_4 4ULL
461 #define SPA_VERSION_5 5ULL
462 #define SPA_VERSION_6 6ULL
463 #define SPA_VERSION_7 7ULL
464 #define SPA_VERSION_8 8ULL
465 #define SPA_VERSION_9 9ULL
466 #define SPA_VERSION_10 10ULL
467 #define SPA_VERSION_11 11ULL
468 #define SPA_VERSION_12 12ULL
469 #define SPA_VERSION_13 13ULL
470 #define SPA_VERSION_14 14ULL
471 #define SPA_VERSION_15 15ULL
472 #define SPA_VERSION_16 16ULL
473 #define SPA_VERSION_17 17ULL
474 #define SPA_VERSION_18 18ULL
475 #define SPA_VERSION_19 19ULL
476 #define SPA_VERSION_20 20ULL
477 #define SPA_VERSION_21 21ULL
478 #define SPA_VERSION_22 22ULL
479 #define SPA_VERSION_23 23ULL
480 #define SPA_VERSION_24 24ULL
481 #define SPA_VERSION_25 25ULL
482 #define SPA_VERSION_26 26ULL
483 #define SPA_VERSION_27 27ULL
484 #define SPA_VERSION_28 28ULL
485 #define SPA_VERSION_5000 5000ULL
486
487 /*
488 * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
489 * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
490 * and do the appropriate changes. Also bump the version number in
491 * usr/src/grub/capability.
492 */
493 #define SPA_VERSION SPA_VERSION_5000
494 #define SPA_VERSION_STRING "5000"
495
496 /*
497 * Symbolic names for the changes that caused a SPA_VERSION switch.
498 * Used in the code when checking for presence or absence of a feature.
499 * Feel free to define multiple symbolic names for each version if there
500 * were multiple changes to on-disk structures during that version.
501 *
502 * NOTE: When checking the current SPA_VERSION in your code, be sure
503 * to use spa_version() since it reports the version of the
504 * last synced uberblock. Checking the in-flight version can
505 * be dangerous in some cases.
506 */
507 #define SPA_VERSION_INITIAL SPA_VERSION_1
508 #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2
509 #define SPA_VERSION_SPARES SPA_VERSION_3
510 #define SPA_VERSION_RAIDZ2 SPA_VERSION_3
511 #define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3
512 #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3
513 #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3
514 #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4
515 #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5
516 #define SPA_VERSION_BOOTFS SPA_VERSION_6
517 #define SPA_VERSION_SLOGS SPA_VERSION_7
518 #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8
519 #define SPA_VERSION_FUID SPA_VERSION_9
520 #define SPA_VERSION_REFRESERVATION SPA_VERSION_9
521 #define SPA_VERSION_REFQUOTA SPA_VERSION_9
522 #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9
523 #define SPA_VERSION_L2CACHE SPA_VERSION_10
524 #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11
525 #define SPA_VERSION_ORIGIN SPA_VERSION_11
526 #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11
527 #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12
528 #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13
529 #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14
530 #define SPA_VERSION_USERSPACE SPA_VERSION_15
531 #define SPA_VERSION_STMF_PROP SPA_VERSION_16
532 #define SPA_VERSION_RAIDZ3 SPA_VERSION_17
533 #define SPA_VERSION_USERREFS SPA_VERSION_18
534 #define SPA_VERSION_HOLES SPA_VERSION_19
535 #define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20
536 #define SPA_VERSION_DEDUP SPA_VERSION_21
537 #define SPA_VERSION_RECVD_PROPS SPA_VERSION_22
538 #define SPA_VERSION_SLIM_ZIL SPA_VERSION_23
539 #define SPA_VERSION_SA SPA_VERSION_24
540 #define SPA_VERSION_SCAN SPA_VERSION_25
541 #define SPA_VERSION_DIR_CLONES SPA_VERSION_26
542 #define SPA_VERSION_DEADLISTS SPA_VERSION_26
543 #define SPA_VERSION_FAST_SNAP SPA_VERSION_27
544 #define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28
545 #define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28
546 #define SPA_VERSION_FEATURES SPA_VERSION_5000
547
548 #define SPA_VERSION_IS_SUPPORTED(v) \
549 (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
550 ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
551
552 /*
553 * ZPL version - rev'd whenever an incompatible on-disk format change
554 * occurs. This is independent of SPA/DMU/ZAP versioning. You must
555 * also update the version_table[] and help message in zfs_prop.c.
556 *
557 * When changing, be sure to teach GRUB how to read the new format!
558 * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
559 */
560 #define ZPL_VERSION_1 1ULL
561 #define ZPL_VERSION_2 2ULL
562 #define ZPL_VERSION_3 3ULL
563 #define ZPL_VERSION_4 4ULL
564 #define ZPL_VERSION_5 5ULL
565 #define ZPL_VERSION ZPL_VERSION_5
566 #define ZPL_VERSION_STRING "5"
567
568 #define ZPL_VERSION_INITIAL ZPL_VERSION_1
569 #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2
570 #define ZPL_VERSION_FUID ZPL_VERSION_3
571 #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3
572 #define ZPL_VERSION_SYSATTR ZPL_VERSION_3
573 #define ZPL_VERSION_USERSPACE ZPL_VERSION_4
574 #define ZPL_VERSION_SA ZPL_VERSION_5
575
576 /* Rewind policy information */
577 #define ZPOOL_NO_REWIND 1 /* No policy - default behavior */
578 #define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */
579 #define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */
580 #define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */
581 #define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */
582 #define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */
583 #define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */
584
585 typedef struct zpool_load_policy {
586 uint32_t zlp_rewind; /* rewind policy requested */
587 uint64_t zlp_maxmeta; /* max acceptable meta-data errors */
588 uint64_t zlp_maxdata; /* max acceptable data errors */
589 uint64_t zlp_txg; /* specific txg to load */
590 } zpool_load_policy_t;
591
592 /*
593 * The following are configuration names used in the nvlist describing a pool's
594 * configuration. New on-disk names should be prefixed with "<reverse-DNS>:"
595 * (e.g. "org.open-zfs:") to avoid conflicting names being developed
596 * independently.
597 */
598 #define ZPOOL_CONFIG_VERSION "version"
599 #define ZPOOL_CONFIG_POOL_NAME "name"
600 #define ZPOOL_CONFIG_POOL_STATE "state"
601 #define ZPOOL_CONFIG_POOL_TXG "txg"
602 #define ZPOOL_CONFIG_POOL_GUID "pool_guid"
603 #define ZPOOL_CONFIG_CREATE_TXG "create_txg"
604 #define ZPOOL_CONFIG_TOP_GUID "top_guid"
605 #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
606 #define ZPOOL_CONFIG_TYPE "type"
607 #define ZPOOL_CONFIG_CHILDREN "children"
608 #define ZPOOL_CONFIG_ID "id"
609 #define ZPOOL_CONFIG_GUID "guid"
610 #define ZPOOL_CONFIG_INDIRECT_OBJECT "com.delphix:indirect_object"
611 #define ZPOOL_CONFIG_INDIRECT_BIRTHS "com.delphix:indirect_births"
612 #define ZPOOL_CONFIG_PREV_INDIRECT_VDEV "com.delphix:prev_indirect_vdev"
613 #define ZPOOL_CONFIG_PATH "path"
614 #define ZPOOL_CONFIG_DEVID "devid"
615 #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array"
616 #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift"
617 #define ZPOOL_CONFIG_ASHIFT "ashift"
618 #define ZPOOL_CONFIG_ASIZE "asize"
619 #define ZPOOL_CONFIG_DTL "DTL"
620 #define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */
621 #define ZPOOL_CONFIG_REMOVAL_STATS "removal_stats" /* not stored on disk */
622 #define ZPOOL_CONFIG_CHECKPOINT_STATS "checkpoint_stats" /* not on disk */
623 #define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */
624 #define ZPOOL_CONFIG_INDIRECT_SIZE "indirect_size" /* not stored on disk */
625
626 /* container nvlist of extended stats */
627 #define ZPOOL_CONFIG_VDEV_STATS_EX "vdev_stats_ex"
628
629 /* Active queue read/write stats */
630 #define ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE "vdev_sync_r_active_queue"
631 #define ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE "vdev_sync_w_active_queue"
632 #define ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE "vdev_async_r_active_queue"
633 #define ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE "vdev_async_w_active_queue"
634 #define ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE "vdev_async_scrub_active_queue"
635
636 /* Queue sizes */
637 #define ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE "vdev_sync_r_pend_queue"
638 #define ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE "vdev_sync_w_pend_queue"
639 #define ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE "vdev_async_r_pend_queue"
640 #define ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE "vdev_async_w_pend_queue"
641 #define ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE "vdev_async_scrub_pend_queue"
642
643 /* Latency read/write histogram stats */
644 #define ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO "vdev_tot_r_lat_histo"
645 #define ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO "vdev_tot_w_lat_histo"
646 #define ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO "vdev_disk_r_lat_histo"
647 #define ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO "vdev_disk_w_lat_histo"
648 #define ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO "vdev_sync_r_lat_histo"
649 #define ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO "vdev_sync_w_lat_histo"
650 #define ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO "vdev_async_r_lat_histo"
651 #define ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO "vdev_async_w_lat_histo"
652 #define ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO "vdev_scrub_histo"
653
654 /* Request size histograms */
655 #define ZPOOL_CONFIG_VDEV_SYNC_IND_R_HISTO "vdev_sync_ind_r_histo"
656 #define ZPOOL_CONFIG_VDEV_SYNC_IND_W_HISTO "vdev_sync_ind_w_histo"
657 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_R_HISTO "vdev_async_ind_r_histo"
658 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_W_HISTO "vdev_async_ind_w_histo"
659 #define ZPOOL_CONFIG_VDEV_IND_SCRUB_HISTO "vdev_ind_scrub_histo"
660 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_R_HISTO "vdev_sync_agg_r_histo"
661 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_W_HISTO "vdev_sync_agg_w_histo"
662 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_R_HISTO "vdev_async_agg_r_histo"
663 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO "vdev_async_agg_w_histo"
664 #define ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO "vdev_agg_scrub_histo"
665
666 /* vdev enclosure sysfs path */
667 #define ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH "vdev_enc_sysfs_path"
668
669 #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
670 #define ZPOOL_CONFIG_ERRCOUNT "error_count"
671 #define ZPOOL_CONFIG_NOT_PRESENT "not_present"
672 #define ZPOOL_CONFIG_SPARES "spares"
673 #define ZPOOL_CONFIG_IS_SPARE "is_spare"
674 #define ZPOOL_CONFIG_NPARITY "nparity"
675 #define ZPOOL_CONFIG_HOSTID "hostid"
676 #define ZPOOL_CONFIG_HOSTNAME "hostname"
677 #define ZPOOL_CONFIG_LOADED_TIME "initial_load_time"
678 #define ZPOOL_CONFIG_UNSPARE "unspare"
679 #define ZPOOL_CONFIG_PHYS_PATH "phys_path"
680 #define ZPOOL_CONFIG_IS_LOG "is_log"
681 #define ZPOOL_CONFIG_L2CACHE "l2cache"
682 #define ZPOOL_CONFIG_HOLE_ARRAY "hole_array"
683 #define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
684 #define ZPOOL_CONFIG_IS_HOLE "is_hole"
685 #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
686 #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
687 #define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
688 #define ZPOOL_CONFIG_SPLIT "splitcfg"
689 #define ZPOOL_CONFIG_ORIG_GUID "orig_guid"
690 #define ZPOOL_CONFIG_SPLIT_GUID "split_guid"
691 #define ZPOOL_CONFIG_SPLIT_LIST "guid_list"
692 #define ZPOOL_CONFIG_REMOVING "removing"
693 #define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg"
694 #define ZPOOL_CONFIG_COMMENT "comment"
695 #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */
696 #define ZPOOL_CONFIG_SUSPENDED_REASON "suspended_reason" /* not stored */
697 #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */
698 #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */
699 #define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */
700 #define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */
701 #define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */
702 #define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */
703 #define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */
704 #define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */
705 #define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read"
706 #define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */
707 #define ZPOOL_CONFIG_ERRATA "errata" /* not stored on disk */
708 #define ZPOOL_CONFIG_VDEV_TOP_ZAP "com.delphix:vdev_zap_top"
709 #define ZPOOL_CONFIG_VDEV_LEAF_ZAP "com.delphix:vdev_zap_leaf"
710 #define ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS "com.delphix:has_per_vdev_zaps"
711 #define ZPOOL_CONFIG_CACHEFILE "cachefile" /* not stored on disk */
712 #define ZPOOL_CONFIG_MMP_STATE "mmp_state" /* not stored on disk */
713 #define ZPOOL_CONFIG_MMP_TXG "mmp_txg" /* not stored on disk */
714 #define ZPOOL_CONFIG_MMP_HOSTNAME "mmp_hostname" /* not stored on disk */
715 #define ZPOOL_CONFIG_MMP_HOSTID "mmp_hostid" /* not stored on disk */
716
717 /*
718 * The persistent vdev state is stored as separate values rather than a single
719 * 'vdev_state' entry. This is because a device can be in multiple states, such
720 * as offline and degraded.
721 */
722 #define ZPOOL_CONFIG_OFFLINE "offline"
723 #define ZPOOL_CONFIG_FAULTED "faulted"
724 #define ZPOOL_CONFIG_DEGRADED "degraded"
725 #define ZPOOL_CONFIG_REMOVED "removed"
726 #define ZPOOL_CONFIG_FRU "fru"
727 #define ZPOOL_CONFIG_AUX_STATE "aux_state"
728
729 /* Pool load policy parameters */
730 #define ZPOOL_LOAD_POLICY "load-policy"
731 #define ZPOOL_LOAD_REWIND_POLICY "load-rewind-policy"
732 #define ZPOOL_LOAD_REQUEST_TXG "load-request-txg"
733 #define ZPOOL_LOAD_META_THRESH "load-meta-thresh"
734 #define ZPOOL_LOAD_DATA_THRESH "load-data-thresh"
735
736 /* Rewind data discovered */
737 #define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts"
738 #define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors"
739 #define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind"
740
741 #define VDEV_TYPE_ROOT "root"
742 #define VDEV_TYPE_MIRROR "mirror"
743 #define VDEV_TYPE_REPLACING "replacing"
744 #define VDEV_TYPE_RAIDZ "raidz"
745 #define VDEV_TYPE_DISK "disk"
746 #define VDEV_TYPE_FILE "file"
747 #define VDEV_TYPE_MISSING "missing"
748 #define VDEV_TYPE_HOLE "hole"
749 #define VDEV_TYPE_SPARE "spare"
750 #define VDEV_TYPE_LOG "log"
751 #define VDEV_TYPE_L2CACHE "l2cache"
752 #define VDEV_TYPE_INDIRECT "indirect"
753
754 /* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */
755 #define VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \
756 "com.delphix:indirect_obsolete_sm"
757 #define VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \
758 "com.delphix:obsolete_counts_are_precise"
759 #define VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \
760 "com.delphix:pool_checkpoint_sm"
761
762 /*
763 * This is needed in userland to report the minimum necessary device size.
764 */
765 #define SPA_MINDEVSIZE (64ULL << 20)
766
767 /*
768 * Set if the fragmentation has not yet been calculated. This can happen
769 * because the space maps have not been upgraded or the histogram feature
770 * is not enabled.
771 */
772 #define ZFS_FRAG_INVALID UINT64_MAX
773
774 /*
775 * The location of the pool configuration repository, shared between kernel and
776 * userland.
777 */
778 #define ZPOOL_CACHE "/etc/zfs/zpool.cache"
779
780 /*
781 * vdev states are ordered from least to most healthy.
782 * A vdev that's CANT_OPEN or below is considered unusable.
783 */
784 typedef enum vdev_state {
785 VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */
786 VDEV_STATE_CLOSED, /* Not currently open */
787 VDEV_STATE_OFFLINE, /* Not allowed to open */
788 VDEV_STATE_REMOVED, /* Explicitly removed from system */
789 VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */
790 VDEV_STATE_FAULTED, /* External request to fault device */
791 VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */
792 VDEV_STATE_HEALTHY /* Presumed good */
793 } vdev_state_t;
794
795 #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY
796
797 /*
798 * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field
799 * of the vdev stats structure uses these constants to distinguish why.
800 */
801 typedef enum vdev_aux {
802 VDEV_AUX_NONE, /* no error */
803 VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */
804 VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */
805 VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */
806 VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */
807 VDEV_AUX_TOO_SMALL, /* vdev size is too small */
808 VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */
809 VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */
810 VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */
811 VDEV_AUX_UNSUP_FEAT, /* unsupported features */
812 VDEV_AUX_SPARED, /* hot spare used in another pool */
813 VDEV_AUX_ERR_EXCEEDED, /* too many errors */
814 VDEV_AUX_IO_FAILURE, /* experienced I/O failure */
815 VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */
816 VDEV_AUX_EXTERNAL, /* external diagnosis or forced fault */
817 VDEV_AUX_SPLIT_POOL, /* vdev was split off into another pool */
818 VDEV_AUX_BAD_ASHIFT, /* vdev ashift is invalid */
819 VDEV_AUX_EXTERNAL_PERSIST, /* persistent forced fault */
820 VDEV_AUX_ACTIVE, /* vdev active on a different host */
821 VDEV_AUX_CHILDREN_OFFLINE, /* all children are offline */
822 } vdev_aux_t;
823
824 /*
825 * pool state. The following states are written to disk as part of the normal
826 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
827 * states are software abstractions used at various levels to communicate
828 * pool state.
829 */
830 typedef enum pool_state {
831 POOL_STATE_ACTIVE = 0, /* In active use */
832 POOL_STATE_EXPORTED, /* Explicitly exported */
833 POOL_STATE_DESTROYED, /* Explicitly destroyed */
834 POOL_STATE_SPARE, /* Reserved for hot spare use */
835 POOL_STATE_L2CACHE, /* Level 2 ARC device */
836 POOL_STATE_UNINITIALIZED, /* Internal spa_t state */
837 POOL_STATE_UNAVAIL, /* Internal libzfs state */
838 POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */
839 } pool_state_t;
840
841 /*
842 * mmp state. The following states provide additional detail describing
843 * why a pool couldn't be safely imported.
844 */
845 typedef enum mmp_state {
846 MMP_STATE_ACTIVE = 0, /* In active use */
847 MMP_STATE_INACTIVE, /* Inactive and safe to import */
848 MMP_STATE_NO_HOSTID /* System hostid is not set */
849 } mmp_state_t;
850
851 /*
852 * Scan Functions.
853 */
854 typedef enum pool_scan_func {
855 POOL_SCAN_NONE,
856 POOL_SCAN_SCRUB,
857 POOL_SCAN_RESILVER,
858 POOL_SCAN_FUNCS
859 } pool_scan_func_t;
860
861 /*
862 * Used to control scrub pause and resume.
863 */
864 typedef enum pool_scrub_cmd {
865 POOL_SCRUB_NORMAL = 0,
866 POOL_SCRUB_PAUSE,
867 POOL_SCRUB_FLAGS_END
868 } pool_scrub_cmd_t;
869
870 typedef enum {
871 CS_NONE,
872 CS_CHECKPOINT_EXISTS,
873 CS_CHECKPOINT_DISCARDING,
874 CS_NUM_STATES
875 } checkpoint_state_t;
876
877 typedef struct pool_checkpoint_stat {
878 uint64_t pcs_state; /* checkpoint_state_t */
879 uint64_t pcs_start_time; /* time checkpoint/discard started */
880 uint64_t pcs_space; /* checkpointed space */
881 } pool_checkpoint_stat_t;
882
883 /*
884 * ZIO types. Needed to interpret vdev statistics below.
885 */
886 typedef enum zio_type {
887 ZIO_TYPE_NULL = 0,
888 ZIO_TYPE_READ,
889 ZIO_TYPE_WRITE,
890 ZIO_TYPE_FREE,
891 ZIO_TYPE_CLAIM,
892 ZIO_TYPE_IOCTL,
893 ZIO_TYPES
894 } zio_type_t;
895
896 /*
897 * Pool statistics. Note: all fields should be 64-bit because this
898 * is passed between kernel and userland as an nvlist uint64 array.
899 */
900 typedef struct pool_scan_stat {
901 /* values stored on disk */
902 uint64_t pss_func; /* pool_scan_func_t */
903 uint64_t pss_state; /* dsl_scan_state_t */
904 uint64_t pss_start_time; /* scan start time */
905 uint64_t pss_end_time; /* scan end time */
906 uint64_t pss_to_examine; /* total bytes to scan */
907 uint64_t pss_examined; /* total bytes located by scanner */
908 uint64_t pss_to_process; /* total bytes to process */
909 uint64_t pss_processed; /* total processed bytes */
910 uint64_t pss_errors; /* scan errors */
911
912 /* values not stored on disk */
913 uint64_t pss_pass_exam; /* examined bytes per scan pass */
914 uint64_t pss_pass_start; /* start time of a scan pass */
915 uint64_t pss_pass_scrub_pause; /* pause time of a scurb pass */
916 /* cumulative time scrub spent paused, needed for rate calculation */
917 uint64_t pss_pass_scrub_spent_paused;
918 uint64_t pss_pass_issued; /* issued bytes per scan pass */
919 uint64_t pss_issued; /* total bytes checked by scanner */
920 } pool_scan_stat_t;
921
922 typedef struct pool_removal_stat {
923 uint64_t prs_state; /* dsl_scan_state_t */
924 uint64_t prs_removing_vdev;
925 uint64_t prs_start_time;
926 uint64_t prs_end_time;
927 uint64_t prs_to_copy; /* bytes that need to be copied */
928 uint64_t prs_copied; /* bytes copied so far */
929 /*
930 * bytes of memory used for indirect mappings.
931 * This includes all removed vdevs.
932 */
933 uint64_t prs_mapping_memory;
934 } pool_removal_stat_t;
935
936 typedef enum dsl_scan_state {
937 DSS_NONE,
938 DSS_SCANNING,
939 DSS_FINISHED,
940 DSS_CANCELED,
941 DSS_NUM_STATES
942 } dsl_scan_state_t;
943
944 /*
945 * Errata described by http://zfsonlinux.org/msg/ZFS-8000-ER. The ordering
946 * of this enum must be maintained to ensure the errata identifiers map to
947 * the correct documentation. New errata may only be appended to the list
948 * and must contain corresponding documentation at the above link.
949 */
950 typedef enum zpool_errata {
951 ZPOOL_ERRATA_NONE,
952 ZPOOL_ERRATA_ZOL_2094_SCRUB,
953 ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY,
954 ZPOOL_ERRATA_ZOL_6845_ENCRYPTION,
955 } zpool_errata_t;
956
957 /*
958 * Vdev statistics. Note: all fields should be 64-bit because this
959 * is passed between kernel and userland as an nvlist uint64 array.
960 */
961 typedef struct vdev_stat {
962 hrtime_t vs_timestamp; /* time since vdev load */
963 uint64_t vs_state; /* vdev state */
964 uint64_t vs_aux; /* see vdev_aux_t */
965 uint64_t vs_alloc; /* space allocated */
966 uint64_t vs_space; /* total capacity */
967 uint64_t vs_dspace; /* deflated capacity */
968 uint64_t vs_rsize; /* replaceable dev size */
969 uint64_t vs_esize; /* expandable dev size */
970 uint64_t vs_ops[ZIO_TYPES]; /* operation count */
971 uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */
972 uint64_t vs_read_errors; /* read errors */
973 uint64_t vs_write_errors; /* write errors */
974 uint64_t vs_checksum_errors; /* checksum errors */
975 uint64_t vs_self_healed; /* self-healed bytes */
976 uint64_t vs_scan_removing; /* removing? */
977 uint64_t vs_scan_processed; /* scan processed bytes */
978 uint64_t vs_fragmentation; /* device fragmentation */
979 uint64_t vs_checkpoint_space; /* checkpoint-consumed space */
980 } vdev_stat_t;
981
982 /*
983 * Extended stats
984 *
985 * These are stats which aren't included in the original iostat output. For
986 * convenience, they are grouped together in vdev_stat_ex, although each stat
987 * is individually exported as an nvlist.
988 */
989 typedef struct vdev_stat_ex {
990 /* Number of ZIOs issued to disk and waiting to finish */
991 uint64_t vsx_active_queue[ZIO_PRIORITY_NUM_QUEUEABLE];
992
993 /* Number of ZIOs pending to be issued to disk */
994 uint64_t vsx_pend_queue[ZIO_PRIORITY_NUM_QUEUEABLE];
995
996 /*
997 * Below are the histograms for various latencies. Buckets are in
998 * units of nanoseconds.
999 */
1000
1001 /*
1002 * 2^37 nanoseconds = 134s. Timeouts will probably start kicking in
1003 * before this.
1004 */
1005 #define VDEV_L_HISTO_BUCKETS 37 /* Latency histo buckets */
1006 #define VDEV_RQ_HISTO_BUCKETS 25 /* Request size histo buckets */
1007
1008
1009 /* Amount of time in ZIO queue (ns) */
1010 uint64_t vsx_queue_histo[ZIO_PRIORITY_NUM_QUEUEABLE]
1011 [VDEV_L_HISTO_BUCKETS];
1012
1013 /* Total ZIO latency (ns). Includes queuing and disk access time */
1014 uint64_t vsx_total_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS];
1015
1016 /* Amount of time to read/write the disk (ns) */
1017 uint64_t vsx_disk_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS];
1018
1019 /* "lookup the bucket for a value" histogram macros */
1020 #define HISTO(val, buckets) (val != 0 ? MIN(highbit64(val) - 1, \
1021 buckets - 1) : 0)
1022 #define L_HISTO(a) HISTO(a, VDEV_L_HISTO_BUCKETS)
1023 #define RQ_HISTO(a) HISTO(a, VDEV_RQ_HISTO_BUCKETS)
1024
1025 /* Physical IO histogram */
1026 uint64_t vsx_ind_histo[ZIO_PRIORITY_NUM_QUEUEABLE]
1027 [VDEV_RQ_HISTO_BUCKETS];
1028
1029 /* Delegated (aggregated) physical IO histogram */
1030 uint64_t vsx_agg_histo[ZIO_PRIORITY_NUM_QUEUEABLE]
1031 [VDEV_RQ_HISTO_BUCKETS];
1032
1033 } vdev_stat_ex_t;
1034
1035 /*
1036 * DDT statistics. Note: all fields should be 64-bit because this
1037 * is passed between kernel and userland as an nvlist uint64 array.
1038 */
1039 typedef struct ddt_object {
1040 uint64_t ddo_count; /* number of elements in ddt */
1041 uint64_t ddo_dspace; /* size of ddt on disk */
1042 uint64_t ddo_mspace; /* size of ddt in-core */
1043 } ddt_object_t;
1044
1045 typedef struct ddt_stat {
1046 uint64_t dds_blocks; /* blocks */
1047 uint64_t dds_lsize; /* logical size */
1048 uint64_t dds_psize; /* physical size */
1049 uint64_t dds_dsize; /* deflated allocated size */
1050 uint64_t dds_ref_blocks; /* referenced blocks */
1051 uint64_t dds_ref_lsize; /* referenced lsize * refcnt */
1052 uint64_t dds_ref_psize; /* referenced psize * refcnt */
1053 uint64_t dds_ref_dsize; /* referenced dsize * refcnt */
1054 } ddt_stat_t;
1055
1056 typedef struct ddt_histogram {
1057 ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */
1058 } ddt_histogram_t;
1059
1060 #define ZVOL_DRIVER "zvol"
1061 #define ZFS_DRIVER "zfs"
1062 #define ZFS_DEV "/dev/zfs"
1063 #define ZFS_SHARETAB "/etc/dfs/sharetab"
1064
1065 #define ZFS_SUPER_MAGIC 0x2fc12fc1
1066
1067 /* general zvol path */
1068 #define ZVOL_DIR "/dev"
1069
1070 #define ZVOL_MAJOR 230
1071 #define ZVOL_MINOR_BITS 4
1072 #define ZVOL_MINOR_MASK ((1U << ZVOL_MINOR_BITS) - 1)
1073 #define ZVOL_MINORS (1 << 4)
1074 #define ZVOL_DEV_NAME "zd"
1075
1076 #define ZVOL_PROP_NAME "name"
1077 #define ZVOL_DEFAULT_BLOCKSIZE 8192
1078
1079 /*
1080 * /dev/zfs ioctl numbers.
1081 */
1082 typedef enum zfs_ioc {
1083 /*
1084 * Illumos - 71/128 numbers reserved.
1085 */
1086 ZFS_IOC_FIRST = ('Z' << 8),
1087 ZFS_IOC = ZFS_IOC_FIRST,
1088 ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,
1089 ZFS_IOC_POOL_DESTROY,
1090 ZFS_IOC_POOL_IMPORT,
1091 ZFS_IOC_POOL_EXPORT,
1092 ZFS_IOC_POOL_CONFIGS,
1093 ZFS_IOC_POOL_STATS,
1094 ZFS_IOC_POOL_TRYIMPORT,
1095 ZFS_IOC_POOL_SCAN,
1096 ZFS_IOC_POOL_FREEZE,
1097 ZFS_IOC_POOL_UPGRADE,
1098 ZFS_IOC_POOL_GET_HISTORY,
1099 ZFS_IOC_VDEV_ADD,
1100 ZFS_IOC_VDEV_REMOVE,
1101 ZFS_IOC_VDEV_SET_STATE,
1102 ZFS_IOC_VDEV_ATTACH,
1103 ZFS_IOC_VDEV_DETACH,
1104 ZFS_IOC_VDEV_SETPATH,
1105 ZFS_IOC_VDEV_SETFRU,
1106 ZFS_IOC_OBJSET_STATS,
1107 ZFS_IOC_OBJSET_ZPLPROPS,
1108 ZFS_IOC_DATASET_LIST_NEXT,
1109 ZFS_IOC_SNAPSHOT_LIST_NEXT,
1110 ZFS_IOC_SET_PROP,
1111 ZFS_IOC_CREATE,
1112 ZFS_IOC_DESTROY,
1113 ZFS_IOC_ROLLBACK,
1114 ZFS_IOC_RENAME,
1115 ZFS_IOC_RECV,
1116 ZFS_IOC_SEND,
1117 ZFS_IOC_INJECT_FAULT,
1118 ZFS_IOC_CLEAR_FAULT,
1119 ZFS_IOC_INJECT_LIST_NEXT,
1120 ZFS_IOC_ERROR_LOG,
1121 ZFS_IOC_CLEAR,
1122 ZFS_IOC_PROMOTE,
1123 ZFS_IOC_SNAPSHOT,
1124 ZFS_IOC_DSOBJ_TO_DSNAME,
1125 ZFS_IOC_OBJ_TO_PATH,
1126 ZFS_IOC_POOL_SET_PROPS,
1127 ZFS_IOC_POOL_GET_PROPS,
1128 ZFS_IOC_SET_FSACL,
1129 ZFS_IOC_GET_FSACL,
1130 ZFS_IOC_SHARE,
1131 ZFS_IOC_INHERIT_PROP,
1132 ZFS_IOC_SMB_ACL,
1133 ZFS_IOC_USERSPACE_ONE,
1134 ZFS_IOC_USERSPACE_MANY,
1135 ZFS_IOC_USERSPACE_UPGRADE,
1136 ZFS_IOC_HOLD,
1137 ZFS_IOC_RELEASE,
1138 ZFS_IOC_GET_HOLDS,
1139 ZFS_IOC_OBJSET_RECVD_PROPS,
1140 ZFS_IOC_VDEV_SPLIT,
1141 ZFS_IOC_NEXT_OBJ,
1142 ZFS_IOC_DIFF,
1143 ZFS_IOC_TMP_SNAPSHOT,
1144 ZFS_IOC_OBJ_TO_STATS,
1145 ZFS_IOC_SPACE_WRITTEN,
1146 ZFS_IOC_SPACE_SNAPS,
1147 ZFS_IOC_DESTROY_SNAPS,
1148 ZFS_IOC_POOL_REGUID,
1149 ZFS_IOC_POOL_REOPEN,
1150 ZFS_IOC_SEND_PROGRESS,
1151 ZFS_IOC_LOG_HISTORY,
1152 ZFS_IOC_SEND_NEW,
1153 ZFS_IOC_SEND_SPACE,
1154 ZFS_IOC_CLONE,
1155 ZFS_IOC_BOOKMARK,
1156 ZFS_IOC_GET_BOOKMARKS,
1157 ZFS_IOC_DESTROY_BOOKMARKS,
1158 ZFS_IOC_CHANNEL_PROGRAM,
1159 ZFS_IOC_RECV_NEW,
1160 ZFS_IOC_POOL_SYNC,
1161 ZFS_IOC_LOAD_KEY,
1162 ZFS_IOC_UNLOAD_KEY,
1163 ZFS_IOC_CHANGE_KEY,
1164 ZFS_IOC_REMAP,
1165 ZFS_IOC_POOL_CHECKPOINT,
1166 ZFS_IOC_POOL_DISCARD_CHECKPOINT,
1167
1168 /*
1169 * Linux - 3/64 numbers reserved.
1170 */
1171 ZFS_IOC_LINUX = ('Z' << 8) + 0x80,
1172 ZFS_IOC_EVENTS_NEXT,
1173 ZFS_IOC_EVENTS_CLEAR,
1174 ZFS_IOC_EVENTS_SEEK,
1175
1176 /*
1177 * FreeBSD - 1/64 numbers reserved.
1178 */
1179 ZFS_IOC_FREEBSD = ('Z' << 8) + 0xC0,
1180
1181 ZFS_IOC_LAST
1182 } zfs_ioc_t;
1183
1184 /*
1185 * zvol ioctl to get dataset name
1186 */
1187 #define BLKZNAME _IOR(0x12, 125, char[ZFS_MAX_DATASET_NAME_LEN])
1188
1189 /*
1190 * ZFS-specific error codes used for returning descriptive errors
1191 * to the userland through zfs ioctls.
1192 *
1193 * The enum implicitly includes all the error codes from errno.h.
1194 * New code should use and extend this enum for errors that are
1195 * not described precisely by generic errno codes.
1196 */
1197 typedef enum {
1198 ZFS_ERR_CHECKPOINT_EXISTS = 1024,
1199 ZFS_ERR_DISCARDING_CHECKPOINT,
1200 ZFS_ERR_NO_CHECKPOINT,
1201 ZFS_ERR_DEVRM_IN_PROGRESS,
1202 ZFS_ERR_VDEV_TOO_BIG
1203 } zfs_errno_t;
1204
1205 /*
1206 * Internal SPA load state. Used by FMA diagnosis engine.
1207 */
1208 typedef enum {
1209 SPA_LOAD_NONE, /* no load in progress */
1210 SPA_LOAD_OPEN, /* normal open */
1211 SPA_LOAD_IMPORT, /* import in progress */
1212 SPA_LOAD_TRYIMPORT, /* tryimport in progress */
1213 SPA_LOAD_RECOVER, /* recovery requested */
1214 SPA_LOAD_ERROR, /* load failed */
1215 SPA_LOAD_CREATE /* creation in progress */
1216 } spa_load_state_t;
1217
1218 /*
1219 * Bookmark name values.
1220 */
1221 #define ZPOOL_ERR_LIST "error list"
1222 #define ZPOOL_ERR_DATASET "dataset"
1223 #define ZPOOL_ERR_OBJECT "object"
1224
1225 #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1)
1226
1227 /*
1228 * The following are names used in the nvlist describing
1229 * the pool's history log.
1230 */
1231 #define ZPOOL_HIST_RECORD "history record"
1232 #define ZPOOL_HIST_TIME "history time"
1233 #define ZPOOL_HIST_CMD "history command"
1234 #define ZPOOL_HIST_WHO "history who"
1235 #define ZPOOL_HIST_ZONE "history zone"
1236 #define ZPOOL_HIST_HOST "history hostname"
1237 #define ZPOOL_HIST_TXG "history txg"
1238 #define ZPOOL_HIST_INT_EVENT "history internal event"
1239 #define ZPOOL_HIST_INT_STR "history internal str"
1240 #define ZPOOL_HIST_INT_NAME "internal_name"
1241 #define ZPOOL_HIST_IOCTL "ioctl"
1242 #define ZPOOL_HIST_INPUT_NVL "in_nvl"
1243 #define ZPOOL_HIST_OUTPUT_NVL "out_nvl"
1244 #define ZPOOL_HIST_DSNAME "dsname"
1245 #define ZPOOL_HIST_DSID "dsid"
1246 #define ZPOOL_HIST_ERRNO "errno"
1247
1248 /*
1249 * Special nvlist name that will not have its args recorded in the pool's
1250 * history log.
1251 */
1252 #define ZPOOL_HIDDEN_ARGS "hidden_args"
1253
1254 /*
1255 * Flags for ZFS_IOC_VDEV_SET_STATE
1256 */
1257 #define ZFS_ONLINE_CHECKREMOVE 0x1
1258 #define ZFS_ONLINE_UNSPARE 0x2
1259 #define ZFS_ONLINE_FORCEFAULT 0x4
1260 #define ZFS_ONLINE_EXPAND 0x8
1261 #define ZFS_OFFLINE_TEMPORARY 0x1
1262
1263 /*
1264 * Flags for ZFS_IOC_POOL_IMPORT
1265 */
1266 #define ZFS_IMPORT_NORMAL 0x0
1267 #define ZFS_IMPORT_VERBATIM 0x1
1268 #define ZFS_IMPORT_ANY_HOST 0x2
1269 #define ZFS_IMPORT_MISSING_LOG 0x4
1270 #define ZFS_IMPORT_ONLY 0x8
1271 #define ZFS_IMPORT_TEMP_NAME 0x10
1272 #define ZFS_IMPORT_SKIP_MMP 0x20
1273 #define ZFS_IMPORT_LOAD_KEYS 0x40
1274 #define ZFS_IMPORT_CHECKPOINT 0x80
1275
1276 /*
1277 * Channel program argument/return nvlist keys and defaults.
1278 */
1279 #define ZCP_ARG_PROGRAM "program"
1280 #define ZCP_ARG_ARGLIST "arg"
1281 #define ZCP_ARG_SYNC "sync"
1282 #define ZCP_ARG_INSTRLIMIT "instrlimit"
1283 #define ZCP_ARG_MEMLIMIT "memlimit"
1284
1285 #define ZCP_ARG_CLIARGV "argv"
1286
1287 #define ZCP_RET_ERROR "error"
1288 #define ZCP_RET_RETURN "return"
1289
1290 #define ZCP_DEFAULT_INSTRLIMIT (10 * 1000 * 1000)
1291 #define ZCP_MAX_INSTRLIMIT (10 * ZCP_DEFAULT_INSTRLIMIT)
1292 #define ZCP_DEFAULT_MEMLIMIT (10 * 1024 * 1024)
1293 #define ZCP_MAX_MEMLIMIT (10 * ZCP_DEFAULT_MEMLIMIT)
1294
1295 /*
1296 * Sysevent payload members. ZFS will generate the following sysevents with the
1297 * given payloads:
1298 *
1299 * ESC_ZFS_RESILVER_START
1300 * ESC_ZFS_RESILVER_END
1301 * ESC_ZFS_POOL_DESTROY
1302 * ESC_ZFS_POOL_REGUID
1303 *
1304 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1305 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1306 *
1307 * ESC_ZFS_VDEV_REMOVE
1308 * ESC_ZFS_VDEV_CLEAR
1309 * ESC_ZFS_VDEV_CHECK
1310 *
1311 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1312 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1313 * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional)
1314 * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64
1315 *
1316 * ESC_ZFS_HISTORY_EVENT
1317 *
1318 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1319 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1320 * ZFS_EV_HIST_TIME DATA_TYPE_UINT64 (optional)
1321 * ZFS_EV_HIST_CMD DATA_TYPE_STRING (optional)
1322 * ZFS_EV_HIST_WHO DATA_TYPE_UINT64 (optional)
1323 * ZFS_EV_HIST_ZONE DATA_TYPE_STRING (optional)
1324 * ZFS_EV_HIST_HOST DATA_TYPE_STRING (optional)
1325 * ZFS_EV_HIST_TXG DATA_TYPE_UINT64 (optional)
1326 * ZFS_EV_HIST_INT_EVENT DATA_TYPE_UINT64 (optional)
1327 * ZFS_EV_HIST_INT_STR DATA_TYPE_STRING (optional)
1328 * ZFS_EV_HIST_INT_NAME DATA_TYPE_STRING (optional)
1329 * ZFS_EV_HIST_IOCTL DATA_TYPE_STRING (optional)
1330 * ZFS_EV_HIST_DSNAME DATA_TYPE_STRING (optional)
1331 * ZFS_EV_HIST_DSID DATA_TYPE_UINT64 (optional)
1332 *
1333 * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the
1334 * history log nvlist. The keynames will be free of any spaces or other
1335 * characters that could be potentially unexpected to consumers of the
1336 * sysevents.
1337 */
1338 #define ZFS_EV_POOL_NAME "pool_name"
1339 #define ZFS_EV_POOL_GUID "pool_guid"
1340 #define ZFS_EV_VDEV_PATH "vdev_path"
1341 #define ZFS_EV_VDEV_GUID "vdev_guid"
1342 #define ZFS_EV_HIST_TIME "history_time"
1343 #define ZFS_EV_HIST_CMD "history_command"
1344 #define ZFS_EV_HIST_WHO "history_who"
1345 #define ZFS_EV_HIST_ZONE "history_zone"
1346 #define ZFS_EV_HIST_HOST "history_hostname"
1347 #define ZFS_EV_HIST_TXG "history_txg"
1348 #define ZFS_EV_HIST_INT_EVENT "history_internal_event"
1349 #define ZFS_EV_HIST_INT_STR "history_internal_str"
1350 #define ZFS_EV_HIST_INT_NAME "history_internal_name"
1351 #define ZFS_EV_HIST_IOCTL "history_ioctl"
1352 #define ZFS_EV_HIST_DSNAME "history_dsname"
1353 #define ZFS_EV_HIST_DSID "history_dsid"
1354
1355 #ifdef __cplusplus
1356 }
1357 #endif
1358
1359 #endif /* _SYS_FS_ZFS_H */