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