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)
57 typedef enum dmu_objset_type
{
62 DMU_OST_OTHER
, /* For testing only! */
63 DMU_OST_ANY
, /* Be careful! */
67 #define ZFS_TYPE_DATASET \
68 (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
71 * All of these include the terminating NUL byte.
73 #define ZAP_MAXNAMELEN 256
74 #define ZAP_MAXVALUELEN (1024 * 8)
75 #define ZAP_OLDMAXVALUELEN 1024
76 #define ZFS_MAX_DATASET_NAME_LEN 256
79 * Dataset properties are identified by these constants and must be added to
80 * the end of this list to ensure that external consumers are not affected
81 * by the change. If you make any changes to this list, be sure to update
82 * the property table in module/zcommon/zfs_prop.c.
90 ZFS_PROP_COMPRESSRATIO
,
96 ZFS_PROP_VOLBLOCKSIZE
,
101 ZFS_PROP_COMPRESSION
,
109 ZFS_PROP_PRIVATE
, /* not exposed to user, temporary */
111 ZFS_PROP_CREATETXG
, /* not exposed to the user */
112 ZFS_PROP_NAME
, /* not exposed to the user */
114 ZFS_PROP_ISCSIOPTIONS
, /* not exposed to the user */
116 ZFS_PROP_NUMCLONES
, /* not exposed to the user */
126 ZFS_PROP_REFRESERVATION
,
128 ZFS_PROP_PRIMARYCACHE
,
129 ZFS_PROP_SECONDARYCACHE
,
133 ZFS_PROP_USEDREFRESERV
,
134 ZFS_PROP_USERACCOUNTING
, /* not exposed to the user */
135 ZFS_PROP_STMF_SHAREINFO
, /* not exposed to the user */
136 ZFS_PROP_DEFER_DESTROY
,
139 ZFS_PROP_UNIQUE
, /* not exposed to the user */
140 ZFS_PROP_OBJSETID
, /* not exposed to the user */
148 ZFS_PROP_LOGICALUSED
,
149 ZFS_PROP_LOGICALREFERENCED
,
150 ZFS_PROP_INCONSISTENT
, /* not exposed to the user */
151 ZFS_PROP_FILESYSTEM_LIMIT
,
152 ZFS_PROP_SNAPSHOT_LIMIT
,
153 ZFS_PROP_FILESYSTEM_COUNT
,
154 ZFS_PROP_SNAPSHOT_COUNT
,
157 ZFS_PROP_SELINUX_CONTEXT
,
158 ZFS_PROP_SELINUX_FSCONTEXT
,
159 ZFS_PROP_SELINUX_DEFCONTEXT
,
160 ZFS_PROP_SELINUX_ROOTCONTEXT
,
162 ZFS_PROP_REDUNDANT_METADATA
,
165 ZFS_PROP_RECEIVE_RESUME_TOKEN
,
174 ZFS_PROP_USEROBJUSED
,
175 ZFS_PROP_USEROBJQUOTA
,
176 ZFS_PROP_GROUPOBJUSED
,
177 ZFS_PROP_GROUPOBJQUOTA
,
178 ZFS_NUM_USERQUOTA_PROPS
179 } zfs_userquota_prop_t
;
181 extern const char *zfs_userquota_prop_prefixes
[ZFS_NUM_USERQUOTA_PROPS
];
184 * Pool properties are identified by these constants and must be added to the
185 * end of this list to ensure that external consumers are not affected
186 * by the change. If you make any changes to this list, be sure to update
187 * the property table in module/zcommon/zpool_prop.c.
198 ZPOOL_PROP_DELEGATION
,
199 ZPOOL_PROP_AUTOREPLACE
,
200 ZPOOL_PROP_CACHEFILE
,
201 ZPOOL_PROP_FAILUREMODE
,
202 ZPOOL_PROP_LISTSNAPS
,
203 ZPOOL_PROP_AUTOEXPAND
,
204 ZPOOL_PROP_DEDUPDITTO
,
205 ZPOOL_PROP_DEDUPRATIO
,
207 ZPOOL_PROP_ALLOCATED
,
213 ZPOOL_PROP_FRAGMENTATION
,
215 ZPOOL_PROP_MAXBLOCKSIZE
,
217 ZPOOL_PROP_MAXDNODESIZE
,
221 /* Small enough to not hog a whole line of printout in zpool(1M). */
222 #define ZPROP_MAX_COMMENT 32
224 #define ZPROP_CONT -2
225 #define ZPROP_INVAL -1
227 #define ZPROP_VALUE "value"
228 #define ZPROP_SOURCE "source"
231 ZPROP_SRC_NONE
= 0x1,
232 ZPROP_SRC_DEFAULT
= 0x2,
233 ZPROP_SRC_TEMPORARY
= 0x4,
234 ZPROP_SRC_LOCAL
= 0x8,
235 ZPROP_SRC_INHERITED
= 0x10,
236 ZPROP_SRC_RECEIVED
= 0x20
239 #define ZPROP_SRC_ALL 0x3f
241 #define ZPROP_SOURCE_VAL_RECVD "$recvd"
242 #define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS"
245 * Dataset flag implemented as a special entry in the props zap object
246 * indicating that the dataset has received properties on or after
247 * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
248 * just as it did in earlier versions, and thereafter, local properties are
251 #define ZPROP_HAS_RECVD "$hasrecvd"
254 ZPROP_ERR_NOCLEAR
= 0x1, /* failure to clear existing props */
255 ZPROP_ERR_NORESTORE
= 0x2 /* failure to restore props on error */
258 typedef int (*zprop_func
)(int, void *);
261 * Properties to be set on the root file system of a new pool
262 * are stuffed into their own nvlist, which is then included in
263 * the properties nvlist with the pool properties.
265 #define ZPOOL_ROOTFS_PROPS "root-props-nvl"
268 * Dataset property functions shared between libzfs and kernel.
270 const char *zfs_prop_default_string(zfs_prop_t
);
271 uint64_t zfs_prop_default_numeric(zfs_prop_t
);
272 boolean_t
zfs_prop_readonly(zfs_prop_t
);
273 boolean_t
zfs_prop_inheritable(zfs_prop_t
);
274 boolean_t
zfs_prop_setonce(zfs_prop_t
);
275 const char *zfs_prop_to_name(zfs_prop_t
);
276 zfs_prop_t
zfs_name_to_prop(const char *);
277 boolean_t
zfs_prop_user(const char *);
278 boolean_t
zfs_prop_userquota(const char *);
279 boolean_t
zfs_prop_written(const char *);
280 int zfs_prop_index_to_string(zfs_prop_t
, uint64_t, const char **);
281 int zfs_prop_string_to_index(zfs_prop_t
, const char *, uint64_t *);
282 uint64_t zfs_prop_random_value(zfs_prop_t
, uint64_t seed
);
283 boolean_t
zfs_prop_valid_for_type(int, zfs_type_t
, boolean_t
);
286 * Pool property functions shared between libzfs and kernel.
288 zpool_prop_t
zpool_name_to_prop(const char *);
289 const char *zpool_prop_to_name(zpool_prop_t
);
290 const char *zpool_prop_default_string(zpool_prop_t
);
291 uint64_t zpool_prop_default_numeric(zpool_prop_t
);
292 boolean_t
zpool_prop_readonly(zpool_prop_t
);
293 boolean_t
zpool_prop_feature(const char *);
294 boolean_t
zpool_prop_unsupported(const char *);
295 int zpool_prop_index_to_string(zpool_prop_t
, uint64_t, const char **);
296 int zpool_prop_string_to_index(zpool_prop_t
, const char *, uint64_t *);
297 uint64_t zpool_prop_random_value(zpool_prop_t
, uint64_t seed
);
300 * Definitions for the Delegation.
303 ZFS_DELEG_WHO_UNKNOWN
= 0,
304 ZFS_DELEG_USER
= 'u',
305 ZFS_DELEG_USER_SETS
= 'U',
306 ZFS_DELEG_GROUP
= 'g',
307 ZFS_DELEG_GROUP_SETS
= 'G',
308 ZFS_DELEG_EVERYONE
= 'e',
309 ZFS_DELEG_EVERYONE_SETS
= 'E',
310 ZFS_DELEG_CREATE
= 'c',
311 ZFS_DELEG_CREATE_SETS
= 'C',
312 ZFS_DELEG_NAMED_SET
= 's',
313 ZFS_DELEG_NAMED_SET_SETS
= 'S'
314 } zfs_deleg_who_type_t
;
318 ZFS_DELEG_PERM_LOCAL
= 1,
319 ZFS_DELEG_PERM_DESCENDENT
= 2,
320 ZFS_DELEG_PERM_LOCALDESCENDENT
= 3,
321 ZFS_DELEG_PERM_CREATE
= 4
322 } zfs_deleg_inherit_t
;
324 #define ZFS_DELEG_PERM_UID "uid"
325 #define ZFS_DELEG_PERM_GID "gid"
326 #define ZFS_DELEG_PERM_GROUPS "groups"
328 #define ZFS_MLSLABEL_DEFAULT "none"
330 #define ZFS_SMB_ACL_SRC "src"
331 #define ZFS_SMB_ACL_TARGET "target"
334 ZFS_CANMOUNT_OFF
= 0,
336 ZFS_CANMOUNT_NOAUTO
= 2
337 } zfs_canmount_type_t
;
340 ZFS_LOGBIAS_LATENCY
= 0,
341 ZFS_LOGBIAS_THROUGHPUT
= 1
344 typedef enum zfs_share_op
{
351 typedef enum zfs_smb_acl_op
{
358 typedef enum zfs_cache_type
{
360 ZFS_CACHE_METADATA
= 1,
365 ZFS_SYNC_STANDARD
= 0,
367 ZFS_SYNC_DISABLED
= 2
377 ZFS_DNSIZE_LEGACY
= 0,
379 ZFS_DNSIZE_1K
= 1024,
380 ZFS_DNSIZE_2K
= 2048,
381 ZFS_DNSIZE_4K
= 4096,
382 ZFS_DNSIZE_8K
= 8192,
383 ZFS_DNSIZE_16K
= 16384
387 ZFS_REDUNDANT_METADATA_ALL
,
388 ZFS_REDUNDANT_METADATA_MOST
389 } zfs_redundant_metadata_type_t
;
392 * On-disk version number.
394 #define SPA_VERSION_1 1ULL
395 #define SPA_VERSION_2 2ULL
396 #define SPA_VERSION_3 3ULL
397 #define SPA_VERSION_4 4ULL
398 #define SPA_VERSION_5 5ULL
399 #define SPA_VERSION_6 6ULL
400 #define SPA_VERSION_7 7ULL
401 #define SPA_VERSION_8 8ULL
402 #define SPA_VERSION_9 9ULL
403 #define SPA_VERSION_10 10ULL
404 #define SPA_VERSION_11 11ULL
405 #define SPA_VERSION_12 12ULL
406 #define SPA_VERSION_13 13ULL
407 #define SPA_VERSION_14 14ULL
408 #define SPA_VERSION_15 15ULL
409 #define SPA_VERSION_16 16ULL
410 #define SPA_VERSION_17 17ULL
411 #define SPA_VERSION_18 18ULL
412 #define SPA_VERSION_19 19ULL
413 #define SPA_VERSION_20 20ULL
414 #define SPA_VERSION_21 21ULL
415 #define SPA_VERSION_22 22ULL
416 #define SPA_VERSION_23 23ULL
417 #define SPA_VERSION_24 24ULL
418 #define SPA_VERSION_25 25ULL
419 #define SPA_VERSION_26 26ULL
420 #define SPA_VERSION_27 27ULL
421 #define SPA_VERSION_28 28ULL
422 #define SPA_VERSION_5000 5000ULL
425 * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
426 * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
427 * and do the appropriate changes. Also bump the version number in
428 * usr/src/grub/capability.
430 #define SPA_VERSION SPA_VERSION_5000
431 #define SPA_VERSION_STRING "5000"
434 * Symbolic names for the changes that caused a SPA_VERSION switch.
435 * Used in the code when checking for presence or absence of a feature.
436 * Feel free to define multiple symbolic names for each version if there
437 * were multiple changes to on-disk structures during that version.
439 * NOTE: When checking the current SPA_VERSION in your code, be sure
440 * to use spa_version() since it reports the version of the
441 * last synced uberblock. Checking the in-flight version can
442 * be dangerous in some cases.
444 #define SPA_VERSION_INITIAL SPA_VERSION_1
445 #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2
446 #define SPA_VERSION_SPARES SPA_VERSION_3
447 #define SPA_VERSION_RAIDZ2 SPA_VERSION_3
448 #define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3
449 #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3
450 #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3
451 #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4
452 #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5
453 #define SPA_VERSION_BOOTFS SPA_VERSION_6
454 #define SPA_VERSION_SLOGS SPA_VERSION_7
455 #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8
456 #define SPA_VERSION_FUID SPA_VERSION_9
457 #define SPA_VERSION_REFRESERVATION SPA_VERSION_9
458 #define SPA_VERSION_REFQUOTA SPA_VERSION_9
459 #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9
460 #define SPA_VERSION_L2CACHE SPA_VERSION_10
461 #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11
462 #define SPA_VERSION_ORIGIN SPA_VERSION_11
463 #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11
464 #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12
465 #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13
466 #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14
467 #define SPA_VERSION_USERSPACE SPA_VERSION_15
468 #define SPA_VERSION_STMF_PROP SPA_VERSION_16
469 #define SPA_VERSION_RAIDZ3 SPA_VERSION_17
470 #define SPA_VERSION_USERREFS SPA_VERSION_18
471 #define SPA_VERSION_HOLES SPA_VERSION_19
472 #define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20
473 #define SPA_VERSION_DEDUP SPA_VERSION_21
474 #define SPA_VERSION_RECVD_PROPS SPA_VERSION_22
475 #define SPA_VERSION_SLIM_ZIL SPA_VERSION_23
476 #define SPA_VERSION_SA SPA_VERSION_24
477 #define SPA_VERSION_SCAN SPA_VERSION_25
478 #define SPA_VERSION_DIR_CLONES SPA_VERSION_26
479 #define SPA_VERSION_DEADLISTS SPA_VERSION_26
480 #define SPA_VERSION_FAST_SNAP SPA_VERSION_27
481 #define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28
482 #define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28
483 #define SPA_VERSION_FEATURES SPA_VERSION_5000
485 #define SPA_VERSION_IS_SUPPORTED(v) \
486 (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
487 ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
490 * ZPL version - rev'd whenever an incompatible on-disk format change
491 * occurs. This is independent of SPA/DMU/ZAP versioning. You must
492 * also update the version_table[] and help message in zfs_prop.c.
494 * When changing, be sure to teach GRUB how to read the new format!
495 * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
497 #define ZPL_VERSION_1 1ULL
498 #define ZPL_VERSION_2 2ULL
499 #define ZPL_VERSION_3 3ULL
500 #define ZPL_VERSION_4 4ULL
501 #define ZPL_VERSION_5 5ULL
502 #define ZPL_VERSION ZPL_VERSION_5
503 #define ZPL_VERSION_STRING "5"
505 #define ZPL_VERSION_INITIAL ZPL_VERSION_1
506 #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2
507 #define ZPL_VERSION_FUID ZPL_VERSION_3
508 #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3
509 #define ZPL_VERSION_SYSATTR ZPL_VERSION_3
510 #define ZPL_VERSION_USERSPACE ZPL_VERSION_4
511 #define ZPL_VERSION_SA ZPL_VERSION_5
513 /* Rewind request information */
514 #define ZPOOL_NO_REWIND 1 /* No policy - default behavior */
515 #define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */
516 #define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */
517 #define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */
518 #define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */
519 #define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */
520 #define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */
522 typedef struct zpool_rewind_policy
{
523 uint32_t zrp_request
; /* rewind behavior requested */
524 uint64_t zrp_maxmeta
; /* max acceptable meta-data errors */
525 uint64_t zrp_maxdata
; /* max acceptable data errors */
526 uint64_t zrp_txg
; /* specific txg to load */
527 } zpool_rewind_policy_t
;
530 * The following are configuration names used in the nvlist describing a pool's
533 #define ZPOOL_CONFIG_VERSION "version"
534 #define ZPOOL_CONFIG_POOL_NAME "name"
535 #define ZPOOL_CONFIG_POOL_STATE "state"
536 #define ZPOOL_CONFIG_POOL_TXG "txg"
537 #define ZPOOL_CONFIG_POOL_GUID "pool_guid"
538 #define ZPOOL_CONFIG_CREATE_TXG "create_txg"
539 #define ZPOOL_CONFIG_TOP_GUID "top_guid"
540 #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
541 #define ZPOOL_CONFIG_TYPE "type"
542 #define ZPOOL_CONFIG_CHILDREN "children"
543 #define ZPOOL_CONFIG_ID "id"
544 #define ZPOOL_CONFIG_GUID "guid"
545 #define ZPOOL_CONFIG_PATH "path"
546 #define ZPOOL_CONFIG_DEVID "devid"
547 #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array"
548 #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift"
549 #define ZPOOL_CONFIG_ASHIFT "ashift"
550 #define ZPOOL_CONFIG_ASIZE "asize"
551 #define ZPOOL_CONFIG_DTL "DTL"
552 #define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */
553 #define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */
555 /* container nvlist of extended stats */
556 #define ZPOOL_CONFIG_VDEV_STATS_EX "vdev_stats_ex"
558 /* Active queue read/write stats */
559 #define ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE "vdev_sync_r_active_queue"
560 #define ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE "vdev_sync_w_active_queue"
561 #define ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE "vdev_async_r_active_queue"
562 #define ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE "vdev_async_w_active_queue"
563 #define ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE "vdev_async_scrub_active_queue"
566 #define ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE "vdev_sync_r_pend_queue"
567 #define ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE "vdev_sync_w_pend_queue"
568 #define ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE "vdev_async_r_pend_queue"
569 #define ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE "vdev_async_w_pend_queue"
570 #define ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE "vdev_async_scrub_pend_queue"
572 /* Latency read/write histogram stats */
573 #define ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO "vdev_tot_r_lat_histo"
574 #define ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO "vdev_tot_w_lat_histo"
575 #define ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO "vdev_disk_r_lat_histo"
576 #define ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO "vdev_disk_w_lat_histo"
577 #define ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO "vdev_sync_r_lat_histo"
578 #define ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO "vdev_sync_w_lat_histo"
579 #define ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO "vdev_async_r_lat_histo"
580 #define ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO "vdev_async_w_lat_histo"
581 #define ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO "vdev_scrub_histo"
583 /* Request size histograms */
584 #define ZPOOL_CONFIG_VDEV_SYNC_IND_R_HISTO "vdev_sync_ind_r_histo"
585 #define ZPOOL_CONFIG_VDEV_SYNC_IND_W_HISTO "vdev_sync_ind_w_histo"
586 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_R_HISTO "vdev_async_ind_r_histo"
587 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_W_HISTO "vdev_async_ind_w_histo"
588 #define ZPOOL_CONFIG_VDEV_IND_SCRUB_HISTO "vdev_ind_scrub_histo"
589 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_R_HISTO "vdev_sync_agg_r_histo"
590 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_W_HISTO "vdev_sync_agg_w_histo"
591 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_R_HISTO "vdev_async_agg_r_histo"
592 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO "vdev_async_agg_w_histo"
593 #define ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO "vdev_agg_scrub_histo"
595 #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
596 #define ZPOOL_CONFIG_ERRCOUNT "error_count"
597 #define ZPOOL_CONFIG_NOT_PRESENT "not_present"
598 #define ZPOOL_CONFIG_SPARES "spares"
599 #define ZPOOL_CONFIG_IS_SPARE "is_spare"
600 #define ZPOOL_CONFIG_NPARITY "nparity"
601 #define ZPOOL_CONFIG_HOSTID "hostid"
602 #define ZPOOL_CONFIG_HOSTNAME "hostname"
603 #define ZPOOL_CONFIG_LOADED_TIME "initial_load_time"
604 #define ZPOOL_CONFIG_UNSPARE "unspare"
605 #define ZPOOL_CONFIG_PHYS_PATH "phys_path"
606 #define ZPOOL_CONFIG_IS_LOG "is_log"
607 #define ZPOOL_CONFIG_L2CACHE "l2cache"
608 #define ZPOOL_CONFIG_HOLE_ARRAY "hole_array"
609 #define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
610 #define ZPOOL_CONFIG_IS_HOLE "is_hole"
611 #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
612 #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
613 #define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
614 #define ZPOOL_CONFIG_SPLIT "splitcfg"
615 #define ZPOOL_CONFIG_ORIG_GUID "orig_guid"
616 #define ZPOOL_CONFIG_SPLIT_GUID "split_guid"
617 #define ZPOOL_CONFIG_SPLIT_LIST "guid_list"
618 #define ZPOOL_CONFIG_REMOVING "removing"
619 #define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg"
620 #define ZPOOL_CONFIG_COMMENT "comment"
621 #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */
622 #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */
623 #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */
624 #define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */
625 #define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */
626 #define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */
627 #define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */
628 #define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */
629 #define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */
630 #define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read"
631 #define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */
632 #define ZPOOL_CONFIG_ERRATA "errata" /* not stored on disk */
633 #define ZPOOL_CONFIG_VDEV_TOP_ZAP "com.delphix:vdev_zap_top"
634 #define ZPOOL_CONFIG_VDEV_LEAF_ZAP "com.delphix:vdev_zap_leaf"
635 #define ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS "com.delphix:has_per_vdev_zaps"
637 * The persistent vdev state is stored as separate values rather than a single
638 * 'vdev_state' entry. This is because a device can be in multiple states, such
639 * as offline and degraded.
641 #define ZPOOL_CONFIG_OFFLINE "offline"
642 #define ZPOOL_CONFIG_FAULTED "faulted"
643 #define ZPOOL_CONFIG_DEGRADED "degraded"
644 #define ZPOOL_CONFIG_REMOVED "removed"
645 #define ZPOOL_CONFIG_FRU "fru"
646 #define ZPOOL_CONFIG_AUX_STATE "aux_state"
648 /* Rewind policy parameters */
649 #define ZPOOL_REWIND_POLICY "rewind-policy"
650 #define ZPOOL_REWIND_REQUEST "rewind-request"
651 #define ZPOOL_REWIND_REQUEST_TXG "rewind-request-txg"
652 #define ZPOOL_REWIND_META_THRESH "rewind-meta-thresh"
653 #define ZPOOL_REWIND_DATA_THRESH "rewind-data-thresh"
655 /* Rewind data discovered */
656 #define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts"
657 #define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors"
658 #define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind"
660 #define VDEV_TYPE_ROOT "root"
661 #define VDEV_TYPE_MIRROR "mirror"
662 #define VDEV_TYPE_REPLACING "replacing"
663 #define VDEV_TYPE_RAIDZ "raidz"
664 #define VDEV_TYPE_DISK "disk"
665 #define VDEV_TYPE_FILE "file"
666 #define VDEV_TYPE_MISSING "missing"
667 #define VDEV_TYPE_HOLE "hole"
668 #define VDEV_TYPE_SPARE "spare"
669 #define VDEV_TYPE_LOG "log"
670 #define VDEV_TYPE_L2CACHE "l2cache"
673 * This is needed in userland to report the minimum necessary device size.
675 #define SPA_MINDEVSIZE (64ULL << 20)
678 * Set if the fragmentation has not yet been calculated. This can happen
679 * because the space maps have not been upgraded or the histogram feature
682 #define ZFS_FRAG_INVALID UINT64_MAX
685 * The location of the pool configuration repository, shared between kernel and
688 #define ZPOOL_CACHE "/etc/zfs/zpool.cache"
691 * vdev states are ordered from least to most healthy.
692 * A vdev that's CANT_OPEN or below is considered unusable.
694 typedef enum vdev_state
{
695 VDEV_STATE_UNKNOWN
= 0, /* Uninitialized vdev */
696 VDEV_STATE_CLOSED
, /* Not currently open */
697 VDEV_STATE_OFFLINE
, /* Not allowed to open */
698 VDEV_STATE_REMOVED
, /* Explicitly removed from system */
699 VDEV_STATE_CANT_OPEN
, /* Tried to open, but failed */
700 VDEV_STATE_FAULTED
, /* External request to fault device */
701 VDEV_STATE_DEGRADED
, /* Replicated vdev with unhealthy kids */
702 VDEV_STATE_HEALTHY
/* Presumed good */
705 #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY
708 * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field
709 * of the vdev stats structure uses these constants to distinguish why.
711 typedef enum vdev_aux
{
712 VDEV_AUX_NONE
, /* no error */
713 VDEV_AUX_OPEN_FAILED
, /* ldi_open_*() or vn_open() failed */
714 VDEV_AUX_CORRUPT_DATA
, /* bad label or disk contents */
715 VDEV_AUX_NO_REPLICAS
, /* insufficient number of replicas */
716 VDEV_AUX_BAD_GUID_SUM
, /* vdev guid sum doesn't match */
717 VDEV_AUX_TOO_SMALL
, /* vdev size is too small */
718 VDEV_AUX_BAD_LABEL
, /* the label is OK but invalid */
719 VDEV_AUX_VERSION_NEWER
, /* on-disk version is too new */
720 VDEV_AUX_VERSION_OLDER
, /* on-disk version is too old */
721 VDEV_AUX_UNSUP_FEAT
, /* unsupported features */
722 VDEV_AUX_SPARED
, /* hot spare used in another pool */
723 VDEV_AUX_ERR_EXCEEDED
, /* too many errors */
724 VDEV_AUX_IO_FAILURE
, /* experienced I/O failure */
725 VDEV_AUX_BAD_LOG
, /* cannot read log chain(s) */
726 VDEV_AUX_EXTERNAL
, /* external diagnosis */
727 VDEV_AUX_SPLIT_POOL
/* vdev was split off into another pool */
731 * pool state. The following states are written to disk as part of the normal
732 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
733 * states are software abstractions used at various levels to communicate
736 typedef enum pool_state
{
737 POOL_STATE_ACTIVE
= 0, /* In active use */
738 POOL_STATE_EXPORTED
, /* Explicitly exported */
739 POOL_STATE_DESTROYED
, /* Explicitly destroyed */
740 POOL_STATE_SPARE
, /* Reserved for hot spare use */
741 POOL_STATE_L2CACHE
, /* Level 2 ARC device */
742 POOL_STATE_UNINITIALIZED
, /* Internal spa_t state */
743 POOL_STATE_UNAVAIL
, /* Internal libzfs state */
744 POOL_STATE_POTENTIALLY_ACTIVE
/* Internal libzfs state */
750 typedef enum pool_scan_func
{
758 * ZIO types. Needed to interpret vdev statistics below.
760 typedef enum zio_type
{
771 * Pool statistics. Note: all fields should be 64-bit because this
772 * is passed between kernel and userland as an nvlist uint64 array.
774 typedef struct pool_scan_stat
{
775 /* values stored on disk */
776 uint64_t pss_func
; /* pool_scan_func_t */
777 uint64_t pss_state
; /* dsl_scan_state_t */
778 uint64_t pss_start_time
; /* scan start time */
779 uint64_t pss_end_time
; /* scan end time */
780 uint64_t pss_to_examine
; /* total bytes to scan */
781 uint64_t pss_examined
; /* total examined bytes */
782 uint64_t pss_to_process
; /* total bytes to process */
783 uint64_t pss_processed
; /* total processed bytes */
784 uint64_t pss_errors
; /* scan errors */
786 /* values not stored on disk */
787 uint64_t pss_pass_exam
; /* examined bytes per scan pass */
788 uint64_t pss_pass_start
; /* start time of a scan pass */
791 typedef enum dsl_scan_state
{
800 * Errata described by http://zfsonlinux.org/msg/ZFS-8000-ER. The ordering
801 * of this enum must be maintained to ensure the errata identifiers map to
802 * the correct documentation. New errata may only be appended to the list
803 * and must contain corresponding documentation at the above link.
805 typedef enum zpool_errata
{
807 ZPOOL_ERRATA_ZOL_2094_SCRUB
,
808 ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY
,
812 * Vdev statistics. Note: all fields should be 64-bit because this
813 * is passed between kernel and userland as an nvlist uint64 array.
815 typedef struct vdev_stat
{
816 hrtime_t vs_timestamp
; /* time since vdev load */
817 uint64_t vs_state
; /* vdev state */
818 uint64_t vs_aux
; /* see vdev_aux_t */
819 uint64_t vs_alloc
; /* space allocated */
820 uint64_t vs_space
; /* total capacity */
821 uint64_t vs_dspace
; /* deflated capacity */
822 uint64_t vs_rsize
; /* replaceable dev size */
823 uint64_t vs_esize
; /* expandable dev size */
824 uint64_t vs_ops
[ZIO_TYPES
]; /* operation count */
825 uint64_t vs_bytes
[ZIO_TYPES
]; /* bytes read/written */
826 uint64_t vs_read_errors
; /* read errors */
827 uint64_t vs_write_errors
; /* write errors */
828 uint64_t vs_checksum_errors
; /* checksum errors */
829 uint64_t vs_self_healed
; /* self-healed bytes */
830 uint64_t vs_scan_removing
; /* removing? */
831 uint64_t vs_scan_processed
; /* scan processed bytes */
832 uint64_t vs_fragmentation
; /* device fragmentation */
839 * These are stats which aren't included in the original iostat output. For
840 * convenience, they are grouped together in vdev_stat_ex, although each stat
841 * is individually exported as an nvlist.
843 typedef struct vdev_stat_ex
{
844 /* Number of ZIOs issued to disk and waiting to finish */
845 uint64_t vsx_active_queue
[ZIO_PRIORITY_NUM_QUEUEABLE
];
847 /* Number of ZIOs pending to be issued to disk */
848 uint64_t vsx_pend_queue
[ZIO_PRIORITY_NUM_QUEUEABLE
];
851 * Below are the histograms for various latencies. Buckets are in
852 * units of nanoseconds.
856 * 2^37 nanoseconds = 134s. Timeouts will probably start kicking in
859 #define VDEV_L_HISTO_BUCKETS 37 /* Latency histo buckets */
860 #define VDEV_RQ_HISTO_BUCKETS 25 /* Request size histo buckets */
863 /* Amount of time in ZIO queue (ns) */
864 uint64_t vsx_queue_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
865 [VDEV_L_HISTO_BUCKETS
];
867 /* Total ZIO latency (ns). Includes queuing and disk access time */
868 uint64_t vsx_total_histo
[ZIO_TYPES
][VDEV_L_HISTO_BUCKETS
];
870 /* Amount of time to read/write the disk (ns) */
871 uint64_t vsx_disk_histo
[ZIO_TYPES
][VDEV_L_HISTO_BUCKETS
];
873 /* "lookup the bucket for a value" histogram macros */
874 #define HISTO(val, buckets) (val != 0 ? MIN(highbit64(val) - 1, \
876 #define L_HISTO(a) HISTO(a, VDEV_L_HISTO_BUCKETS)
877 #define RQ_HISTO(a) HISTO(a, VDEV_RQ_HISTO_BUCKETS)
879 /* Physical IO histogram */
880 uint64_t vsx_ind_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
881 [VDEV_RQ_HISTO_BUCKETS
];
883 /* Delegated (aggregated) physical IO histogram */
884 uint64_t vsx_agg_histo
[ZIO_PRIORITY_NUM_QUEUEABLE
]
885 [VDEV_RQ_HISTO_BUCKETS
];
890 * DDT statistics. Note: all fields should be 64-bit because this
891 * is passed between kernel and userland as an nvlist uint64 array.
893 typedef struct ddt_object
{
894 uint64_t ddo_count
; /* number of elments in ddt */
895 uint64_t ddo_dspace
; /* size of ddt on disk */
896 uint64_t ddo_mspace
; /* size of ddt in-core */
899 typedef struct ddt_stat
{
900 uint64_t dds_blocks
; /* blocks */
901 uint64_t dds_lsize
; /* logical size */
902 uint64_t dds_psize
; /* physical size */
903 uint64_t dds_dsize
; /* deflated allocated size */
904 uint64_t dds_ref_blocks
; /* referenced blocks */
905 uint64_t dds_ref_lsize
; /* referenced lsize * refcnt */
906 uint64_t dds_ref_psize
; /* referenced psize * refcnt */
907 uint64_t dds_ref_dsize
; /* referenced dsize * refcnt */
910 typedef struct ddt_histogram
{
911 ddt_stat_t ddh_stat
[64]; /* power-of-two histogram buckets */
914 #define ZVOL_DRIVER "zvol"
915 #define ZFS_DRIVER "zfs"
916 #define ZFS_DEV "/dev/zfs"
918 /* general zvol path */
919 #define ZVOL_DIR "/dev"
921 #define ZVOL_MAJOR 230
922 #define ZVOL_MINOR_BITS 4
923 #define ZVOL_MINOR_MASK ((1U << ZVOL_MINOR_BITS) - 1)
924 #define ZVOL_MINORS (1 << 4)
925 #define ZVOL_DEV_NAME "zd"
927 #define ZVOL_PROP_NAME "name"
928 #define ZVOL_DEFAULT_BLOCKSIZE 8192
931 * /dev/zfs ioctl numbers.
933 typedef enum zfs_ioc
{
935 * Illumos - 71/128 numbers reserved.
937 ZFS_IOC_FIRST
= ('Z' << 8),
938 ZFS_IOC
= ZFS_IOC_FIRST
,
939 ZFS_IOC_POOL_CREATE
= ZFS_IOC_FIRST
,
940 ZFS_IOC_POOL_DESTROY
,
943 ZFS_IOC_POOL_CONFIGS
,
945 ZFS_IOC_POOL_TRYIMPORT
,
948 ZFS_IOC_POOL_UPGRADE
,
949 ZFS_IOC_POOL_GET_HISTORY
,
952 ZFS_IOC_VDEV_SET_STATE
,
955 ZFS_IOC_VDEV_SETPATH
,
957 ZFS_IOC_OBJSET_STATS
,
958 ZFS_IOC_OBJSET_ZPLPROPS
,
959 ZFS_IOC_DATASET_LIST_NEXT
,
960 ZFS_IOC_SNAPSHOT_LIST_NEXT
,
968 ZFS_IOC_INJECT_FAULT
,
970 ZFS_IOC_INJECT_LIST_NEXT
,
975 ZFS_IOC_DSOBJ_TO_DSNAME
,
977 ZFS_IOC_POOL_SET_PROPS
,
978 ZFS_IOC_POOL_GET_PROPS
,
982 ZFS_IOC_INHERIT_PROP
,
984 ZFS_IOC_USERSPACE_ONE
,
985 ZFS_IOC_USERSPACE_MANY
,
986 ZFS_IOC_USERSPACE_UPGRADE
,
990 ZFS_IOC_OBJSET_RECVD_PROPS
,
994 ZFS_IOC_TMP_SNAPSHOT
,
995 ZFS_IOC_OBJ_TO_STATS
,
996 ZFS_IOC_SPACE_WRITTEN
,
998 ZFS_IOC_DESTROY_SNAPS
,
1000 ZFS_IOC_POOL_REOPEN
,
1001 ZFS_IOC_SEND_PROGRESS
,
1002 ZFS_IOC_LOG_HISTORY
,
1007 ZFS_IOC_GET_BOOKMARKS
,
1008 ZFS_IOC_DESTROY_BOOKMARKS
,
1012 * Linux - 3/64 numbers reserved.
1014 ZFS_IOC_LINUX
= ('Z' << 8) + 0x80,
1015 ZFS_IOC_EVENTS_NEXT
,
1016 ZFS_IOC_EVENTS_CLEAR
,
1017 ZFS_IOC_EVENTS_SEEK
,
1020 * FreeBSD - 1/64 numbers reserved.
1022 ZFS_IOC_FREEBSD
= ('Z' << 8) + 0xC0,
1028 * zvol ioctl to get dataset name
1030 #define BLKZNAME _IOR(0x12, 125, char[ZFS_MAX_DATASET_NAME_LEN])
1033 * Internal SPA load state. Used by FMA diagnosis engine.
1036 SPA_LOAD_NONE
, /* no load in progress */
1037 SPA_LOAD_OPEN
, /* normal open */
1038 SPA_LOAD_IMPORT
, /* import in progress */
1039 SPA_LOAD_TRYIMPORT
, /* tryimport in progress */
1040 SPA_LOAD_RECOVER
, /* recovery requested */
1041 SPA_LOAD_ERROR
/* load failed */
1045 * Bookmark name values.
1047 #define ZPOOL_ERR_LIST "error list"
1048 #define ZPOOL_ERR_DATASET "dataset"
1049 #define ZPOOL_ERR_OBJECT "object"
1051 #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1)
1054 * The following are names used in the nvlist describing
1055 * the pool's history log.
1057 #define ZPOOL_HIST_RECORD "history record"
1058 #define ZPOOL_HIST_TIME "history time"
1059 #define ZPOOL_HIST_CMD "history command"
1060 #define ZPOOL_HIST_WHO "history who"
1061 #define ZPOOL_HIST_ZONE "history zone"
1062 #define ZPOOL_HIST_HOST "history hostname"
1063 #define ZPOOL_HIST_TXG "history txg"
1064 #define ZPOOL_HIST_INT_EVENT "history internal event"
1065 #define ZPOOL_HIST_INT_STR "history internal str"
1066 #define ZPOOL_HIST_INT_NAME "internal_name"
1067 #define ZPOOL_HIST_IOCTL "ioctl"
1068 #define ZPOOL_HIST_INPUT_NVL "in_nvl"
1069 #define ZPOOL_HIST_OUTPUT_NVL "out_nvl"
1070 #define ZPOOL_HIST_DSNAME "dsname"
1071 #define ZPOOL_HIST_DSID "dsid"
1074 * Flags for ZFS_IOC_VDEV_SET_STATE
1076 #define ZFS_ONLINE_CHECKREMOVE 0x1
1077 #define ZFS_ONLINE_UNSPARE 0x2
1078 #define ZFS_ONLINE_FORCEFAULT 0x4
1079 #define ZFS_ONLINE_EXPAND 0x8
1080 #define ZFS_OFFLINE_TEMPORARY 0x1
1083 * Flags for ZFS_IOC_POOL_IMPORT
1085 #define ZFS_IMPORT_NORMAL 0x0
1086 #define ZFS_IMPORT_VERBATIM 0x1
1087 #define ZFS_IMPORT_ANY_HOST 0x2
1088 #define ZFS_IMPORT_MISSING_LOG 0x4
1089 #define ZFS_IMPORT_ONLY 0x8
1090 #define ZFS_IMPORT_TEMP_NAME 0x10
1093 * Sysevent payload members. ZFS will generate the following sysevents with the
1096 * ESC_ZFS_RESILVER_START
1097 * ESC_ZFS_RESILVER_END
1098 * ESC_ZFS_POOL_DESTROY
1099 * ESC_ZFS_POOL_REGUID
1101 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1102 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1104 * ESC_ZFS_VDEV_REMOVE
1105 * ESC_ZFS_VDEV_CLEAR
1106 * ESC_ZFS_VDEV_CHECK
1108 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1109 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1110 * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional)
1111 * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64
1113 #define ZFS_EV_POOL_NAME "pool_name"
1114 #define ZFS_EV_POOL_GUID "pool_guid"
1115 #define ZFS_EV_VDEV_PATH "vdev_path"
1116 #define ZFS_EV_VDEV_GUID "vdev_guid"
1122 #endif /* _SYS_FS_ZFS_H */