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