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.
30 * Portions Copyright 2010 Robert Milkowski
31 * Copyright (c) 2021, Colm Buckley <colm@tuatha.org>
35 #define _SYS_FS_ZFS_H extern __attribute__((visibility("default")))
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),
58 ZFS_TYPE_VDEV
= (1 << 5),
62 * NB: lzc_dataset_type should be updated whenever a new objset type is added,
63 * if it represents a real type of a dataset that can be created from userland.
65 typedef enum dmu_objset_type
{
70 DMU_OST_OTHER
, /* For testing only! */
71 DMU_OST_ANY
, /* Be careful! */
75 #define ZFS_TYPE_DATASET \
76 (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
79 * All of these include the terminating NUL byte.
81 #define ZAP_MAXNAMELEN 256
82 #define ZAP_MAXVALUELEN (1024 * 8)
83 #define ZAP_OLDMAXVALUELEN 1024
84 #define ZFS_MAX_DATASET_NAME_LEN 256
87 * Dataset properties are identified by these constants and must be added to
88 * the end of this list to ensure that external consumers are not affected
89 * by the change. If you make any changes to this list, be sure to update
90 * the property table in module/zcommon/zfs_prop.c.
100 ZFS_PROP_COMPRESSRATIO
,
104 ZFS_PROP_RESERVATION
,
106 ZFS_PROP_VOLBLOCKSIZE
,
111 ZFS_PROP_COMPRESSION
,
122 ZFS_PROP_NAME
, /* not exposed to the user */
124 ZFS_PROP_ISCSIOPTIONS
, /* not exposed to the user */
126 ZFS_PROP_NUMCLONES
, /* not exposed to the user */
136 ZFS_PROP_REFRESERVATION
,
138 ZFS_PROP_PRIMARYCACHE
,
139 ZFS_PROP_SECONDARYCACHE
,
143 ZFS_PROP_USEDREFRESERV
,
144 ZFS_PROP_USERACCOUNTING
, /* not exposed to the user */
145 ZFS_PROP_STMF_SHAREINFO
, /* not exposed to the user */
146 ZFS_PROP_DEFER_DESTROY
,
149 ZFS_PROP_UNIQUE
, /* not exposed to the user */
158 ZFS_PROP_LOGICALUSED
,
159 ZFS_PROP_LOGICALREFERENCED
,
160 ZFS_PROP_INCONSISTENT
, /* not exposed to the user */
162 ZFS_PROP_FILESYSTEM_LIMIT
,
163 ZFS_PROP_SNAPSHOT_LIMIT
,
164 ZFS_PROP_FILESYSTEM_COUNT
,
165 ZFS_PROP_SNAPSHOT_COUNT
,
168 ZFS_PROP_SELINUX_CONTEXT
,
169 ZFS_PROP_SELINUX_FSCONTEXT
,
170 ZFS_PROP_SELINUX_DEFCONTEXT
,
171 ZFS_PROP_SELINUX_ROOTCONTEXT
,
173 ZFS_PROP_REDUNDANT_METADATA
,
176 ZFS_PROP_RECEIVE_RESUME_TOKEN
,
178 ZFS_PROP_KEYLOCATION
,
180 ZFS_PROP_PBKDF2_SALT
,
181 ZFS_PROP_PBKDF2_ITERS
,
182 ZFS_PROP_ENCRYPTION_ROOT
,
185 ZFS_PROP_REMAPTXG
, /* obsolete - no longer used */
186 ZFS_PROP_SPECIAL_SMALL_BLOCKS
,
187 ZFS_PROP_IVSET_GUID
, /* not exposed to the user */
189 ZFS_PROP_REDACT_SNAPS
,
198 ZFS_PROP_USEROBJUSED
,
199 ZFS_PROP_USEROBJQUOTA
,
200 ZFS_PROP_GROUPOBJUSED
,
201 ZFS_PROP_GROUPOBJQUOTA
,
202 ZFS_PROP_PROJECTUSED
,
203 ZFS_PROP_PROJECTQUOTA
,
204 ZFS_PROP_PROJECTOBJUSED
,
205 ZFS_PROP_PROJECTOBJQUOTA
,
206 ZFS_NUM_USERQUOTA_PROPS
207 } zfs_userquota_prop_t
;
209 _SYS_FS_ZFS_H
const char *const zfs_userquota_prop_prefixes
[
210 ZFS_NUM_USERQUOTA_PROPS
];
213 * Pool properties are identified by these constants and must be added to the
214 * end of this list to ensure that external consumers are not affected
215 * by the change. Properties must be registered in zfs_prop_init().
218 ZPOOL_PROP_INVAL
= -1,
227 ZPOOL_PROP_DELEGATION
,
228 ZPOOL_PROP_AUTOREPLACE
,
229 ZPOOL_PROP_CACHEFILE
,
230 ZPOOL_PROP_FAILUREMODE
,
231 ZPOOL_PROP_LISTSNAPS
,
232 ZPOOL_PROP_AUTOEXPAND
,
233 ZPOOL_PROP_DEDUPDITTO
,
234 ZPOOL_PROP_DEDUPRATIO
,
236 ZPOOL_PROP_ALLOCATED
,
242 ZPOOL_PROP_FRAGMENTATION
,
244 ZPOOL_PROP_MAXBLOCKSIZE
,
246 ZPOOL_PROP_MAXDNODESIZE
,
247 ZPOOL_PROP_MULTIHOST
,
248 ZPOOL_PROP_CHECKPOINT
,
249 ZPOOL_PROP_LOAD_GUID
,
251 ZPOOL_PROP_COMPATIBILITY
,
255 /* Small enough to not hog a whole line of printout in zpool(8). */
256 #define ZPROP_MAX_COMMENT 32
257 #define ZPROP_BOOLEAN_NA 2
259 #define ZPROP_VALUE "value"
260 #define ZPROP_SOURCE "source"
263 ZPROP_SRC_NONE
= 0x1,
264 ZPROP_SRC_DEFAULT
= 0x2,
265 ZPROP_SRC_TEMPORARY
= 0x4,
266 ZPROP_SRC_LOCAL
= 0x8,
267 ZPROP_SRC_INHERITED
= 0x10,
268 ZPROP_SRC_RECEIVED
= 0x20
271 #define ZPROP_SRC_ALL 0x3f
273 #define ZPROP_SOURCE_VAL_RECVD "$recvd"
274 #define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS"
277 * Dataset flag implemented as a special entry in the props zap object
278 * indicating that the dataset has received properties on or after
279 * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
280 * just as it did in earlier versions, and thereafter, local properties are
283 #define ZPROP_HAS_RECVD "$hasrecvd"
286 ZPROP_ERR_NOCLEAR
= 0x1, /* failure to clear existing props */
287 ZPROP_ERR_NORESTORE
= 0x2 /* failure to restore props on error */
290 typedef int (*zprop_func
)(int, void *);
293 * Properties to be set on the root file system of a new pool
294 * are stuffed into their own nvlist, which is then included in
295 * the properties nvlist with the pool properties.
297 #define ZPOOL_ROOTFS_PROPS "root-props-nvl"
300 * Length of 'written@' and 'written#'
302 #define ZFS_WRITTEN_PROP_PREFIX_LEN 8
305 * VDEV properties are identified by these constants and must be added to the
306 * end of this list to ensure that external consumers are not affected
307 * by the change. If you make any changes to this list, be sure to update
308 * the property table in usr/src/common/zfs/zpool_prop.c.
311 VDEV_PROP_INVAL
= -1,
312 #define VDEV_PROP_USER VDEV_PROP_INVAL
325 VDEV_PROP_FRAGMENTATION
,
335 VDEV_PROP_NUMCHILDREN
,
336 VDEV_PROP_READ_ERRORS
,
337 VDEV_PROP_WRITE_ERRORS
,
338 VDEV_PROP_CHECKSUM_ERRORS
,
339 VDEV_PROP_INITIALIZE_ERRORS
,
346 VDEV_PROP_BYTES_NULL
,
347 VDEV_PROP_BYTES_READ
,
348 VDEV_PROP_BYTES_WRITE
,
349 VDEV_PROP_BYTES_FREE
,
350 VDEV_PROP_BYTES_CLAIM
,
351 VDEV_PROP_BYTES_TRIM
,
353 VDEV_PROP_ALLOCATING
,
358 * Dataset property functions shared between libzfs and kernel.
360 _SYS_FS_ZFS_H
const char *zfs_prop_default_string(zfs_prop_t
);
361 _SYS_FS_ZFS_H
uint64_t zfs_prop_default_numeric(zfs_prop_t
);
362 _SYS_FS_ZFS_H boolean_t
zfs_prop_readonly(zfs_prop_t
);
363 _SYS_FS_ZFS_H boolean_t
zfs_prop_visible(zfs_prop_t prop
);
364 _SYS_FS_ZFS_H boolean_t
zfs_prop_inheritable(zfs_prop_t
);
365 _SYS_FS_ZFS_H boolean_t
zfs_prop_setonce(zfs_prop_t
);
366 _SYS_FS_ZFS_H boolean_t
zfs_prop_encryption_key_param(zfs_prop_t
);
367 _SYS_FS_ZFS_H boolean_t
zfs_prop_valid_keylocation(const char *, boolean_t
);
368 _SYS_FS_ZFS_H
const char *zfs_prop_to_name(zfs_prop_t
);
369 _SYS_FS_ZFS_H zfs_prop_t
zfs_name_to_prop(const char *);
370 _SYS_FS_ZFS_H boolean_t
zfs_prop_user(const char *);
371 _SYS_FS_ZFS_H boolean_t
zfs_prop_userquota(const char *);
372 _SYS_FS_ZFS_H boolean_t
zfs_prop_written(const char *);
373 _SYS_FS_ZFS_H
int zfs_prop_index_to_string(zfs_prop_t
, uint64_t, const char **);
374 _SYS_FS_ZFS_H
int zfs_prop_string_to_index(zfs_prop_t
, const char *,
376 _SYS_FS_ZFS_H
uint64_t zfs_prop_random_value(zfs_prop_t
, uint64_t seed
);
377 _SYS_FS_ZFS_H boolean_t
zfs_prop_valid_for_type(int, zfs_type_t
, boolean_t
);
380 * Pool property functions shared between libzfs and kernel.
382 _SYS_FS_ZFS_H zpool_prop_t
zpool_name_to_prop(const char *);
383 _SYS_FS_ZFS_H
const char *zpool_prop_to_name(zpool_prop_t
);
384 _SYS_FS_ZFS_H
const char *zpool_prop_default_string(zpool_prop_t
);
385 _SYS_FS_ZFS_H
uint64_t zpool_prop_default_numeric(zpool_prop_t
);
386 _SYS_FS_ZFS_H boolean_t
zpool_prop_readonly(zpool_prop_t
);
387 _SYS_FS_ZFS_H boolean_t
zpool_prop_setonce(zpool_prop_t
);
388 _SYS_FS_ZFS_H boolean_t
zpool_prop_feature(const char *);
389 _SYS_FS_ZFS_H boolean_t
zpool_prop_unsupported(const char *);
390 _SYS_FS_ZFS_H
int zpool_prop_index_to_string(zpool_prop_t
, uint64_t,
392 _SYS_FS_ZFS_H
int zpool_prop_string_to_index(zpool_prop_t
, const char *,
394 _SYS_FS_ZFS_H
uint64_t zpool_prop_random_value(zpool_prop_t
, uint64_t seed
);
397 * VDEV property functions shared between libzfs and kernel.
399 _SYS_FS_ZFS_H vdev_prop_t
vdev_name_to_prop(const char *);
400 _SYS_FS_ZFS_H boolean_t
vdev_prop_user(const char *name
);
401 _SYS_FS_ZFS_H
const char *vdev_prop_to_name(vdev_prop_t
);
402 _SYS_FS_ZFS_H
const char *vdev_prop_default_string(vdev_prop_t
);
403 _SYS_FS_ZFS_H
uint64_t vdev_prop_default_numeric(vdev_prop_t
);
404 _SYS_FS_ZFS_H boolean_t
vdev_prop_readonly(vdev_prop_t prop
);
405 _SYS_FS_ZFS_H
int vdev_prop_index_to_string(vdev_prop_t
, uint64_t,
407 _SYS_FS_ZFS_H
int vdev_prop_string_to_index(vdev_prop_t
, const char *,
409 _SYS_FS_ZFS_H boolean_t
zpool_prop_vdev(const char *name
);
410 _SYS_FS_ZFS_H
uint64_t vdev_prop_random_value(vdev_prop_t prop
, uint64_t seed
);
413 * Definitions for the Delegation.
416 ZFS_DELEG_WHO_UNKNOWN
= 0,
417 ZFS_DELEG_USER
= 'u',
418 ZFS_DELEG_USER_SETS
= 'U',
419 ZFS_DELEG_GROUP
= 'g',
420 ZFS_DELEG_GROUP_SETS
= 'G',
421 ZFS_DELEG_EVERYONE
= 'e',
422 ZFS_DELEG_EVERYONE_SETS
= 'E',
423 ZFS_DELEG_CREATE
= 'c',
424 ZFS_DELEG_CREATE_SETS
= 'C',
425 ZFS_DELEG_NAMED_SET
= 's',
426 ZFS_DELEG_NAMED_SET_SETS
= 'S'
427 } zfs_deleg_who_type_t
;
431 ZFS_DELEG_PERM_LOCAL
= 1,
432 ZFS_DELEG_PERM_DESCENDENT
= 2,
433 ZFS_DELEG_PERM_LOCALDESCENDENT
= 3,
434 ZFS_DELEG_PERM_CREATE
= 4
435 } zfs_deleg_inherit_t
;
437 #define ZFS_DELEG_PERM_UID "uid"
438 #define ZFS_DELEG_PERM_GID "gid"
439 #define ZFS_DELEG_PERM_GROUPS "groups"
441 #define ZFS_MLSLABEL_DEFAULT "none"
443 #define ZFS_SMB_ACL_SRC "src"
444 #define ZFS_SMB_ACL_TARGET "target"
447 ZFS_CANMOUNT_OFF
= 0,
449 ZFS_CANMOUNT_NOAUTO
= 2
450 } zfs_canmount_type_t
;
453 ZFS_LOGBIAS_LATENCY
= 0,
454 ZFS_LOGBIAS_THROUGHPUT
= 1
457 typedef enum zfs_share_op
{
464 typedef enum zfs_smb_acl_op
{
471 typedef enum zfs_cache_type
{
473 ZFS_CACHE_METADATA
= 1,
478 ZFS_SYNC_STANDARD
= 0,
480 ZFS_SYNC_DISABLED
= 2
490 ZFS_DNSIZE_LEGACY
= 0,
492 ZFS_DNSIZE_1K
= 1024,
493 ZFS_DNSIZE_2K
= 2048,
494 ZFS_DNSIZE_4K
= 4096,
495 ZFS_DNSIZE_8K
= 8192,
496 ZFS_DNSIZE_16K
= 16384
500 ZFS_REDUNDANT_METADATA_ALL
,
501 ZFS_REDUNDANT_METADATA_MOST
502 } zfs_redundant_metadata_type_t
;
505 ZFS_VOLMODE_DEFAULT
= 0,
506 ZFS_VOLMODE_GEOM
= 1,
511 typedef enum zfs_keystatus
{
512 ZFS_KEYSTATUS_NONE
= 0,
513 ZFS_KEYSTATUS_UNAVAILABLE
,
514 ZFS_KEYSTATUS_AVAILABLE
,
517 typedef enum zfs_keyformat
{
518 ZFS_KEYFORMAT_NONE
= 0,
521 ZFS_KEYFORMAT_PASSPHRASE
,
522 ZFS_KEYFORMAT_FORMATS
525 typedef enum zfs_key_location
{
526 ZFS_KEYLOCATION_NONE
= 0,
527 ZFS_KEYLOCATION_PROMPT
,
529 ZFS_KEYLOCATION_LOCATIONS
532 #define DEFAULT_PBKDF2_ITERATIONS 350000
533 #define MIN_PBKDF2_ITERATIONS 100000
536 * On-disk version number.
538 #define SPA_VERSION_1 1ULL
539 #define SPA_VERSION_2 2ULL
540 #define SPA_VERSION_3 3ULL
541 #define SPA_VERSION_4 4ULL
542 #define SPA_VERSION_5 5ULL
543 #define SPA_VERSION_6 6ULL
544 #define SPA_VERSION_7 7ULL
545 #define SPA_VERSION_8 8ULL
546 #define SPA_VERSION_9 9ULL
547 #define SPA_VERSION_10 10ULL
548 #define SPA_VERSION_11 11ULL
549 #define SPA_VERSION_12 12ULL
550 #define SPA_VERSION_13 13ULL
551 #define SPA_VERSION_14 14ULL
552 #define SPA_VERSION_15 15ULL
553 #define SPA_VERSION_16 16ULL
554 #define SPA_VERSION_17 17ULL
555 #define SPA_VERSION_18 18ULL
556 #define SPA_VERSION_19 19ULL
557 #define SPA_VERSION_20 20ULL
558 #define SPA_VERSION_21 21ULL
559 #define SPA_VERSION_22 22ULL
560 #define SPA_VERSION_23 23ULL
561 #define SPA_VERSION_24 24ULL
562 #define SPA_VERSION_25 25ULL
563 #define SPA_VERSION_26 26ULL
564 #define SPA_VERSION_27 27ULL
565 #define SPA_VERSION_28 28ULL
566 #define SPA_VERSION_5000 5000ULL
569 * The incrementing pool version number has been replaced by pool feature
570 * flags. For more details, see zfeature.c.
572 #define SPA_VERSION SPA_VERSION_5000
573 #define SPA_VERSION_STRING "5000"
576 * Symbolic names for the changes that caused a SPA_VERSION switch.
577 * Used in the code when checking for presence or absence of a feature.
578 * Feel free to define multiple symbolic names for each version if there
579 * were multiple changes to on-disk structures during that version.
581 * NOTE: When checking the current SPA_VERSION in your code, be sure
582 * to use spa_version() since it reports the version of the
583 * last synced uberblock. Checking the in-flight version can
584 * be dangerous in some cases.
586 #define SPA_VERSION_INITIAL SPA_VERSION_1
587 #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2
588 #define SPA_VERSION_SPARES SPA_VERSION_3
589 #define SPA_VERSION_RAIDZ2 SPA_VERSION_3
590 #define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3
591 #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3
592 #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3
593 #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4
594 #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5
595 #define SPA_VERSION_BOOTFS SPA_VERSION_6
596 #define SPA_VERSION_SLOGS SPA_VERSION_7
597 #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8
598 #define SPA_VERSION_FUID SPA_VERSION_9
599 #define SPA_VERSION_REFRESERVATION SPA_VERSION_9
600 #define SPA_VERSION_REFQUOTA SPA_VERSION_9
601 #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9
602 #define SPA_VERSION_L2CACHE SPA_VERSION_10
603 #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11
604 #define SPA_VERSION_ORIGIN SPA_VERSION_11
605 #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11
606 #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12
607 #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13
608 #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14
609 #define SPA_VERSION_USERSPACE SPA_VERSION_15
610 #define SPA_VERSION_STMF_PROP SPA_VERSION_16
611 #define SPA_VERSION_RAIDZ3 SPA_VERSION_17
612 #define SPA_VERSION_USERREFS SPA_VERSION_18
613 #define SPA_VERSION_HOLES SPA_VERSION_19
614 #define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20
615 #define SPA_VERSION_DEDUP SPA_VERSION_21
616 #define SPA_VERSION_RECVD_PROPS SPA_VERSION_22
617 #define SPA_VERSION_SLIM_ZIL SPA_VERSION_23
618 #define SPA_VERSION_SA SPA_VERSION_24
619 #define SPA_VERSION_SCAN SPA_VERSION_25
620 #define SPA_VERSION_DIR_CLONES SPA_VERSION_26
621 #define SPA_VERSION_DEADLISTS SPA_VERSION_26
622 #define SPA_VERSION_FAST_SNAP SPA_VERSION_27
623 #define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28
624 #define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28
625 #define SPA_VERSION_FEATURES SPA_VERSION_5000
627 #define SPA_VERSION_IS_SUPPORTED(v) \
628 (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
629 ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
632 * ZPL version - rev'd whenever an incompatible on-disk format change
633 * occurs. This is independent of SPA/DMU/ZAP versioning. You must
634 * also update the version_table[] and help message in zfs_prop.c.
636 #define ZPL_VERSION_1 1ULL
637 #define ZPL_VERSION_2 2ULL
638 #define ZPL_VERSION_3 3ULL
639 #define ZPL_VERSION_4 4ULL
640 #define ZPL_VERSION_5 5ULL
641 #define ZPL_VERSION ZPL_VERSION_5
642 #define ZPL_VERSION_STRING "5"
644 #define ZPL_VERSION_INITIAL ZPL_VERSION_1
645 #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2
646 #define ZPL_VERSION_FUID ZPL_VERSION_3
647 #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3
648 #define ZPL_VERSION_SYSATTR ZPL_VERSION_3
649 #define ZPL_VERSION_USERSPACE ZPL_VERSION_4
650 #define ZPL_VERSION_SA ZPL_VERSION_5
652 /* Persistent L2ARC version */
653 #define L2ARC_PERSISTENT_VERSION_1 1ULL
654 #define L2ARC_PERSISTENT_VERSION L2ARC_PERSISTENT_VERSION_1
655 #define L2ARC_PERSISTENT_VERSION_STRING "1"
657 /* Rewind policy information */
658 #define ZPOOL_NO_REWIND 1 /* No policy - default behavior */
659 #define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */
660 #define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */
661 #define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */
662 #define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */
663 #define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */
664 #define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */
666 typedef struct zpool_load_policy
{
667 uint32_t zlp_rewind
; /* rewind policy requested */
668 uint64_t zlp_maxmeta
; /* max acceptable meta-data errors */
669 uint64_t zlp_maxdata
; /* max acceptable data errors */
670 uint64_t zlp_txg
; /* specific txg to load */
671 } zpool_load_policy_t
;
674 * The following are configuration names used in the nvlist describing a pool's
675 * configuration. New on-disk names should be prefixed with "<reversed-DNS>:"
676 * (e.g. "org.openzfs:") to avoid conflicting names being developed
679 #define ZPOOL_CONFIG_VERSION "version"
680 #define ZPOOL_CONFIG_POOL_NAME "name"
681 #define ZPOOL_CONFIG_POOL_STATE "state"
682 #define ZPOOL_CONFIG_POOL_TXG "txg"
683 #define ZPOOL_CONFIG_POOL_GUID "pool_guid"
684 #define ZPOOL_CONFIG_CREATE_TXG "create_txg"
685 #define ZPOOL_CONFIG_TOP_GUID "top_guid"
686 #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
687 #define ZPOOL_CONFIG_TYPE "type"
688 #define ZPOOL_CONFIG_CHILDREN "children"
689 #define ZPOOL_CONFIG_ID "id"
690 #define ZPOOL_CONFIG_GUID "guid"
691 #define ZPOOL_CONFIG_INDIRECT_OBJECT "com.delphix:indirect_object"
692 #define ZPOOL_CONFIG_INDIRECT_BIRTHS "com.delphix:indirect_births"
693 #define ZPOOL_CONFIG_PREV_INDIRECT_VDEV "com.delphix:prev_indirect_vdev"
694 #define ZPOOL_CONFIG_PATH "path"
695 #define ZPOOL_CONFIG_DEVID "devid"
696 #define ZPOOL_CONFIG_SPARE_ID "spareid"
697 #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array"
698 #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift"
699 #define ZPOOL_CONFIG_ASHIFT "ashift"
700 #define ZPOOL_CONFIG_ASIZE "asize"
701 #define ZPOOL_CONFIG_DTL "DTL"
702 #define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */
703 #define ZPOOL_CONFIG_REMOVAL_STATS "removal_stats" /* not stored on disk */
704 #define ZPOOL_CONFIG_CHECKPOINT_STATS "checkpoint_stats" /* not on disk */
705 #define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */
706 #define ZPOOL_CONFIG_INDIRECT_SIZE "indirect_size" /* not stored on disk */
708 /* container nvlist of extended stats */
709 #define ZPOOL_CONFIG_VDEV_STATS_EX "vdev_stats_ex"
711 /* Active queue read/write stats */
712 #define ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE "vdev_sync_r_active_queue"
713 #define ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE "vdev_sync_w_active_queue"
714 #define ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE "vdev_async_r_active_queue"
715 #define ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE "vdev_async_w_active_queue"
716 #define ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE "vdev_async_scrub_active_queue"
717 #define ZPOOL_CONFIG_VDEV_TRIM_ACTIVE_QUEUE "vdev_async_trim_active_queue"
718 #define ZPOOL_CONFIG_VDEV_REBUILD_ACTIVE_QUEUE "vdev_rebuild_active_queue"
721 #define ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE "vdev_sync_r_pend_queue"
722 #define ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE "vdev_sync_w_pend_queue"
723 #define ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE "vdev_async_r_pend_queue"
724 #define ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE "vdev_async_w_pend_queue"
725 #define ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE "vdev_async_scrub_pend_queue"
726 #define ZPOOL_CONFIG_VDEV_TRIM_PEND_QUEUE "vdev_async_trim_pend_queue"
727 #define ZPOOL_CONFIG_VDEV_REBUILD_PEND_QUEUE "vdev_rebuild_pend_queue"
729 /* Latency read/write histogram stats */
730 #define ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO "vdev_tot_r_lat_histo"
731 #define ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO "vdev_tot_w_lat_histo"
732 #define ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO "vdev_disk_r_lat_histo"
733 #define ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO "vdev_disk_w_lat_histo"
734 #define ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO "vdev_sync_r_lat_histo"
735 #define ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO "vdev_sync_w_lat_histo"
736 #define ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO "vdev_async_r_lat_histo"
737 #define ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO "vdev_async_w_lat_histo"
738 #define ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO "vdev_scrub_histo"
739 #define ZPOOL_CONFIG_VDEV_TRIM_LAT_HISTO "vdev_trim_histo"
740 #define ZPOOL_CONFIG_VDEV_REBUILD_LAT_HISTO "vdev_rebuild_histo"
742 /* Request size histograms */
743 #define ZPOOL_CONFIG_VDEV_SYNC_IND_R_HISTO "vdev_sync_ind_r_histo"
744 #define ZPOOL_CONFIG_VDEV_SYNC_IND_W_HISTO "vdev_sync_ind_w_histo"
745 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_R_HISTO "vdev_async_ind_r_histo"
746 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_W_HISTO "vdev_async_ind_w_histo"
747 #define ZPOOL_CONFIG_VDEV_IND_SCRUB_HISTO "vdev_ind_scrub_histo"
748 #define ZPOOL_CONFIG_VDEV_IND_TRIM_HISTO "vdev_ind_trim_histo"
749 #define ZPOOL_CONFIG_VDEV_IND_REBUILD_HISTO "vdev_ind_rebuild_histo"
750 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_R_HISTO "vdev_sync_agg_r_histo"
751 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_W_HISTO "vdev_sync_agg_w_histo"
752 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_R_HISTO "vdev_async_agg_r_histo"
753 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO "vdev_async_agg_w_histo"
754 #define ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO "vdev_agg_scrub_histo"
755 #define ZPOOL_CONFIG_VDEV_AGG_TRIM_HISTO "vdev_agg_trim_histo"
756 #define ZPOOL_CONFIG_VDEV_AGG_REBUILD_HISTO "vdev_agg_rebuild_histo"
758 /* Number of slow IOs */
759 #define ZPOOL_CONFIG_VDEV_SLOW_IOS "vdev_slow_ios"
761 /* vdev enclosure sysfs path */
762 #define ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH "vdev_enc_sysfs_path"
764 #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
765 #define ZPOOL_CONFIG_ERRCOUNT "error_count"
766 #define ZPOOL_CONFIG_NOT_PRESENT "not_present"
767 #define ZPOOL_CONFIG_SPARES "spares"
768 #define ZPOOL_CONFIG_IS_SPARE "is_spare"
769 #define ZPOOL_CONFIG_NPARITY "nparity"
770 #define ZPOOL_CONFIG_HOSTID "hostid"
771 #define ZPOOL_CONFIG_HOSTNAME "hostname"
772 #define ZPOOL_CONFIG_LOADED_TIME "initial_load_time"
773 #define ZPOOL_CONFIG_UNSPARE "unspare"
774 #define ZPOOL_CONFIG_PHYS_PATH "phys_path"
775 #define ZPOOL_CONFIG_IS_LOG "is_log"
776 #define ZPOOL_CONFIG_L2CACHE "l2cache"
777 #define ZPOOL_CONFIG_HOLE_ARRAY "hole_array"
778 #define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
779 #define ZPOOL_CONFIG_IS_HOLE "is_hole"
780 #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
781 #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
782 #define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
783 #define ZPOOL_CONFIG_SPLIT "splitcfg"
784 #define ZPOOL_CONFIG_ORIG_GUID "orig_guid"
785 #define ZPOOL_CONFIG_SPLIT_GUID "split_guid"
786 #define ZPOOL_CONFIG_SPLIT_LIST "guid_list"
787 #define ZPOOL_CONFIG_NONALLOCATING "non_allocating"
788 #define ZPOOL_CONFIG_REMOVING "removing"
789 #define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg"
790 #define ZPOOL_CONFIG_REBUILD_TXG "rebuild_txg"
791 #define ZPOOL_CONFIG_COMMENT "comment"
792 #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */
793 #define ZPOOL_CONFIG_SUSPENDED_REASON "suspended_reason" /* not stored */
794 #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */
795 #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */
796 #define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */
797 #define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */
798 #define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */
799 #define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */
800 #define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */
801 #define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */
802 #define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read"
803 #define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */
804 #define ZPOOL_CONFIG_ERRATA "errata" /* not stored on disk */
805 #define ZPOOL_CONFIG_VDEV_TOP_ZAP "com.delphix:vdev_zap_top"
806 #define ZPOOL_CONFIG_VDEV_LEAF_ZAP "com.delphix:vdev_zap_leaf"
807 #define ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS "com.delphix:has_per_vdev_zaps"
808 #define ZPOOL_CONFIG_RESILVER_DEFER "com.datto:resilver_defer"
809 #define ZPOOL_CONFIG_CACHEFILE "cachefile" /* not stored on disk */
810 #define ZPOOL_CONFIG_MMP_STATE "mmp_state" /* not stored on disk */
811 #define ZPOOL_CONFIG_MMP_TXG "mmp_txg" /* not stored on disk */
812 #define ZPOOL_CONFIG_MMP_SEQ "mmp_seq" /* not stored on disk */
813 #define ZPOOL_CONFIG_MMP_HOSTNAME "mmp_hostname" /* not stored on disk */
814 #define ZPOOL_CONFIG_MMP_HOSTID "mmp_hostid" /* not stored on disk */
815 #define ZPOOL_CONFIG_ALLOCATION_BIAS "alloc_bias" /* not stored on disk */
816 #define ZPOOL_CONFIG_EXPANSION_TIME "expansion_time" /* not stored */
817 #define ZPOOL_CONFIG_REBUILD_STATS "org.openzfs:rebuild_stats"
818 #define ZPOOL_CONFIG_COMPATIBILITY "compatibility"
821 * The persistent vdev state is stored as separate values rather than a single
822 * 'vdev_state' entry. This is because a device can be in multiple states, such
823 * as offline and degraded.
825 #define ZPOOL_CONFIG_OFFLINE "offline"
826 #define ZPOOL_CONFIG_FAULTED "faulted"
827 #define ZPOOL_CONFIG_DEGRADED "degraded"
828 #define ZPOOL_CONFIG_REMOVED "removed"
829 #define ZPOOL_CONFIG_FRU "fru"
830 #define ZPOOL_CONFIG_AUX_STATE "aux_state"
832 /* Pool load policy parameters */
833 #define ZPOOL_LOAD_POLICY "load-policy"
834 #define ZPOOL_LOAD_REWIND_POLICY "load-rewind-policy"
835 #define ZPOOL_LOAD_REQUEST_TXG "load-request-txg"
836 #define ZPOOL_LOAD_META_THRESH "load-meta-thresh"
837 #define ZPOOL_LOAD_DATA_THRESH "load-data-thresh"
839 /* Rewind data discovered */
840 #define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts"
841 #define ZPOOL_CONFIG_LOAD_META_ERRORS "verify_meta_errors"
842 #define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors"
843 #define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind"
845 /* dRAID configuration */
846 #define ZPOOL_CONFIG_DRAID_NDATA "draid_ndata"
847 #define ZPOOL_CONFIG_DRAID_NSPARES "draid_nspares"
848 #define ZPOOL_CONFIG_DRAID_NGROUPS "draid_ngroups"
850 #define VDEV_TYPE_ROOT "root"
851 #define VDEV_TYPE_MIRROR "mirror"
852 #define VDEV_TYPE_REPLACING "replacing"
853 #define VDEV_TYPE_RAIDZ "raidz"
854 #define VDEV_TYPE_DRAID "draid"
855 #define VDEV_TYPE_DRAID_SPARE "dspare"
856 #define VDEV_TYPE_DISK "disk"
857 #define VDEV_TYPE_FILE "file"
858 #define VDEV_TYPE_MISSING "missing"
859 #define VDEV_TYPE_HOLE "hole"
860 #define VDEV_TYPE_SPARE "spare"
861 #define VDEV_TYPE_LOG "log"
862 #define VDEV_TYPE_L2CACHE "l2cache"
863 #define VDEV_TYPE_INDIRECT "indirect"
865 #define VDEV_RAIDZ_MAXPARITY 3
867 #define VDEV_DRAID_MAXPARITY 3
868 #define VDEV_DRAID_MIN_CHILDREN 2
869 #define VDEV_DRAID_MAX_CHILDREN UINT8_MAX
871 /* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */
872 #define VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \
873 "com.delphix:indirect_obsolete_sm"
874 #define VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \
875 "com.delphix:obsolete_counts_are_precise"
876 #define VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \
877 "com.delphix:pool_checkpoint_sm"
878 #define VDEV_TOP_ZAP_MS_UNFLUSHED_PHYS_TXGS \
879 "com.delphix:ms_unflushed_phys_txgs"
881 #define VDEV_TOP_ZAP_VDEV_REBUILD_PHYS \
882 "org.openzfs:vdev_rebuild"
884 #define VDEV_TOP_ZAP_ALLOCATION_BIAS \
885 "org.zfsonlinux:allocation_bias"
887 /* vdev metaslab allocation bias */
888 #define VDEV_ALLOC_BIAS_LOG "log"
889 #define VDEV_ALLOC_BIAS_SPECIAL "special"
890 #define VDEV_ALLOC_BIAS_DEDUP "dedup"
892 /* vdev initialize state */
893 #define VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET \
894 "com.delphix:next_offset_to_initialize"
895 #define VDEV_LEAF_ZAP_INITIALIZE_STATE \
896 "com.delphix:vdev_initialize_state"
897 #define VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME \
898 "com.delphix:vdev_initialize_action_time"
900 /* vdev TRIM state */
901 #define VDEV_LEAF_ZAP_TRIM_LAST_OFFSET \
902 "org.zfsonlinux:next_offset_to_trim"
903 #define VDEV_LEAF_ZAP_TRIM_STATE \
904 "org.zfsonlinux:vdev_trim_state"
905 #define VDEV_LEAF_ZAP_TRIM_ACTION_TIME \
906 "org.zfsonlinux:vdev_trim_action_time"
907 #define VDEV_LEAF_ZAP_TRIM_RATE \
908 "org.zfsonlinux:vdev_trim_rate"
909 #define VDEV_LEAF_ZAP_TRIM_PARTIAL \
910 "org.zfsonlinux:vdev_trim_partial"
911 #define VDEV_LEAF_ZAP_TRIM_SECURE \
912 "org.zfsonlinux:vdev_trim_secure"
915 * This is needed in userland to report the minimum necessary device size.
917 #define SPA_MINDEVSIZE (64ULL << 20)
920 * Set if the fragmentation has not yet been calculated. This can happen
921 * because the space maps have not been upgraded or the histogram feature
924 #define ZFS_FRAG_INVALID UINT64_MAX
927 * The location of the pool configuration repository, shared between kernel and
930 #define ZPOOL_CACHE_BOOT "/boot/zfs/zpool.cache"
931 #define ZPOOL_CACHE "/etc/zfs/zpool.cache"
933 * Settings for zpool compatibility features files
935 #define ZPOOL_SYSCONF_COMPAT_D SYSCONFDIR "/zfs/compatibility.d"
936 #define ZPOOL_DATA_COMPAT_D PKGDATADIR "/compatibility.d"
937 #define ZPOOL_COMPAT_MAXSIZE 16384
940 * Hard-wired compatibility settings
942 #define ZPOOL_COMPAT_LEGACY "legacy"
943 #define ZPOOL_COMPAT_OFF "off"
946 * vdev states are ordered from least to most healthy.
947 * A vdev that's CANT_OPEN or below is considered unusable.
949 typedef enum vdev_state
{
950 VDEV_STATE_UNKNOWN
= 0, /* Uninitialized vdev */
951 VDEV_STATE_CLOSED
, /* Not currently open */
952 VDEV_STATE_OFFLINE
, /* Not allowed to open */
953 VDEV_STATE_REMOVED
, /* Explicitly removed from system */
954 VDEV_STATE_CANT_OPEN
, /* Tried to open, but failed */
955 VDEV_STATE_FAULTED
, /* External request to fault device */
956 VDEV_STATE_DEGRADED
, /* Replicated vdev with unhealthy kids */
957 VDEV_STATE_HEALTHY
/* Presumed good */
960 #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY
963 * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field
964 * of the vdev stats structure uses these constants to distinguish why.
966 typedef enum vdev_aux
{
967 VDEV_AUX_NONE
, /* no error */
968 VDEV_AUX_OPEN_FAILED
, /* ldi_open_*() or vn_open() failed */
969 VDEV_AUX_CORRUPT_DATA
, /* bad label or disk contents */
970 VDEV_AUX_NO_REPLICAS
, /* insufficient number of replicas */
971 VDEV_AUX_BAD_GUID_SUM
, /* vdev guid sum doesn't match */
972 VDEV_AUX_TOO_SMALL
, /* vdev size is too small */
973 VDEV_AUX_BAD_LABEL
, /* the label is OK but invalid */
974 VDEV_AUX_VERSION_NEWER
, /* on-disk version is too new */
975 VDEV_AUX_VERSION_OLDER
, /* on-disk version is too old */
976 VDEV_AUX_UNSUP_FEAT
, /* unsupported features */
977 VDEV_AUX_SPARED
, /* hot spare used in another pool */
978 VDEV_AUX_ERR_EXCEEDED
, /* too many errors */
979 VDEV_AUX_IO_FAILURE
, /* experienced I/O failure */
980 VDEV_AUX_BAD_LOG
, /* cannot read log chain(s) */
981 VDEV_AUX_EXTERNAL
, /* external diagnosis or forced fault */
982 VDEV_AUX_SPLIT_POOL
, /* vdev was split off into another pool */
983 VDEV_AUX_BAD_ASHIFT
, /* vdev ashift is invalid */
984 VDEV_AUX_EXTERNAL_PERSIST
, /* persistent forced fault */
985 VDEV_AUX_ACTIVE
, /* vdev active on a different host */
986 VDEV_AUX_CHILDREN_OFFLINE
, /* all children are offline */
987 VDEV_AUX_ASHIFT_TOO_BIG
, /* vdev's min block size is too large */
991 * pool state. The following states are written to disk as part of the normal
992 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
993 * states are software abstractions used at various levels to communicate
996 typedef enum pool_state
{
997 POOL_STATE_ACTIVE
= 0, /* In active use */
998 POOL_STATE_EXPORTED
, /* Explicitly exported */
999 POOL_STATE_DESTROYED
, /* Explicitly destroyed */
1000 POOL_STATE_SPARE
, /* Reserved for hot spare use */
1001 POOL_STATE_L2CACHE
, /* Level 2 ARC device */
1002 POOL_STATE_UNINITIALIZED
, /* Internal spa_t state */
1003 POOL_STATE_UNAVAIL
, /* Internal libzfs state */
1004 POOL_STATE_POTENTIALLY_ACTIVE
/* Internal libzfs state */
1008 * mmp state. The following states provide additional detail describing
1009 * why a pool couldn't be safely imported.
1011 typedef enum mmp_state
{
1012 MMP_STATE_ACTIVE
= 0, /* In active use */
1013 MMP_STATE_INACTIVE
, /* Inactive and safe to import */
1014 MMP_STATE_NO_HOSTID
/* System hostid is not set */
1020 typedef enum pool_scan_func
{
1028 * Used to control scrub pause and resume.
1030 typedef enum pool_scrub_cmd
{
1031 POOL_SCRUB_NORMAL
= 0,
1033 POOL_SCRUB_FLAGS_END
1038 CS_CHECKPOINT_EXISTS
,
1039 CS_CHECKPOINT_DISCARDING
,
1041 } checkpoint_state_t
;
1043 typedef struct pool_checkpoint_stat
{
1044 uint64_t pcs_state
; /* checkpoint_state_t */
1045 uint64_t pcs_start_time
; /* time checkpoint/discard started */
1046 uint64_t pcs_space
; /* checkpointed space */
1047 } pool_checkpoint_stat_t
;
1050 * ZIO types. Needed to interpret vdev statistics below.
1052 typedef enum zio_type
{
1064 * Pool statistics. Note: all fields should be 64-bit because this
1065 * is passed between kernel and userland as an nvlist uint64 array.
1067 typedef struct pool_scan_stat
{
1068 /* values stored on disk */
1069 uint64_t pss_func
; /* pool_scan_func_t */
1070 uint64_t pss_state
; /* dsl_scan_state_t */
1071 uint64_t pss_start_time
; /* scan start time */
1072 uint64_t pss_end_time
; /* scan end time */
1073 uint64_t pss_to_examine
; /* total bytes to scan */
1074 uint64_t pss_examined
; /* total bytes located by scanner */
1075 uint64_t pss_to_process
; /* total bytes to process */
1076 uint64_t pss_processed
; /* total processed bytes */
1077 uint64_t pss_errors
; /* scan errors */
1079 /* values not stored on disk */
1080 uint64_t pss_pass_exam
; /* examined bytes per scan pass */
1081 uint64_t pss_pass_start
; /* start time of a scan pass */
1082 uint64_t pss_pass_scrub_pause
; /* pause time of a scrub pass */
1083 /* cumulative time scrub spent paused, needed for rate calculation */
1084 uint64_t pss_pass_scrub_spent_paused
;
1085 uint64_t pss_pass_issued
; /* issued bytes per scan pass */
1086 uint64_t pss_issued
; /* total bytes checked by scanner */
1089 typedef struct pool_removal_stat
{
1090 uint64_t prs_state
; /* dsl_scan_state_t */
1091 uint64_t prs_removing_vdev
;
1092 uint64_t prs_start_time
;
1093 uint64_t prs_end_time
;
1094 uint64_t prs_to_copy
; /* bytes that need to be copied */
1095 uint64_t prs_copied
; /* bytes copied so far */
1097 * bytes of memory used for indirect mappings.
1098 * This includes all removed vdevs.
1100 uint64_t prs_mapping_memory
;
1101 } pool_removal_stat_t
;
1103 typedef enum dsl_scan_state
{
1111 typedef struct vdev_rebuild_stat
{
1112 uint64_t vrs_state
; /* vdev_rebuild_state_t */
1113 uint64_t vrs_start_time
; /* time_t */
1114 uint64_t vrs_end_time
; /* time_t */
1115 uint64_t vrs_scan_time_ms
; /* total run time (millisecs) */
1116 uint64_t vrs_bytes_scanned
; /* allocated bytes scanned */
1117 uint64_t vrs_bytes_issued
; /* read bytes issued */
1118 uint64_t vrs_bytes_rebuilt
; /* rebuilt bytes */
1119 uint64_t vrs_bytes_est
; /* total bytes to scan */
1120 uint64_t vrs_errors
; /* scanning errors */
1121 uint64_t vrs_pass_time_ms
; /* pass run time (millisecs) */
1122 uint64_t vrs_pass_bytes_scanned
; /* bytes scanned since start/resume */
1123 uint64_t vrs_pass_bytes_issued
; /* bytes rebuilt since start/resume */
1124 } vdev_rebuild_stat_t
;
1127 * Errata described by https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-ER.
1128 * The ordering of this enum must be maintained to ensure the errata identifiers
1129 * map to the correct documentation. New errata may only be appended to the
1130 * list and must contain corresponding documentation at the above link.
1132 typedef enum zpool_errata
{
1134 ZPOOL_ERRATA_ZOL_2094_SCRUB
,
1135 ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY
,
1136 ZPOOL_ERRATA_ZOL_6845_ENCRYPTION
,
1137 ZPOOL_ERRATA_ZOL_8308_ENCRYPTION
,
1141 * Vdev statistics. Note: all fields should be 64-bit because this
1142 * is passed between kernel and user land as an nvlist uint64 array.
1144 * The vs_ops[] and vs_bytes[] arrays must always be an array size of 6 in
1145 * order to keep subsequent members at their known fixed offsets. When
1146 * adding a new field it must be added to the end the structure.
1148 #define VS_ZIO_TYPES 6
1150 typedef struct vdev_stat
{
1151 hrtime_t vs_timestamp
; /* time since vdev load */
1152 uint64_t vs_state
; /* vdev state */
1153 uint64_t vs_aux
; /* see vdev_aux_t */
1154 uint64_t vs_alloc
; /* space allocated */
1155 uint64_t vs_space
; /* total capacity */
1156 uint64_t vs_dspace
; /* deflated capacity */
1157 uint64_t vs_rsize
; /* replaceable dev size */
1158 uint64_t vs_esize
; /* expandable dev size */
1159 uint64_t vs_ops
[VS_ZIO_TYPES
]; /* operation count */
1160 uint64_t vs_bytes
[VS_ZIO_TYPES
]; /* bytes read/written */
1161 uint64_t vs_read_errors
; /* read errors */
1162 uint64_t vs_write_errors
; /* write errors */
1163 uint64_t vs_checksum_errors
; /* checksum errors */
1164 uint64_t vs_initialize_errors
; /* initializing errors */
1165 uint64_t vs_self_healed
; /* self-healed bytes */
1166 uint64_t vs_scan_removing
; /* removing? */
1167 uint64_t vs_scan_processed
; /* scan processed bytes */
1168 uint64_t vs_fragmentation
; /* device fragmentation */
1169 uint64_t vs_initialize_bytes_done
; /* bytes initialized */
1170 uint64_t vs_initialize_bytes_est
; /* total bytes to initialize */
1171 uint64_t vs_initialize_state
; /* vdev_initializing_state_t */
1172 uint64_t vs_initialize_action_time
; /* time_t */
1173 uint64_t vs_checkpoint_space
; /* checkpoint-consumed space */
1174 uint64_t vs_resilver_deferred
; /* resilver deferred */
1175 uint64_t vs_slow_ios
; /* slow IOs */
1176 uint64_t vs_trim_errors
; /* trimming errors */
1177 uint64_t vs_trim_notsup
; /* supported by device */
1178 uint64_t vs_trim_bytes_done
; /* bytes trimmed */
1179 uint64_t vs_trim_bytes_est
; /* total bytes to trim */
1180 uint64_t vs_trim_state
; /* vdev_trim_state_t */
1181 uint64_t vs_trim_action_time
; /* time_t */
1182 uint64_t vs_rebuild_processed
; /* bytes rebuilt */
1183 uint64_t vs_configured_ashift
; /* TLV vdev_ashift */
1184 uint64_t vs_logical_ashift
; /* vdev_logical_ashift */
1185 uint64_t vs_physical_ashift
; /* vdev_physical_ashift */
1186 uint64_t vs_noalloc
; /* allocations halted? */
1189 #define VDEV_STAT_VALID(field, uint64_t_field_count) \
1190 ((uint64_t_field_count * sizeof (uint64_t)) >= \
1191 (offsetof(vdev_stat_t, field) + sizeof (((vdev_stat_t *)NULL)->field)))
1196 * These are stats which aren't included in the original iostat output. For
1197 * convenience, they are grouped together in vdev_stat_ex, although each stat
1198 * is individually exported as an nvlist.
1200 typedef struct vdev_stat_ex
{
1201 /* Number of ZIOs issued to disk and waiting to finish */
1202 uint64_t vsx_active_queue
[ZIO_PRIORITY_NUM_QUEUEABLE
];
1204 /* Number of ZIOs pending to be issued to disk */
1205 uint64_t vsx_pend_queue
[ZIO_PRIORITY_NUM_QUEUEABLE
];
1208 * Below are the histograms for various latencies. Buckets are in
1209 * units of nanoseconds.
1213 * 2^37 nanoseconds = 134s. Timeouts will probably start kicking in
1216 #define VDEV_L_HISTO_BUCKETS 37 /* Latency histo buckets */
1217 #define VDEV_RQ_HISTO_BUCKETS 25 /* Request size histo buckets */
1219 /* Amount of time in ZIO queue (ns) */
1220 uint64_t vsx_queue_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
1221 [VDEV_L_HISTO_BUCKETS
];
1223 /* Total ZIO latency (ns). Includes queuing and disk access time */
1224 uint64_t vsx_total_histo
[ZIO_TYPES
][VDEV_L_HISTO_BUCKETS
];
1226 /* Amount of time to read/write the disk (ns) */
1227 uint64_t vsx_disk_histo
[ZIO_TYPES
][VDEV_L_HISTO_BUCKETS
];
1229 /* "lookup the bucket for a value" histogram macros */
1230 #define HISTO(val, buckets) (val != 0 ? MIN(highbit64(val) - 1, \
1232 #define L_HISTO(a) HISTO(a, VDEV_L_HISTO_BUCKETS)
1233 #define RQ_HISTO(a) HISTO(a, VDEV_RQ_HISTO_BUCKETS)
1235 /* Physical IO histogram */
1236 uint64_t vsx_ind_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
1237 [VDEV_RQ_HISTO_BUCKETS
];
1239 /* Delegated (aggregated) physical IO histogram */
1240 uint64_t vsx_agg_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
1241 [VDEV_RQ_HISTO_BUCKETS
];
1246 * Initialize functions.
1248 typedef enum pool_initialize_func
{
1249 POOL_INITIALIZE_START
,
1250 POOL_INITIALIZE_CANCEL
,
1251 POOL_INITIALIZE_SUSPEND
,
1252 POOL_INITIALIZE_FUNCS
1253 } pool_initialize_func_t
;
1258 typedef enum pool_trim_func
{
1266 * DDT statistics. Note: all fields should be 64-bit because this
1267 * is passed between kernel and userland as an nvlist uint64 array.
1269 typedef struct ddt_object
{
1270 uint64_t ddo_count
; /* number of elements in ddt */
1271 uint64_t ddo_dspace
; /* size of ddt on disk */
1272 uint64_t ddo_mspace
; /* size of ddt in-core */
1275 typedef struct ddt_stat
{
1276 uint64_t dds_blocks
; /* blocks */
1277 uint64_t dds_lsize
; /* logical size */
1278 uint64_t dds_psize
; /* physical size */
1279 uint64_t dds_dsize
; /* deflated allocated size */
1280 uint64_t dds_ref_blocks
; /* referenced blocks */
1281 uint64_t dds_ref_lsize
; /* referenced lsize * refcnt */
1282 uint64_t dds_ref_psize
; /* referenced psize * refcnt */
1283 uint64_t dds_ref_dsize
; /* referenced dsize * refcnt */
1286 typedef struct ddt_histogram
{
1287 ddt_stat_t ddh_stat
[64]; /* power-of-two histogram buckets */
1290 #define ZVOL_DRIVER "zvol"
1291 #define ZFS_DRIVER "zfs"
1292 #define ZFS_DEV "/dev/zfs"
1294 #define ZFS_SUPER_MAGIC 0x2fc12fc1
1296 /* general zvol path */
1297 #define ZVOL_DIR "/dev/zvol/"
1299 #define ZVOL_MAJOR 230
1300 #define ZVOL_MINOR_BITS 4
1301 #define ZVOL_MINOR_MASK ((1U << ZVOL_MINOR_BITS) - 1)
1302 #define ZVOL_MINORS (1 << 4)
1303 #define ZVOL_DEV_NAME "zd"
1305 #define ZVOL_PROP_NAME "name"
1306 #define ZVOL_DEFAULT_BLOCKSIZE 16384
1309 VDEV_INITIALIZE_NONE
,
1310 VDEV_INITIALIZE_ACTIVE
,
1311 VDEV_INITIALIZE_CANCELED
,
1312 VDEV_INITIALIZE_SUSPENDED
,
1313 VDEV_INITIALIZE_COMPLETE
1314 } vdev_initializing_state_t
;
1320 VDEV_TRIM_SUSPENDED
,
1322 } vdev_trim_state_t
;
1326 VDEV_REBUILD_ACTIVE
,
1327 VDEV_REBUILD_CANCELED
,
1328 VDEV_REBUILD_COMPLETE
,
1329 } vdev_rebuild_state_t
;
1332 * nvlist name constants. Facilitate restricting snapshot iteration range for
1333 * the "list next snapshot" ioctl
1335 #define SNAP_ITER_MIN_TXG "snap_iter_min_txg"
1336 #define SNAP_ITER_MAX_TXG "snap_iter_max_txg"
1339 * /dev/zfs ioctl numbers.
1341 * These numbers cannot change over time. New ioctl numbers must be appended.
1343 typedef enum zfs_ioc
{
1345 * Core features - 81/128 numbers reserved.
1350 ZFS_IOC_FIRST
= ('Z' << 8),
1352 ZFS_IOC
= ZFS_IOC_FIRST
,
1353 ZFS_IOC_POOL_CREATE
= ZFS_IOC_FIRST
, /* 0x5a00 */
1354 ZFS_IOC_POOL_DESTROY
, /* 0x5a01 */
1355 ZFS_IOC_POOL_IMPORT
, /* 0x5a02 */
1356 ZFS_IOC_POOL_EXPORT
, /* 0x5a03 */
1357 ZFS_IOC_POOL_CONFIGS
, /* 0x5a04 */
1358 ZFS_IOC_POOL_STATS
, /* 0x5a05 */
1359 ZFS_IOC_POOL_TRYIMPORT
, /* 0x5a06 */
1360 ZFS_IOC_POOL_SCAN
, /* 0x5a07 */
1361 ZFS_IOC_POOL_FREEZE
, /* 0x5a08 */
1362 ZFS_IOC_POOL_UPGRADE
, /* 0x5a09 */
1363 ZFS_IOC_POOL_GET_HISTORY
, /* 0x5a0a */
1364 ZFS_IOC_VDEV_ADD
, /* 0x5a0b */
1365 ZFS_IOC_VDEV_REMOVE
, /* 0x5a0c */
1366 ZFS_IOC_VDEV_SET_STATE
, /* 0x5a0d */
1367 ZFS_IOC_VDEV_ATTACH
, /* 0x5a0e */
1368 ZFS_IOC_VDEV_DETACH
, /* 0x5a0f */
1369 ZFS_IOC_VDEV_SETPATH
, /* 0x5a10 */
1370 ZFS_IOC_VDEV_SETFRU
, /* 0x5a11 */
1371 ZFS_IOC_OBJSET_STATS
, /* 0x5a12 */
1372 ZFS_IOC_OBJSET_ZPLPROPS
, /* 0x5a13 */
1373 ZFS_IOC_DATASET_LIST_NEXT
, /* 0x5a14 */
1374 ZFS_IOC_SNAPSHOT_LIST_NEXT
, /* 0x5a15 */
1375 ZFS_IOC_SET_PROP
, /* 0x5a16 */
1376 ZFS_IOC_CREATE
, /* 0x5a17 */
1377 ZFS_IOC_DESTROY
, /* 0x5a18 */
1378 ZFS_IOC_ROLLBACK
, /* 0x5a19 */
1379 ZFS_IOC_RENAME
, /* 0x5a1a */
1380 ZFS_IOC_RECV
, /* 0x5a1b */
1381 ZFS_IOC_SEND
, /* 0x5a1c */
1382 ZFS_IOC_INJECT_FAULT
, /* 0x5a1d */
1383 ZFS_IOC_CLEAR_FAULT
, /* 0x5a1e */
1384 ZFS_IOC_INJECT_LIST_NEXT
, /* 0x5a1f */
1385 ZFS_IOC_ERROR_LOG
, /* 0x5a20 */
1386 ZFS_IOC_CLEAR
, /* 0x5a21 */
1387 ZFS_IOC_PROMOTE
, /* 0x5a22 */
1388 ZFS_IOC_SNAPSHOT
, /* 0x5a23 */
1389 ZFS_IOC_DSOBJ_TO_DSNAME
, /* 0x5a24 */
1390 ZFS_IOC_OBJ_TO_PATH
, /* 0x5a25 */
1391 ZFS_IOC_POOL_SET_PROPS
, /* 0x5a26 */
1392 ZFS_IOC_POOL_GET_PROPS
, /* 0x5a27 */
1393 ZFS_IOC_SET_FSACL
, /* 0x5a28 */
1394 ZFS_IOC_GET_FSACL
, /* 0x5a29 */
1395 ZFS_IOC_SHARE
, /* 0x5a2a */
1396 ZFS_IOC_INHERIT_PROP
, /* 0x5a2b */
1397 ZFS_IOC_SMB_ACL
, /* 0x5a2c */
1398 ZFS_IOC_USERSPACE_ONE
, /* 0x5a2d */
1399 ZFS_IOC_USERSPACE_MANY
, /* 0x5a2e */
1400 ZFS_IOC_USERSPACE_UPGRADE
, /* 0x5a2f */
1401 ZFS_IOC_HOLD
, /* 0x5a30 */
1402 ZFS_IOC_RELEASE
, /* 0x5a31 */
1403 ZFS_IOC_GET_HOLDS
, /* 0x5a32 */
1404 ZFS_IOC_OBJSET_RECVD_PROPS
, /* 0x5a33 */
1405 ZFS_IOC_VDEV_SPLIT
, /* 0x5a34 */
1406 ZFS_IOC_NEXT_OBJ
, /* 0x5a35 */
1407 ZFS_IOC_DIFF
, /* 0x5a36 */
1408 ZFS_IOC_TMP_SNAPSHOT
, /* 0x5a37 */
1409 ZFS_IOC_OBJ_TO_STATS
, /* 0x5a38 */
1410 ZFS_IOC_SPACE_WRITTEN
, /* 0x5a39 */
1411 ZFS_IOC_SPACE_SNAPS
, /* 0x5a3a */
1412 ZFS_IOC_DESTROY_SNAPS
, /* 0x5a3b */
1413 ZFS_IOC_POOL_REGUID
, /* 0x5a3c */
1414 ZFS_IOC_POOL_REOPEN
, /* 0x5a3d */
1415 ZFS_IOC_SEND_PROGRESS
, /* 0x5a3e */
1416 ZFS_IOC_LOG_HISTORY
, /* 0x5a3f */
1417 ZFS_IOC_SEND_NEW
, /* 0x5a40 */
1418 ZFS_IOC_SEND_SPACE
, /* 0x5a41 */
1419 ZFS_IOC_CLONE
, /* 0x5a42 */
1420 ZFS_IOC_BOOKMARK
, /* 0x5a43 */
1421 ZFS_IOC_GET_BOOKMARKS
, /* 0x5a44 */
1422 ZFS_IOC_DESTROY_BOOKMARKS
, /* 0x5a45 */
1423 ZFS_IOC_RECV_NEW
, /* 0x5a46 */
1424 ZFS_IOC_POOL_SYNC
, /* 0x5a47 */
1425 ZFS_IOC_CHANNEL_PROGRAM
, /* 0x5a48 */
1426 ZFS_IOC_LOAD_KEY
, /* 0x5a49 */
1427 ZFS_IOC_UNLOAD_KEY
, /* 0x5a4a */
1428 ZFS_IOC_CHANGE_KEY
, /* 0x5a4b */
1429 ZFS_IOC_REMAP
, /* 0x5a4c */
1430 ZFS_IOC_POOL_CHECKPOINT
, /* 0x5a4d */
1431 ZFS_IOC_POOL_DISCARD_CHECKPOINT
, /* 0x5a4e */
1432 ZFS_IOC_POOL_INITIALIZE
, /* 0x5a4f */
1433 ZFS_IOC_POOL_TRIM
, /* 0x5a50 */
1434 ZFS_IOC_REDACT
, /* 0x5a51 */
1435 ZFS_IOC_GET_BOOKMARK_PROPS
, /* 0x5a52 */
1436 ZFS_IOC_WAIT
, /* 0x5a53 */
1437 ZFS_IOC_WAIT_FS
, /* 0x5a54 */
1438 ZFS_IOC_VDEV_GET_PROPS
, /* 0x5a55 */
1439 ZFS_IOC_VDEV_SET_PROPS
, /* 0x5a56 */
1442 * Per-platform (Optional) - 8/128 numbers reserved.
1444 ZFS_IOC_PLATFORM
= ZFS_IOC_FIRST
+ 0x80,
1445 ZFS_IOC_EVENTS_NEXT
, /* 0x81 (Linux) */
1446 ZFS_IOC_EVENTS_CLEAR
, /* 0x82 (Linux) */
1447 ZFS_IOC_EVENTS_SEEK
, /* 0x83 (Linux) */
1448 ZFS_IOC_NEXTBOOT
, /* 0x84 (FreeBSD) */
1449 ZFS_IOC_JAIL
, /* 0x85 (FreeBSD) */
1450 ZFS_IOC_UNJAIL
, /* 0x86 (FreeBSD) */
1451 ZFS_IOC_SET_BOOTENV
, /* 0x87 */
1452 ZFS_IOC_GET_BOOTENV
, /* 0x88 */
1457 * zvol ioctl to get dataset name
1459 #define BLKZNAME _IOR(0x12, 125, char[ZFS_MAX_DATASET_NAME_LEN])
1462 * ZFS-specific error codes used for returning descriptive errors
1463 * to the userland through zfs ioctls.
1465 * The enum implicitly includes all the error codes from errno.h.
1466 * New code should use and extend this enum for errors that are
1467 * not described precisely by generic errno codes.
1469 * These numbers should not change over time. New entries should be appended.
1471 * (Keep in sync with contrib/pyzfs/libzfs_core/_constants.py)
1474 ZFS_ERR_CHECKPOINT_EXISTS
= 1024,
1475 ZFS_ERR_DISCARDING_CHECKPOINT
,
1476 ZFS_ERR_NO_CHECKPOINT
,
1477 ZFS_ERR_DEVRM_IN_PROGRESS
,
1478 ZFS_ERR_VDEV_TOO_BIG
,
1479 ZFS_ERR_IOC_CMD_UNAVAIL
,
1480 ZFS_ERR_IOC_ARG_UNAVAIL
,
1481 ZFS_ERR_IOC_ARG_REQUIRED
,
1482 ZFS_ERR_IOC_ARG_BADTYPE
,
1483 ZFS_ERR_WRONG_PARENT
,
1484 ZFS_ERR_FROM_IVSET_GUID_MISSING
,
1485 ZFS_ERR_FROM_IVSET_GUID_MISMATCH
,
1486 ZFS_ERR_SPILL_BLOCK_FLAG_MISSING
,
1487 ZFS_ERR_UNKNOWN_SEND_STREAM_FEATURE
,
1488 ZFS_ERR_EXPORT_IN_PROGRESS
,
1489 ZFS_ERR_BOOKMARK_SOURCE_NOT_ANCESTOR
,
1490 ZFS_ERR_STREAM_TRUNCATED
,
1491 ZFS_ERR_STREAM_LARGE_BLOCK_MISMATCH
,
1492 ZFS_ERR_RESILVER_IN_PROGRESS
,
1493 ZFS_ERR_REBUILD_IN_PROGRESS
,
1495 ZFS_ERR_VDEV_NOTSUP
,
1499 * Internal SPA load state. Used by FMA diagnosis engine.
1502 SPA_LOAD_NONE
, /* no load in progress */
1503 SPA_LOAD_OPEN
, /* normal open */
1504 SPA_LOAD_IMPORT
, /* import in progress */
1505 SPA_LOAD_TRYIMPORT
, /* tryimport in progress */
1506 SPA_LOAD_RECOVER
, /* recovery requested */
1507 SPA_LOAD_ERROR
, /* load failed */
1508 SPA_LOAD_CREATE
/* creation in progress */
1512 ZPOOL_WAIT_CKPT_DISCARD
,
1514 ZPOOL_WAIT_INITIALIZE
,
1517 ZPOOL_WAIT_RESILVER
,
1520 ZPOOL_WAIT_NUM_ACTIVITIES
1521 } zpool_wait_activity_t
;
1525 ZFS_WAIT_NUM_ACTIVITIES
1526 } zfs_wait_activity_t
;
1529 * Bookmark name values.
1531 #define ZPOOL_ERR_LIST "error list"
1532 #define ZPOOL_ERR_DATASET "dataset"
1533 #define ZPOOL_ERR_OBJECT "object"
1535 #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1)
1538 * The following are names used in the nvlist describing
1539 * the pool's history log.
1541 #define ZPOOL_HIST_RECORD "history record"
1542 #define ZPOOL_HIST_TIME "history time"
1543 #define ZPOOL_HIST_CMD "history command"
1544 #define ZPOOL_HIST_WHO "history who"
1545 #define ZPOOL_HIST_ZONE "history zone"
1546 #define ZPOOL_HIST_HOST "history hostname"
1547 #define ZPOOL_HIST_TXG "history txg"
1548 #define ZPOOL_HIST_INT_EVENT "history internal event"
1549 #define ZPOOL_HIST_INT_STR "history internal str"
1550 #define ZPOOL_HIST_INT_NAME "internal_name"
1551 #define ZPOOL_HIST_IOCTL "ioctl"
1552 #define ZPOOL_HIST_INPUT_NVL "in_nvl"
1553 #define ZPOOL_HIST_OUTPUT_NVL "out_nvl"
1554 #define ZPOOL_HIST_OUTPUT_SIZE "out_size"
1555 #define ZPOOL_HIST_DSNAME "dsname"
1556 #define ZPOOL_HIST_DSID "dsid"
1557 #define ZPOOL_HIST_ERRNO "errno"
1558 #define ZPOOL_HIST_ELAPSED_NS "elapsed_ns"
1561 * Special nvlist name that will not have its args recorded in the pool's
1564 #define ZPOOL_HIDDEN_ARGS "hidden_args"
1567 * The following are names used when invoking ZFS_IOC_POOL_INITIALIZE.
1569 #define ZPOOL_INITIALIZE_COMMAND "initialize_command"
1570 #define ZPOOL_INITIALIZE_VDEVS "initialize_vdevs"
1573 * The following are names used when invoking ZFS_IOC_POOL_TRIM.
1575 #define ZPOOL_TRIM_COMMAND "trim_command"
1576 #define ZPOOL_TRIM_VDEVS "trim_vdevs"
1577 #define ZPOOL_TRIM_RATE "trim_rate"
1578 #define ZPOOL_TRIM_SECURE "trim_secure"
1581 * The following are names used when invoking ZFS_IOC_POOL_WAIT.
1583 #define ZPOOL_WAIT_ACTIVITY "wait_activity"
1584 #define ZPOOL_WAIT_TAG "wait_tag"
1585 #define ZPOOL_WAIT_WAITED "wait_waited"
1588 * The following are names used when invoking ZFS_IOC_VDEV_GET_PROP.
1590 #define ZPOOL_VDEV_PROPS_GET_VDEV "vdevprops_get_vdev"
1591 #define ZPOOL_VDEV_PROPS_GET_PROPS "vdevprops_get_props"
1594 * The following are names used when invoking ZFS_IOC_VDEV_SET_PROP.
1596 #define ZPOOL_VDEV_PROPS_SET_VDEV "vdevprops_set_vdev"
1597 #define ZPOOL_VDEV_PROPS_SET_PROPS "vdevprops_set_props"
1600 * The following are names used when invoking ZFS_IOC_WAIT_FS.
1602 #define ZFS_WAIT_ACTIVITY "wait_activity"
1603 #define ZFS_WAIT_WAITED "wait_waited"
1606 * Flags for ZFS_IOC_VDEV_SET_STATE
1608 #define ZFS_ONLINE_CHECKREMOVE 0x1
1609 #define ZFS_ONLINE_UNSPARE 0x2
1610 #define ZFS_ONLINE_FORCEFAULT 0x4
1611 #define ZFS_ONLINE_EXPAND 0x8
1612 #define ZFS_OFFLINE_TEMPORARY 0x1
1615 * Flags for ZFS_IOC_POOL_IMPORT
1617 #define ZFS_IMPORT_NORMAL 0x0
1618 #define ZFS_IMPORT_VERBATIM 0x1
1619 #define ZFS_IMPORT_ANY_HOST 0x2
1620 #define ZFS_IMPORT_MISSING_LOG 0x4
1621 #define ZFS_IMPORT_ONLY 0x8
1622 #define ZFS_IMPORT_TEMP_NAME 0x10
1623 #define ZFS_IMPORT_SKIP_MMP 0x20
1624 #define ZFS_IMPORT_LOAD_KEYS 0x40
1625 #define ZFS_IMPORT_CHECKPOINT 0x80
1628 * Channel program argument/return nvlist keys and defaults.
1630 #define ZCP_ARG_PROGRAM "program"
1631 #define ZCP_ARG_ARGLIST "arg"
1632 #define ZCP_ARG_SYNC "sync"
1633 #define ZCP_ARG_INSTRLIMIT "instrlimit"
1634 #define ZCP_ARG_MEMLIMIT "memlimit"
1636 #define ZCP_ARG_CLIARGV "argv"
1638 #define ZCP_RET_ERROR "error"
1639 #define ZCP_RET_RETURN "return"
1641 #define ZCP_DEFAULT_INSTRLIMIT (10 * 1000 * 1000)
1642 #define ZCP_MAX_INSTRLIMIT (10 * ZCP_DEFAULT_INSTRLIMIT)
1643 #define ZCP_DEFAULT_MEMLIMIT (10 * 1024 * 1024)
1644 #define ZCP_MAX_MEMLIMIT (10 * ZCP_DEFAULT_MEMLIMIT)
1647 * Sysevent payload members. ZFS will generate the following sysevents with the
1650 * ESC_ZFS_RESILVER_START
1651 * ESC_ZFS_RESILVER_FINISH
1653 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1654 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1655 * ZFS_EV_RESILVER_TYPE DATA_TYPE_STRING
1657 * ESC_ZFS_POOL_DESTROY
1658 * ESC_ZFS_POOL_REGUID
1660 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1661 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1663 * ESC_ZFS_VDEV_REMOVE
1664 * ESC_ZFS_VDEV_CLEAR
1665 * ESC_ZFS_VDEV_CHECK
1667 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1668 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1669 * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional)
1670 * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64
1672 * ESC_ZFS_HISTORY_EVENT
1674 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1675 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1676 * ZFS_EV_HIST_TIME DATA_TYPE_UINT64 (optional)
1677 * ZFS_EV_HIST_CMD DATA_TYPE_STRING (optional)
1678 * ZFS_EV_HIST_WHO DATA_TYPE_UINT64 (optional)
1679 * ZFS_EV_HIST_ZONE DATA_TYPE_STRING (optional)
1680 * ZFS_EV_HIST_HOST DATA_TYPE_STRING (optional)
1681 * ZFS_EV_HIST_TXG DATA_TYPE_UINT64 (optional)
1682 * ZFS_EV_HIST_INT_EVENT DATA_TYPE_UINT64 (optional)
1683 * ZFS_EV_HIST_INT_STR DATA_TYPE_STRING (optional)
1684 * ZFS_EV_HIST_INT_NAME DATA_TYPE_STRING (optional)
1685 * ZFS_EV_HIST_IOCTL DATA_TYPE_STRING (optional)
1686 * ZFS_EV_HIST_DSNAME DATA_TYPE_STRING (optional)
1687 * ZFS_EV_HIST_DSID DATA_TYPE_UINT64 (optional)
1689 * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the
1690 * history log nvlist. The keynames will be free of any spaces or other
1691 * characters that could be potentially unexpected to consumers of the
1694 #define ZFS_EV_POOL_NAME "pool_name"
1695 #define ZFS_EV_POOL_GUID "pool_guid"
1696 #define ZFS_EV_VDEV_PATH "vdev_path"
1697 #define ZFS_EV_VDEV_GUID "vdev_guid"
1698 #define ZFS_EV_HIST_TIME "history_time"
1699 #define ZFS_EV_HIST_CMD "history_command"
1700 #define ZFS_EV_HIST_WHO "history_who"
1701 #define ZFS_EV_HIST_ZONE "history_zone"
1702 #define ZFS_EV_HIST_HOST "history_hostname"
1703 #define ZFS_EV_HIST_TXG "history_txg"
1704 #define ZFS_EV_HIST_INT_EVENT "history_internal_event"
1705 #define ZFS_EV_HIST_INT_STR "history_internal_str"
1706 #define ZFS_EV_HIST_INT_NAME "history_internal_name"
1707 #define ZFS_EV_HIST_IOCTL "history_ioctl"
1708 #define ZFS_EV_HIST_DSNAME "history_dsname"
1709 #define ZFS_EV_HIST_DSID "history_dsid"
1710 #define ZFS_EV_RESILVER_TYPE "resilver_type"
1713 * We currently support block sizes from 512 bytes to 16MB.
1714 * The benefits of larger blocks, and thus larger IO, need to be weighed
1715 * against the cost of COWing a giant block to modify one byte, and the
1716 * large latency of reading or writing a large block.
1718 * Note that although blocks up to 16MB are supported, the recordsize
1719 * property can not be set larger than zfs_max_recordsize (default 1MB).
1720 * See the comment near zfs_max_recordsize in dsl_dataset.c for details.
1722 * Note that although the LSIZE field of the blkptr_t can store sizes up
1723 * to 32MB, the dnode's dn_datablkszsec can only store sizes up to
1724 * 32MB - 512 bytes. Therefore, we limit SPA_MAXBLOCKSIZE to 16MB.
1726 #define SPA_MINBLOCKSHIFT 9
1727 #define SPA_OLD_MAXBLOCKSHIFT 17
1728 #define SPA_MAXBLOCKSHIFT 24
1729 #define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT)
1730 #define SPA_OLD_MAXBLOCKSIZE (1ULL << SPA_OLD_MAXBLOCKSHIFT)
1731 #define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT)
1733 /* supported encryption algorithms */
1735 ZIO_CRYPT_INHERIT
= 0,
1738 ZIO_CRYPT_AES_128_CCM
,
1739 ZIO_CRYPT_AES_192_CCM
,
1740 ZIO_CRYPT_AES_256_CCM
,
1741 ZIO_CRYPT_AES_128_GCM
,
1742 ZIO_CRYPT_AES_192_GCM
,
1743 ZIO_CRYPT_AES_256_GCM
,
1747 #define ZIO_CRYPT_ON_VALUE ZIO_CRYPT_AES_256_GCM
1748 #define ZIO_CRYPT_DEFAULT ZIO_CRYPT_OFF
1751 * xattr namespace prefixes. These are forbidden in xattr names.
1753 * For cross-platform compatibility, xattrs in the user namespace should not be
1754 * prefixed with the namespace name, but for backwards compatibility with older
1755 * ZFS on Linux versions we do prefix the namespace.
1757 #define ZFS_XA_NS_FREEBSD_PREFIX "freebsd:"
1758 #define ZFS_XA_NS_FREEBSD_PREFIX_LEN strlen("freebsd:")
1759 #define ZFS_XA_NS_LINUX_SECURITY_PREFIX "security."
1760 #define ZFS_XA_NS_LINUX_SECURITY_PREFIX_LEN strlen("security.")
1761 #define ZFS_XA_NS_LINUX_SYSTEM_PREFIX "system."
1762 #define ZFS_XA_NS_LINUX_SYSTEM_PREFIX_LEN strlen("system.")
1763 #define ZFS_XA_NS_LINUX_TRUSTED_PREFIX "trusted."
1764 #define ZFS_XA_NS_LINUX_TRUSTED_PREFIX_LEN strlen("trusted.")
1765 #define ZFS_XA_NS_LINUX_USER_PREFIX "user."
1766 #define ZFS_XA_NS_LINUX_USER_PREFIX_LEN strlen("user.")
1768 #define ZFS_XA_NS_PREFIX_MATCH(ns, name) \
1769 (strncmp(name, ZFS_XA_NS_##ns##_PREFIX, \
1770 ZFS_XA_NS_##ns##_PREFIX_LEN) == 0)
1772 #define ZFS_XA_NS_PREFIX_FORBIDDEN(name) \
1773 (ZFS_XA_NS_PREFIX_MATCH(FREEBSD, name) || \
1774 ZFS_XA_NS_PREFIX_MATCH(LINUX_SECURITY, name) || \
1775 ZFS_XA_NS_PREFIX_MATCH(LINUX_SYSTEM, name) || \
1776 ZFS_XA_NS_PREFIX_MATCH(LINUX_TRUSTED, name) || \
1777 ZFS_XA_NS_PREFIX_MATCH(LINUX_USER, name))
1783 #endif /* _SYS_FS_ZFS_H */