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.
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.
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]
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2011, 2020 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, Intel Corporation.
29 * Copyright (c) 2019 Datto Inc.
32 /* Portions Copyright 2010 Robert Milkowski */
38 #include <sys/zio_priority.h>
45 * Types and constants shared between userland and the kernel.
49 * Each dataset can be one of the following types. These constants can be
50 * combined into masks that can be passed to various functions.
53 ZFS_TYPE_FILESYSTEM
= (1 << 0),
54 ZFS_TYPE_SNAPSHOT
= (1 << 1),
55 ZFS_TYPE_VOLUME
= (1 << 2),
56 ZFS_TYPE_POOL
= (1 << 3),
57 ZFS_TYPE_BOOKMARK
= (1 << 4)
61 * NB: lzc_dataset_type should be updated whenever a new objset type is added,
62 * if it represents a real type of a dataset that can be created from userland.
64 typedef enum dmu_objset_type
{
69 DMU_OST_OTHER
, /* For testing only! */
70 DMU_OST_ANY
, /* Be careful! */
74 #define ZFS_TYPE_DATASET \
75 (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
78 * All of these include the terminating NUL byte.
80 #define ZAP_MAXNAMELEN 256
81 #define ZAP_MAXVALUELEN (1024 * 8)
82 #define ZAP_OLDMAXVALUELEN 1024
83 #define ZFS_MAX_DATASET_NAME_LEN 256
86 * Dataset properties are identified by these constants and must be added to
87 * the end of this list to ensure that external consumers are not affected
88 * by the change. If you make any changes to this list, be sure to update
89 * the property table in module/zcommon/zfs_prop.c.
99 ZFS_PROP_COMPRESSRATIO
,
103 ZFS_PROP_RESERVATION
,
105 ZFS_PROP_VOLBLOCKSIZE
,
110 ZFS_PROP_COMPRESSION
,
121 ZFS_PROP_NAME
, /* not exposed to the user */
123 ZFS_PROP_ISCSIOPTIONS
, /* not exposed to the user */
125 ZFS_PROP_NUMCLONES
, /* not exposed to the user */
135 ZFS_PROP_REFRESERVATION
,
137 ZFS_PROP_PRIMARYCACHE
,
138 ZFS_PROP_SECONDARYCACHE
,
142 ZFS_PROP_USEDREFRESERV
,
143 ZFS_PROP_USERACCOUNTING
, /* not exposed to the user */
144 ZFS_PROP_STMF_SHAREINFO
, /* not exposed to the user */
145 ZFS_PROP_DEFER_DESTROY
,
148 ZFS_PROP_UNIQUE
, /* not exposed to the user */
157 ZFS_PROP_LOGICALUSED
,
158 ZFS_PROP_LOGICALREFERENCED
,
159 ZFS_PROP_INCONSISTENT
, /* not exposed to the user */
161 ZFS_PROP_FILESYSTEM_LIMIT
,
162 ZFS_PROP_SNAPSHOT_LIMIT
,
163 ZFS_PROP_FILESYSTEM_COUNT
,
164 ZFS_PROP_SNAPSHOT_COUNT
,
167 ZFS_PROP_SELINUX_CONTEXT
,
168 ZFS_PROP_SELINUX_FSCONTEXT
,
169 ZFS_PROP_SELINUX_DEFCONTEXT
,
170 ZFS_PROP_SELINUX_ROOTCONTEXT
,
172 ZFS_PROP_REDUNDANT_METADATA
,
175 ZFS_PROP_RECEIVE_RESUME_TOKEN
,
177 ZFS_PROP_KEYLOCATION
,
179 ZFS_PROP_PBKDF2_SALT
,
180 ZFS_PROP_PBKDF2_ITERS
,
181 ZFS_PROP_ENCRYPTION_ROOT
,
184 ZFS_PROP_REMAPTXG
, /* obsolete - no longer used */
185 ZFS_PROP_SPECIAL_SMALL_BLOCKS
,
186 ZFS_PROP_IVSET_GUID
, /* not exposed to the user */
188 ZFS_PROP_REDACT_SNAPS
,
197 ZFS_PROP_USEROBJUSED
,
198 ZFS_PROP_USEROBJQUOTA
,
199 ZFS_PROP_GROUPOBJUSED
,
200 ZFS_PROP_GROUPOBJQUOTA
,
201 ZFS_PROP_PROJECTUSED
,
202 ZFS_PROP_PROJECTQUOTA
,
203 ZFS_PROP_PROJECTOBJUSED
,
204 ZFS_PROP_PROJECTOBJQUOTA
,
205 ZFS_NUM_USERQUOTA_PROPS
206 } zfs_userquota_prop_t
;
208 extern const char *zfs_userquota_prop_prefixes
[ZFS_NUM_USERQUOTA_PROPS
];
211 * Pool properties are identified by these constants and must be added to the
212 * end of this list to ensure that external consumers are not affected
213 * by the change. Properties must be registered in zfs_prop_init().
216 ZPOOL_PROP_INVAL
= -1,
225 ZPOOL_PROP_DELEGATION
,
226 ZPOOL_PROP_AUTOREPLACE
,
227 ZPOOL_PROP_CACHEFILE
,
228 ZPOOL_PROP_FAILUREMODE
,
229 ZPOOL_PROP_LISTSNAPS
,
230 ZPOOL_PROP_AUTOEXPAND
,
231 ZPOOL_PROP_DEDUPDITTO
,
232 ZPOOL_PROP_DEDUPRATIO
,
234 ZPOOL_PROP_ALLOCATED
,
240 ZPOOL_PROP_FRAGMENTATION
,
242 ZPOOL_PROP_MAXBLOCKSIZE
,
244 ZPOOL_PROP_MAXDNODESIZE
,
245 ZPOOL_PROP_MULTIHOST
,
246 ZPOOL_PROP_CHECKPOINT
,
247 ZPOOL_PROP_LOAD_GUID
,
252 /* Small enough to not hog a whole line of printout in zpool(1M). */
253 #define ZPROP_MAX_COMMENT 32
255 #define ZPROP_VALUE "value"
256 #define ZPROP_SOURCE "source"
259 ZPROP_SRC_NONE
= 0x1,
260 ZPROP_SRC_DEFAULT
= 0x2,
261 ZPROP_SRC_TEMPORARY
= 0x4,
262 ZPROP_SRC_LOCAL
= 0x8,
263 ZPROP_SRC_INHERITED
= 0x10,
264 ZPROP_SRC_RECEIVED
= 0x20
267 #define ZPROP_SRC_ALL 0x3f
269 #define ZPROP_SOURCE_VAL_RECVD "$recvd"
270 #define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS"
273 * Dataset flag implemented as a special entry in the props zap object
274 * indicating that the dataset has received properties on or after
275 * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
276 * just as it did in earlier versions, and thereafter, local properties are
279 #define ZPROP_HAS_RECVD "$hasrecvd"
282 ZPROP_ERR_NOCLEAR
= 0x1, /* failure to clear existing props */
283 ZPROP_ERR_NORESTORE
= 0x2 /* failure to restore props on error */
286 typedef int (*zprop_func
)(int, void *);
289 * Properties to be set on the root file system of a new pool
290 * are stuffed into their own nvlist, which is then included in
291 * the properties nvlist with the pool properties.
293 #define ZPOOL_ROOTFS_PROPS "root-props-nvl"
296 * Length of 'written@' and 'written#'
298 #define ZFS_WRITTEN_PROP_PREFIX_LEN 8
301 * Dataset property functions shared between libzfs and kernel.
303 const char *zfs_prop_default_string(zfs_prop_t
);
304 uint64_t zfs_prop_default_numeric(zfs_prop_t
);
305 boolean_t
zfs_prop_readonly(zfs_prop_t
);
306 boolean_t
zfs_prop_visible(zfs_prop_t prop
);
307 boolean_t
zfs_prop_inheritable(zfs_prop_t
);
308 boolean_t
zfs_prop_setonce(zfs_prop_t
);
309 boolean_t
zfs_prop_encryption_key_param(zfs_prop_t
);
310 boolean_t
zfs_prop_valid_keylocation(const char *, boolean_t
);
311 const char *zfs_prop_to_name(zfs_prop_t
);
312 zfs_prop_t
zfs_name_to_prop(const char *);
313 boolean_t
zfs_prop_user(const char *);
314 boolean_t
zfs_prop_userquota(const char *);
315 boolean_t
zfs_prop_written(const char *);
316 int zfs_prop_index_to_string(zfs_prop_t
, uint64_t, const char **);
317 int zfs_prop_string_to_index(zfs_prop_t
, const char *, uint64_t *);
318 uint64_t zfs_prop_random_value(zfs_prop_t
, uint64_t seed
);
319 boolean_t
zfs_prop_valid_for_type(int, zfs_type_t
, boolean_t
);
322 * Pool property functions shared between libzfs and kernel.
324 zpool_prop_t
zpool_name_to_prop(const char *);
325 const char *zpool_prop_to_name(zpool_prop_t
);
326 const char *zpool_prop_default_string(zpool_prop_t
);
327 uint64_t zpool_prop_default_numeric(zpool_prop_t
);
328 boolean_t
zpool_prop_readonly(zpool_prop_t
);
329 boolean_t
zpool_prop_setonce(zpool_prop_t
);
330 boolean_t
zpool_prop_feature(const char *);
331 boolean_t
zpool_prop_unsupported(const char *);
332 int zpool_prop_index_to_string(zpool_prop_t
, uint64_t, const char **);
333 int zpool_prop_string_to_index(zpool_prop_t
, const char *, uint64_t *);
334 uint64_t zpool_prop_random_value(zpool_prop_t
, uint64_t seed
);
337 * Definitions for the Delegation.
340 ZFS_DELEG_WHO_UNKNOWN
= 0,
341 ZFS_DELEG_USER
= 'u',
342 ZFS_DELEG_USER_SETS
= 'U',
343 ZFS_DELEG_GROUP
= 'g',
344 ZFS_DELEG_GROUP_SETS
= 'G',
345 ZFS_DELEG_EVERYONE
= 'e',
346 ZFS_DELEG_EVERYONE_SETS
= 'E',
347 ZFS_DELEG_CREATE
= 'c',
348 ZFS_DELEG_CREATE_SETS
= 'C',
349 ZFS_DELEG_NAMED_SET
= 's',
350 ZFS_DELEG_NAMED_SET_SETS
= 'S'
351 } zfs_deleg_who_type_t
;
355 ZFS_DELEG_PERM_LOCAL
= 1,
356 ZFS_DELEG_PERM_DESCENDENT
= 2,
357 ZFS_DELEG_PERM_LOCALDESCENDENT
= 3,
358 ZFS_DELEG_PERM_CREATE
= 4
359 } zfs_deleg_inherit_t
;
361 #define ZFS_DELEG_PERM_UID "uid"
362 #define ZFS_DELEG_PERM_GID "gid"
363 #define ZFS_DELEG_PERM_GROUPS "groups"
365 #define ZFS_MLSLABEL_DEFAULT "none"
367 #define ZFS_SMB_ACL_SRC "src"
368 #define ZFS_SMB_ACL_TARGET "target"
371 ZFS_CANMOUNT_OFF
= 0,
373 ZFS_CANMOUNT_NOAUTO
= 2
374 } zfs_canmount_type_t
;
377 ZFS_LOGBIAS_LATENCY
= 0,
378 ZFS_LOGBIAS_THROUGHPUT
= 1
381 typedef enum zfs_share_op
{
388 typedef enum zfs_smb_acl_op
{
395 typedef enum zfs_cache_type
{
397 ZFS_CACHE_METADATA
= 1,
402 ZFS_SYNC_STANDARD
= 0,
404 ZFS_SYNC_DISABLED
= 2
414 ZFS_DNSIZE_LEGACY
= 0,
416 ZFS_DNSIZE_1K
= 1024,
417 ZFS_DNSIZE_2K
= 2048,
418 ZFS_DNSIZE_4K
= 4096,
419 ZFS_DNSIZE_8K
= 8192,
420 ZFS_DNSIZE_16K
= 16384
424 ZFS_REDUNDANT_METADATA_ALL
,
425 ZFS_REDUNDANT_METADATA_MOST
426 } zfs_redundant_metadata_type_t
;
429 ZFS_VOLMODE_DEFAULT
= 0,
430 ZFS_VOLMODE_GEOM
= 1,
435 typedef enum zfs_keystatus
{
436 ZFS_KEYSTATUS_NONE
= 0,
437 ZFS_KEYSTATUS_UNAVAILABLE
,
438 ZFS_KEYSTATUS_AVAILABLE
,
441 typedef enum zfs_keyformat
{
442 ZFS_KEYFORMAT_NONE
= 0,
445 ZFS_KEYFORMAT_PASSPHRASE
,
446 ZFS_KEYFORMAT_FORMATS
449 typedef enum zfs_key_location
{
450 ZFS_KEYLOCATION_NONE
= 0,
451 ZFS_KEYLOCATION_PROMPT
,
453 ZFS_KEYLOCATION_LOCATIONS
456 #define DEFAULT_PBKDF2_ITERATIONS 350000
457 #define MIN_PBKDF2_ITERATIONS 100000
460 * On-disk version number.
462 #define SPA_VERSION_1 1ULL
463 #define SPA_VERSION_2 2ULL
464 #define SPA_VERSION_3 3ULL
465 #define SPA_VERSION_4 4ULL
466 #define SPA_VERSION_5 5ULL
467 #define SPA_VERSION_6 6ULL
468 #define SPA_VERSION_7 7ULL
469 #define SPA_VERSION_8 8ULL
470 #define SPA_VERSION_9 9ULL
471 #define SPA_VERSION_10 10ULL
472 #define SPA_VERSION_11 11ULL
473 #define SPA_VERSION_12 12ULL
474 #define SPA_VERSION_13 13ULL
475 #define SPA_VERSION_14 14ULL
476 #define SPA_VERSION_15 15ULL
477 #define SPA_VERSION_16 16ULL
478 #define SPA_VERSION_17 17ULL
479 #define SPA_VERSION_18 18ULL
480 #define SPA_VERSION_19 19ULL
481 #define SPA_VERSION_20 20ULL
482 #define SPA_VERSION_21 21ULL
483 #define SPA_VERSION_22 22ULL
484 #define SPA_VERSION_23 23ULL
485 #define SPA_VERSION_24 24ULL
486 #define SPA_VERSION_25 25ULL
487 #define SPA_VERSION_26 26ULL
488 #define SPA_VERSION_27 27ULL
489 #define SPA_VERSION_28 28ULL
490 #define SPA_VERSION_5000 5000ULL
493 * The incrementing pool version number has been replaced by pool feature
494 * flags. For more details, see zfeature.c.
496 #define SPA_VERSION SPA_VERSION_5000
497 #define SPA_VERSION_STRING "5000"
500 * Symbolic names for the changes that caused a SPA_VERSION switch.
501 * Used in the code when checking for presence or absence of a feature.
502 * Feel free to define multiple symbolic names for each version if there
503 * were multiple changes to on-disk structures during that version.
505 * NOTE: When checking the current SPA_VERSION in your code, be sure
506 * to use spa_version() since it reports the version of the
507 * last synced uberblock. Checking the in-flight version can
508 * be dangerous in some cases.
510 #define SPA_VERSION_INITIAL SPA_VERSION_1
511 #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2
512 #define SPA_VERSION_SPARES SPA_VERSION_3
513 #define SPA_VERSION_RAIDZ2 SPA_VERSION_3
514 #define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3
515 #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3
516 #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3
517 #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4
518 #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5
519 #define SPA_VERSION_BOOTFS SPA_VERSION_6
520 #define SPA_VERSION_SLOGS SPA_VERSION_7
521 #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8
522 #define SPA_VERSION_FUID SPA_VERSION_9
523 #define SPA_VERSION_REFRESERVATION SPA_VERSION_9
524 #define SPA_VERSION_REFQUOTA SPA_VERSION_9
525 #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9
526 #define SPA_VERSION_L2CACHE SPA_VERSION_10
527 #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11
528 #define SPA_VERSION_ORIGIN SPA_VERSION_11
529 #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11
530 #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12
531 #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13
532 #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14
533 #define SPA_VERSION_USERSPACE SPA_VERSION_15
534 #define SPA_VERSION_STMF_PROP SPA_VERSION_16
535 #define SPA_VERSION_RAIDZ3 SPA_VERSION_17
536 #define SPA_VERSION_USERREFS SPA_VERSION_18
537 #define SPA_VERSION_HOLES SPA_VERSION_19
538 #define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20
539 #define SPA_VERSION_DEDUP SPA_VERSION_21
540 #define SPA_VERSION_RECVD_PROPS SPA_VERSION_22
541 #define SPA_VERSION_SLIM_ZIL SPA_VERSION_23
542 #define SPA_VERSION_SA SPA_VERSION_24
543 #define SPA_VERSION_SCAN SPA_VERSION_25
544 #define SPA_VERSION_DIR_CLONES SPA_VERSION_26
545 #define SPA_VERSION_DEADLISTS SPA_VERSION_26
546 #define SPA_VERSION_FAST_SNAP SPA_VERSION_27
547 #define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28
548 #define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28
549 #define SPA_VERSION_FEATURES SPA_VERSION_5000
551 #define SPA_VERSION_IS_SUPPORTED(v) \
552 (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
553 ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
556 * ZPL version - rev'd whenever an incompatible on-disk format change
557 * occurs. This is independent of SPA/DMU/ZAP versioning. You must
558 * also update the version_table[] and help message in zfs_prop.c.
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"
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
576 /* Persistent L2ARC version */
577 #define L2ARC_PERSISTENT_VERSION_1 1ULL
578 #define L2ARC_PERSISTENT_VERSION L2ARC_PERSISTENT_VERSION_1
579 #define L2ARC_PERSISTENT_VERSION_STRING "1"
581 /* Rewind policy information */
582 #define ZPOOL_NO_REWIND 1 /* No policy - default behavior */
583 #define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */
584 #define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */
585 #define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */
586 #define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */
587 #define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */
588 #define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */
590 typedef struct zpool_load_policy
{
591 uint32_t zlp_rewind
; /* rewind policy requested */
592 uint64_t zlp_maxmeta
; /* max acceptable meta-data errors */
593 uint64_t zlp_maxdata
; /* max acceptable data errors */
594 uint64_t zlp_txg
; /* specific txg to load */
595 } zpool_load_policy_t
;
598 * The following are configuration names used in the nvlist describing a pool's
599 * configuration. New on-disk names should be prefixed with "<reversed-DNS>:"
600 * (e.g. "org.openzfs:") to avoid conflicting names being developed
603 #define ZPOOL_CONFIG_VERSION "version"
604 #define ZPOOL_CONFIG_POOL_NAME "name"
605 #define ZPOOL_CONFIG_POOL_STATE "state"
606 #define ZPOOL_CONFIG_POOL_TXG "txg"
607 #define ZPOOL_CONFIG_POOL_GUID "pool_guid"
608 #define ZPOOL_CONFIG_CREATE_TXG "create_txg"
609 #define ZPOOL_CONFIG_TOP_GUID "top_guid"
610 #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
611 #define ZPOOL_CONFIG_TYPE "type"
612 #define ZPOOL_CONFIG_CHILDREN "children"
613 #define ZPOOL_CONFIG_ID "id"
614 #define ZPOOL_CONFIG_GUID "guid"
615 #define ZPOOL_CONFIG_INDIRECT_OBJECT "com.delphix:indirect_object"
616 #define ZPOOL_CONFIG_INDIRECT_BIRTHS "com.delphix:indirect_births"
617 #define ZPOOL_CONFIG_PREV_INDIRECT_VDEV "com.delphix:prev_indirect_vdev"
618 #define ZPOOL_CONFIG_PATH "path"
619 #define ZPOOL_CONFIG_DEVID "devid"
620 #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array"
621 #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift"
622 #define ZPOOL_CONFIG_ASHIFT "ashift"
623 #define ZPOOL_CONFIG_ASIZE "asize"
624 #define ZPOOL_CONFIG_DTL "DTL"
625 #define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */
626 #define ZPOOL_CONFIG_REMOVAL_STATS "removal_stats" /* not stored on disk */
627 #define ZPOOL_CONFIG_CHECKPOINT_STATS "checkpoint_stats" /* not on disk */
628 #define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */
629 #define ZPOOL_CONFIG_INDIRECT_SIZE "indirect_size" /* not stored on disk */
631 /* container nvlist of extended stats */
632 #define ZPOOL_CONFIG_VDEV_STATS_EX "vdev_stats_ex"
634 /* Active queue read/write stats */
635 #define ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE "vdev_sync_r_active_queue"
636 #define ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE "vdev_sync_w_active_queue"
637 #define ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE "vdev_async_r_active_queue"
638 #define ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE "vdev_async_w_active_queue"
639 #define ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE "vdev_async_scrub_active_queue"
640 #define ZPOOL_CONFIG_VDEV_TRIM_ACTIVE_QUEUE "vdev_async_trim_active_queue"
643 #define ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE "vdev_sync_r_pend_queue"
644 #define ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE "vdev_sync_w_pend_queue"
645 #define ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE "vdev_async_r_pend_queue"
646 #define ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE "vdev_async_w_pend_queue"
647 #define ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE "vdev_async_scrub_pend_queue"
648 #define ZPOOL_CONFIG_VDEV_TRIM_PEND_QUEUE "vdev_async_trim_pend_queue"
650 /* Latency read/write histogram stats */
651 #define ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO "vdev_tot_r_lat_histo"
652 #define ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO "vdev_tot_w_lat_histo"
653 #define ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO "vdev_disk_r_lat_histo"
654 #define ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO "vdev_disk_w_lat_histo"
655 #define ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO "vdev_sync_r_lat_histo"
656 #define ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO "vdev_sync_w_lat_histo"
657 #define ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO "vdev_async_r_lat_histo"
658 #define ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO "vdev_async_w_lat_histo"
659 #define ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO "vdev_scrub_histo"
660 #define ZPOOL_CONFIG_VDEV_TRIM_LAT_HISTO "vdev_trim_histo"
662 /* Request size histograms */
663 #define ZPOOL_CONFIG_VDEV_SYNC_IND_R_HISTO "vdev_sync_ind_r_histo"
664 #define ZPOOL_CONFIG_VDEV_SYNC_IND_W_HISTO "vdev_sync_ind_w_histo"
665 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_R_HISTO "vdev_async_ind_r_histo"
666 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_W_HISTO "vdev_async_ind_w_histo"
667 #define ZPOOL_CONFIG_VDEV_IND_SCRUB_HISTO "vdev_ind_scrub_histo"
668 #define ZPOOL_CONFIG_VDEV_IND_TRIM_HISTO "vdev_ind_trim_histo"
669 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_R_HISTO "vdev_sync_agg_r_histo"
670 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_W_HISTO "vdev_sync_agg_w_histo"
671 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_R_HISTO "vdev_async_agg_r_histo"
672 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO "vdev_async_agg_w_histo"
673 #define ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO "vdev_agg_scrub_histo"
674 #define ZPOOL_CONFIG_VDEV_AGG_TRIM_HISTO "vdev_agg_trim_histo"
676 /* Number of slow IOs */
677 #define ZPOOL_CONFIG_VDEV_SLOW_IOS "vdev_slow_ios"
679 /* vdev enclosure sysfs path */
680 #define ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH "vdev_enc_sysfs_path"
682 #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
683 #define ZPOOL_CONFIG_ERRCOUNT "error_count"
684 #define ZPOOL_CONFIG_NOT_PRESENT "not_present"
685 #define ZPOOL_CONFIG_SPARES "spares"
686 #define ZPOOL_CONFIG_IS_SPARE "is_spare"
687 #define ZPOOL_CONFIG_NPARITY "nparity"
688 #define ZPOOL_CONFIG_HOSTID "hostid"
689 #define ZPOOL_CONFIG_HOSTNAME "hostname"
690 #define ZPOOL_CONFIG_LOADED_TIME "initial_load_time"
691 #define ZPOOL_CONFIG_UNSPARE "unspare"
692 #define ZPOOL_CONFIG_PHYS_PATH "phys_path"
693 #define ZPOOL_CONFIG_IS_LOG "is_log"
694 #define ZPOOL_CONFIG_L2CACHE "l2cache"
695 #define ZPOOL_CONFIG_HOLE_ARRAY "hole_array"
696 #define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
697 #define ZPOOL_CONFIG_IS_HOLE "is_hole"
698 #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
699 #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
700 #define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
701 #define ZPOOL_CONFIG_SPLIT "splitcfg"
702 #define ZPOOL_CONFIG_ORIG_GUID "orig_guid"
703 #define ZPOOL_CONFIG_SPLIT_GUID "split_guid"
704 #define ZPOOL_CONFIG_SPLIT_LIST "guid_list"
705 #define ZPOOL_CONFIG_REMOVING "removing"
706 #define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg"
707 #define ZPOOL_CONFIG_COMMENT "comment"
708 #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */
709 #define ZPOOL_CONFIG_SUSPENDED_REASON "suspended_reason" /* not stored */
710 #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */
711 #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */
712 #define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */
713 #define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */
714 #define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */
715 #define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */
716 #define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */
717 #define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */
718 #define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read"
719 #define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */
720 #define ZPOOL_CONFIG_ERRATA "errata" /* not stored on disk */
721 #define ZPOOL_CONFIG_VDEV_TOP_ZAP "com.delphix:vdev_zap_top"
722 #define ZPOOL_CONFIG_VDEV_LEAF_ZAP "com.delphix:vdev_zap_leaf"
723 #define ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS "com.delphix:has_per_vdev_zaps"
724 #define ZPOOL_CONFIG_RESILVER_DEFER "com.datto:resilver_defer"
725 #define ZPOOL_CONFIG_CACHEFILE "cachefile" /* not stored on disk */
726 #define ZPOOL_CONFIG_MMP_STATE "mmp_state" /* not stored on disk */
727 #define ZPOOL_CONFIG_MMP_TXG "mmp_txg" /* not stored on disk */
728 #define ZPOOL_CONFIG_MMP_SEQ "mmp_seq" /* not stored on disk */
729 #define ZPOOL_CONFIG_MMP_HOSTNAME "mmp_hostname" /* not stored on disk */
730 #define ZPOOL_CONFIG_MMP_HOSTID "mmp_hostid" /* not stored on disk */
731 #define ZPOOL_CONFIG_ALLOCATION_BIAS "alloc_bias" /* not stored on disk */
732 #define ZPOOL_CONFIG_EXPANSION_TIME "expansion_time" /* not stored */
735 * The persistent vdev state is stored as separate values rather than a single
736 * 'vdev_state' entry. This is because a device can be in multiple states, such
737 * as offline and degraded.
739 #define ZPOOL_CONFIG_OFFLINE "offline"
740 #define ZPOOL_CONFIG_FAULTED "faulted"
741 #define ZPOOL_CONFIG_DEGRADED "degraded"
742 #define ZPOOL_CONFIG_REMOVED "removed"
743 #define ZPOOL_CONFIG_FRU "fru"
744 #define ZPOOL_CONFIG_AUX_STATE "aux_state"
746 /* Pool load policy parameters */
747 #define ZPOOL_LOAD_POLICY "load-policy"
748 #define ZPOOL_LOAD_REWIND_POLICY "load-rewind-policy"
749 #define ZPOOL_LOAD_REQUEST_TXG "load-request-txg"
750 #define ZPOOL_LOAD_META_THRESH "load-meta-thresh"
751 #define ZPOOL_LOAD_DATA_THRESH "load-data-thresh"
753 /* Rewind data discovered */
754 #define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts"
755 #define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors"
756 #define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind"
758 #define VDEV_TYPE_ROOT "root"
759 #define VDEV_TYPE_MIRROR "mirror"
760 #define VDEV_TYPE_REPLACING "replacing"
761 #define VDEV_TYPE_RAIDZ "raidz"
762 #define VDEV_TYPE_DISK "disk"
763 #define VDEV_TYPE_FILE "file"
764 #define VDEV_TYPE_MISSING "missing"
765 #define VDEV_TYPE_HOLE "hole"
766 #define VDEV_TYPE_SPARE "spare"
767 #define VDEV_TYPE_LOG "log"
768 #define VDEV_TYPE_L2CACHE "l2cache"
769 #define VDEV_TYPE_INDIRECT "indirect"
771 /* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */
772 #define VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \
773 "com.delphix:indirect_obsolete_sm"
774 #define VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \
775 "com.delphix:obsolete_counts_are_precise"
776 #define VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \
777 "com.delphix:pool_checkpoint_sm"
778 #define VDEV_TOP_ZAP_MS_UNFLUSHED_PHYS_TXGS \
779 "com.delphix:ms_unflushed_phys_txgs"
781 #define VDEV_TOP_ZAP_ALLOCATION_BIAS \
782 "org.zfsonlinux:allocation_bias"
784 /* vdev metaslab allocation bias */
785 #define VDEV_ALLOC_BIAS_LOG "log"
786 #define VDEV_ALLOC_BIAS_SPECIAL "special"
787 #define VDEV_ALLOC_BIAS_DEDUP "dedup"
789 /* vdev initialize state */
790 #define VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET \
791 "com.delphix:next_offset_to_initialize"
792 #define VDEV_LEAF_ZAP_INITIALIZE_STATE \
793 "com.delphix:vdev_initialize_state"
794 #define VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME \
795 "com.delphix:vdev_initialize_action_time"
797 /* vdev TRIM state */
798 #define VDEV_LEAF_ZAP_TRIM_LAST_OFFSET \
799 "org.zfsonlinux:next_offset_to_trim"
800 #define VDEV_LEAF_ZAP_TRIM_STATE \
801 "org.zfsonlinux:vdev_trim_state"
802 #define VDEV_LEAF_ZAP_TRIM_ACTION_TIME \
803 "org.zfsonlinux:vdev_trim_action_time"
804 #define VDEV_LEAF_ZAP_TRIM_RATE \
805 "org.zfsonlinux:vdev_trim_rate"
806 #define VDEV_LEAF_ZAP_TRIM_PARTIAL \
807 "org.zfsonlinux:vdev_trim_partial"
808 #define VDEV_LEAF_ZAP_TRIM_SECURE \
809 "org.zfsonlinux:vdev_trim_secure"
812 * This is needed in userland to report the minimum necessary device size.
814 #define SPA_MINDEVSIZE (64ULL << 20)
817 * Set if the fragmentation has not yet been calculated. This can happen
818 * because the space maps have not been upgraded or the histogram feature
821 #define ZFS_FRAG_INVALID UINT64_MAX
824 * The location of the pool configuration repository, shared between kernel and
827 #define ZPOOL_CACHE "/etc/zfs/zpool.cache"
830 * vdev states are ordered from least to most healthy.
831 * A vdev that's CANT_OPEN or below is considered unusable.
833 typedef enum vdev_state
{
834 VDEV_STATE_UNKNOWN
= 0, /* Uninitialized vdev */
835 VDEV_STATE_CLOSED
, /* Not currently open */
836 VDEV_STATE_OFFLINE
, /* Not allowed to open */
837 VDEV_STATE_REMOVED
, /* Explicitly removed from system */
838 VDEV_STATE_CANT_OPEN
, /* Tried to open, but failed */
839 VDEV_STATE_FAULTED
, /* External request to fault device */
840 VDEV_STATE_DEGRADED
, /* Replicated vdev with unhealthy kids */
841 VDEV_STATE_HEALTHY
/* Presumed good */
844 #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY
847 * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field
848 * of the vdev stats structure uses these constants to distinguish why.
850 typedef enum vdev_aux
{
851 VDEV_AUX_NONE
, /* no error */
852 VDEV_AUX_OPEN_FAILED
, /* ldi_open_*() or vn_open() failed */
853 VDEV_AUX_CORRUPT_DATA
, /* bad label or disk contents */
854 VDEV_AUX_NO_REPLICAS
, /* insufficient number of replicas */
855 VDEV_AUX_BAD_GUID_SUM
, /* vdev guid sum doesn't match */
856 VDEV_AUX_TOO_SMALL
, /* vdev size is too small */
857 VDEV_AUX_BAD_LABEL
, /* the label is OK but invalid */
858 VDEV_AUX_VERSION_NEWER
, /* on-disk version is too new */
859 VDEV_AUX_VERSION_OLDER
, /* on-disk version is too old */
860 VDEV_AUX_UNSUP_FEAT
, /* unsupported features */
861 VDEV_AUX_SPARED
, /* hot spare used in another pool */
862 VDEV_AUX_ERR_EXCEEDED
, /* too many errors */
863 VDEV_AUX_IO_FAILURE
, /* experienced I/O failure */
864 VDEV_AUX_BAD_LOG
, /* cannot read log chain(s) */
865 VDEV_AUX_EXTERNAL
, /* external diagnosis or forced fault */
866 VDEV_AUX_SPLIT_POOL
, /* vdev was split off into another pool */
867 VDEV_AUX_BAD_ASHIFT
, /* vdev ashift is invalid */
868 VDEV_AUX_EXTERNAL_PERSIST
, /* persistent forced fault */
869 VDEV_AUX_ACTIVE
, /* vdev active on a different host */
870 VDEV_AUX_CHILDREN_OFFLINE
, /* all children are offline */
874 * pool state. The following states are written to disk as part of the normal
875 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
876 * states are software abstractions used at various levels to communicate
879 typedef enum pool_state
{
880 POOL_STATE_ACTIVE
= 0, /* In active use */
881 POOL_STATE_EXPORTED
, /* Explicitly exported */
882 POOL_STATE_DESTROYED
, /* Explicitly destroyed */
883 POOL_STATE_SPARE
, /* Reserved for hot spare use */
884 POOL_STATE_L2CACHE
, /* Level 2 ARC device */
885 POOL_STATE_UNINITIALIZED
, /* Internal spa_t state */
886 POOL_STATE_UNAVAIL
, /* Internal libzfs state */
887 POOL_STATE_POTENTIALLY_ACTIVE
/* Internal libzfs state */
891 * mmp state. The following states provide additional detail describing
892 * why a pool couldn't be safely imported.
894 typedef enum mmp_state
{
895 MMP_STATE_ACTIVE
= 0, /* In active use */
896 MMP_STATE_INACTIVE
, /* Inactive and safe to import */
897 MMP_STATE_NO_HOSTID
/* System hostid is not set */
903 typedef enum pool_scan_func
{
911 * Used to control scrub pause and resume.
913 typedef enum pool_scrub_cmd
{
914 POOL_SCRUB_NORMAL
= 0,
921 CS_CHECKPOINT_EXISTS
,
922 CS_CHECKPOINT_DISCARDING
,
924 } checkpoint_state_t
;
926 typedef struct pool_checkpoint_stat
{
927 uint64_t pcs_state
; /* checkpoint_state_t */
928 uint64_t pcs_start_time
; /* time checkpoint/discard started */
929 uint64_t pcs_space
; /* checkpointed space */
930 } pool_checkpoint_stat_t
;
933 * ZIO types. Needed to interpret vdev statistics below.
935 typedef enum zio_type
{
947 * Pool statistics. Note: all fields should be 64-bit because this
948 * is passed between kernel and userland as an nvlist uint64 array.
950 typedef struct pool_scan_stat
{
951 /* values stored on disk */
952 uint64_t pss_func
; /* pool_scan_func_t */
953 uint64_t pss_state
; /* dsl_scan_state_t */
954 uint64_t pss_start_time
; /* scan start time */
955 uint64_t pss_end_time
; /* scan end time */
956 uint64_t pss_to_examine
; /* total bytes to scan */
957 uint64_t pss_examined
; /* total bytes located by scanner */
958 uint64_t pss_to_process
; /* total bytes to process */
959 uint64_t pss_processed
; /* total processed bytes */
960 uint64_t pss_errors
; /* scan errors */
962 /* values not stored on disk */
963 uint64_t pss_pass_exam
; /* examined bytes per scan pass */
964 uint64_t pss_pass_start
; /* start time of a scan pass */
965 uint64_t pss_pass_scrub_pause
; /* pause time of a scrub pass */
966 /* cumulative time scrub spent paused, needed for rate calculation */
967 uint64_t pss_pass_scrub_spent_paused
;
968 uint64_t pss_pass_issued
; /* issued bytes per scan pass */
969 uint64_t pss_issued
; /* total bytes checked by scanner */
972 typedef struct pool_removal_stat
{
973 uint64_t prs_state
; /* dsl_scan_state_t */
974 uint64_t prs_removing_vdev
;
975 uint64_t prs_start_time
;
976 uint64_t prs_end_time
;
977 uint64_t prs_to_copy
; /* bytes that need to be copied */
978 uint64_t prs_copied
; /* bytes copied so far */
980 * bytes of memory used for indirect mappings.
981 * This includes all removed vdevs.
983 uint64_t prs_mapping_memory
;
984 } pool_removal_stat_t
;
986 typedef enum dsl_scan_state
{
995 * Errata described by https://zfsonlinux.org/msg/ZFS-8000-ER. The ordering
996 * of this enum must be maintained to ensure the errata identifiers map to
997 * the correct documentation. New errata may only be appended to the list
998 * and must contain corresponding documentation at the above link.
1000 typedef enum zpool_errata
{
1002 ZPOOL_ERRATA_ZOL_2094_SCRUB
,
1003 ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY
,
1004 ZPOOL_ERRATA_ZOL_6845_ENCRYPTION
,
1005 ZPOOL_ERRATA_ZOL_8308_ENCRYPTION
,
1009 * Vdev statistics. Note: all fields should be 64-bit because this
1010 * is passed between kernel and user land as an nvlist uint64 array.
1012 * The vs_ops[] and vs_bytes[] arrays must always be an array size of 6 in
1013 * order to keep subsequent members at their known fixed offsets. When
1014 * adding a new field it must be added to the end the structure.
1016 #define VS_ZIO_TYPES 6
1018 typedef struct vdev_stat
{
1019 hrtime_t vs_timestamp
; /* time since vdev load */
1020 uint64_t vs_state
; /* vdev state */
1021 uint64_t vs_aux
; /* see vdev_aux_t */
1022 uint64_t vs_alloc
; /* space allocated */
1023 uint64_t vs_space
; /* total capacity */
1024 uint64_t vs_dspace
; /* deflated capacity */
1025 uint64_t vs_rsize
; /* replaceable dev size */
1026 uint64_t vs_esize
; /* expandable dev size */
1027 uint64_t vs_ops
[VS_ZIO_TYPES
]; /* operation count */
1028 uint64_t vs_bytes
[VS_ZIO_TYPES
]; /* bytes read/written */
1029 uint64_t vs_read_errors
; /* read errors */
1030 uint64_t vs_write_errors
; /* write errors */
1031 uint64_t vs_checksum_errors
; /* checksum errors */
1032 uint64_t vs_initialize_errors
; /* initializing errors */
1033 uint64_t vs_self_healed
; /* self-healed bytes */
1034 uint64_t vs_scan_removing
; /* removing? */
1035 uint64_t vs_scan_processed
; /* scan processed bytes */
1036 uint64_t vs_fragmentation
; /* device fragmentation */
1037 uint64_t vs_initialize_bytes_done
; /* bytes initialized */
1038 uint64_t vs_initialize_bytes_est
; /* total bytes to initialize */
1039 uint64_t vs_initialize_state
; /* vdev_initializing_state_t */
1040 uint64_t vs_initialize_action_time
; /* time_t */
1041 uint64_t vs_checkpoint_space
; /* checkpoint-consumed space */
1042 uint64_t vs_resilver_deferred
; /* resilver deferred */
1043 uint64_t vs_slow_ios
; /* slow IOs */
1044 uint64_t vs_trim_errors
; /* trimming errors */
1045 uint64_t vs_trim_notsup
; /* supported by device */
1046 uint64_t vs_trim_bytes_done
; /* bytes trimmed */
1047 uint64_t vs_trim_bytes_est
; /* total bytes to trim */
1048 uint64_t vs_trim_state
; /* vdev_trim_state_t */
1049 uint64_t vs_trim_action_time
; /* time_t */
1055 * These are stats which aren't included in the original iostat output. For
1056 * convenience, they are grouped together in vdev_stat_ex, although each stat
1057 * is individually exported as an nvlist.
1059 typedef struct vdev_stat_ex
{
1060 /* Number of ZIOs issued to disk and waiting to finish */
1061 uint64_t vsx_active_queue
[ZIO_PRIORITY_NUM_QUEUEABLE
];
1063 /* Number of ZIOs pending to be issued to disk */
1064 uint64_t vsx_pend_queue
[ZIO_PRIORITY_NUM_QUEUEABLE
];
1067 * Below are the histograms for various latencies. Buckets are in
1068 * units of nanoseconds.
1072 * 2^37 nanoseconds = 134s. Timeouts will probably start kicking in
1075 #define VDEV_L_HISTO_BUCKETS 37 /* Latency histo buckets */
1076 #define VDEV_RQ_HISTO_BUCKETS 25 /* Request size histo buckets */
1078 /* Amount of time in ZIO queue (ns) */
1079 uint64_t vsx_queue_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
1080 [VDEV_L_HISTO_BUCKETS
];
1082 /* Total ZIO latency (ns). Includes queuing and disk access time */
1083 uint64_t vsx_total_histo
[ZIO_TYPES
][VDEV_L_HISTO_BUCKETS
];
1085 /* Amount of time to read/write the disk (ns) */
1086 uint64_t vsx_disk_histo
[ZIO_TYPES
][VDEV_L_HISTO_BUCKETS
];
1088 /* "lookup the bucket for a value" histogram macros */
1089 #define HISTO(val, buckets) (val != 0 ? MIN(highbit64(val) - 1, \
1091 #define L_HISTO(a) HISTO(a, VDEV_L_HISTO_BUCKETS)
1092 #define RQ_HISTO(a) HISTO(a, VDEV_RQ_HISTO_BUCKETS)
1094 /* Physical IO histogram */
1095 uint64_t vsx_ind_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
1096 [VDEV_RQ_HISTO_BUCKETS
];
1098 /* Delegated (aggregated) physical IO histogram */
1099 uint64_t vsx_agg_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
1100 [VDEV_RQ_HISTO_BUCKETS
];
1105 * Initialize functions.
1107 typedef enum pool_initialize_func
{
1108 POOL_INITIALIZE_START
,
1109 POOL_INITIALIZE_CANCEL
,
1110 POOL_INITIALIZE_SUSPEND
,
1111 POOL_INITIALIZE_FUNCS
1112 } pool_initialize_func_t
;
1117 typedef enum pool_trim_func
{
1125 * DDT statistics. Note: all fields should be 64-bit because this
1126 * is passed between kernel and userland as an nvlist uint64 array.
1128 typedef struct ddt_object
{
1129 uint64_t ddo_count
; /* number of elements in ddt */
1130 uint64_t ddo_dspace
; /* size of ddt on disk */
1131 uint64_t ddo_mspace
; /* size of ddt in-core */
1134 typedef struct ddt_stat
{
1135 uint64_t dds_blocks
; /* blocks */
1136 uint64_t dds_lsize
; /* logical size */
1137 uint64_t dds_psize
; /* physical size */
1138 uint64_t dds_dsize
; /* deflated allocated size */
1139 uint64_t dds_ref_blocks
; /* referenced blocks */
1140 uint64_t dds_ref_lsize
; /* referenced lsize * refcnt */
1141 uint64_t dds_ref_psize
; /* referenced psize * refcnt */
1142 uint64_t dds_ref_dsize
; /* referenced dsize * refcnt */
1145 typedef struct ddt_histogram
{
1146 ddt_stat_t ddh_stat
[64]; /* power-of-two histogram buckets */
1149 #define ZVOL_DRIVER "zvol"
1150 #define ZFS_DRIVER "zfs"
1151 #define ZFS_DEV "/dev/zfs"
1152 #define ZFS_SHARETAB "/etc/dfs/sharetab"
1154 #define ZFS_SUPER_MAGIC 0x2fc12fc1
1156 /* general zvol path */
1157 #define ZVOL_DIR "/dev"
1159 #define ZVOL_MAJOR 230
1160 #define ZVOL_MINOR_BITS 4
1161 #define ZVOL_MINOR_MASK ((1U << ZVOL_MINOR_BITS) - 1)
1162 #define ZVOL_MINORS (1 << 4)
1163 #define ZVOL_DEV_NAME "zd"
1165 #define ZVOL_PROP_NAME "name"
1166 #define ZVOL_DEFAULT_BLOCKSIZE 8192
1169 VDEV_INITIALIZE_NONE
,
1170 VDEV_INITIALIZE_ACTIVE
,
1171 VDEV_INITIALIZE_CANCELED
,
1172 VDEV_INITIALIZE_SUSPENDED
,
1173 VDEV_INITIALIZE_COMPLETE
1174 } vdev_initializing_state_t
;
1180 VDEV_TRIM_SUSPENDED
,
1182 } vdev_trim_state_t
;
1185 * nvlist name constants. Facilitate restricting snapshot iteration range for
1186 * the "list next snapshot" ioctl
1188 #define SNAP_ITER_MIN_TXG "snap_iter_min_txg"
1189 #define SNAP_ITER_MAX_TXG "snap_iter_max_txg"
1192 * /dev/zfs ioctl numbers.
1194 * These numbers cannot change over time. New ioctl numbers must be appended.
1196 typedef enum zfs_ioc
{
1198 * Core features - 81/128 numbers reserved.
1203 ZFS_IOC_FIRST
= ('Z' << 8),
1205 ZFS_IOC
= ZFS_IOC_FIRST
,
1206 ZFS_IOC_POOL_CREATE
= ZFS_IOC_FIRST
, /* 0x5a00 */
1207 ZFS_IOC_POOL_DESTROY
, /* 0x5a01 */
1208 ZFS_IOC_POOL_IMPORT
, /* 0x5a02 */
1209 ZFS_IOC_POOL_EXPORT
, /* 0x5a03 */
1210 ZFS_IOC_POOL_CONFIGS
, /* 0x5a04 */
1211 ZFS_IOC_POOL_STATS
, /* 0x5a05 */
1212 ZFS_IOC_POOL_TRYIMPORT
, /* 0x5a06 */
1213 ZFS_IOC_POOL_SCAN
, /* 0x5a07 */
1214 ZFS_IOC_POOL_FREEZE
, /* 0x5a08 */
1215 ZFS_IOC_POOL_UPGRADE
, /* 0x5a09 */
1216 ZFS_IOC_POOL_GET_HISTORY
, /* 0x5a0a */
1217 ZFS_IOC_VDEV_ADD
, /* 0x5a0b */
1218 ZFS_IOC_VDEV_REMOVE
, /* 0x5a0c */
1219 ZFS_IOC_VDEV_SET_STATE
, /* 0x5a0d */
1220 ZFS_IOC_VDEV_ATTACH
, /* 0x5a0e */
1221 ZFS_IOC_VDEV_DETACH
, /* 0x5a0f */
1222 ZFS_IOC_VDEV_SETPATH
, /* 0x5a10 */
1223 ZFS_IOC_VDEV_SETFRU
, /* 0x5a11 */
1224 ZFS_IOC_OBJSET_STATS
, /* 0x5a12 */
1225 ZFS_IOC_OBJSET_ZPLPROPS
, /* 0x5a13 */
1226 ZFS_IOC_DATASET_LIST_NEXT
, /* 0x5a14 */
1227 ZFS_IOC_SNAPSHOT_LIST_NEXT
, /* 0x5a15 */
1228 ZFS_IOC_SET_PROP
, /* 0x5a16 */
1229 ZFS_IOC_CREATE
, /* 0x5a17 */
1230 ZFS_IOC_DESTROY
, /* 0x5a18 */
1231 ZFS_IOC_ROLLBACK
, /* 0x5a19 */
1232 ZFS_IOC_RENAME
, /* 0x5a1a */
1233 ZFS_IOC_RECV
, /* 0x5a1b */
1234 ZFS_IOC_SEND
, /* 0x5a1c */
1235 ZFS_IOC_INJECT_FAULT
, /* 0x5a1d */
1236 ZFS_IOC_CLEAR_FAULT
, /* 0x5a1e */
1237 ZFS_IOC_INJECT_LIST_NEXT
, /* 0x5a1f */
1238 ZFS_IOC_ERROR_LOG
, /* 0x5a20 */
1239 ZFS_IOC_CLEAR
, /* 0x5a21 */
1240 ZFS_IOC_PROMOTE
, /* 0x5a22 */
1241 ZFS_IOC_SNAPSHOT
, /* 0x5a23 */
1242 ZFS_IOC_DSOBJ_TO_DSNAME
, /* 0x5a24 */
1243 ZFS_IOC_OBJ_TO_PATH
, /* 0x5a25 */
1244 ZFS_IOC_POOL_SET_PROPS
, /* 0x5a26 */
1245 ZFS_IOC_POOL_GET_PROPS
, /* 0x5a27 */
1246 ZFS_IOC_SET_FSACL
, /* 0x5a28 */
1247 ZFS_IOC_GET_FSACL
, /* 0x5a29 */
1248 ZFS_IOC_SHARE
, /* 0x5a2a */
1249 ZFS_IOC_INHERIT_PROP
, /* 0x5a2b */
1250 ZFS_IOC_SMB_ACL
, /* 0x5a2c */
1251 ZFS_IOC_USERSPACE_ONE
, /* 0x5a2d */
1252 ZFS_IOC_USERSPACE_MANY
, /* 0x5a2e */
1253 ZFS_IOC_USERSPACE_UPGRADE
, /* 0x5a2f */
1254 ZFS_IOC_HOLD
, /* 0x5a30 */
1255 ZFS_IOC_RELEASE
, /* 0x5a31 */
1256 ZFS_IOC_GET_HOLDS
, /* 0x5a32 */
1257 ZFS_IOC_OBJSET_RECVD_PROPS
, /* 0x5a33 */
1258 ZFS_IOC_VDEV_SPLIT
, /* 0x5a34 */
1259 ZFS_IOC_NEXT_OBJ
, /* 0x5a35 */
1260 ZFS_IOC_DIFF
, /* 0x5a36 */
1261 ZFS_IOC_TMP_SNAPSHOT
, /* 0x5a37 */
1262 ZFS_IOC_OBJ_TO_STATS
, /* 0x5a38 */
1263 ZFS_IOC_SPACE_WRITTEN
, /* 0x5a39 */
1264 ZFS_IOC_SPACE_SNAPS
, /* 0x5a3a */
1265 ZFS_IOC_DESTROY_SNAPS
, /* 0x5a3b */
1266 ZFS_IOC_POOL_REGUID
, /* 0x5a3c */
1267 ZFS_IOC_POOL_REOPEN
, /* 0x5a3d */
1268 ZFS_IOC_SEND_PROGRESS
, /* 0x5a3e */
1269 ZFS_IOC_LOG_HISTORY
, /* 0x5a3f */
1270 ZFS_IOC_SEND_NEW
, /* 0x5a40 */
1271 ZFS_IOC_SEND_SPACE
, /* 0x5a41 */
1272 ZFS_IOC_CLONE
, /* 0x5a42 */
1273 ZFS_IOC_BOOKMARK
, /* 0x5a43 */
1274 ZFS_IOC_GET_BOOKMARKS
, /* 0x5a44 */
1275 ZFS_IOC_DESTROY_BOOKMARKS
, /* 0x5a45 */
1276 ZFS_IOC_RECV_NEW
, /* 0x5a46 */
1277 ZFS_IOC_POOL_SYNC
, /* 0x5a47 */
1278 ZFS_IOC_CHANNEL_PROGRAM
, /* 0x5a48 */
1279 ZFS_IOC_LOAD_KEY
, /* 0x5a49 */
1280 ZFS_IOC_UNLOAD_KEY
, /* 0x5a4a */
1281 ZFS_IOC_CHANGE_KEY
, /* 0x5a4b */
1282 ZFS_IOC_REMAP
, /* 0x5a4c */
1283 ZFS_IOC_POOL_CHECKPOINT
, /* 0x5a4d */
1284 ZFS_IOC_POOL_DISCARD_CHECKPOINT
, /* 0x5a4e */
1285 ZFS_IOC_POOL_INITIALIZE
, /* 0x5a4f */
1286 ZFS_IOC_POOL_TRIM
, /* 0x5a50 */
1287 ZFS_IOC_REDACT
, /* 0x5a51 */
1288 ZFS_IOC_GET_BOOKMARK_PROPS
, /* 0x5a52 */
1289 ZFS_IOC_WAIT
, /* 0x5a53 */
1290 ZFS_IOC_WAIT_FS
, /* 0x5a54 */
1293 * Per-platform (Optional) - 8/128 numbers reserved.
1295 ZFS_IOC_PLATFORM
= ZFS_IOC_FIRST
+ 0x80,
1296 ZFS_IOC_EVENTS_NEXT
, /* 0x81 (Linux) */
1297 ZFS_IOC_EVENTS_CLEAR
, /* 0x82 (Linux) */
1298 ZFS_IOC_EVENTS_SEEK
, /* 0x83 (Linux) */
1299 ZFS_IOC_NEXTBOOT
, /* 0x84 (FreeBSD) */
1300 ZFS_IOC_JAIL
, /* 0x85 (FreeBSD) */
1301 ZFS_IOC_UNJAIL
, /* 0x86 (FreeBSD) */
1302 ZFS_IOC_SET_BOOTENV
, /* 0x87 (Linux) */
1303 ZFS_IOC_GET_BOOTENV
, /* 0x88 (Linux) */
1308 * zvol ioctl to get dataset name
1310 #define BLKZNAME _IOR(0x12, 125, char[ZFS_MAX_DATASET_NAME_LEN])
1313 * ZFS-specific error codes used for returning descriptive errors
1314 * to the userland through zfs ioctls.
1316 * The enum implicitly includes all the error codes from errno.h.
1317 * New code should use and extend this enum for errors that are
1318 * not described precisely by generic errno codes.
1320 * These numbers should not change over time. New entries should be appended.
1322 * (Keep in sync with contrib/pyzfs/libzfs_core/_constants.py)
1325 ZFS_ERR_CHECKPOINT_EXISTS
= 1024,
1326 ZFS_ERR_DISCARDING_CHECKPOINT
,
1327 ZFS_ERR_NO_CHECKPOINT
,
1328 ZFS_ERR_DEVRM_IN_PROGRESS
,
1329 ZFS_ERR_VDEV_TOO_BIG
,
1330 ZFS_ERR_IOC_CMD_UNAVAIL
,
1331 ZFS_ERR_IOC_ARG_UNAVAIL
,
1332 ZFS_ERR_IOC_ARG_REQUIRED
,
1333 ZFS_ERR_IOC_ARG_BADTYPE
,
1334 ZFS_ERR_WRONG_PARENT
,
1335 ZFS_ERR_FROM_IVSET_GUID_MISSING
,
1336 ZFS_ERR_FROM_IVSET_GUID_MISMATCH
,
1337 ZFS_ERR_SPILL_BLOCK_FLAG_MISSING
,
1338 ZFS_ERR_UNKNOWN_SEND_STREAM_FEATURE
,
1339 ZFS_ERR_EXPORT_IN_PROGRESS
,
1340 ZFS_ERR_BOOKMARK_SOURCE_NOT_ANCESTOR
,
1341 ZFS_ERR_STREAM_TRUNCATED
,
1345 * Internal SPA load state. Used by FMA diagnosis engine.
1348 SPA_LOAD_NONE
, /* no load in progress */
1349 SPA_LOAD_OPEN
, /* normal open */
1350 SPA_LOAD_IMPORT
, /* import in progress */
1351 SPA_LOAD_TRYIMPORT
, /* tryimport in progress */
1352 SPA_LOAD_RECOVER
, /* recovery requested */
1353 SPA_LOAD_ERROR
, /* load failed */
1354 SPA_LOAD_CREATE
/* creation in progress */
1358 ZPOOL_WAIT_CKPT_DISCARD
,
1360 ZPOOL_WAIT_INITIALIZE
,
1363 ZPOOL_WAIT_RESILVER
,
1366 ZPOOL_WAIT_NUM_ACTIVITIES
1367 } zpool_wait_activity_t
;
1371 ZFS_WAIT_NUM_ACTIVITIES
1372 } zfs_wait_activity_t
;
1375 * Bookmark name values.
1377 #define ZPOOL_ERR_LIST "error list"
1378 #define ZPOOL_ERR_DATASET "dataset"
1379 #define ZPOOL_ERR_OBJECT "object"
1381 #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1)
1384 * The following are names used in the nvlist describing
1385 * the pool's history log.
1387 #define ZPOOL_HIST_RECORD "history record"
1388 #define ZPOOL_HIST_TIME "history time"
1389 #define ZPOOL_HIST_CMD "history command"
1390 #define ZPOOL_HIST_WHO "history who"
1391 #define ZPOOL_HIST_ZONE "history zone"
1392 #define ZPOOL_HIST_HOST "history hostname"
1393 #define ZPOOL_HIST_TXG "history txg"
1394 #define ZPOOL_HIST_INT_EVENT "history internal event"
1395 #define ZPOOL_HIST_INT_STR "history internal str"
1396 #define ZPOOL_HIST_INT_NAME "internal_name"
1397 #define ZPOOL_HIST_IOCTL "ioctl"
1398 #define ZPOOL_HIST_INPUT_NVL "in_nvl"
1399 #define ZPOOL_HIST_OUTPUT_NVL "out_nvl"
1400 #define ZPOOL_HIST_DSNAME "dsname"
1401 #define ZPOOL_HIST_DSID "dsid"
1402 #define ZPOOL_HIST_ERRNO "errno"
1405 * Special nvlist name that will not have its args recorded in the pool's
1408 #define ZPOOL_HIDDEN_ARGS "hidden_args"
1411 * The following are names used when invoking ZFS_IOC_POOL_INITIALIZE.
1413 #define ZPOOL_INITIALIZE_COMMAND "initialize_command"
1414 #define ZPOOL_INITIALIZE_VDEVS "initialize_vdevs"
1417 * The following are names used when invoking ZFS_IOC_POOL_TRIM.
1419 #define ZPOOL_TRIM_COMMAND "trim_command"
1420 #define ZPOOL_TRIM_VDEVS "trim_vdevs"
1421 #define ZPOOL_TRIM_RATE "trim_rate"
1422 #define ZPOOL_TRIM_SECURE "trim_secure"
1425 * The following are names used when invoking ZFS_IOC_POOL_WAIT.
1427 #define ZPOOL_WAIT_ACTIVITY "wait_activity"
1428 #define ZPOOL_WAIT_TAG "wait_tag"
1429 #define ZPOOL_WAIT_WAITED "wait_waited"
1432 * The following are names used when invoking ZFS_IOC_WAIT_FS.
1434 #define ZFS_WAIT_ACTIVITY "wait_activity"
1435 #define ZFS_WAIT_WAITED "wait_waited"
1438 * Flags for ZFS_IOC_VDEV_SET_STATE
1440 #define ZFS_ONLINE_CHECKREMOVE 0x1
1441 #define ZFS_ONLINE_UNSPARE 0x2
1442 #define ZFS_ONLINE_FORCEFAULT 0x4
1443 #define ZFS_ONLINE_EXPAND 0x8
1444 #define ZFS_OFFLINE_TEMPORARY 0x1
1447 * Flags for ZFS_IOC_POOL_IMPORT
1449 #define ZFS_IMPORT_NORMAL 0x0
1450 #define ZFS_IMPORT_VERBATIM 0x1
1451 #define ZFS_IMPORT_ANY_HOST 0x2
1452 #define ZFS_IMPORT_MISSING_LOG 0x4
1453 #define ZFS_IMPORT_ONLY 0x8
1454 #define ZFS_IMPORT_TEMP_NAME 0x10
1455 #define ZFS_IMPORT_SKIP_MMP 0x20
1456 #define ZFS_IMPORT_LOAD_KEYS 0x40
1457 #define ZFS_IMPORT_CHECKPOINT 0x80
1460 * Channel program argument/return nvlist keys and defaults.
1462 #define ZCP_ARG_PROGRAM "program"
1463 #define ZCP_ARG_ARGLIST "arg"
1464 #define ZCP_ARG_SYNC "sync"
1465 #define ZCP_ARG_INSTRLIMIT "instrlimit"
1466 #define ZCP_ARG_MEMLIMIT "memlimit"
1468 #define ZCP_ARG_CLIARGV "argv"
1470 #define ZCP_RET_ERROR "error"
1471 #define ZCP_RET_RETURN "return"
1473 #define ZCP_DEFAULT_INSTRLIMIT (10 * 1000 * 1000)
1474 #define ZCP_MAX_INSTRLIMIT (10 * ZCP_DEFAULT_INSTRLIMIT)
1475 #define ZCP_DEFAULT_MEMLIMIT (10 * 1024 * 1024)
1476 #define ZCP_MAX_MEMLIMIT (10 * ZCP_DEFAULT_MEMLIMIT)
1479 * Sysevent payload members. ZFS will generate the following sysevents with the
1482 * ESC_ZFS_RESILVER_START
1483 * ESC_ZFS_RESILVER_END
1484 * ESC_ZFS_POOL_DESTROY
1485 * ESC_ZFS_POOL_REGUID
1487 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1488 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1490 * ESC_ZFS_VDEV_REMOVE
1491 * ESC_ZFS_VDEV_CLEAR
1492 * ESC_ZFS_VDEV_CHECK
1494 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1495 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1496 * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional)
1497 * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64
1499 * ESC_ZFS_HISTORY_EVENT
1501 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1502 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1503 * ZFS_EV_HIST_TIME DATA_TYPE_UINT64 (optional)
1504 * ZFS_EV_HIST_CMD DATA_TYPE_STRING (optional)
1505 * ZFS_EV_HIST_WHO DATA_TYPE_UINT64 (optional)
1506 * ZFS_EV_HIST_ZONE DATA_TYPE_STRING (optional)
1507 * ZFS_EV_HIST_HOST DATA_TYPE_STRING (optional)
1508 * ZFS_EV_HIST_TXG DATA_TYPE_UINT64 (optional)
1509 * ZFS_EV_HIST_INT_EVENT DATA_TYPE_UINT64 (optional)
1510 * ZFS_EV_HIST_INT_STR DATA_TYPE_STRING (optional)
1511 * ZFS_EV_HIST_INT_NAME DATA_TYPE_STRING (optional)
1512 * ZFS_EV_HIST_IOCTL DATA_TYPE_STRING (optional)
1513 * ZFS_EV_HIST_DSNAME DATA_TYPE_STRING (optional)
1514 * ZFS_EV_HIST_DSID DATA_TYPE_UINT64 (optional)
1516 * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the
1517 * history log nvlist. The keynames will be free of any spaces or other
1518 * characters that could be potentially unexpected to consumers of the
1521 #define ZFS_EV_POOL_NAME "pool_name"
1522 #define ZFS_EV_POOL_GUID "pool_guid"
1523 #define ZFS_EV_VDEV_PATH "vdev_path"
1524 #define ZFS_EV_VDEV_GUID "vdev_guid"
1525 #define ZFS_EV_HIST_TIME "history_time"
1526 #define ZFS_EV_HIST_CMD "history_command"
1527 #define ZFS_EV_HIST_WHO "history_who"
1528 #define ZFS_EV_HIST_ZONE "history_zone"
1529 #define ZFS_EV_HIST_HOST "history_hostname"
1530 #define ZFS_EV_HIST_TXG "history_txg"
1531 #define ZFS_EV_HIST_INT_EVENT "history_internal_event"
1532 #define ZFS_EV_HIST_INT_STR "history_internal_str"
1533 #define ZFS_EV_HIST_INT_NAME "history_internal_name"
1534 #define ZFS_EV_HIST_IOCTL "history_ioctl"
1535 #define ZFS_EV_HIST_DSNAME "history_dsname"
1536 #define ZFS_EV_HIST_DSID "history_dsid"
1542 #endif /* _SYS_FS_ZFS_H */