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, 2014 by Delphix. All rights reserved.
25 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
27 * Copyright (c) 2017 Datto Inc.
30 /* Portions Copyright 2010 Robert Milkowski */
36 #include <sys/zio_priority.h>
43 * Types and constants shared between userland and the kernel.
47 * Each dataset can be one of the following types. These constants can be
48 * combined into masks that can be passed to various functions.
51 ZFS_TYPE_FILESYSTEM
= (1 << 0),
52 ZFS_TYPE_SNAPSHOT
= (1 << 1),
53 ZFS_TYPE_VOLUME
= (1 << 2),
54 ZFS_TYPE_POOL
= (1 << 3),
55 ZFS_TYPE_BOOKMARK
= (1 << 4)
59 * NB: lzc_dataset_type should be updated whenever a new objset type is added,
60 * if it represents a real type of a dataset that can be created from userland.
62 typedef enum dmu_objset_type
{
67 DMU_OST_OTHER
, /* For testing only! */
68 DMU_OST_ANY
, /* Be careful! */
72 #define ZFS_TYPE_DATASET \
73 (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
76 * All of these include the terminating NUL byte.
78 #define ZAP_MAXNAMELEN 256
79 #define ZAP_MAXVALUELEN (1024 * 8)
80 #define ZAP_OLDMAXVALUELEN 1024
81 #define ZFS_MAX_DATASET_NAME_LEN 256
84 * Dataset properties are identified by these constants and must be added to
85 * the end of this list to ensure that external consumers are not affected
86 * by the change. If you make any changes to this list, be sure to update
87 * the property table in module/zcommon/zfs_prop.c.
96 ZFS_PROP_COMPRESSRATIO
,
100 ZFS_PROP_RESERVATION
,
102 ZFS_PROP_VOLBLOCKSIZE
,
107 ZFS_PROP_COMPRESSION
,
115 ZFS_PROP_PRIVATE
, /* not exposed to user, temporary */
118 ZFS_PROP_NAME
, /* not exposed to the user */
120 ZFS_PROP_ISCSIOPTIONS
, /* not exposed to the user */
122 ZFS_PROP_NUMCLONES
, /* not exposed to the user */
132 ZFS_PROP_REFRESERVATION
,
134 ZFS_PROP_PRIMARYCACHE
,
135 ZFS_PROP_SECONDARYCACHE
,
139 ZFS_PROP_USEDREFRESERV
,
140 ZFS_PROP_USERACCOUNTING
, /* not exposed to the user */
141 ZFS_PROP_STMF_SHAREINFO
, /* not exposed to the user */
142 ZFS_PROP_DEFER_DESTROY
,
145 ZFS_PROP_UNIQUE
, /* not exposed to the user */
146 ZFS_PROP_OBJSETID
, /* not exposed to the user */
154 ZFS_PROP_LOGICALUSED
,
155 ZFS_PROP_LOGICALREFERENCED
,
156 ZFS_PROP_INCONSISTENT
, /* not exposed to the user */
157 ZFS_PROP_FILESYSTEM_LIMIT
,
158 ZFS_PROP_SNAPSHOT_LIMIT
,
159 ZFS_PROP_FILESYSTEM_COUNT
,
160 ZFS_PROP_SNAPSHOT_COUNT
,
163 ZFS_PROP_SELINUX_CONTEXT
,
164 ZFS_PROP_SELINUX_FSCONTEXT
,
165 ZFS_PROP_SELINUX_DEFCONTEXT
,
166 ZFS_PROP_SELINUX_ROOTCONTEXT
,
168 ZFS_PROP_REDUNDANT_METADATA
,
171 ZFS_PROP_RECEIVE_RESUME_TOKEN
,
180 ZFS_PROP_USEROBJUSED
,
181 ZFS_PROP_USEROBJQUOTA
,
182 ZFS_PROP_GROUPOBJUSED
,
183 ZFS_PROP_GROUPOBJQUOTA
,
184 ZFS_NUM_USERQUOTA_PROPS
185 } zfs_userquota_prop_t
;
187 extern const char *zfs_userquota_prop_prefixes
[ZFS_NUM_USERQUOTA_PROPS
];
190 * Pool properties are identified by these constants and must be added to the
191 * end of this list to ensure that external consumers are not affected
192 * by the change. If you make any changes to this list, be sure to update
193 * the property table in module/zcommon/zpool_prop.c.
204 ZPOOL_PROP_DELEGATION
,
205 ZPOOL_PROP_AUTOREPLACE
,
206 ZPOOL_PROP_CACHEFILE
,
207 ZPOOL_PROP_FAILUREMODE
,
208 ZPOOL_PROP_LISTSNAPS
,
209 ZPOOL_PROP_AUTOEXPAND
,
210 ZPOOL_PROP_DEDUPDITTO
,
211 ZPOOL_PROP_DEDUPRATIO
,
213 ZPOOL_PROP_ALLOCATED
,
219 ZPOOL_PROP_FRAGMENTATION
,
221 ZPOOL_PROP_MAXBLOCKSIZE
,
223 ZPOOL_PROP_MAXDNODESIZE
,
227 /* Small enough to not hog a whole line of printout in zpool(1M). */
228 #define ZPROP_MAX_COMMENT 32
230 #define ZPROP_CONT -2
231 #define ZPROP_INVAL -1
233 #define ZPROP_VALUE "value"
234 #define ZPROP_SOURCE "source"
237 ZPROP_SRC_NONE
= 0x1,
238 ZPROP_SRC_DEFAULT
= 0x2,
239 ZPROP_SRC_TEMPORARY
= 0x4,
240 ZPROP_SRC_LOCAL
= 0x8,
241 ZPROP_SRC_INHERITED
= 0x10,
242 ZPROP_SRC_RECEIVED
= 0x20
245 #define ZPROP_SRC_ALL 0x3f
247 #define ZPROP_SOURCE_VAL_RECVD "$recvd"
248 #define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS"
251 * Dataset flag implemented as a special entry in the props zap object
252 * indicating that the dataset has received properties on or after
253 * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
254 * just as it did in earlier versions, and thereafter, local properties are
257 #define ZPROP_HAS_RECVD "$hasrecvd"
260 ZPROP_ERR_NOCLEAR
= 0x1, /* failure to clear existing props */
261 ZPROP_ERR_NORESTORE
= 0x2 /* failure to restore props on error */
264 typedef int (*zprop_func
)(int, void *);
267 * Properties to be set on the root file system of a new pool
268 * are stuffed into their own nvlist, which is then included in
269 * the properties nvlist with the pool properties.
271 #define ZPOOL_ROOTFS_PROPS "root-props-nvl"
274 * Dataset property functions shared between libzfs and kernel.
276 const char *zfs_prop_default_string(zfs_prop_t
);
277 uint64_t zfs_prop_default_numeric(zfs_prop_t
);
278 boolean_t
zfs_prop_readonly(zfs_prop_t
);
279 boolean_t
zfs_prop_inheritable(zfs_prop_t
);
280 boolean_t
zfs_prop_setonce(zfs_prop_t
);
281 const char *zfs_prop_to_name(zfs_prop_t
);
282 zfs_prop_t
zfs_name_to_prop(const char *);
283 boolean_t
zfs_prop_user(const char *);
284 boolean_t
zfs_prop_userquota(const char *);
285 boolean_t
zfs_prop_written(const char *);
286 int zfs_prop_index_to_string(zfs_prop_t
, uint64_t, const char **);
287 int zfs_prop_string_to_index(zfs_prop_t
, const char *, uint64_t *);
288 uint64_t zfs_prop_random_value(zfs_prop_t
, uint64_t seed
);
289 boolean_t
zfs_prop_valid_for_type(int, zfs_type_t
, boolean_t
);
292 * Pool property functions shared between libzfs and kernel.
294 zpool_prop_t
zpool_name_to_prop(const char *);
295 const char *zpool_prop_to_name(zpool_prop_t
);
296 const char *zpool_prop_default_string(zpool_prop_t
);
297 uint64_t zpool_prop_default_numeric(zpool_prop_t
);
298 boolean_t
zpool_prop_readonly(zpool_prop_t
);
299 boolean_t
zpool_prop_feature(const char *);
300 boolean_t
zpool_prop_unsupported(const char *);
301 int zpool_prop_index_to_string(zpool_prop_t
, uint64_t, const char **);
302 int zpool_prop_string_to_index(zpool_prop_t
, const char *, uint64_t *);
303 uint64_t zpool_prop_random_value(zpool_prop_t
, uint64_t seed
);
306 * Definitions for the Delegation.
309 ZFS_DELEG_WHO_UNKNOWN
= 0,
310 ZFS_DELEG_USER
= 'u',
311 ZFS_DELEG_USER_SETS
= 'U',
312 ZFS_DELEG_GROUP
= 'g',
313 ZFS_DELEG_GROUP_SETS
= 'G',
314 ZFS_DELEG_EVERYONE
= 'e',
315 ZFS_DELEG_EVERYONE_SETS
= 'E',
316 ZFS_DELEG_CREATE
= 'c',
317 ZFS_DELEG_CREATE_SETS
= 'C',
318 ZFS_DELEG_NAMED_SET
= 's',
319 ZFS_DELEG_NAMED_SET_SETS
= 'S'
320 } zfs_deleg_who_type_t
;
324 ZFS_DELEG_PERM_LOCAL
= 1,
325 ZFS_DELEG_PERM_DESCENDENT
= 2,
326 ZFS_DELEG_PERM_LOCALDESCENDENT
= 3,
327 ZFS_DELEG_PERM_CREATE
= 4
328 } zfs_deleg_inherit_t
;
330 #define ZFS_DELEG_PERM_UID "uid"
331 #define ZFS_DELEG_PERM_GID "gid"
332 #define ZFS_DELEG_PERM_GROUPS "groups"
334 #define ZFS_MLSLABEL_DEFAULT "none"
336 #define ZFS_SMB_ACL_SRC "src"
337 #define ZFS_SMB_ACL_TARGET "target"
340 ZFS_CANMOUNT_OFF
= 0,
342 ZFS_CANMOUNT_NOAUTO
= 2
343 } zfs_canmount_type_t
;
346 ZFS_LOGBIAS_LATENCY
= 0,
347 ZFS_LOGBIAS_THROUGHPUT
= 1
350 typedef enum zfs_share_op
{
357 typedef enum zfs_smb_acl_op
{
364 typedef enum zfs_cache_type
{
366 ZFS_CACHE_METADATA
= 1,
371 ZFS_SYNC_STANDARD
= 0,
373 ZFS_SYNC_DISABLED
= 2
383 ZFS_DNSIZE_LEGACY
= 0,
385 ZFS_DNSIZE_1K
= 1024,
386 ZFS_DNSIZE_2K
= 2048,
387 ZFS_DNSIZE_4K
= 4096,
388 ZFS_DNSIZE_8K
= 8192,
389 ZFS_DNSIZE_16K
= 16384
393 ZFS_REDUNDANT_METADATA_ALL
,
394 ZFS_REDUNDANT_METADATA_MOST
395 } zfs_redundant_metadata_type_t
;
398 * On-disk version number.
400 #define SPA_VERSION_1 1ULL
401 #define SPA_VERSION_2 2ULL
402 #define SPA_VERSION_3 3ULL
403 #define SPA_VERSION_4 4ULL
404 #define SPA_VERSION_5 5ULL
405 #define SPA_VERSION_6 6ULL
406 #define SPA_VERSION_7 7ULL
407 #define SPA_VERSION_8 8ULL
408 #define SPA_VERSION_9 9ULL
409 #define SPA_VERSION_10 10ULL
410 #define SPA_VERSION_11 11ULL
411 #define SPA_VERSION_12 12ULL
412 #define SPA_VERSION_13 13ULL
413 #define SPA_VERSION_14 14ULL
414 #define SPA_VERSION_15 15ULL
415 #define SPA_VERSION_16 16ULL
416 #define SPA_VERSION_17 17ULL
417 #define SPA_VERSION_18 18ULL
418 #define SPA_VERSION_19 19ULL
419 #define SPA_VERSION_20 20ULL
420 #define SPA_VERSION_21 21ULL
421 #define SPA_VERSION_22 22ULL
422 #define SPA_VERSION_23 23ULL
423 #define SPA_VERSION_24 24ULL
424 #define SPA_VERSION_25 25ULL
425 #define SPA_VERSION_26 26ULL
426 #define SPA_VERSION_27 27ULL
427 #define SPA_VERSION_28 28ULL
428 #define SPA_VERSION_5000 5000ULL
431 * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
432 * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
433 * and do the appropriate changes. Also bump the version number in
434 * usr/src/grub/capability.
436 #define SPA_VERSION SPA_VERSION_5000
437 #define SPA_VERSION_STRING "5000"
440 * Symbolic names for the changes that caused a SPA_VERSION switch.
441 * Used in the code when checking for presence or absence of a feature.
442 * Feel free to define multiple symbolic names for each version if there
443 * were multiple changes to on-disk structures during that version.
445 * NOTE: When checking the current SPA_VERSION in your code, be sure
446 * to use spa_version() since it reports the version of the
447 * last synced uberblock. Checking the in-flight version can
448 * be dangerous in some cases.
450 #define SPA_VERSION_INITIAL SPA_VERSION_1
451 #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2
452 #define SPA_VERSION_SPARES SPA_VERSION_3
453 #define SPA_VERSION_RAIDZ2 SPA_VERSION_3
454 #define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3
455 #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3
456 #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3
457 #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4
458 #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5
459 #define SPA_VERSION_BOOTFS SPA_VERSION_6
460 #define SPA_VERSION_SLOGS SPA_VERSION_7
461 #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8
462 #define SPA_VERSION_FUID SPA_VERSION_9
463 #define SPA_VERSION_REFRESERVATION SPA_VERSION_9
464 #define SPA_VERSION_REFQUOTA SPA_VERSION_9
465 #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9
466 #define SPA_VERSION_L2CACHE SPA_VERSION_10
467 #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11
468 #define SPA_VERSION_ORIGIN SPA_VERSION_11
469 #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11
470 #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12
471 #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13
472 #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14
473 #define SPA_VERSION_USERSPACE SPA_VERSION_15
474 #define SPA_VERSION_STMF_PROP SPA_VERSION_16
475 #define SPA_VERSION_RAIDZ3 SPA_VERSION_17
476 #define SPA_VERSION_USERREFS SPA_VERSION_18
477 #define SPA_VERSION_HOLES SPA_VERSION_19
478 #define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20
479 #define SPA_VERSION_DEDUP SPA_VERSION_21
480 #define SPA_VERSION_RECVD_PROPS SPA_VERSION_22
481 #define SPA_VERSION_SLIM_ZIL SPA_VERSION_23
482 #define SPA_VERSION_SA SPA_VERSION_24
483 #define SPA_VERSION_SCAN SPA_VERSION_25
484 #define SPA_VERSION_DIR_CLONES SPA_VERSION_26
485 #define SPA_VERSION_DEADLISTS SPA_VERSION_26
486 #define SPA_VERSION_FAST_SNAP SPA_VERSION_27
487 #define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28
488 #define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28
489 #define SPA_VERSION_FEATURES SPA_VERSION_5000
491 #define SPA_VERSION_IS_SUPPORTED(v) \
492 (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
493 ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
496 * ZPL version - rev'd whenever an incompatible on-disk format change
497 * occurs. This is independent of SPA/DMU/ZAP versioning. You must
498 * also update the version_table[] and help message in zfs_prop.c.
500 * When changing, be sure to teach GRUB how to read the new format!
501 * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
503 #define ZPL_VERSION_1 1ULL
504 #define ZPL_VERSION_2 2ULL
505 #define ZPL_VERSION_3 3ULL
506 #define ZPL_VERSION_4 4ULL
507 #define ZPL_VERSION_5 5ULL
508 #define ZPL_VERSION ZPL_VERSION_5
509 #define ZPL_VERSION_STRING "5"
511 #define ZPL_VERSION_INITIAL ZPL_VERSION_1
512 #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2
513 #define ZPL_VERSION_FUID ZPL_VERSION_3
514 #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3
515 #define ZPL_VERSION_SYSATTR ZPL_VERSION_3
516 #define ZPL_VERSION_USERSPACE ZPL_VERSION_4
517 #define ZPL_VERSION_SA ZPL_VERSION_5
519 /* Rewind request information */
520 #define ZPOOL_NO_REWIND 1 /* No policy - default behavior */
521 #define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */
522 #define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */
523 #define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */
524 #define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */
525 #define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */
526 #define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */
528 typedef struct zpool_rewind_policy
{
529 uint32_t zrp_request
; /* rewind behavior requested */
530 uint64_t zrp_maxmeta
; /* max acceptable meta-data errors */
531 uint64_t zrp_maxdata
; /* max acceptable data errors */
532 uint64_t zrp_txg
; /* specific txg to load */
533 } zpool_rewind_policy_t
;
536 * The following are configuration names used in the nvlist describing a pool's
539 #define ZPOOL_CONFIG_VERSION "version"
540 #define ZPOOL_CONFIG_POOL_NAME "name"
541 #define ZPOOL_CONFIG_POOL_STATE "state"
542 #define ZPOOL_CONFIG_POOL_TXG "txg"
543 #define ZPOOL_CONFIG_POOL_GUID "pool_guid"
544 #define ZPOOL_CONFIG_CREATE_TXG "create_txg"
545 #define ZPOOL_CONFIG_TOP_GUID "top_guid"
546 #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
547 #define ZPOOL_CONFIG_TYPE "type"
548 #define ZPOOL_CONFIG_CHILDREN "children"
549 #define ZPOOL_CONFIG_ID "id"
550 #define ZPOOL_CONFIG_GUID "guid"
551 #define ZPOOL_CONFIG_PATH "path"
552 #define ZPOOL_CONFIG_DEVID "devid"
553 #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array"
554 #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift"
555 #define ZPOOL_CONFIG_ASHIFT "ashift"
556 #define ZPOOL_CONFIG_ASIZE "asize"
557 #define ZPOOL_CONFIG_DTL "DTL"
558 #define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */
559 #define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */
561 /* container nvlist of extended stats */
562 #define ZPOOL_CONFIG_VDEV_STATS_EX "vdev_stats_ex"
564 /* Active queue read/write stats */
565 #define ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE "vdev_sync_r_active_queue"
566 #define ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE "vdev_sync_w_active_queue"
567 #define ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE "vdev_async_r_active_queue"
568 #define ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE "vdev_async_w_active_queue"
569 #define ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE "vdev_async_scrub_active_queue"
572 #define ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE "vdev_sync_r_pend_queue"
573 #define ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE "vdev_sync_w_pend_queue"
574 #define ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE "vdev_async_r_pend_queue"
575 #define ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE "vdev_async_w_pend_queue"
576 #define ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE "vdev_async_scrub_pend_queue"
578 /* Latency read/write histogram stats */
579 #define ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO "vdev_tot_r_lat_histo"
580 #define ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO "vdev_tot_w_lat_histo"
581 #define ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO "vdev_disk_r_lat_histo"
582 #define ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO "vdev_disk_w_lat_histo"
583 #define ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO "vdev_sync_r_lat_histo"
584 #define ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO "vdev_sync_w_lat_histo"
585 #define ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO "vdev_async_r_lat_histo"
586 #define ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO "vdev_async_w_lat_histo"
587 #define ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO "vdev_scrub_histo"
589 /* Request size histograms */
590 #define ZPOOL_CONFIG_VDEV_SYNC_IND_R_HISTO "vdev_sync_ind_r_histo"
591 #define ZPOOL_CONFIG_VDEV_SYNC_IND_W_HISTO "vdev_sync_ind_w_histo"
592 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_R_HISTO "vdev_async_ind_r_histo"
593 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_W_HISTO "vdev_async_ind_w_histo"
594 #define ZPOOL_CONFIG_VDEV_IND_SCRUB_HISTO "vdev_ind_scrub_histo"
595 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_R_HISTO "vdev_sync_agg_r_histo"
596 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_W_HISTO "vdev_sync_agg_w_histo"
597 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_R_HISTO "vdev_async_agg_r_histo"
598 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO "vdev_async_agg_w_histo"
599 #define ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO "vdev_agg_scrub_histo"
601 /* vdev enclosure sysfs path */
602 #define ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH "vdev_enc_sysfs_path"
604 #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
605 #define ZPOOL_CONFIG_ERRCOUNT "error_count"
606 #define ZPOOL_CONFIG_NOT_PRESENT "not_present"
607 #define ZPOOL_CONFIG_SPARES "spares"
608 #define ZPOOL_CONFIG_IS_SPARE "is_spare"
609 #define ZPOOL_CONFIG_NPARITY "nparity"
610 #define ZPOOL_CONFIG_HOSTID "hostid"
611 #define ZPOOL_CONFIG_HOSTNAME "hostname"
612 #define ZPOOL_CONFIG_LOADED_TIME "initial_load_time"
613 #define ZPOOL_CONFIG_UNSPARE "unspare"
614 #define ZPOOL_CONFIG_PHYS_PATH "phys_path"
615 #define ZPOOL_CONFIG_IS_LOG "is_log"
616 #define ZPOOL_CONFIG_L2CACHE "l2cache"
617 #define ZPOOL_CONFIG_HOLE_ARRAY "hole_array"
618 #define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
619 #define ZPOOL_CONFIG_IS_HOLE "is_hole"
620 #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
621 #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
622 #define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
623 #define ZPOOL_CONFIG_SPLIT "splitcfg"
624 #define ZPOOL_CONFIG_ORIG_GUID "orig_guid"
625 #define ZPOOL_CONFIG_SPLIT_GUID "split_guid"
626 #define ZPOOL_CONFIG_SPLIT_LIST "guid_list"
627 #define ZPOOL_CONFIG_REMOVING "removing"
628 #define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg"
629 #define ZPOOL_CONFIG_COMMENT "comment"
630 #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */
631 #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */
632 #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */
633 #define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */
634 #define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */
635 #define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */
636 #define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */
637 #define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */
638 #define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */
639 #define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read"
640 #define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */
641 #define ZPOOL_CONFIG_ERRATA "errata" /* not stored on disk */
642 #define ZPOOL_CONFIG_VDEV_TOP_ZAP "com.delphix:vdev_zap_top"
643 #define ZPOOL_CONFIG_VDEV_LEAF_ZAP "com.delphix:vdev_zap_leaf"
644 #define ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS "com.delphix:has_per_vdev_zaps"
646 * The persistent vdev state is stored as separate values rather than a single
647 * 'vdev_state' entry. This is because a device can be in multiple states, such
648 * as offline and degraded.
650 #define ZPOOL_CONFIG_OFFLINE "offline"
651 #define ZPOOL_CONFIG_FAULTED "faulted"
652 #define ZPOOL_CONFIG_DEGRADED "degraded"
653 #define ZPOOL_CONFIG_REMOVED "removed"
654 #define ZPOOL_CONFIG_FRU "fru"
655 #define ZPOOL_CONFIG_AUX_STATE "aux_state"
657 /* Rewind policy parameters */
658 #define ZPOOL_REWIND_POLICY "rewind-policy"
659 #define ZPOOL_REWIND_REQUEST "rewind-request"
660 #define ZPOOL_REWIND_REQUEST_TXG "rewind-request-txg"
661 #define ZPOOL_REWIND_META_THRESH "rewind-meta-thresh"
662 #define ZPOOL_REWIND_DATA_THRESH "rewind-data-thresh"
664 /* Rewind data discovered */
665 #define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts"
666 #define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors"
667 #define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind"
669 #define VDEV_TYPE_ROOT "root"
670 #define VDEV_TYPE_MIRROR "mirror"
671 #define VDEV_TYPE_REPLACING "replacing"
672 #define VDEV_TYPE_RAIDZ "raidz"
673 #define VDEV_TYPE_DISK "disk"
674 #define VDEV_TYPE_FILE "file"
675 #define VDEV_TYPE_MISSING "missing"
676 #define VDEV_TYPE_HOLE "hole"
677 #define VDEV_TYPE_SPARE "spare"
678 #define VDEV_TYPE_LOG "log"
679 #define VDEV_TYPE_L2CACHE "l2cache"
682 * This is needed in userland to report the minimum necessary device size.
684 #define SPA_MINDEVSIZE (64ULL << 20)
687 * Set if the fragmentation has not yet been calculated. This can happen
688 * because the space maps have not been upgraded or the histogram feature
691 #define ZFS_FRAG_INVALID UINT64_MAX
694 * The location of the pool configuration repository, shared between kernel and
697 #define ZPOOL_CACHE "/etc/zfs/zpool.cache"
700 * vdev states are ordered from least to most healthy.
701 * A vdev that's CANT_OPEN or below is considered unusable.
703 typedef enum vdev_state
{
704 VDEV_STATE_UNKNOWN
= 0, /* Uninitialized vdev */
705 VDEV_STATE_CLOSED
, /* Not currently open */
706 VDEV_STATE_OFFLINE
, /* Not allowed to open */
707 VDEV_STATE_REMOVED
, /* Explicitly removed from system */
708 VDEV_STATE_CANT_OPEN
, /* Tried to open, but failed */
709 VDEV_STATE_FAULTED
, /* External request to fault device */
710 VDEV_STATE_DEGRADED
, /* Replicated vdev with unhealthy kids */
711 VDEV_STATE_HEALTHY
/* Presumed good */
714 #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY
717 * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field
718 * of the vdev stats structure uses these constants to distinguish why.
720 typedef enum vdev_aux
{
721 VDEV_AUX_NONE
, /* no error */
722 VDEV_AUX_OPEN_FAILED
, /* ldi_open_*() or vn_open() failed */
723 VDEV_AUX_CORRUPT_DATA
, /* bad label or disk contents */
724 VDEV_AUX_NO_REPLICAS
, /* insufficient number of replicas */
725 VDEV_AUX_BAD_GUID_SUM
, /* vdev guid sum doesn't match */
726 VDEV_AUX_TOO_SMALL
, /* vdev size is too small */
727 VDEV_AUX_BAD_LABEL
, /* the label is OK but invalid */
728 VDEV_AUX_VERSION_NEWER
, /* on-disk version is too new */
729 VDEV_AUX_VERSION_OLDER
, /* on-disk version is too old */
730 VDEV_AUX_UNSUP_FEAT
, /* unsupported features */
731 VDEV_AUX_SPARED
, /* hot spare used in another pool */
732 VDEV_AUX_ERR_EXCEEDED
, /* too many errors */
733 VDEV_AUX_IO_FAILURE
, /* experienced I/O failure */
734 VDEV_AUX_BAD_LOG
, /* cannot read log chain(s) */
735 VDEV_AUX_EXTERNAL
, /* external diagnosis or forced fault */
736 VDEV_AUX_SPLIT_POOL
, /* vdev was split off into another pool */
737 VDEV_AUX_BAD_ASHIFT
, /* vdev ashift is invalid */
738 VDEV_AUX_EXTERNAL_PERSIST
/* persistent forced fault */
742 * pool state. The following states are written to disk as part of the normal
743 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
744 * states are software abstractions used at various levels to communicate
747 typedef enum pool_state
{
748 POOL_STATE_ACTIVE
= 0, /* In active use */
749 POOL_STATE_EXPORTED
, /* Explicitly exported */
750 POOL_STATE_DESTROYED
, /* Explicitly destroyed */
751 POOL_STATE_SPARE
, /* Reserved for hot spare use */
752 POOL_STATE_L2CACHE
, /* Level 2 ARC device */
753 POOL_STATE_UNINITIALIZED
, /* Internal spa_t state */
754 POOL_STATE_UNAVAIL
, /* Internal libzfs state */
755 POOL_STATE_POTENTIALLY_ACTIVE
/* Internal libzfs state */
761 typedef enum pool_scan_func
{
769 * ZIO types. Needed to interpret vdev statistics below.
771 typedef enum zio_type
{
782 * Pool statistics. Note: all fields should be 64-bit because this
783 * is passed between kernel and userland as an nvlist uint64 array.
785 typedef struct pool_scan_stat
{
786 /* values stored on disk */
787 uint64_t pss_func
; /* pool_scan_func_t */
788 uint64_t pss_state
; /* dsl_scan_state_t */
789 uint64_t pss_start_time
; /* scan start time */
790 uint64_t pss_end_time
; /* scan end time */
791 uint64_t pss_to_examine
; /* total bytes to scan */
792 uint64_t pss_examined
; /* total examined bytes */
793 uint64_t pss_to_process
; /* total bytes to process */
794 uint64_t pss_processed
; /* total processed bytes */
795 uint64_t pss_errors
; /* scan errors */
797 /* values not stored on disk */
798 uint64_t pss_pass_exam
; /* examined bytes per scan pass */
799 uint64_t pss_pass_start
; /* start time of a scan pass */
802 typedef enum dsl_scan_state
{
811 * Errata described by http://zfsonlinux.org/msg/ZFS-8000-ER. The ordering
812 * of this enum must be maintained to ensure the errata identifiers map to
813 * the correct documentation. New errata may only be appended to the list
814 * and must contain corresponding documentation at the above link.
816 typedef enum zpool_errata
{
818 ZPOOL_ERRATA_ZOL_2094_SCRUB
,
819 ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY
,
823 * Vdev statistics. Note: all fields should be 64-bit because this
824 * is passed between kernel and userland as an nvlist uint64 array.
826 typedef struct vdev_stat
{
827 hrtime_t vs_timestamp
; /* time since vdev load */
828 uint64_t vs_state
; /* vdev state */
829 uint64_t vs_aux
; /* see vdev_aux_t */
830 uint64_t vs_alloc
; /* space allocated */
831 uint64_t vs_space
; /* total capacity */
832 uint64_t vs_dspace
; /* deflated capacity */
833 uint64_t vs_rsize
; /* replaceable dev size */
834 uint64_t vs_esize
; /* expandable dev size */
835 uint64_t vs_ops
[ZIO_TYPES
]; /* operation count */
836 uint64_t vs_bytes
[ZIO_TYPES
]; /* bytes read/written */
837 uint64_t vs_read_errors
; /* read errors */
838 uint64_t vs_write_errors
; /* write errors */
839 uint64_t vs_checksum_errors
; /* checksum errors */
840 uint64_t vs_self_healed
; /* self-healed bytes */
841 uint64_t vs_scan_removing
; /* removing? */
842 uint64_t vs_scan_processed
; /* scan processed bytes */
843 uint64_t vs_fragmentation
; /* device fragmentation */
850 * These are stats which aren't included in the original iostat output. For
851 * convenience, they are grouped together in vdev_stat_ex, although each stat
852 * is individually exported as an nvlist.
854 typedef struct vdev_stat_ex
{
855 /* Number of ZIOs issued to disk and waiting to finish */
856 uint64_t vsx_active_queue
[ZIO_PRIORITY_NUM_QUEUEABLE
];
858 /* Number of ZIOs pending to be issued to disk */
859 uint64_t vsx_pend_queue
[ZIO_PRIORITY_NUM_QUEUEABLE
];
862 * Below are the histograms for various latencies. Buckets are in
863 * units of nanoseconds.
867 * 2^37 nanoseconds = 134s. Timeouts will probably start kicking in
870 #define VDEV_L_HISTO_BUCKETS 37 /* Latency histo buckets */
871 #define VDEV_RQ_HISTO_BUCKETS 25 /* Request size histo buckets */
874 /* Amount of time in ZIO queue (ns) */
875 uint64_t vsx_queue_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
876 [VDEV_L_HISTO_BUCKETS
];
878 /* Total ZIO latency (ns). Includes queuing and disk access time */
879 uint64_t vsx_total_histo
[ZIO_TYPES
][VDEV_L_HISTO_BUCKETS
];
881 /* Amount of time to read/write the disk (ns) */
882 uint64_t vsx_disk_histo
[ZIO_TYPES
][VDEV_L_HISTO_BUCKETS
];
884 /* "lookup the bucket for a value" histogram macros */
885 #define HISTO(val, buckets) (val != 0 ? MIN(highbit64(val) - 1, \
887 #define L_HISTO(a) HISTO(a, VDEV_L_HISTO_BUCKETS)
888 #define RQ_HISTO(a) HISTO(a, VDEV_RQ_HISTO_BUCKETS)
890 /* Physical IO histogram */
891 uint64_t vsx_ind_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
892 [VDEV_RQ_HISTO_BUCKETS
];
894 /* Delegated (aggregated) physical IO histogram */
895 uint64_t vsx_agg_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
896 [VDEV_RQ_HISTO_BUCKETS
];
901 * DDT statistics. Note: all fields should be 64-bit because this
902 * is passed between kernel and userland as an nvlist uint64 array.
904 typedef struct ddt_object
{
905 uint64_t ddo_count
; /* number of elements in ddt */
906 uint64_t ddo_dspace
; /* size of ddt on disk */
907 uint64_t ddo_mspace
; /* size of ddt in-core */
910 typedef struct ddt_stat
{
911 uint64_t dds_blocks
; /* blocks */
912 uint64_t dds_lsize
; /* logical size */
913 uint64_t dds_psize
; /* physical size */
914 uint64_t dds_dsize
; /* deflated allocated size */
915 uint64_t dds_ref_blocks
; /* referenced blocks */
916 uint64_t dds_ref_lsize
; /* referenced lsize * refcnt */
917 uint64_t dds_ref_psize
; /* referenced psize * refcnt */
918 uint64_t dds_ref_dsize
; /* referenced dsize * refcnt */
921 typedef struct ddt_histogram
{
922 ddt_stat_t ddh_stat
[64]; /* power-of-two histogram buckets */
925 #define ZVOL_DRIVER "zvol"
926 #define ZFS_DRIVER "zfs"
927 #define ZFS_DEV "/dev/zfs"
928 #define ZFS_SHARETAB "/etc/dfs/sharetab"
930 #define ZFS_SUPER_MAGIC 0x2fc12fc1
932 /* general zvol path */
933 #define ZVOL_DIR "/dev"
935 #define ZVOL_MAJOR 230
936 #define ZVOL_MINOR_BITS 4
937 #define ZVOL_MINOR_MASK ((1U << ZVOL_MINOR_BITS) - 1)
938 #define ZVOL_MINORS (1 << 4)
939 #define ZVOL_DEV_NAME "zd"
941 #define ZVOL_PROP_NAME "name"
942 #define ZVOL_DEFAULT_BLOCKSIZE 8192
945 * /dev/zfs ioctl numbers.
947 typedef enum zfs_ioc
{
949 * Illumos - 71/128 numbers reserved.
951 ZFS_IOC_FIRST
= ('Z' << 8),
952 ZFS_IOC
= ZFS_IOC_FIRST
,
953 ZFS_IOC_POOL_CREATE
= ZFS_IOC_FIRST
,
954 ZFS_IOC_POOL_DESTROY
,
957 ZFS_IOC_POOL_CONFIGS
,
959 ZFS_IOC_POOL_TRYIMPORT
,
962 ZFS_IOC_POOL_UPGRADE
,
963 ZFS_IOC_POOL_GET_HISTORY
,
966 ZFS_IOC_VDEV_SET_STATE
,
969 ZFS_IOC_VDEV_SETPATH
,
971 ZFS_IOC_OBJSET_STATS
,
972 ZFS_IOC_OBJSET_ZPLPROPS
,
973 ZFS_IOC_DATASET_LIST_NEXT
,
974 ZFS_IOC_SNAPSHOT_LIST_NEXT
,
982 ZFS_IOC_INJECT_FAULT
,
984 ZFS_IOC_INJECT_LIST_NEXT
,
989 ZFS_IOC_DSOBJ_TO_DSNAME
,
991 ZFS_IOC_POOL_SET_PROPS
,
992 ZFS_IOC_POOL_GET_PROPS
,
996 ZFS_IOC_INHERIT_PROP
,
998 ZFS_IOC_USERSPACE_ONE
,
999 ZFS_IOC_USERSPACE_MANY
,
1000 ZFS_IOC_USERSPACE_UPGRADE
,
1004 ZFS_IOC_OBJSET_RECVD_PROPS
,
1008 ZFS_IOC_TMP_SNAPSHOT
,
1009 ZFS_IOC_OBJ_TO_STATS
,
1010 ZFS_IOC_SPACE_WRITTEN
,
1011 ZFS_IOC_SPACE_SNAPS
,
1012 ZFS_IOC_DESTROY_SNAPS
,
1013 ZFS_IOC_POOL_REGUID
,
1014 ZFS_IOC_POOL_REOPEN
,
1015 ZFS_IOC_SEND_PROGRESS
,
1016 ZFS_IOC_LOG_HISTORY
,
1021 ZFS_IOC_GET_BOOKMARKS
,
1022 ZFS_IOC_DESTROY_BOOKMARKS
,
1027 * Linux - 3/64 numbers reserved.
1029 ZFS_IOC_LINUX
= ('Z' << 8) + 0x80,
1030 ZFS_IOC_EVENTS_NEXT
,
1031 ZFS_IOC_EVENTS_CLEAR
,
1032 ZFS_IOC_EVENTS_SEEK
,
1035 * FreeBSD - 1/64 numbers reserved.
1037 ZFS_IOC_FREEBSD
= ('Z' << 8) + 0xC0,
1043 * zvol ioctl to get dataset name
1045 #define BLKZNAME _IOR(0x12, 125, char[ZFS_MAX_DATASET_NAME_LEN])
1048 * Internal SPA load state. Used by FMA diagnosis engine.
1051 SPA_LOAD_NONE
, /* no load in progress */
1052 SPA_LOAD_OPEN
, /* normal open */
1053 SPA_LOAD_IMPORT
, /* import in progress */
1054 SPA_LOAD_TRYIMPORT
, /* tryimport in progress */
1055 SPA_LOAD_RECOVER
, /* recovery requested */
1056 SPA_LOAD_ERROR
, /* load failed */
1057 SPA_LOAD_CREATE
/* creation in progress */
1061 * Bookmark name values.
1063 #define ZPOOL_ERR_LIST "error list"
1064 #define ZPOOL_ERR_DATASET "dataset"
1065 #define ZPOOL_ERR_OBJECT "object"
1067 #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1)
1070 * The following are names used in the nvlist describing
1071 * the pool's history log.
1073 #define ZPOOL_HIST_RECORD "history record"
1074 #define ZPOOL_HIST_TIME "history time"
1075 #define ZPOOL_HIST_CMD "history command"
1076 #define ZPOOL_HIST_WHO "history who"
1077 #define ZPOOL_HIST_ZONE "history zone"
1078 #define ZPOOL_HIST_HOST "history hostname"
1079 #define ZPOOL_HIST_TXG "history txg"
1080 #define ZPOOL_HIST_INT_EVENT "history internal event"
1081 #define ZPOOL_HIST_INT_STR "history internal str"
1082 #define ZPOOL_HIST_INT_NAME "internal_name"
1083 #define ZPOOL_HIST_IOCTL "ioctl"
1084 #define ZPOOL_HIST_INPUT_NVL "in_nvl"
1085 #define ZPOOL_HIST_OUTPUT_NVL "out_nvl"
1086 #define ZPOOL_HIST_DSNAME "dsname"
1087 #define ZPOOL_HIST_DSID "dsid"
1090 * Flags for ZFS_IOC_VDEV_SET_STATE
1092 #define ZFS_ONLINE_CHECKREMOVE 0x1
1093 #define ZFS_ONLINE_UNSPARE 0x2
1094 #define ZFS_ONLINE_FORCEFAULT 0x4
1095 #define ZFS_ONLINE_EXPAND 0x8
1096 #define ZFS_OFFLINE_TEMPORARY 0x1
1099 * Flags for ZFS_IOC_POOL_IMPORT
1101 #define ZFS_IMPORT_NORMAL 0x0
1102 #define ZFS_IMPORT_VERBATIM 0x1
1103 #define ZFS_IMPORT_ANY_HOST 0x2
1104 #define ZFS_IMPORT_MISSING_LOG 0x4
1105 #define ZFS_IMPORT_ONLY 0x8
1106 #define ZFS_IMPORT_TEMP_NAME 0x10
1109 * Sysevent payload members. ZFS will generate the following sysevents with the
1112 * ESC_ZFS_RESILVER_START
1113 * ESC_ZFS_RESILVER_END
1114 * ESC_ZFS_POOL_DESTROY
1115 * ESC_ZFS_POOL_REGUID
1117 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1118 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1120 * ESC_ZFS_VDEV_REMOVE
1121 * ESC_ZFS_VDEV_CLEAR
1122 * ESC_ZFS_VDEV_CHECK
1124 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1125 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1126 * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional)
1127 * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64
1129 #define ZFS_EV_POOL_NAME "pool_name"
1130 #define ZFS_EV_POOL_GUID "pool_guid"
1131 #define ZFS_EV_VDEV_PATH "vdev_path"
1132 #define ZFS_EV_VDEV_GUID "vdev_guid"
1138 #endif /* _SYS_FS_ZFS_H */