1 /* 2 * CDDL HEADER START 3 * 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. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright (c) 2011, 2020 by Delphix. All rights reserved. 25 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 26 * Copyright (c) 2014 Integros [integros.com] 27 * Copyright 2020 Joyent, Inc. 28 * Copyright (c) 2017 Datto Inc. 29 * Copyright (c) 2017, Intel Corporation. 30 */ 31 32 /* Portions Copyright 2010 Robert Milkowski */ 33 34 #ifndef _SYS_FS_ZFS_H 35 #define _SYS_FS_ZFS_H 36 37 #include <sys/time.h> 38 /* 39 * In OpenZFS we include sys/zio_priority.h to get the enum value of 40 * ZIO_PRIORITY_NUM_QUEUEABLE, which is used for the various array sizes in 41 * the structure definitions below. However, in illumos zio_priority.h is not 42 * readily available to the userland code where we have a very large number of 43 * files including sys/zfs.h. Thus, we define ZIO_PRIORITY_N_QUEUEABLE here and 44 * this should be kept in sync if ZIO_PRIORITY_NUM_QUEUEABLE changes. 45 */ 46 #define ZIO_PRIORITY_N_QUEUEABLE 8 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 /* 53 * Types and constants shared between userland and the kernel. 54 */ 55 56 /* 57 * Each dataset can be one of the following types. These constants can be 58 * combined into masks that can be passed to various functions. 59 */ 60 typedef enum { 61 ZFS_TYPE_FILESYSTEM = (1 << 0), 62 ZFS_TYPE_SNAPSHOT = (1 << 1), 63 ZFS_TYPE_VOLUME = (1 << 2), 64 ZFS_TYPE_POOL = (1 << 3), 65 ZFS_TYPE_BOOKMARK = (1 << 4) 66 } zfs_type_t; 67 68 /* 69 * NB: lzc_dataset_type should be updated whenever a new objset type is added, 70 * if it represents a real type of a dataset that can be created from userland. 71 */ 72 typedef enum dmu_objset_type { 73 DMU_OST_NONE, 74 DMU_OST_META, 75 DMU_OST_ZFS, 76 DMU_OST_ZVOL, 77 DMU_OST_OTHER, /* For testing only! */ 78 DMU_OST_ANY, /* Be careful! */ 79 DMU_OST_NUMTYPES 80 } dmu_objset_type_t; 81 82 #define ZFS_TYPE_DATASET \ 83 (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) 84 85 /* 86 * All of these include the terminating NUL byte. 87 */ 88 #define ZAP_MAXNAMELEN 256 89 #define ZAP_MAXVALUELEN (1024 * 8) 90 #define ZAP_OLDMAXVALUELEN 1024 91 #define ZFS_MAX_DATASET_NAME_LEN 256 92 93 /* 94 * Dataset properties are identified by these constants and must be added to 95 * the end of this list to ensure that external consumers are not affected 96 * by the change. If you make any changes to this list, be sure to update 97 * the property table in usr/src/common/zfs/zfs_prop.c. 98 */ 99 typedef enum { 100 ZPROP_CONT = -2, 101 ZPROP_INVAL = -1, 102 ZFS_PROP_TYPE = 0, 103 ZFS_PROP_CREATION, 104 ZFS_PROP_USED, 105 ZFS_PROP_AVAILABLE, 106 ZFS_PROP_REFERENCED, 107 ZFS_PROP_COMPRESSRATIO, 108 ZFS_PROP_MOUNTED, 109 ZFS_PROP_ORIGIN, 110 ZFS_PROP_QUOTA, 111 ZFS_PROP_RESERVATION, 112 ZFS_PROP_VOLSIZE, 113 ZFS_PROP_VOLBLOCKSIZE, 114 ZFS_PROP_RECORDSIZE, 115 ZFS_PROP_MOUNTPOINT, 116 ZFS_PROP_SHARENFS, 117 ZFS_PROP_CHECKSUM, 118 ZFS_PROP_COMPRESSION, 119 ZFS_PROP_ATIME, 120 ZFS_PROP_DEVICES, 121 ZFS_PROP_EXEC, 122 ZFS_PROP_SETUID, 123 ZFS_PROP_READONLY, 124 ZFS_PROP_ZONED, 125 ZFS_PROP_SNAPDIR, 126 ZFS_PROP_ACLMODE, 127 ZFS_PROP_ACLINHERIT, 128 ZFS_PROP_ACLIMPLICIT, /* ACL Implicit Owner Rights (RackTop) */ 129 ZFS_PROP_CREATETXG, 130 ZFS_PROP_NAME, /* not exposed to the user */ 131 ZFS_PROP_CANMOUNT, 132 ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */ 133 ZFS_PROP_XATTR, 134 ZFS_PROP_NUMCLONES, /* not exposed to the user */ 135 ZFS_PROP_COPIES, 136 ZFS_PROP_VERSION, 137 ZFS_PROP_UTF8ONLY, 138 ZFS_PROP_NORMALIZE, 139 ZFS_PROP_CASE, 140 ZFS_PROP_VSCAN, 141 ZFS_PROP_NBMAND, 142 ZFS_PROP_SHARESMB, 143 ZFS_PROP_REFQUOTA, 144 ZFS_PROP_REFRESERVATION, 145 ZFS_PROP_GUID, 146 ZFS_PROP_PRIMARYCACHE, 147 ZFS_PROP_SECONDARYCACHE, 148 ZFS_PROP_USEDSNAP, 149 ZFS_PROP_USEDDS, 150 ZFS_PROP_USEDCHILD, 151 ZFS_PROP_USEDREFRESERV, 152 ZFS_PROP_USERACCOUNTING, /* not exposed to the user */ 153 ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */ 154 ZFS_PROP_DEFER_DESTROY, 155 ZFS_PROP_USERREFS, 156 ZFS_PROP_LOGBIAS, 157 ZFS_PROP_UNIQUE, /* not exposed to the user */ 158 ZFS_PROP_OBJSETID, /* not exposed to the user */ 159 ZFS_PROP_DEDUP, 160 ZFS_PROP_MLSLABEL, 161 ZFS_PROP_SYNC, 162 ZFS_PROP_DNODESIZE, 163 ZFS_PROP_REFRATIO, 164 ZFS_PROP_WRITTEN, 165 ZFS_PROP_CLONES, 166 ZFS_PROP_LOGICALUSED, 167 ZFS_PROP_LOGICALREFERENCED, 168 ZFS_PROP_INCONSISTENT, /* not exposed to the user */ 169 ZFS_PROP_FILESYSTEM_LIMIT, 170 ZFS_PROP_SNAPSHOT_LIMIT, 171 ZFS_PROP_FILESYSTEM_COUNT, 172 ZFS_PROP_SNAPSHOT_COUNT, 173 ZFS_PROP_REDUNDANT_METADATA, 174 ZFS_PROP_PREV_SNAP, 175 ZFS_PROP_RECEIVE_RESUME_TOKEN, 176 ZFS_PROP_REMAPTXG, /* not exposed to the user */ 177 ZFS_PROP_SPECIAL_SMALL_BLOCKS, 178 ZFS_PROP_ENCRYPTION, 179 ZFS_PROP_KEYLOCATION, 180 ZFS_PROP_KEYFORMAT, 181 ZFS_PROP_PBKDF2_SALT, 182 ZFS_PROP_PBKDF2_ITERS, 183 ZFS_PROP_ENCRYPTION_ROOT, 184 ZFS_PROP_KEY_GUID, 185 ZFS_PROP_KEYSTATUS, 186 ZFS_PROP_IVSET_GUID, /* not exposed to the user */ 187 ZFS_NUM_PROPS 188 } zfs_prop_t; 189 190 typedef enum { 191 ZFS_PROP_USERUSED, 192 ZFS_PROP_USERQUOTA, 193 ZFS_PROP_GROUPUSED, 194 ZFS_PROP_GROUPQUOTA, 195 ZFS_PROP_USEROBJUSED, 196 ZFS_PROP_USEROBJQUOTA, 197 ZFS_PROP_GROUPOBJUSED, 198 ZFS_PROP_GROUPOBJQUOTA, 199 ZFS_PROP_PROJECTUSED, 200 ZFS_PROP_PROJECTQUOTA, 201 ZFS_PROP_PROJECTOBJUSED, 202 ZFS_PROP_PROJECTOBJQUOTA, 203 ZFS_NUM_USERQUOTA_PROPS 204 } zfs_userquota_prop_t; 205 206 extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS]; 207 208 /* 209 * Pool properties are identified by these constants and must be added to the 210 * end of this list to ensure that external consumers are not affected 211 * by the change. If you make any changes to this list, be sure to update 212 * the property table in usr/src/common/zfs/zpool_prop.c. 213 */ 214 typedef enum { 215 ZPOOL_PROP_INVAL = -1, 216 ZPOOL_PROP_NAME, 217 ZPOOL_PROP_SIZE, 218 ZPOOL_PROP_CAPACITY, 219 ZPOOL_PROP_ALTROOT, 220 ZPOOL_PROP_HEALTH, 221 ZPOOL_PROP_GUID, 222 ZPOOL_PROP_VERSION, 223 ZPOOL_PROP_BOOTFS, 224 ZPOOL_PROP_DELEGATION, 225 ZPOOL_PROP_AUTOREPLACE, 226 ZPOOL_PROP_CACHEFILE, 227 ZPOOL_PROP_FAILUREMODE, 228 ZPOOL_PROP_LISTSNAPS, 229 ZPOOL_PROP_AUTOEXPAND, 230 ZPOOL_PROP_DEDUPDITTO, 231 ZPOOL_PROP_DEDUPRATIO, 232 ZPOOL_PROP_FREE, 233 ZPOOL_PROP_ALLOCATED, 234 ZPOOL_PROP_READONLY, 235 ZPOOL_PROP_COMMENT, 236 ZPOOL_PROP_EXPANDSZ, 237 ZPOOL_PROP_FREEING, 238 ZPOOL_PROP_FRAGMENTATION, 239 ZPOOL_PROP_LEAKED, 240 ZPOOL_PROP_MAXBLOCKSIZE, 241 ZPOOL_PROP_BOOTSIZE, 242 ZPOOL_PROP_CHECKPOINT, 243 ZPOOL_PROP_TNAME, 244 ZPOOL_PROP_MAXDNODESIZE, 245 ZPOOL_PROP_MULTIHOST, 246 ZPOOL_PROP_ASHIFT, 247 ZPOOL_PROP_AUTOTRIM, 248 ZPOOL_NUM_PROPS 249 } zpool_prop_t; 250 251 /* Small enough to not hog a whole line of printout in zpool(8). */ 252 #define ZPROP_MAX_COMMENT 32 253 254 #define ZPROP_VALUE "value" 255 #define ZPROP_SOURCE "source" 256 257 typedef enum { 258 ZPROP_SRC_NONE = 0x1, 259 ZPROP_SRC_DEFAULT = 0x2, 260 ZPROP_SRC_TEMPORARY = 0x4, 261 ZPROP_SRC_LOCAL = 0x8, 262 ZPROP_SRC_INHERITED = 0x10, 263 ZPROP_SRC_RECEIVED = 0x20 264 } zprop_source_t; 265 266 #define ZPROP_SRC_ALL 0x3f 267 268 #define ZPROP_SOURCE_VAL_RECVD "$recvd" 269 #define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS" 270 /* 271 * Dataset flag implemented as a special entry in the props zap object 272 * indicating that the dataset has received properties on or after 273 * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties 274 * just as it did in earlier versions, and thereafter, local properties are 275 * preserved. 276 */ 277 #define ZPROP_HAS_RECVD "$hasrecvd" 278 279 typedef enum { 280 ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */ 281 ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */ 282 } zprop_errflags_t; 283 284 typedef int (*zprop_func)(int, void *); 285 286 /* 287 * Properties to be set on the root file system of a new pool 288 * are stuffed into their own nvlist, which is then included in 289 * the properties nvlist with the pool properties. 290 */ 291 #define ZPOOL_ROOTFS_PROPS "root-props-nvl" 292 293 /* 294 * Length of 'written@' and 'written#' 295 */ 296 #define ZFS_WRITTEN_PROP_PREFIX_LEN 8 297 298 /* 299 * Dataset property functions shared between libzfs and kernel. 300 */ 301 const char *zfs_prop_default_string(zfs_prop_t); 302 uint64_t zfs_prop_default_numeric(zfs_prop_t); 303 boolean_t zfs_prop_readonly(zfs_prop_t); 304 boolean_t zfs_prop_visible(zfs_prop_t prop); 305 boolean_t zfs_prop_inheritable(zfs_prop_t); 306 boolean_t zfs_prop_setonce(zfs_prop_t); 307 boolean_t zfs_prop_encryption_key_param(zfs_prop_t); 308 boolean_t zfs_prop_valid_keylocation(const char *, boolean_t); 309 const char *zfs_prop_to_name(zfs_prop_t); 310 zfs_prop_t zfs_name_to_prop(const char *); 311 boolean_t zfs_prop_user(const char *); 312 boolean_t zfs_prop_userquota(const char *); 313 boolean_t zfs_prop_written(const char *); 314 int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); 315 int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *); 316 uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed); 317 boolean_t zfs_prop_valid_for_type(int, zfs_type_t); 318 319 /* 320 * Pool property functions shared between libzfs and kernel. 321 */ 322 zpool_prop_t zpool_name_to_prop(const char *); 323 const char *zpool_prop_to_name(zpool_prop_t); 324 const char *zpool_prop_default_string(zpool_prop_t); 325 uint64_t zpool_prop_default_numeric(zpool_prop_t); 326 boolean_t zpool_prop_readonly(zpool_prop_t); 327 boolean_t zpool_prop_feature(const char *); 328 boolean_t zpool_prop_unsupported(const char *name); 329 int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **); 330 int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *); 331 uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed); 332 333 /* 334 * Definitions for the Delegation. 335 */ 336 typedef enum { 337 ZFS_DELEG_WHO_UNKNOWN = 0, 338 ZFS_DELEG_USER = 'u', 339 ZFS_DELEG_USER_SETS = 'U', 340 ZFS_DELEG_GROUP = 'g', 341 ZFS_DELEG_GROUP_SETS = 'G', 342 ZFS_DELEG_EVERYONE = 'e', 343 ZFS_DELEG_EVERYONE_SETS = 'E', 344 ZFS_DELEG_CREATE = 'c', 345 ZFS_DELEG_CREATE_SETS = 'C', 346 ZFS_DELEG_NAMED_SET = 's', 347 ZFS_DELEG_NAMED_SET_SETS = 'S' 348 } zfs_deleg_who_type_t; 349 350 typedef enum { 351 ZFS_DELEG_NONE = 0, 352 ZFS_DELEG_PERM_LOCAL = 1, 353 ZFS_DELEG_PERM_DESCENDENT = 2, 354 ZFS_DELEG_PERM_LOCALDESCENDENT = 3, 355 ZFS_DELEG_PERM_CREATE = 4 356 } zfs_deleg_inherit_t; 357 358 #define ZFS_DELEG_PERM_UID "uid" 359 #define ZFS_DELEG_PERM_GID "gid" 360 #define ZFS_DELEG_PERM_GROUPS "groups" 361 362 #define ZFS_MLSLABEL_DEFAULT "none" 363 364 #define ZFS_SMB_ACL_SRC "src" 365 #define ZFS_SMB_ACL_TARGET "target" 366 367 typedef enum { 368 ZFS_CANMOUNT_OFF = 0, 369 ZFS_CANMOUNT_ON = 1, 370 ZFS_CANMOUNT_NOAUTO = 2 371 } zfs_canmount_type_t; 372 373 typedef enum { 374 ZFS_LOGBIAS_LATENCY = 0, 375 ZFS_LOGBIAS_THROUGHPUT = 1 376 } zfs_logbias_op_t; 377 378 typedef enum zfs_share_op { 379 ZFS_SHARE_NFS = 0, 380 ZFS_UNSHARE_NFS = 1, 381 ZFS_SHARE_SMB = 2, 382 ZFS_UNSHARE_SMB = 3 383 } zfs_share_op_t; 384 385 typedef enum zfs_smb_acl_op { 386 ZFS_SMB_ACL_ADD, 387 ZFS_SMB_ACL_REMOVE, 388 ZFS_SMB_ACL_RENAME, 389 ZFS_SMB_ACL_PURGE 390 } zfs_smb_acl_op_t; 391 392 typedef enum zfs_cache_type { 393 ZFS_CACHE_NONE = 0, 394 ZFS_CACHE_METADATA = 1, 395 ZFS_CACHE_ALL = 2 396 } zfs_cache_type_t; 397 398 typedef enum { 399 ZFS_SYNC_STANDARD = 0, 400 ZFS_SYNC_ALWAYS = 1, 401 ZFS_SYNC_DISABLED = 2 402 } zfs_sync_type_t; 403 404 typedef enum { 405 ZFS_DNSIZE_LEGACY = 0, 406 ZFS_DNSIZE_AUTO = 1, 407 ZFS_DNSIZE_1K = 1024, 408 ZFS_DNSIZE_2K = 2048, 409 ZFS_DNSIZE_4K = 4096, 410 ZFS_DNSIZE_8K = 8192, 411 ZFS_DNSIZE_16K = 16384 412 } zfs_dnsize_type_t; 413 414 typedef enum { 415 ZFS_REDUNDANT_METADATA_ALL, 416 ZFS_REDUNDANT_METADATA_MOST 417 } zfs_redundant_metadata_type_t; 418 419 typedef enum zfs_keystatus { 420 ZFS_KEYSTATUS_NONE = 0, 421 ZFS_KEYSTATUS_UNAVAILABLE, 422 ZFS_KEYSTATUS_AVAILABLE 423 } zfs_keystatus_t; 424 425 typedef enum zfs_keyformat { 426 ZFS_KEYFORMAT_NONE = 0, 427 ZFS_KEYFORMAT_RAW, 428 ZFS_KEYFORMAT_HEX, 429 ZFS_KEYFORMAT_PASSPHRASE, 430 ZFS_KEYFORMAT_FORMATS 431 } zfs_keyformat_t; 432 433 typedef enum zfs_key_location { 434 ZFS_KEYLOCATION_NONE = 0, 435 ZFS_KEYLOCATION_PROMPT, 436 ZFS_KEYLOCATION_URI, 437 ZFS_KEYLOCATION_LOCATIONS 438 } zfs_keylocation_t; 439 440 #define DEFAULT_PBKDF2_ITERATIONS 350000 441 #define MIN_PBKDF2_ITERATIONS 100000 442 443 /* 444 * On-disk version number. 445 */ 446 #define SPA_VERSION_1 1ULL 447 #define SPA_VERSION_2 2ULL 448 #define SPA_VERSION_3 3ULL 449 #define SPA_VERSION_4 4ULL 450 #define SPA_VERSION_5 5ULL 451 #define SPA_VERSION_6 6ULL 452 #define SPA_VERSION_7 7ULL 453 #define SPA_VERSION_8 8ULL 454 #define SPA_VERSION_9 9ULL 455 #define SPA_VERSION_10 10ULL 456 #define SPA_VERSION_11 11ULL 457 #define SPA_VERSION_12 12ULL 458 #define SPA_VERSION_13 13ULL 459 #define SPA_VERSION_14 14ULL 460 #define SPA_VERSION_15 15ULL 461 #define SPA_VERSION_16 16ULL 462 #define SPA_VERSION_17 17ULL 463 #define SPA_VERSION_18 18ULL 464 #define SPA_VERSION_19 19ULL 465 #define SPA_VERSION_20 20ULL 466 #define SPA_VERSION_21 21ULL 467 #define SPA_VERSION_22 22ULL 468 #define SPA_VERSION_23 23ULL 469 #define SPA_VERSION_24 24ULL 470 #define SPA_VERSION_25 25ULL 471 #define SPA_VERSION_26 26ULL 472 #define SPA_VERSION_27 27ULL 473 #define SPA_VERSION_28 28ULL 474 #define SPA_VERSION_5000 5000ULL 475 476 /* 477 * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk 478 * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*}, 479 * and do the appropriate changes. Also bump the version number in 480 * usr/src/grub/capability. 481 */ 482 #define SPA_VERSION SPA_VERSION_5000 483 #define SPA_VERSION_STRING "5000" 484 485 /* 486 * Symbolic names for the changes that caused a SPA_VERSION switch. 487 * Used in the code when checking for presence or absence of a feature. 488 * Feel free to define multiple symbolic names for each version if there 489 * were multiple changes to on-disk structures during that version. 490 * 491 * NOTE: When checking the current SPA_VERSION in your code, be sure 492 * to use spa_version() since it reports the version of the 493 * last synced uberblock. Checking the in-flight version can 494 * be dangerous in some cases. 495 */ 496 #define SPA_VERSION_INITIAL SPA_VERSION_1 497 #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 498 #define SPA_VERSION_SPARES SPA_VERSION_3 499 #define SPA_VERSION_RAIDZ2 SPA_VERSION_3 500 #define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3 501 #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 502 #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 503 #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 504 #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 505 #define SPA_VERSION_BOOTFS SPA_VERSION_6 506 #define SPA_VERSION_SLOGS SPA_VERSION_7 507 #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8 508 #define SPA_VERSION_FUID SPA_VERSION_9 509 #define SPA_VERSION_REFRESERVATION SPA_VERSION_9 510 #define SPA_VERSION_REFQUOTA SPA_VERSION_9 511 #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9 512 #define SPA_VERSION_L2CACHE SPA_VERSION_10 513 #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11 514 #define SPA_VERSION_ORIGIN SPA_VERSION_11 515 #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11 516 #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12 517 #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13 518 #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14 519 #define SPA_VERSION_USERSPACE SPA_VERSION_15 520 #define SPA_VERSION_STMF_PROP SPA_VERSION_16 521 #define SPA_VERSION_RAIDZ3 SPA_VERSION_17 522 #define SPA_VERSION_USERREFS SPA_VERSION_18 523 #define SPA_VERSION_HOLES SPA_VERSION_19 524 #define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20 525 #define SPA_VERSION_DEDUP SPA_VERSION_21 526 #define SPA_VERSION_RECVD_PROPS SPA_VERSION_22 527 #define SPA_VERSION_SLIM_ZIL SPA_VERSION_23 528 #define SPA_VERSION_SA SPA_VERSION_24 529 #define SPA_VERSION_SCAN SPA_VERSION_25 530 #define SPA_VERSION_DIR_CLONES SPA_VERSION_26 531 #define SPA_VERSION_DEADLISTS SPA_VERSION_26 532 #define SPA_VERSION_FAST_SNAP SPA_VERSION_27 533 #define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28 534 #define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28 535 #define SPA_VERSION_FEATURES SPA_VERSION_5000 536 537 #define SPA_VERSION_IS_SUPPORTED(v) \ 538 (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \ 539 ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION)) 540 541 /* 542 * ZPL version - rev'd whenever an incompatible on-disk format change 543 * occurs. This is independent of SPA/DMU/ZAP versioning. You must 544 * also update the version_table[] and help message in zfs_prop.c. 545 * 546 * When changing, be sure to teach GRUB how to read the new format! 547 * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*} 548 */ 549 #define ZPL_VERSION_1 1ULL 550 #define ZPL_VERSION_2 2ULL 551 #define ZPL_VERSION_3 3ULL 552 #define ZPL_VERSION_4 4ULL 553 #define ZPL_VERSION_5 5ULL 554 #define ZPL_VERSION ZPL_VERSION_5 555 #define ZPL_VERSION_STRING "5" 556 557 #define ZPL_VERSION_INITIAL ZPL_VERSION_1 558 #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 559 #define ZPL_VERSION_FUID ZPL_VERSION_3 560 #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3 561 #define ZPL_VERSION_SYSATTR ZPL_VERSION_3 562 #define ZPL_VERSION_USERSPACE ZPL_VERSION_4 563 #define ZPL_VERSION_SA ZPL_VERSION_5 564 565 /* Persistent L2ARC version */ 566 #define L2ARC_PERSISTENT_VERSION_1 1ULL 567 #define L2ARC_PERSISTENT_VERSION L2ARC_PERSISTENT_VERSION_1 568 #define L2ARC_PERSISTENT_VERSION_STRING "1" 569 570 /* Rewind policy information */ 571 #define ZPOOL_NO_REWIND 1 /* No policy - default behavior */ 572 #define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */ 573 #define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */ 574 #define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */ 575 #define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */ 576 #define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */ 577 #define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */ 578 579 typedef struct zpool_load_policy { 580 uint32_t zlp_rewind; /* rewind policy requested */ 581 uint64_t zlp_maxmeta; /* max acceptable meta-data errors */ 582 uint64_t zlp_maxdata; /* max acceptable data errors */ 583 uint64_t zlp_txg; /* specific txg to load */ 584 } zpool_load_policy_t; 585 586 /* 587 * The following are configuration names used in the nvlist describing a pool's 588 * configuration. New on-disk names should be prefixed with "<reverse-DNS>:" 589 * (e.g. "org.open-zfs:") to avoid conflicting names being developed 590 * independently. 591 */ 592 #define ZPOOL_CONFIG_VERSION "version" 593 #define ZPOOL_CONFIG_POOL_NAME "name" 594 #define ZPOOL_CONFIG_POOL_STATE "state" 595 #define ZPOOL_CONFIG_POOL_TXG "txg" 596 #define ZPOOL_CONFIG_POOL_GUID "pool_guid" 597 #define ZPOOL_CONFIG_CREATE_TXG "create_txg" 598 #define ZPOOL_CONFIG_TOP_GUID "top_guid" 599 #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" 600 #define ZPOOL_CONFIG_TYPE "type" 601 #define ZPOOL_CONFIG_CHILDREN "children" 602 #define ZPOOL_CONFIG_ID "id" 603 #define ZPOOL_CONFIG_GUID "guid" 604 #define ZPOOL_CONFIG_INDIRECT_OBJECT "com.delphix:indirect_object" 605 #define ZPOOL_CONFIG_INDIRECT_BIRTHS "com.delphix:indirect_births" 606 #define ZPOOL_CONFIG_PREV_INDIRECT_VDEV "com.delphix:prev_indirect_vdev" 607 #define ZPOOL_CONFIG_PATH "path" 608 #define ZPOOL_CONFIG_DEVID "devid" 609 #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" 610 #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" 611 #define ZPOOL_CONFIG_ASHIFT "ashift" 612 #define ZPOOL_CONFIG_ASIZE "asize" 613 #define ZPOOL_CONFIG_DTL "DTL" 614 #define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */ 615 #define ZPOOL_CONFIG_REMOVAL_STATS "removal_stats" /* not stored on disk */ 616 #define ZPOOL_CONFIG_CHECKPOINT_STATS "checkpoint_stats" /* not on disk */ 617 #define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */ 618 #define ZPOOL_CONFIG_INDIRECT_SIZE "indirect_size" /* not stored on disk */ 619 620 /* container nvlist of extended stats */ 621 #define ZPOOL_CONFIG_VDEV_STATS_EX "vdev_stats_ex" 622 623 /* Active queue read/write stats */ 624 #define ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE "vdev_sync_r_active_queue" 625 #define ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE "vdev_sync_w_active_queue" 626 #define ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE "vdev_async_r_active_queue" 627 #define ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE "vdev_async_w_active_queue" 628 #define ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE "vdev_async_scrub_active_queue" 629 #define ZPOOL_CONFIG_VDEV_TRIM_ACTIVE_QUEUE "vdev_async_trim_active_queue" 630 631 /* Queue sizes */ 632 #define ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE "vdev_sync_r_pend_queue" 633 #define ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE "vdev_sync_w_pend_queue" 634 #define ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE "vdev_async_r_pend_queue" 635 #define ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE "vdev_async_w_pend_queue" 636 #define ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE "vdev_async_scrub_pend_queue" 637 #define ZPOOL_CONFIG_VDEV_TRIM_PEND_QUEUE "vdev_async_trim_pend_queue" 638 639 /* Latency read/write histogram stats */ 640 #define ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO "vdev_tot_r_lat_histo" 641 #define ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO "vdev_tot_w_lat_histo" 642 #define ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO "vdev_disk_r_lat_histo" 643 #define ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO "vdev_disk_w_lat_histo" 644 #define ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO "vdev_sync_r_lat_histo" 645 #define ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO "vdev_sync_w_lat_histo" 646 #define ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO "vdev_async_r_lat_histo" 647 #define ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO "vdev_async_w_lat_histo" 648 #define ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO "vdev_scrub_histo" 649 #define ZPOOL_CONFIG_VDEV_TRIM_LAT_HISTO "vdev_trim_histo" 650 651 /* Request size histograms */ 652 #define ZPOOL_CONFIG_VDEV_SYNC_IND_R_HISTO "vdev_sync_ind_r_histo" 653 #define ZPOOL_CONFIG_VDEV_SYNC_IND_W_HISTO "vdev_sync_ind_w_histo" 654 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_R_HISTO "vdev_async_ind_r_histo" 655 #define ZPOOL_CONFIG_VDEV_ASYNC_IND_W_HISTO "vdev_async_ind_w_histo" 656 #define ZPOOL_CONFIG_VDEV_IND_SCRUB_HISTO "vdev_ind_scrub_histo" 657 #define ZPOOL_CONFIG_VDEV_IND_TRIM_HISTO "vdev_ind_trim_histo" 658 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_R_HISTO "vdev_sync_agg_r_histo" 659 #define ZPOOL_CONFIG_VDEV_SYNC_AGG_W_HISTO "vdev_sync_agg_w_histo" 660 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_R_HISTO "vdev_async_agg_r_histo" 661 #define ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO "vdev_async_agg_w_histo" 662 #define ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO "vdev_agg_scrub_histo" 663 #define ZPOOL_CONFIG_VDEV_AGG_TRIM_HISTO "vdev_agg_trim_histo" 664 665 /* Number of slow IOs */ 666 #define ZPOOL_CONFIG_VDEV_SLOW_IOS "vdev_slow_ios" 667 668 #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" 669 #define ZPOOL_CONFIG_ERRCOUNT "error_count" 670 #define ZPOOL_CONFIG_NOT_PRESENT "not_present" 671 #define ZPOOL_CONFIG_SPARES "spares" 672 #define ZPOOL_CONFIG_IS_SPARE "is_spare" 673 #define ZPOOL_CONFIG_NPARITY "nparity" 674 #define ZPOOL_CONFIG_HOSTID "hostid" 675 #define ZPOOL_CONFIG_HOSTNAME "hostname" 676 #define ZPOOL_CONFIG_LOADED_TIME "initial_load_time" 677 #define ZPOOL_CONFIG_UNSPARE "unspare" 678 #define ZPOOL_CONFIG_PHYS_PATH "phys_path" 679 #define ZPOOL_CONFIG_IS_LOG "is_log" 680 #define ZPOOL_CONFIG_L2CACHE "l2cache" 681 #define ZPOOL_CONFIG_HOLE_ARRAY "hole_array" 682 #define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children" 683 #define ZPOOL_CONFIG_IS_HOLE "is_hole" 684 #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram" 685 #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats" 686 #define ZPOOL_CONFIG_DDT_STATS "ddt_stats" 687 #define ZPOOL_CONFIG_SPLIT "splitcfg" 688 #define ZPOOL_CONFIG_ORIG_GUID "orig_guid" 689 #define ZPOOL_CONFIG_SPLIT_GUID "split_guid" 690 #define ZPOOL_CONFIG_SPLIT_LIST "guid_list" 691 #define ZPOOL_CONFIG_REMOVING "removing" 692 #define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg" 693 #define ZPOOL_CONFIG_COMMENT "comment" 694 #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */ 695 #define ZPOOL_CONFIG_SUSPENDED_REASON "suspended_reason" /* not stored */ 696 #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ 697 #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */ 698 #define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */ 699 #define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */ 700 #define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */ 701 #define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */ 702 #define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */ 703 #define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */ 704 #define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read" 705 #define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */ 706 #define ZPOOL_CONFIG_ERRATA "errata" /* not stored on disk */ 707 #define ZPOOL_CONFIG_VDEV_TOP_ZAP "com.delphix:vdev_zap_top" 708 #define ZPOOL_CONFIG_VDEV_LEAF_ZAP "com.delphix:vdev_zap_leaf" 709 #define ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS "com.delphix:has_per_vdev_zaps" 710 #define ZPOOL_CONFIG_RESILVER_DEFER "com.datto:resilver_defer" 711 #define ZPOOL_CONFIG_CACHEFILE "cachefile" /* not stored on disk */ 712 #define ZPOOL_CONFIG_MMP_STATE "mmp_state" /* not stored on disk */ 713 #define ZPOOL_CONFIG_MMP_TXG "mmp_txg" /* not stored on disk */ 714 #define ZPOOL_CONFIG_MMP_SEQ "mmp_seq" /* not stored on disk */ 715 #define ZPOOL_CONFIG_MMP_HOSTNAME "mmp_hostname" /* not stored on disk */ 716 #define ZPOOL_CONFIG_MMP_HOSTID "mmp_hostid" /* not stored on disk */ 717 #define ZPOOL_CONFIG_ALLOCATION_BIAS "alloc_bias" /* not stored on disk */ 718 719 /* 720 * The persistent vdev state is stored as separate values rather than a single 721 * 'vdev_state' entry. This is because a device can be in multiple states, such 722 * as offline and degraded. 723 */ 724 #define ZPOOL_CONFIG_OFFLINE "offline" 725 #define ZPOOL_CONFIG_FAULTED "faulted" 726 #define ZPOOL_CONFIG_DEGRADED "degraded" 727 #define ZPOOL_CONFIG_REMOVED "removed" 728 #define ZPOOL_CONFIG_FRU "fru" 729 #define ZPOOL_CONFIG_AUX_STATE "aux_state" 730 731 /* Pool load policy parameters */ 732 #define ZPOOL_LOAD_POLICY "load-policy" 733 #define ZPOOL_LOAD_REWIND_POLICY "load-rewind-policy" 734 #define ZPOOL_LOAD_REQUEST_TXG "load-request-txg" 735 #define ZPOOL_LOAD_META_THRESH "load-meta-thresh" 736 #define ZPOOL_LOAD_DATA_THRESH "load-data-thresh" 737 738 /* Rewind data discovered */ 739 #define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts" 740 #define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors" 741 #define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind" 742 743 #define VDEV_TYPE_ROOT "root" 744 #define VDEV_TYPE_MIRROR "mirror" 745 #define VDEV_TYPE_REPLACING "replacing" 746 #define VDEV_TYPE_RAIDZ "raidz" 747 #define VDEV_TYPE_DISK "disk" 748 #define VDEV_TYPE_FILE "file" 749 #define VDEV_TYPE_MISSING "missing" 750 #define VDEV_TYPE_HOLE "hole" 751 #define VDEV_TYPE_SPARE "spare" 752 #define VDEV_TYPE_LOG "log" 753 #define VDEV_TYPE_L2CACHE "l2cache" 754 #define VDEV_TYPE_INDIRECT "indirect" 755 756 /* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */ 757 #define VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \ 758 "com.delphix:indirect_obsolete_sm" 759 #define VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \ 760 "com.delphix:obsolete_counts_are_precise" 761 #define VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \ 762 "com.delphix:pool_checkpoint_sm" 763 #define VDEV_TOP_ZAP_MS_UNFLUSHED_PHYS_TXGS \ 764 "com.delphix:ms_unflushed_phys_txgs" 765 766 #define VDEV_TOP_ZAP_ALLOCATION_BIAS \ 767 "org.zfsonlinux:allocation_bias" 768 769 /* vdev metaslab allocation bias */ 770 #define VDEV_ALLOC_BIAS_LOG "log" 771 #define VDEV_ALLOC_BIAS_SPECIAL "special" 772 #define VDEV_ALLOC_BIAS_DEDUP "dedup" 773 774 /* vdev initialize state */ 775 #define VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET \ 776 "com.delphix:next_offset_to_initialize" 777 #define VDEV_LEAF_ZAP_INITIALIZE_STATE \ 778 "com.delphix:vdev_initialize_state" 779 #define VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME \ 780 "com.delphix:vdev_initialize_action_time" 781 782 /* vdev TRIM state */ 783 #define VDEV_LEAF_ZAP_TRIM_LAST_OFFSET \ 784 "org.zfsonlinux:next_offset_to_trim" 785 #define VDEV_LEAF_ZAP_TRIM_STATE \ 786 "org.zfsonlinux:vdev_trim_state" 787 #define VDEV_LEAF_ZAP_TRIM_ACTION_TIME \ 788 "org.zfsonlinux:vdev_trim_action_time" 789 #define VDEV_LEAF_ZAP_TRIM_RATE \ 790 "org.zfsonlinux:vdev_trim_rate" 791 #define VDEV_LEAF_ZAP_TRIM_PARTIAL \ 792 "org.zfsonlinux:vdev_trim_partial" 793 #define VDEV_LEAF_ZAP_TRIM_SECURE \ 794 "org.zfsonlinux:vdev_trim_secure" 795 796 /* 797 * This is needed in userland to report the minimum necessary device size. 798 * 799 * Note that the zfs test suite uses 64MB vdevs. 800 */ 801 #define SPA_MINDEVSIZE (64ULL << 20) 802 803 /* 804 * Set if the fragmentation has not yet been calculated. This can happen 805 * because the space maps have not been upgraded or the histogram feature 806 * is not enabled. 807 */ 808 #define ZFS_FRAG_INVALID UINT64_MAX 809 810 /* 811 * The location of the pool configuration repository, shared between kernel and 812 * userland. 813 */ 814 #define ZPOOL_CACHE "/etc/zfs/zpool.cache" 815 816 /* 817 * vdev states are ordered from least to most healthy. 818 * A vdev that's CANT_OPEN or below is considered unusable. 819 */ 820 typedef enum vdev_state { 821 VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ 822 VDEV_STATE_CLOSED, /* Not currently open */ 823 VDEV_STATE_OFFLINE, /* Not allowed to open */ 824 VDEV_STATE_REMOVED, /* Explicitly removed from system */ 825 VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ 826 VDEV_STATE_FAULTED, /* External request to fault device */ 827 VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ 828 VDEV_STATE_HEALTHY /* Presumed good */ 829 } vdev_state_t; 830 831 #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY 832 833 /* 834 * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field 835 * of the vdev stats structure uses these constants to distinguish why. 836 */ 837 typedef enum vdev_aux { 838 VDEV_AUX_NONE, /* no error */ 839 VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ 840 VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ 841 VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ 842 VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ 843 VDEV_AUX_TOO_SMALL, /* vdev size is too small */ 844 VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ 845 VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ 846 VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ 847 VDEV_AUX_UNSUP_FEAT, /* unsupported features */ 848 VDEV_AUX_SPARED, /* hot spare used in another pool */ 849 VDEV_AUX_ERR_EXCEEDED, /* too many errors */ 850 VDEV_AUX_IO_FAILURE, /* experienced I/O failure */ 851 VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */ 852 VDEV_AUX_EXTERNAL, /* external diagnosis */ 853 VDEV_AUX_SPLIT_POOL, /* vdev was split off into another pool */ 854 VDEV_AUX_ACTIVE, /* vdev active on a different host */ 855 VDEV_AUX_CHILDREN_OFFLINE, /* all children are offline */ 856 VDEV_AUX_BAD_ASHIFT /* vdev ashift is invalid */ 857 } vdev_aux_t; 858 859 /* 860 * pool state. The following states are written to disk as part of the normal 861 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining 862 * states are software abstractions used at various levels to communicate 863 * pool state. 864 */ 865 typedef enum pool_state { 866 POOL_STATE_ACTIVE = 0, /* In active use */ 867 POOL_STATE_EXPORTED, /* Explicitly exported */ 868 POOL_STATE_DESTROYED, /* Explicitly destroyed */ 869 POOL_STATE_SPARE, /* Reserved for hot spare use */ 870 POOL_STATE_L2CACHE, /* Level 2 ARC device */ 871 POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ 872 POOL_STATE_UNAVAIL, /* Internal libzfs state */ 873 POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ 874 } pool_state_t; 875 876 /* 877 * mmp state. The following states provide additional detail describing 878 * why a pool couldn't be safely imported. 879 */ 880 typedef enum mmp_state { 881 MMP_STATE_ACTIVE = 0, /* In active use */ 882 MMP_STATE_INACTIVE, /* Inactive and safe to import */ 883 MMP_STATE_NO_HOSTID /* System hostid is not set */ 884 } mmp_state_t; 885 886 /* 887 * Scan Functions. 888 */ 889 typedef enum pool_scan_func { 890 POOL_SCAN_NONE, 891 POOL_SCAN_SCRUB, 892 POOL_SCAN_RESILVER, 893 POOL_SCAN_FUNCS 894 } pool_scan_func_t; 895 896 /* 897 * Used to control scrub pause and resume. 898 */ 899 typedef enum pool_scrub_cmd { 900 POOL_SCRUB_NORMAL = 0, 901 POOL_SCRUB_PAUSE, 902 POOL_SCRUB_FLAGS_END 903 } pool_scrub_cmd_t; 904 905 /* 906 * Initialize functions. 907 */ 908 typedef enum pool_initialize_func { 909 POOL_INITIALIZE_START, 910 POOL_INITIALIZE_CANCEL, 911 POOL_INITIALIZE_SUSPEND, 912 POOL_INITIALIZE_FUNCS 913 } pool_initialize_func_t; 914 915 /* 916 * TRIM functions. 917 */ 918 typedef enum pool_trim_func { 919 POOL_TRIM_START, 920 POOL_TRIM_CANCEL, 921 POOL_TRIM_SUSPEND, 922 POOL_TRIM_FUNCS 923 } pool_trim_func_t; 924 925 /* 926 * ZIO types. Needed to interpret vdev statistics below. 927 */ 928 typedef enum zio_type { 929 ZIO_TYPE_NULL = 0, 930 ZIO_TYPE_READ, 931 ZIO_TYPE_WRITE, 932 ZIO_TYPE_FREE, 933 ZIO_TYPE_CLAIM, 934 ZIO_TYPE_IOCTL, 935 ZIO_TYPE_TRIM, 936 ZIO_TYPES 937 } zio_type_t; 938 939 /* 940 * Pool statistics. Note: all fields should be 64-bit because this 941 * is passed between kernel and userland as an nvlist uint64 array. 942 */ 943 typedef struct pool_scan_stat { 944 /* values stored on disk */ 945 uint64_t pss_func; /* pool_scan_func_t */ 946 uint64_t pss_state; /* dsl_scan_state_t */ 947 uint64_t pss_start_time; /* scan start time */ 948 uint64_t pss_end_time; /* scan end time */ 949 uint64_t pss_to_examine; /* total bytes to scan */ 950 uint64_t pss_examined; /* total bytes located by scanner */ 951 uint64_t pss_to_process; /* total bytes to process */ 952 uint64_t pss_processed; /* total processed bytes */ 953 uint64_t pss_errors; /* scan errors */ 954 955 /* values not stored on disk */ 956 uint64_t pss_pass_exam; /* examined bytes per scan pass */ 957 uint64_t pss_pass_issued; /* issued bytes per scan pass */ 958 uint64_t pss_pass_start; /* start time of a scan pass */ 959 uint64_t pss_pass_scrub_pause; /* pause time of a scurb pass */ 960 /* cumulative time scrub spent paused, needed for rate calculation */ 961 uint64_t pss_pass_scrub_spent_paused; 962 963 /* Sorted scrubbing new fields */ 964 /* Stored on disk */ 965 uint64_t pss_issued; /* total bytes checked by scanner */ 966 } pool_scan_stat_t; 967 968 /* 969 * Errata described by http://zfsonlinux.org/msg/ZFS-8000-ER. The ordering 970 * of this enum must be maintained to ensure the errata identifiers map to 971 * the correct documentation. New errata may only be appended to the list 972 * and must contain corresponding documentation at the above link. 973 */ 974 typedef enum zpool_errata { 975 ZPOOL_ERRATA_NONE, 976 ZPOOL_ERRATA_ZOL_2094_SCRUB, 977 ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY, 978 ZPOOL_ERRATA_ZOL_6845_ENCRYPTION, 979 ZPOOL_ERRATA_ZOL_8308_ENCRYPTION, 980 } zpool_errata_t; 981 982 typedef struct pool_removal_stat { 983 uint64_t prs_state; /* dsl_scan_state_t */ 984 uint64_t prs_removing_vdev; 985 uint64_t prs_start_time; 986 uint64_t prs_end_time; 987 uint64_t prs_to_copy; /* bytes that need to be copied */ 988 uint64_t prs_copied; /* bytes copied so far */ 989 /* 990 * bytes of memory used for indirect mappings. 991 * This includes all removed vdevs. 992 */ 993 uint64_t prs_mapping_memory; 994 } pool_removal_stat_t; 995 996 typedef enum dsl_scan_state { 997 DSS_NONE, 998 DSS_SCANNING, 999 DSS_FINISHED, 1000 DSS_CANCELED, 1001 DSS_NUM_STATES 1002 } dsl_scan_state_t; 1003 1004 typedef enum { 1005 CS_NONE, 1006 CS_CHECKPOINT_EXISTS, 1007 CS_CHECKPOINT_DISCARDING, 1008 CS_NUM_STATES 1009 } checkpoint_state_t; 1010 1011 typedef struct pool_checkpoint_stat { 1012 uint64_t pcs_state; /* checkpoint_state_t */ 1013 uint64_t pcs_start_time; /* time checkpoint/discard started */ 1014 uint64_t pcs_space; /* checkpointed space */ 1015 } pool_checkpoint_stat_t; 1016 1017 typedef enum { 1018 VDEV_INITIALIZE_NONE, 1019 VDEV_INITIALIZE_ACTIVE, 1020 VDEV_INITIALIZE_CANCELED, 1021 VDEV_INITIALIZE_SUSPENDED, 1022 VDEV_INITIALIZE_COMPLETE 1023 } vdev_initializing_state_t; 1024 1025 typedef enum { 1026 VDEV_TRIM_NONE, 1027 VDEV_TRIM_ACTIVE, 1028 VDEV_TRIM_CANCELED, 1029 VDEV_TRIM_SUSPENDED, 1030 VDEV_TRIM_COMPLETE, 1031 } vdev_trim_state_t; 1032 1033 /* 1034 * Vdev statistics. Note: all fields should be 64-bit because this 1035 * is passed between kernel and user land as an nvlist uint64 array. 1036 * 1037 * The vs_ops[] and vs_bytes[] arrays must always be an array size of 6 in 1038 * order to keep subsequent members at their known fixed offsets. When 1039 * adding a new field it must be added to the end the structure. 1040 */ 1041 #define VS_ZIO_TYPES 6 1042 1043 typedef struct vdev_stat { 1044 hrtime_t vs_timestamp; /* time since vdev load */ 1045 uint64_t vs_state; /* vdev state */ 1046 uint64_t vs_aux; /* see vdev_aux_t */ 1047 uint64_t vs_alloc; /* space allocated */ 1048 uint64_t vs_space; /* total capacity */ 1049 uint64_t vs_dspace; /* deflated capacity */ 1050 uint64_t vs_rsize; /* replaceable dev size */ 1051 uint64_t vs_esize; /* expandable dev size */ 1052 uint64_t vs_ops[VS_ZIO_TYPES]; /* operation count */ 1053 uint64_t vs_bytes[VS_ZIO_TYPES]; /* bytes read/written */ 1054 uint64_t vs_read_errors; /* read errors */ 1055 uint64_t vs_write_errors; /* write errors */ 1056 uint64_t vs_checksum_errors; /* checksum errors */ 1057 uint64_t vs_initialize_errors; /* initializing errors */ 1058 uint64_t vs_self_healed; /* self-healed bytes */ 1059 uint64_t vs_scan_removing; /* removing? */ 1060 uint64_t vs_scan_processed; /* scan processed bytes */ 1061 uint64_t vs_fragmentation; /* device fragmentation */ 1062 uint64_t vs_initialize_bytes_done; /* bytes initialized */ 1063 uint64_t vs_initialize_bytes_est; /* total bytes to initialize */ 1064 uint64_t vs_initialize_state; /* vdev_initialzing_state_t */ 1065 uint64_t vs_initialize_action_time; /* time_t */ 1066 uint64_t vs_checkpoint_space; /* checkpoint-consumed space */ 1067 uint64_t vs_resilver_deferred; /* resilver deferred */ 1068 uint64_t vs_slow_ios; /* slow IOs */ 1069 uint64_t vs_trim_errors; /* trimming errors */ 1070 uint64_t vs_trim_notsup; /* supported by device */ 1071 uint64_t vs_trim_bytes_done; /* bytes trimmed */ 1072 uint64_t vs_trim_bytes_est; /* total bytes to trim */ 1073 uint64_t vs_trim_state; /* vdev_trim_state_t */ 1074 uint64_t vs_trim_action_time; /* time_t */ 1075 } vdev_stat_t; 1076 1077 /* 1078 * Extended stats 1079 * 1080 * These are stats which aren't included in the original iostat output. For 1081 * convenience, they are grouped together in vdev_stat_ex, although each stat 1082 * is individually exported as a nvlist. 1083 */ 1084 typedef struct vdev_stat_ex { 1085 /* Number of ZIOs issued to disk and waiting to finish */ 1086 uint64_t vsx_active_queue[ZIO_PRIORITY_N_QUEUEABLE]; 1087 1088 /* Number of ZIOs pending to be issued to disk */ 1089 uint64_t vsx_pend_queue[ZIO_PRIORITY_N_QUEUEABLE]; 1090 1091 /* 1092 * Below are the histograms for various latencies. Buckets are in 1093 * units of nanoseconds. 1094 */ 1095 1096 /* 1097 * 2^37 nanoseconds = 134s. Timeouts will probably start kicking in 1098 * before this. 1099 */ 1100 #define VDEV_L_HISTO_BUCKETS 37 /* Latency histo buckets */ 1101 #define VDEV_RQ_HISTO_BUCKETS 25 /* Request size histo buckets */ 1102 1103 /* Amount of time in ZIO queue (ns) */ 1104 uint64_t vsx_queue_histo[ZIO_PRIORITY_N_QUEUEABLE] 1105 [VDEV_L_HISTO_BUCKETS]; 1106 1107 /* Total ZIO latency (ns). Includes queuing and disk access time */ 1108 uint64_t vsx_total_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS]; 1109 1110 /* Amount of time to read/write the disk (ns) */ 1111 uint64_t vsx_disk_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS]; 1112 1113 /* "lookup the bucket for a value" macro */ 1114 #define HISTO(val, buckets) (val != 0 ? MIN(highbit64(val) - 1, \ 1115 buckets - 1) : 0) 1116 #define L_HISTO(a) HISTO(a, VDEV_L_HISTO_BUCKETS) 1117 #define RQ_HISTO(a) HISTO(a, VDEV_RQ_HISTO_BUCKETS) 1118 1119 /* Physical IO histogram */ 1120 uint64_t vsx_ind_histo[ZIO_PRIORITY_N_QUEUEABLE] 1121 [VDEV_RQ_HISTO_BUCKETS]; 1122 1123 /* Delegated (aggregated) physical IO histogram */ 1124 uint64_t vsx_agg_histo[ZIO_PRIORITY_N_QUEUEABLE] 1125 [VDEV_RQ_HISTO_BUCKETS]; 1126 1127 } vdev_stat_ex_t; 1128 1129 /* 1130 * DDT statistics. Note: all fields should be 64-bit because this 1131 * is passed between kernel and userland as an nvlist uint64 array. 1132 */ 1133 typedef struct ddt_object { 1134 uint64_t ddo_count; /* number of elments in ddt */ 1135 uint64_t ddo_dspace; /* size of ddt on disk */ 1136 uint64_t ddo_mspace; /* size of ddt in-core */ 1137 } ddt_object_t; 1138 1139 typedef struct ddt_stat { 1140 uint64_t dds_blocks; /* blocks */ 1141 uint64_t dds_lsize; /* logical size */ 1142 uint64_t dds_psize; /* physical size */ 1143 uint64_t dds_dsize; /* deflated allocated size */ 1144 uint64_t dds_ref_blocks; /* referenced blocks */ 1145 uint64_t dds_ref_lsize; /* referenced lsize * refcnt */ 1146 uint64_t dds_ref_psize; /* referenced psize * refcnt */ 1147 uint64_t dds_ref_dsize; /* referenced dsize * refcnt */ 1148 } ddt_stat_t; 1149 1150 typedef struct ddt_histogram { 1151 ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */ 1152 } ddt_histogram_t; 1153 1154 #define ZVOL_DRIVER "zvol" 1155 #define ZFS_DRIVER "zfs" 1156 #define ZFS_DEV "/dev/zfs" 1157 #define ZFS_DISK_ROOT "/dev/dsk" 1158 #define ZFS_DISK_ROOTD ZFS_DISK_ROOT "/" 1159 #define ZFS_RDISK_ROOT "/dev/rdsk" 1160 #define ZFS_RDISK_ROOTD ZFS_RDISK_ROOT "/" 1161 1162 /* general zvol path */ 1163 #define ZVOL_DIR "/dev/zvol" 1164 /* expansion */ 1165 #define ZVOL_PSEUDO_DEV "/devices/pseudo/zfs@0:" 1166 /* for dump and swap */ 1167 #define ZVOL_FULL_DEV_DIR ZVOL_DIR "/dsk/" 1168 #define ZVOL_FULL_RDEV_DIR ZVOL_DIR "/rdsk/" 1169 1170 #define ZVOL_PROP_NAME "name" 1171 #define ZVOL_DEFAULT_BLOCKSIZE 8192 1172 1173 /* 1174 * /dev/zfs ioctl numbers. 1175 */ 1176 typedef enum zfs_ioc { 1177 /* 1178 * Core features - 81/128 numbers reserved. 1179 */ 1180 #ifdef __FreeBSD__ 1181 ZFS_IOC_FIRST = 0, 1182 #else 1183 ZFS_IOC_FIRST = ('Z' << 8), 1184 #endif 1185 ZFS_IOC = ZFS_IOC_FIRST, 1186 ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST, /* 0x5a00 */ 1187 ZFS_IOC_POOL_DESTROY, /* 0x5a01 */ 1188 ZFS_IOC_POOL_IMPORT, /* 0x5a02 */ 1189 ZFS_IOC_POOL_EXPORT, /* 0x5a03 */ 1190 ZFS_IOC_POOL_CONFIGS, /* 0x5a04 */ 1191 ZFS_IOC_POOL_STATS, /* 0x5a05 */ 1192 ZFS_IOC_POOL_TRYIMPORT, /* 0x5a06 */ 1193 ZFS_IOC_POOL_SCAN, /* 0x5a07 */ 1194 ZFS_IOC_POOL_FREEZE, /* 0x5a08 */ 1195 ZFS_IOC_POOL_UPGRADE, /* 0x5a09 */ 1196 ZFS_IOC_POOL_GET_HISTORY, /* 0x5a0a */ 1197 ZFS_IOC_VDEV_ADD, /* 0x5a0b */ 1198 ZFS_IOC_VDEV_REMOVE, /* 0x5a0c */ 1199 ZFS_IOC_VDEV_SET_STATE, /* 0x5a0d */ 1200 ZFS_IOC_VDEV_ATTACH, /* 0x5a0e */ 1201 ZFS_IOC_VDEV_DETACH, /* 0x5a0f */ 1202 ZFS_IOC_VDEV_SETPATH, /* 0x5a10 */ 1203 ZFS_IOC_VDEV_SETFRU, /* 0x5a11 */ 1204 ZFS_IOC_OBJSET_STATS, /* 0x5a12 */ 1205 ZFS_IOC_OBJSET_ZPLPROPS, /* 0x5a13 */ 1206 ZFS_IOC_DATASET_LIST_NEXT, /* 0x5a14 */ 1207 ZFS_IOC_SNAPSHOT_LIST_NEXT, /* 0x5a15 */ 1208 ZFS_IOC_SET_PROP, /* 0x5a16 */ 1209 ZFS_IOC_CREATE, /* 0x5a17 */ 1210 ZFS_IOC_DESTROY, /* 0x5a18 */ 1211 ZFS_IOC_ROLLBACK, /* 0x5a19 */ 1212 ZFS_IOC_RENAME, /* 0x5a1a */ 1213 ZFS_IOC_RECV, /* 0x5a1b */ 1214 ZFS_IOC_SEND, /* 0x5a1c */ 1215 ZFS_IOC_INJECT_FAULT, /* 0x5a1d */ 1216 ZFS_IOC_CLEAR_FAULT, /* 0x5a1e */ 1217 ZFS_IOC_INJECT_LIST_NEXT, /* 0x5a1f */ 1218 ZFS_IOC_ERROR_LOG, /* 0x5a20 */ 1219 ZFS_IOC_CLEAR, /* 0x5a21 */ 1220 ZFS_IOC_PROMOTE, /* 0x5a22 */ 1221 ZFS_IOC_SNAPSHOT, /* 0x5a23 */ 1222 ZFS_IOC_DSOBJ_TO_DSNAME, /* 0x5a24 */ 1223 ZFS_IOC_OBJ_TO_PATH, /* 0x5a25 */ 1224 ZFS_IOC_POOL_SET_PROPS, /* 0x5a26 */ 1225 ZFS_IOC_POOL_GET_PROPS, /* 0x5a27 */ 1226 ZFS_IOC_SET_FSACL, /* 0x5a28 */ 1227 ZFS_IOC_GET_FSACL, /* 0x5a29 */ 1228 ZFS_IOC_SHARE, /* 0x5a2a */ 1229 ZFS_IOC_INHERIT_PROP, /* 0x5a2b */ 1230 ZFS_IOC_SMB_ACL, /* 0x5a2c */ 1231 ZFS_IOC_USERSPACE_ONE, /* 0x5a2d */ 1232 ZFS_IOC_USERSPACE_MANY, /* 0x5a2e */ 1233 ZFS_IOC_USERSPACE_UPGRADE, /* 0x5a2f */ 1234 ZFS_IOC_HOLD, /* 0x5a30 */ 1235 ZFS_IOC_RELEASE, /* 0x5a31 */ 1236 ZFS_IOC_GET_HOLDS, /* 0x5a32 */ 1237 ZFS_IOC_OBJSET_RECVD_PROPS, /* 0x5a33 */ 1238 ZFS_IOC_VDEV_SPLIT, /* 0x5a34 */ 1239 ZFS_IOC_NEXT_OBJ, /* 0x5a35 */ 1240 ZFS_IOC_DIFF, /* 0x5a36 */ 1241 ZFS_IOC_TMP_SNAPSHOT, /* 0x5a37 */ 1242 ZFS_IOC_OBJ_TO_STATS, /* 0x5a38 */ 1243 ZFS_IOC_SPACE_WRITTEN, /* 0x5a39 */ 1244 ZFS_IOC_SPACE_SNAPS, /* 0x5a3a */ 1245 ZFS_IOC_DESTROY_SNAPS, /* 0x5a3b */ 1246 ZFS_IOC_POOL_REGUID, /* 0x5a3c */ 1247 ZFS_IOC_POOL_REOPEN, /* 0x5a3d */ 1248 ZFS_IOC_SEND_PROGRESS, /* 0x5a3e */ 1249 ZFS_IOC_LOG_HISTORY, /* 0x5a3f */ 1250 ZFS_IOC_SEND_NEW, /* 0x5a40 */ 1251 ZFS_IOC_SEND_SPACE, /* 0x5a41 */ 1252 ZFS_IOC_CLONE, /* 0x5a42 */ 1253 ZFS_IOC_BOOKMARK, /* 0x5a43 */ 1254 ZFS_IOC_GET_BOOKMARKS, /* 0x5a44 */ 1255 ZFS_IOC_DESTROY_BOOKMARKS, /* 0x5a45 */ 1256 ZFS_IOC_POOL_SYNC, /* 0x5a47 */ 1257 ZFS_IOC_CHANNEL_PROGRAM, /* 0x5a48 */ 1258 ZFS_IOC_LOAD_KEY, /* 0x5a49 */ 1259 ZFS_IOC_UNLOAD_KEY, /* 0x5a4a */ 1260 ZFS_IOC_CHANGE_KEY, /* 0x5a4b */ 1261 ZFS_IOC_REMAP, /* 0x5a4c */ 1262 ZFS_IOC_POOL_CHECKPOINT, /* 0x5a4d */ 1263 ZFS_IOC_POOL_DISCARD_CHECKPOINT, /* 0x5a4e */ 1264 ZFS_IOC_POOL_INITIALIZE, /* 0x5a4f */ 1265 ZFS_IOC_POOL_TRIM, /* 0x5a50 */ 1266 ZFS_IOC_REDACT, /* 0x5a51 */ 1267 ZFS_IOC_GET_BOOKMARK_PROPS, /* 0x5a52 */ 1268 1269 /* 1270 * Per-platform (Optional) - 8/128 numbers reserved. 1271 */ 1272 ZFS_IOC_PLATFORM = ZFS_IOC_FIRST + 0x80, 1273 ZFS_IOC_EVENTS_NEXT, /* 0x81 (Linux) */ 1274 ZFS_IOC_EVENTS_CLEAR, /* 0x82 (Linux) */ 1275 ZFS_IOC_EVENTS_SEEK, /* 0x83 (Linux) */ 1276 ZFS_IOC_NEXTBOOT, /* 0x84 (FreeBSD) */ 1277 ZFS_IOC_JAIL, /* 0x85 (FreeBSD) */ 1278 ZFS_IOC_UNJAIL, /* 0x86 (FreeBSD) */ 1279 ZFS_IOC_SET_BOOTENV, /* 0x87 */ 1280 ZFS_IOC_GET_BOOTENV, /* 0x88 */ 1281 ZFS_IOC_LAST 1282 } zfs_ioc_t; 1283 1284 /* 1285 * ZFS-specific error codes used for returning descriptive errors 1286 * to the userland through zfs ioctls. 1287 * 1288 * The enum implicitly includes all the error codes from errno.h. 1289 * New code should use and extend this enum for errors that are 1290 * not described precisely by generic errno codes. 1291 */ 1292 typedef enum { 1293 ZFS_ERR_CHECKPOINT_EXISTS = 1024, 1294 ZFS_ERR_DISCARDING_CHECKPOINT, 1295 ZFS_ERR_NO_CHECKPOINT, 1296 ZFS_ERR_DEVRM_IN_PROGRESS, 1297 ZFS_ERR_VDEV_TOO_BIG, 1298 ZFS_ERR_FROM_IVSET_GUID_MISSING, 1299 ZFS_ERR_FROM_IVSET_GUID_MISMATCH, 1300 ZFS_ERR_SPILL_BLOCK_FLAG_MISSING, 1301 ZFS_ERR_UNKNOWN_SEND_STREAM_FEATURE, 1302 ZFS_ERR_IOC_CMD_UNAVAIL, 1303 ZFS_ERR_IOC_ARG_UNAVAIL, 1304 ZFS_ERR_IOC_ARG_REQUIRED, 1305 ZFS_ERR_IOC_ARG_BADTYPE, 1306 } zfs_errno_t; 1307 1308 /* 1309 * Internal SPA load state. Used by FMA diagnosis engine. 1310 */ 1311 typedef enum { 1312 SPA_LOAD_NONE, /* no load in progress */ 1313 SPA_LOAD_OPEN, /* normal open */ 1314 SPA_LOAD_IMPORT, /* import in progress */ 1315 SPA_LOAD_TRYIMPORT, /* tryimport in progress */ 1316 SPA_LOAD_RECOVER, /* recovery requested */ 1317 SPA_LOAD_ERROR, /* load failed */ 1318 SPA_LOAD_CREATE /* creation in progress */ 1319 } spa_load_state_t; 1320 1321 /* supported encryption algorithms */ 1322 enum zio_encrypt { 1323 ZIO_CRYPT_INHERIT = 0, 1324 ZIO_CRYPT_ON, 1325 ZIO_CRYPT_OFF, 1326 ZIO_CRYPT_AES_128_CCM, 1327 ZIO_CRYPT_AES_192_CCM, 1328 ZIO_CRYPT_AES_256_CCM, 1329 ZIO_CRYPT_AES_128_GCM, 1330 ZIO_CRYPT_AES_192_GCM, 1331 ZIO_CRYPT_AES_256_GCM, 1332 ZIO_CRYPT_FUNCTIONS 1333 }; 1334 1335 /* 1336 * Bookmark name values. 1337 */ 1338 #define ZPOOL_ERR_LIST "error list" 1339 #define ZPOOL_ERR_DATASET "dataset" 1340 #define ZPOOL_ERR_OBJECT "object" 1341 1342 #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) 1343 1344 /* 1345 * The following are names used in the nvlist describing 1346 * the pool's history log. 1347 */ 1348 #define ZPOOL_HIST_RECORD "history record" 1349 #define ZPOOL_HIST_TIME "history time" 1350 #define ZPOOL_HIST_CMD "history command" 1351 #define ZPOOL_HIST_WHO "history who" 1352 #define ZPOOL_HIST_ZONE "history zone" 1353 #define ZPOOL_HIST_HOST "history hostname" 1354 #define ZPOOL_HIST_TXG "history txg" 1355 #define ZPOOL_HIST_INT_EVENT "history internal event" 1356 #define ZPOOL_HIST_INT_STR "history internal str" 1357 #define ZPOOL_HIST_INT_NAME "internal_name" 1358 #define ZPOOL_HIST_IOCTL "ioctl" 1359 #define ZPOOL_HIST_INPUT_NVL "in_nvl" 1360 #define ZPOOL_HIST_OUTPUT_NVL "out_nvl" 1361 #define ZPOOL_HIST_DSNAME "dsname" 1362 #define ZPOOL_HIST_DSID "dsid" 1363 #define ZPOOL_HIST_ERRNO "errno" 1364 1365 /* 1366 * The following are names used when invoking ZFS_IOC_POOL_INITIALIZE. 1367 */ 1368 #define ZPOOL_INITIALIZE_COMMAND "initialize_command" 1369 #define ZPOOL_INITIALIZE_VDEVS "initialize_vdevs" 1370 1371 /* 1372 * Special nvlist name that will not have its args recorded in the pool's 1373 * history log. 1374 */ 1375 #define ZPOOL_HIDDEN_ARGS "hidden_args" 1376 1377 /* 1378 * The following are names used when invoking ZFS_IOC_POOL_TRIM. 1379 */ 1380 #define ZPOOL_TRIM_COMMAND "trim_command" 1381 #define ZPOOL_TRIM_VDEVS "trim_vdevs" 1382 #define ZPOOL_TRIM_RATE "trim_rate" 1383 #define ZPOOL_TRIM_SECURE "trim_secure" 1384 1385 /* 1386 * Flags for ZFS_IOC_VDEV_SET_STATE 1387 */ 1388 #define ZFS_ONLINE_CHECKREMOVE 0x1 1389 #define ZFS_ONLINE_UNSPARE 0x2 1390 #define ZFS_ONLINE_FORCEFAULT 0x4 1391 #define ZFS_ONLINE_EXPAND 0x8 1392 #define ZFS_OFFLINE_TEMPORARY 0x1 1393 1394 /* 1395 * Flags for ZFS_IOC_POOL_IMPORT 1396 */ 1397 #define ZFS_IMPORT_NORMAL 0x0 1398 #define ZFS_IMPORT_VERBATIM 0x1 1399 #define ZFS_IMPORT_ANY_HOST 0x2 1400 #define ZFS_IMPORT_MISSING_LOG 0x4 1401 #define ZFS_IMPORT_ONLY 0x8 1402 #define ZFS_IMPORT_CHECKPOINT 0x10 1403 #define ZFS_IMPORT_TEMP_NAME 0x20 1404 #define ZFS_IMPORT_SKIP_MMP 0x40 1405 #define ZFS_IMPORT_LOAD_KEYS 0x80 1406 1407 /* 1408 * Channel program argument/return nvlist keys and defaults. 1409 */ 1410 #define ZCP_ARG_PROGRAM "program" 1411 #define ZCP_ARG_ARGLIST "arg" 1412 #define ZCP_ARG_SYNC "sync" 1413 #define ZCP_ARG_INSTRLIMIT "instrlimit" 1414 #define ZCP_ARG_MEMLIMIT "memlimit" 1415 1416 #define ZCP_ARG_CLIARGV "argv" 1417 1418 #define ZCP_RET_ERROR "error" 1419 #define ZCP_RET_RETURN "return" 1420 1421 #define ZCP_DEFAULT_INSTRLIMIT (10 * 1000 * 1000) 1422 #define ZCP_MAX_INSTRLIMIT (10 * ZCP_DEFAULT_INSTRLIMIT) 1423 #define ZCP_DEFAULT_MEMLIMIT (10 * 1024 * 1024) 1424 #define ZCP_MAX_MEMLIMIT (10 * ZCP_DEFAULT_MEMLIMIT) 1425 1426 /* 1427 * Sysevent payload members. ZFS will generate the following sysevents with the 1428 * given payloads: 1429 * 1430 * ESC_ZFS_RESILVER_START 1431 * ESC_ZFS_RESILVER_END 1432 * ESC_ZFS_POOL_DESTROY 1433 * ESC_ZFS_POOL_REGUID 1434 * 1435 * ZFS_EV_POOL_NAME DATA_TYPE_STRING 1436 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 1437 * 1438 * ESC_ZFS_VDEV_REMOVE 1439 * ESC_ZFS_VDEV_CLEAR 1440 * ESC_ZFS_VDEV_CHECK 1441 * 1442 * ZFS_EV_POOL_NAME DATA_TYPE_STRING 1443 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 1444 * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) 1445 * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 1446 * 1447 * ESC_ZFS_HISTORY_EVENT 1448 * 1449 * ZFS_EV_POOL_NAME DATA_TYPE_STRING 1450 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 1451 * ZFS_EV_HIST_TIME DATA_TYPE_UINT64 (optional) 1452 * ZFS_EV_HIST_CMD DATA_TYPE_STRING (optional) 1453 * ZFS_EV_HIST_WHO DATA_TYPE_UINT64 (optional) 1454 * ZFS_EV_HIST_ZONE DATA_TYPE_STRING (optional) 1455 * ZFS_EV_HIST_HOST DATA_TYPE_STRING (optional) 1456 * ZFS_EV_HIST_TXG DATA_TYPE_UINT64 (optional) 1457 * ZFS_EV_HIST_INT_EVENT DATA_TYPE_UINT64 (optional) 1458 * ZFS_EV_HIST_INT_STR DATA_TYPE_STRING (optional) 1459 * ZFS_EV_HIST_INT_NAME DATA_TYPE_STRING (optional) 1460 * ZFS_EV_HIST_IOCTL DATA_TYPE_STRING (optional) 1461 * ZFS_EV_HIST_DSNAME DATA_TYPE_STRING (optional) 1462 * ZFS_EV_HIST_DSID DATA_TYPE_UINT64 (optional) 1463 * 1464 * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the 1465 * history log nvlist. The keynames will be free of any spaces or other 1466 * characters that could be potentially unexpected to consumers of the 1467 * sysevents. 1468 */ 1469 #define ZFS_EV_POOL_NAME "pool_name" 1470 #define ZFS_EV_POOL_GUID "pool_guid" 1471 #define ZFS_EV_VDEV_PATH "vdev_path" 1472 #define ZFS_EV_VDEV_GUID "vdev_guid" 1473 #define ZFS_EV_HIST_TIME "history_time" 1474 #define ZFS_EV_HIST_CMD "history_command" 1475 #define ZFS_EV_HIST_WHO "history_who" 1476 #define ZFS_EV_HIST_ZONE "history_zone" 1477 #define ZFS_EV_HIST_HOST "history_hostname" 1478 #define ZFS_EV_HIST_TXG "history_txg" 1479 #define ZFS_EV_HIST_INT_EVENT "history_internal_event" 1480 #define ZFS_EV_HIST_INT_STR "history_internal_str" 1481 #define ZFS_EV_HIST_INT_NAME "history_internal_name" 1482 #define ZFS_EV_HIST_IOCTL "history_ioctl" 1483 #define ZFS_EV_HIST_DSNAME "history_dsname" 1484 #define ZFS_EV_HIST_DSID "history_dsid" 1485 1486 #ifdef __cplusplus 1487 } 1488 #endif 1489 1490 #endif /* _SYS_FS_ZFS_H */ 1491