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, 2016 by Delphix. All rights reserved. 25 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 26 * Copyright (c) 2014 Integros [integros.com] 27 * Copyright 2017 Joyent, Inc. 28 * Copyright (c) 2017 Datto Inc. 29 */ 30 31 /* Portions Copyright 2010 Robert Milkowski */ 32 33 #ifndef _SYS_FS_ZFS_H 34 #define _SYS_FS_ZFS_H 35 36 #include <sys/time.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* 43 * Types and constants shared between userland and the kernel. 44 */ 45 46 /* 47 * Each dataset can be one of the following types. These constants can be 48 * combined into masks that can be passed to various functions. 49 */ 50 typedef enum { 51 ZFS_TYPE_FILESYSTEM = (1 << 0), 52 ZFS_TYPE_SNAPSHOT = (1 << 1), 53 ZFS_TYPE_VOLUME = (1 << 2), 54 ZFS_TYPE_POOL = (1 << 3), 55 ZFS_TYPE_BOOKMARK = (1 << 4) 56 } zfs_type_t; 57 58 /* 59 * NB: lzc_dataset_type should be updated whenever a new objset type is added, 60 * if it represents a real type of a dataset that can be created from userland. 61 */ 62 typedef enum dmu_objset_type { 63 DMU_OST_NONE, 64 DMU_OST_META, 65 DMU_OST_ZFS, 66 DMU_OST_ZVOL, 67 DMU_OST_OTHER, /* For testing only! */ 68 DMU_OST_ANY, /* Be careful! */ 69 DMU_OST_NUMTYPES 70 } dmu_objset_type_t; 71 72 #define ZFS_TYPE_DATASET \ 73 (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) 74 75 /* 76 * All of these include the terminating NUL byte. 77 */ 78 #define ZAP_MAXNAMELEN 256 79 #define ZAP_MAXVALUELEN (1024 * 8) 80 #define ZAP_OLDMAXVALUELEN 1024 81 #define ZFS_MAX_DATASET_NAME_LEN 256 82 83 /* 84 * Dataset properties are identified by these constants and must be added to 85 * the end of this list to ensure that external consumers are not affected 86 * by the change. If you make any changes to this list, be sure to update 87 * the property table in usr/src/common/zfs/zfs_prop.c. 88 */ 89 typedef enum { 90 ZPROP_CONT = -2, 91 ZPROP_INVAL = -1, 92 ZFS_PROP_TYPE = 0, 93 ZFS_PROP_CREATION, 94 ZFS_PROP_USED, 95 ZFS_PROP_AVAILABLE, 96 ZFS_PROP_REFERENCED, 97 ZFS_PROP_COMPRESSRATIO, 98 ZFS_PROP_MOUNTED, 99 ZFS_PROP_ORIGIN, 100 ZFS_PROP_QUOTA, 101 ZFS_PROP_RESERVATION, 102 ZFS_PROP_VOLSIZE, 103 ZFS_PROP_VOLBLOCKSIZE, 104 ZFS_PROP_RECORDSIZE, 105 ZFS_PROP_MOUNTPOINT, 106 ZFS_PROP_SHARENFS, 107 ZFS_PROP_CHECKSUM, 108 ZFS_PROP_COMPRESSION, 109 ZFS_PROP_ATIME, 110 ZFS_PROP_DEVICES, 111 ZFS_PROP_EXEC, 112 ZFS_PROP_SETUID, 113 ZFS_PROP_READONLY, 114 ZFS_PROP_ZONED, 115 ZFS_PROP_SNAPDIR, 116 ZFS_PROP_ACLMODE, 117 ZFS_PROP_ACLINHERIT, 118 ZFS_PROP_CREATETXG, 119 ZFS_PROP_NAME, /* not exposed to the user */ 120 ZFS_PROP_CANMOUNT, 121 ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */ 122 ZFS_PROP_XATTR, 123 ZFS_PROP_NUMCLONES, /* not exposed to the user */ 124 ZFS_PROP_COPIES, 125 ZFS_PROP_VERSION, 126 ZFS_PROP_UTF8ONLY, 127 ZFS_PROP_NORMALIZE, 128 ZFS_PROP_CASE, 129 ZFS_PROP_VSCAN, 130 ZFS_PROP_NBMAND, 131 ZFS_PROP_SHARESMB, 132 ZFS_PROP_REFQUOTA, 133 ZFS_PROP_REFRESERVATION, 134 ZFS_PROP_GUID, 135 ZFS_PROP_PRIMARYCACHE, 136 ZFS_PROP_SECONDARYCACHE, 137 ZFS_PROP_USEDSNAP, 138 ZFS_PROP_USEDDS, 139 ZFS_PROP_USEDCHILD, 140 ZFS_PROP_USEDREFRESERV, 141 ZFS_PROP_USERACCOUNTING, /* not exposed to the user */ 142 ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */ 143 ZFS_PROP_DEFER_DESTROY, 144 ZFS_PROP_USERREFS, 145 ZFS_PROP_LOGBIAS, 146 ZFS_PROP_UNIQUE, /* not exposed to the user */ 147 ZFS_PROP_OBJSETID, /* not exposed to the user */ 148 ZFS_PROP_DEDUP, 149 ZFS_PROP_MLSLABEL, 150 ZFS_PROP_SYNC, 151 ZFS_PROP_DNODESIZE, 152 ZFS_PROP_REFRATIO, 153 ZFS_PROP_WRITTEN, 154 ZFS_PROP_CLONES, 155 ZFS_PROP_LOGICALUSED, 156 ZFS_PROP_LOGICALREFERENCED, 157 ZFS_PROP_INCONSISTENT, /* not exposed to the user */ 158 ZFS_PROP_FILESYSTEM_LIMIT, 159 ZFS_PROP_SNAPSHOT_LIMIT, 160 ZFS_PROP_FILESYSTEM_COUNT, 161 ZFS_PROP_SNAPSHOT_COUNT, 162 ZFS_PROP_REDUNDANT_METADATA, 163 ZFS_PROP_PREV_SNAP, 164 ZFS_PROP_RECEIVE_RESUME_TOKEN, 165 ZFS_PROP_REMAPTXG, /* not exposed to the user */ 166 ZFS_NUM_PROPS 167 } zfs_prop_t; 168 169 typedef enum { 170 ZFS_PROP_USERUSED, 171 ZFS_PROP_USERQUOTA, 172 ZFS_PROP_GROUPUSED, 173 ZFS_PROP_GROUPQUOTA, 174 ZFS_NUM_USERQUOTA_PROPS 175 } zfs_userquota_prop_t; 176 177 extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS]; 178 179 /* 180 * Pool properties are identified by these constants and must be added to the 181 * end of this list to ensure that external consumers are not affected 182 * by the change. If you make any changes to this list, be sure to update 183 * the property table in usr/src/common/zfs/zpool_prop.c. 184 */ 185 typedef enum { 186 ZPOOL_PROP_INVAL = -1, 187 ZPOOL_PROP_NAME, 188 ZPOOL_PROP_SIZE, 189 ZPOOL_PROP_CAPACITY, 190 ZPOOL_PROP_ALTROOT, 191 ZPOOL_PROP_HEALTH, 192 ZPOOL_PROP_GUID, 193 ZPOOL_PROP_VERSION, 194 ZPOOL_PROP_BOOTFS, 195 ZPOOL_PROP_DELEGATION, 196 ZPOOL_PROP_AUTOREPLACE, 197 ZPOOL_PROP_CACHEFILE, 198 ZPOOL_PROP_FAILUREMODE, 199 ZPOOL_PROP_LISTSNAPS, 200 ZPOOL_PROP_AUTOEXPAND, 201 ZPOOL_PROP_DEDUPDITTO, 202 ZPOOL_PROP_DEDUPRATIO, 203 ZPOOL_PROP_FREE, 204 ZPOOL_PROP_ALLOCATED, 205 ZPOOL_PROP_READONLY, 206 ZPOOL_PROP_COMMENT, 207 ZPOOL_PROP_EXPANDSZ, 208 ZPOOL_PROP_FREEING, 209 ZPOOL_PROP_FRAGMENTATION, 210 ZPOOL_PROP_LEAKED, 211 ZPOOL_PROP_MAXBLOCKSIZE, 212 ZPOOL_PROP_BOOTSIZE, 213 ZPOOL_PROP_CHECKPOINT, 214 ZPOOL_PROP_TNAME, 215 ZPOOL_PROP_MAXDNODESIZE, 216 ZPOOL_NUM_PROPS 217 } zpool_prop_t; 218 219 /* Small enough to not hog a whole line of printout in zpool(1M). */ 220 #define ZPROP_MAX_COMMENT 32 221 222 #define ZPROP_VALUE "value" 223 #define ZPROP_SOURCE "source" 224 225 typedef enum { 226 ZPROP_SRC_NONE = 0x1, 227 ZPROP_SRC_DEFAULT = 0x2, 228 ZPROP_SRC_TEMPORARY = 0x4, 229 ZPROP_SRC_LOCAL = 0x8, 230 ZPROP_SRC_INHERITED = 0x10, 231 ZPROP_SRC_RECEIVED = 0x20 232 } zprop_source_t; 233 234 #define ZPROP_SRC_ALL 0x3f 235 236 #define ZPROP_SOURCE_VAL_RECVD "$recvd" 237 #define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS" 238 /* 239 * Dataset flag implemented as a special entry in the props zap object 240 * indicating that the dataset has received properties on or after 241 * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties 242 * just as it did in earlier versions, and thereafter, local properties are 243 * preserved. 244 */ 245 #define ZPROP_HAS_RECVD "$hasrecvd" 246 247 typedef enum { 248 ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */ 249 ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */ 250 } zprop_errflags_t; 251 252 typedef int (*zprop_func)(int, void *); 253 254 /* 255 * Properties to be set on the root file system of a new pool 256 * are stuffed into their own nvlist, which is then included in 257 * the properties nvlist with the pool properties. 258 */ 259 #define ZPOOL_ROOTFS_PROPS "root-props-nvl" 260 261 /* 262 * Length of 'written@' and 'written#' 263 */ 264 #define ZFS_WRITTEN_PROP_PREFIX_LEN 8 265 266 /* 267 * Dataset property functions shared between libzfs and kernel. 268 */ 269 const char *zfs_prop_default_string(zfs_prop_t); 270 uint64_t zfs_prop_default_numeric(zfs_prop_t); 271 boolean_t zfs_prop_readonly(zfs_prop_t); 272 boolean_t zfs_prop_visible(zfs_prop_t prop); 273 boolean_t zfs_prop_inheritable(zfs_prop_t); 274 boolean_t zfs_prop_setonce(zfs_prop_t); 275 const char *zfs_prop_to_name(zfs_prop_t); 276 zfs_prop_t zfs_name_to_prop(const char *); 277 boolean_t zfs_prop_user(const char *); 278 boolean_t zfs_prop_userquota(const char *); 279 boolean_t zfs_prop_written(const char *); 280 int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); 281 int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *); 282 uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed); 283 boolean_t zfs_prop_valid_for_type(int, zfs_type_t); 284 285 /* 286 * Pool property functions shared between libzfs and kernel. 287 */ 288 zpool_prop_t zpool_name_to_prop(const char *); 289 const char *zpool_prop_to_name(zpool_prop_t); 290 const char *zpool_prop_default_string(zpool_prop_t); 291 uint64_t zpool_prop_default_numeric(zpool_prop_t); 292 boolean_t zpool_prop_readonly(zpool_prop_t); 293 boolean_t zpool_prop_feature(const char *); 294 boolean_t zpool_prop_unsupported(const char *name); 295 int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **); 296 int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *); 297 uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed); 298 299 /* 300 * Definitions for the Delegation. 301 */ 302 typedef enum { 303 ZFS_DELEG_WHO_UNKNOWN = 0, 304 ZFS_DELEG_USER = 'u', 305 ZFS_DELEG_USER_SETS = 'U', 306 ZFS_DELEG_GROUP = 'g', 307 ZFS_DELEG_GROUP_SETS = 'G', 308 ZFS_DELEG_EVERYONE = 'e', 309 ZFS_DELEG_EVERYONE_SETS = 'E', 310 ZFS_DELEG_CREATE = 'c', 311 ZFS_DELEG_CREATE_SETS = 'C', 312 ZFS_DELEG_NAMED_SET = 's', 313 ZFS_DELEG_NAMED_SET_SETS = 'S' 314 } zfs_deleg_who_type_t; 315 316 typedef enum { 317 ZFS_DELEG_NONE = 0, 318 ZFS_DELEG_PERM_LOCAL = 1, 319 ZFS_DELEG_PERM_DESCENDENT = 2, 320 ZFS_DELEG_PERM_LOCALDESCENDENT = 3, 321 ZFS_DELEG_PERM_CREATE = 4 322 } zfs_deleg_inherit_t; 323 324 #define ZFS_DELEG_PERM_UID "uid" 325 #define ZFS_DELEG_PERM_GID "gid" 326 #define ZFS_DELEG_PERM_GROUPS "groups" 327 328 #define ZFS_MLSLABEL_DEFAULT "none" 329 330 #define ZFS_SMB_ACL_SRC "src" 331 #define ZFS_SMB_ACL_TARGET "target" 332 333 typedef enum { 334 ZFS_CANMOUNT_OFF = 0, 335 ZFS_CANMOUNT_ON = 1, 336 ZFS_CANMOUNT_NOAUTO = 2 337 } zfs_canmount_type_t; 338 339 typedef enum { 340 ZFS_LOGBIAS_LATENCY = 0, 341 ZFS_LOGBIAS_THROUGHPUT = 1 342 } zfs_logbias_op_t; 343 344 typedef enum zfs_share_op { 345 ZFS_SHARE_NFS = 0, 346 ZFS_UNSHARE_NFS = 1, 347 ZFS_SHARE_SMB = 2, 348 ZFS_UNSHARE_SMB = 3 349 } zfs_share_op_t; 350 351 typedef enum zfs_smb_acl_op { 352 ZFS_SMB_ACL_ADD, 353 ZFS_SMB_ACL_REMOVE, 354 ZFS_SMB_ACL_RENAME, 355 ZFS_SMB_ACL_PURGE 356 } zfs_smb_acl_op_t; 357 358 typedef enum zfs_cache_type { 359 ZFS_CACHE_NONE = 0, 360 ZFS_CACHE_METADATA = 1, 361 ZFS_CACHE_ALL = 2 362 } zfs_cache_type_t; 363 364 typedef enum { 365 ZFS_SYNC_STANDARD = 0, 366 ZFS_SYNC_ALWAYS = 1, 367 ZFS_SYNC_DISABLED = 2 368 } zfs_sync_type_t; 369 370 typedef enum { 371 ZFS_DNSIZE_LEGACY = 0, 372 ZFS_DNSIZE_AUTO = 1, 373 ZFS_DNSIZE_1K = 1024, 374 ZFS_DNSIZE_2K = 2048, 375 ZFS_DNSIZE_4K = 4096, 376 ZFS_DNSIZE_8K = 8192, 377 ZFS_DNSIZE_16K = 16384 378 } zfs_dnsize_type_t; 379 380 typedef enum { 381 ZFS_REDUNDANT_METADATA_ALL, 382 ZFS_REDUNDANT_METADATA_MOST 383 } zfs_redundant_metadata_type_t; 384 385 /* 386 * On-disk version number. 387 */ 388 #define SPA_VERSION_1 1ULL 389 #define SPA_VERSION_2 2ULL 390 #define SPA_VERSION_3 3ULL 391 #define SPA_VERSION_4 4ULL 392 #define SPA_VERSION_5 5ULL 393 #define SPA_VERSION_6 6ULL 394 #define SPA_VERSION_7 7ULL 395 #define SPA_VERSION_8 8ULL 396 #define SPA_VERSION_9 9ULL 397 #define SPA_VERSION_10 10ULL 398 #define SPA_VERSION_11 11ULL 399 #define SPA_VERSION_12 12ULL 400 #define SPA_VERSION_13 13ULL 401 #define SPA_VERSION_14 14ULL 402 #define SPA_VERSION_15 15ULL 403 #define SPA_VERSION_16 16ULL 404 #define SPA_VERSION_17 17ULL 405 #define SPA_VERSION_18 18ULL 406 #define SPA_VERSION_19 19ULL 407 #define SPA_VERSION_20 20ULL 408 #define SPA_VERSION_21 21ULL 409 #define SPA_VERSION_22 22ULL 410 #define SPA_VERSION_23 23ULL 411 #define SPA_VERSION_24 24ULL 412 #define SPA_VERSION_25 25ULL 413 #define SPA_VERSION_26 26ULL 414 #define SPA_VERSION_27 27ULL 415 #define SPA_VERSION_28 28ULL 416 #define SPA_VERSION_5000 5000ULL 417 418 /* 419 * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk 420 * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*}, 421 * and do the appropriate changes. Also bump the version number in 422 * usr/src/grub/capability. 423 */ 424 #define SPA_VERSION SPA_VERSION_5000 425 #define SPA_VERSION_STRING "5000" 426 427 /* 428 * Symbolic names for the changes that caused a SPA_VERSION switch. 429 * Used in the code when checking for presence or absence of a feature. 430 * Feel free to define multiple symbolic names for each version if there 431 * were multiple changes to on-disk structures during that version. 432 * 433 * NOTE: When checking the current SPA_VERSION in your code, be sure 434 * to use spa_version() since it reports the version of the 435 * last synced uberblock. Checking the in-flight version can 436 * be dangerous in some cases. 437 */ 438 #define SPA_VERSION_INITIAL SPA_VERSION_1 439 #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 440 #define SPA_VERSION_SPARES SPA_VERSION_3 441 #define SPA_VERSION_RAIDZ2 SPA_VERSION_3 442 #define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3 443 #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 444 #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 445 #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 446 #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 447 #define SPA_VERSION_BOOTFS SPA_VERSION_6 448 #define SPA_VERSION_SLOGS SPA_VERSION_7 449 #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8 450 #define SPA_VERSION_FUID SPA_VERSION_9 451 #define SPA_VERSION_REFRESERVATION SPA_VERSION_9 452 #define SPA_VERSION_REFQUOTA SPA_VERSION_9 453 #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9 454 #define SPA_VERSION_L2CACHE SPA_VERSION_10 455 #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11 456 #define SPA_VERSION_ORIGIN SPA_VERSION_11 457 #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11 458 #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12 459 #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13 460 #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14 461 #define SPA_VERSION_USERSPACE SPA_VERSION_15 462 #define SPA_VERSION_STMF_PROP SPA_VERSION_16 463 #define SPA_VERSION_RAIDZ3 SPA_VERSION_17 464 #define SPA_VERSION_USERREFS SPA_VERSION_18 465 #define SPA_VERSION_HOLES SPA_VERSION_19 466 #define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20 467 #define SPA_VERSION_DEDUP SPA_VERSION_21 468 #define SPA_VERSION_RECVD_PROPS SPA_VERSION_22 469 #define SPA_VERSION_SLIM_ZIL SPA_VERSION_23 470 #define SPA_VERSION_SA SPA_VERSION_24 471 #define SPA_VERSION_SCAN SPA_VERSION_25 472 #define SPA_VERSION_DIR_CLONES SPA_VERSION_26 473 #define SPA_VERSION_DEADLISTS SPA_VERSION_26 474 #define SPA_VERSION_FAST_SNAP SPA_VERSION_27 475 #define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28 476 #define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28 477 #define SPA_VERSION_FEATURES SPA_VERSION_5000 478 479 #define SPA_VERSION_IS_SUPPORTED(v) \ 480 (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \ 481 ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION)) 482 483 /* 484 * ZPL version - rev'd whenever an incompatible on-disk format change 485 * occurs. This is independent of SPA/DMU/ZAP versioning. You must 486 * also update the version_table[] and help message in zfs_prop.c. 487 * 488 * When changing, be sure to teach GRUB how to read the new format! 489 * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*} 490 */ 491 #define ZPL_VERSION_1 1ULL 492 #define ZPL_VERSION_2 2ULL 493 #define ZPL_VERSION_3 3ULL 494 #define ZPL_VERSION_4 4ULL 495 #define ZPL_VERSION_5 5ULL 496 #define ZPL_VERSION ZPL_VERSION_5 497 #define ZPL_VERSION_STRING "5" 498 499 #define ZPL_VERSION_INITIAL ZPL_VERSION_1 500 #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 501 #define ZPL_VERSION_FUID ZPL_VERSION_3 502 #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3 503 #define ZPL_VERSION_SYSATTR ZPL_VERSION_3 504 #define ZPL_VERSION_USERSPACE ZPL_VERSION_4 505 #define ZPL_VERSION_SA ZPL_VERSION_5 506 507 /* Rewind policy information */ 508 #define ZPOOL_NO_REWIND 1 /* No policy - default behavior */ 509 #define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */ 510 #define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */ 511 #define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */ 512 #define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */ 513 #define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */ 514 #define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */ 515 516 typedef struct zpool_load_policy { 517 uint32_t zlp_rewind; /* rewind policy requested */ 518 uint64_t zlp_maxmeta; /* max acceptable meta-data errors */ 519 uint64_t zlp_maxdata; /* max acceptable data errors */ 520 uint64_t zlp_txg; /* specific txg to load */ 521 } zpool_load_policy_t; 522 523 /* 524 * The following are configuration names used in the nvlist describing a pool's 525 * configuration. New on-disk names should be prefixed with "<reverse-DNS>:" 526 * (e.g. "org.open-zfs:") to avoid conflicting names being developed 527 * independently. 528 */ 529 #define ZPOOL_CONFIG_VERSION "version" 530 #define ZPOOL_CONFIG_POOL_NAME "name" 531 #define ZPOOL_CONFIG_POOL_STATE "state" 532 #define ZPOOL_CONFIG_POOL_TXG "txg" 533 #define ZPOOL_CONFIG_POOL_GUID "pool_guid" 534 #define ZPOOL_CONFIG_CREATE_TXG "create_txg" 535 #define ZPOOL_CONFIG_TOP_GUID "top_guid" 536 #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" 537 #define ZPOOL_CONFIG_TYPE "type" 538 #define ZPOOL_CONFIG_CHILDREN "children" 539 #define ZPOOL_CONFIG_ID "id" 540 #define ZPOOL_CONFIG_GUID "guid" 541 #define ZPOOL_CONFIG_INDIRECT_OBJECT "com.delphix:indirect_object" 542 #define ZPOOL_CONFIG_INDIRECT_BIRTHS "com.delphix:indirect_births" 543 #define ZPOOL_CONFIG_PREV_INDIRECT_VDEV "com.delphix:prev_indirect_vdev" 544 #define ZPOOL_CONFIG_PATH "path" 545 #define ZPOOL_CONFIG_DEVID "devid" 546 #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" 547 #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" 548 #define ZPOOL_CONFIG_ASHIFT "ashift" 549 #define ZPOOL_CONFIG_ASIZE "asize" 550 #define ZPOOL_CONFIG_DTL "DTL" 551 #define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */ 552 #define ZPOOL_CONFIG_REMOVAL_STATS "removal_stats" /* not stored on disk */ 553 #define ZPOOL_CONFIG_CHECKPOINT_STATS "checkpoint_stats" /* not on disk */ 554 #define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */ 555 #define ZPOOL_CONFIG_INDIRECT_SIZE "indirect_size" /* not stored on disk */ 556 #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" 557 #define ZPOOL_CONFIG_ERRCOUNT "error_count" 558 #define ZPOOL_CONFIG_NOT_PRESENT "not_present" 559 #define ZPOOL_CONFIG_SPARES "spares" 560 #define ZPOOL_CONFIG_IS_SPARE "is_spare" 561 #define ZPOOL_CONFIG_NPARITY "nparity" 562 #define ZPOOL_CONFIG_HOSTID "hostid" 563 #define ZPOOL_CONFIG_HOSTNAME "hostname" 564 #define ZPOOL_CONFIG_LOADED_TIME "initial_load_time" 565 #define ZPOOL_CONFIG_UNSPARE "unspare" 566 #define ZPOOL_CONFIG_PHYS_PATH "phys_path" 567 #define ZPOOL_CONFIG_IS_LOG "is_log" 568 #define ZPOOL_CONFIG_L2CACHE "l2cache" 569 #define ZPOOL_CONFIG_HOLE_ARRAY "hole_array" 570 #define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children" 571 #define ZPOOL_CONFIG_IS_HOLE "is_hole" 572 #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram" 573 #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats" 574 #define ZPOOL_CONFIG_DDT_STATS "ddt_stats" 575 #define ZPOOL_CONFIG_SPLIT "splitcfg" 576 #define ZPOOL_CONFIG_ORIG_GUID "orig_guid" 577 #define ZPOOL_CONFIG_SPLIT_GUID "split_guid" 578 #define ZPOOL_CONFIG_SPLIT_LIST "guid_list" 579 #define ZPOOL_CONFIG_REMOVING "removing" 580 #define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg" 581 #define ZPOOL_CONFIG_COMMENT "comment" 582 #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */ 583 #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ 584 #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */ 585 #define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */ 586 #define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */ 587 #define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */ 588 #define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */ 589 #define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */ 590 #define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */ 591 #define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read" 592 #define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */ 593 #define ZPOOL_CONFIG_VDEV_TOP_ZAP "com.delphix:vdev_zap_top" 594 #define ZPOOL_CONFIG_VDEV_LEAF_ZAP "com.delphix:vdev_zap_leaf" 595 #define ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS "com.delphix:has_per_vdev_zaps" 596 #define ZPOOL_CONFIG_CACHEFILE "cachefile" /* not stored on disk */ 597 /* 598 * The persistent vdev state is stored as separate values rather than a single 599 * 'vdev_state' entry. This is because a device can be in multiple states, such 600 * as offline and degraded. 601 */ 602 #define ZPOOL_CONFIG_OFFLINE "offline" 603 #define ZPOOL_CONFIG_FAULTED "faulted" 604 #define ZPOOL_CONFIG_DEGRADED "degraded" 605 #define ZPOOL_CONFIG_REMOVED "removed" 606 #define ZPOOL_CONFIG_FRU "fru" 607 #define ZPOOL_CONFIG_AUX_STATE "aux_state" 608 609 /* Pool load policy parameters */ 610 #define ZPOOL_LOAD_POLICY "load-policy" 611 #define ZPOOL_LOAD_REWIND_POLICY "load-rewind-policy" 612 #define ZPOOL_LOAD_REQUEST_TXG "load-request-txg" 613 #define ZPOOL_LOAD_META_THRESH "load-meta-thresh" 614 #define ZPOOL_LOAD_DATA_THRESH "load-data-thresh" 615 616 /* Rewind data discovered */ 617 #define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts" 618 #define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors" 619 #define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind" 620 621 #define VDEV_TYPE_ROOT "root" 622 #define VDEV_TYPE_MIRROR "mirror" 623 #define VDEV_TYPE_REPLACING "replacing" 624 #define VDEV_TYPE_RAIDZ "raidz" 625 #define VDEV_TYPE_DISK "disk" 626 #define VDEV_TYPE_FILE "file" 627 #define VDEV_TYPE_MISSING "missing" 628 #define VDEV_TYPE_HOLE "hole" 629 #define VDEV_TYPE_SPARE "spare" 630 #define VDEV_TYPE_LOG "log" 631 #define VDEV_TYPE_L2CACHE "l2cache" 632 #define VDEV_TYPE_INDIRECT "indirect" 633 634 /* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */ 635 #define VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \ 636 "com.delphix:indirect_obsolete_sm" 637 #define VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \ 638 "com.delphix:obsolete_counts_are_precise" 639 #define VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \ 640 "com.delphix:pool_checkpoint_sm" 641 642 #define VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET \ 643 "com.delphix:next_offset_to_initialize" 644 #define VDEV_LEAF_ZAP_INITIALIZE_STATE \ 645 "com.delphix:vdev_initialize_state" 646 #define VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME \ 647 "com.delphix:vdev_initialize_action_time" 648 649 /* 650 * This is needed in userland to report the minimum necessary device size. 651 * 652 * Note that the zfs test suite uses 64MB vdevs. 653 */ 654 #define SPA_MINDEVSIZE (64ULL << 20) 655 656 /* 657 * Set if the fragmentation has not yet been calculated. This can happen 658 * because the space maps have not been upgraded or the histogram feature 659 * is not enabled. 660 */ 661 #define ZFS_FRAG_INVALID UINT64_MAX 662 663 /* 664 * The location of the pool configuration repository, shared between kernel and 665 * userland. 666 */ 667 #define ZPOOL_CACHE "/etc/zfs/zpool.cache" 668 669 /* 670 * vdev states are ordered from least to most healthy. 671 * A vdev that's CANT_OPEN or below is considered unusable. 672 */ 673 typedef enum vdev_state { 674 VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ 675 VDEV_STATE_CLOSED, /* Not currently open */ 676 VDEV_STATE_OFFLINE, /* Not allowed to open */ 677 VDEV_STATE_REMOVED, /* Explicitly removed from system */ 678 VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ 679 VDEV_STATE_FAULTED, /* External request to fault device */ 680 VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ 681 VDEV_STATE_HEALTHY /* Presumed good */ 682 } vdev_state_t; 683 684 #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY 685 686 /* 687 * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field 688 * of the vdev stats structure uses these constants to distinguish why. 689 */ 690 typedef enum vdev_aux { 691 VDEV_AUX_NONE, /* no error */ 692 VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ 693 VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ 694 VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ 695 VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ 696 VDEV_AUX_TOO_SMALL, /* vdev size is too small */ 697 VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ 698 VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ 699 VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ 700 VDEV_AUX_UNSUP_FEAT, /* unsupported features */ 701 VDEV_AUX_SPARED, /* hot spare used in another pool */ 702 VDEV_AUX_ERR_EXCEEDED, /* too many errors */ 703 VDEV_AUX_IO_FAILURE, /* experienced I/O failure */ 704 VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */ 705 VDEV_AUX_EXTERNAL, /* external diagnosis */ 706 VDEV_AUX_SPLIT_POOL, /* vdev was split off into another pool */ 707 VDEV_AUX_CHILDREN_OFFLINE /* all children are offline */ 708 } vdev_aux_t; 709 710 /* 711 * pool state. The following states are written to disk as part of the normal 712 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining 713 * states are software abstractions used at various levels to communicate 714 * pool state. 715 */ 716 typedef enum pool_state { 717 POOL_STATE_ACTIVE = 0, /* In active use */ 718 POOL_STATE_EXPORTED, /* Explicitly exported */ 719 POOL_STATE_DESTROYED, /* Explicitly destroyed */ 720 POOL_STATE_SPARE, /* Reserved for hot spare use */ 721 POOL_STATE_L2CACHE, /* Level 2 ARC device */ 722 POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ 723 POOL_STATE_UNAVAIL, /* Internal libzfs state */ 724 POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ 725 } pool_state_t; 726 727 /* 728 * Scan Functions. 729 */ 730 typedef enum pool_scan_func { 731 POOL_SCAN_NONE, 732 POOL_SCAN_SCRUB, 733 POOL_SCAN_RESILVER, 734 POOL_SCAN_FUNCS 735 } pool_scan_func_t; 736 737 /* 738 * Used to control scrub pause and resume. 739 */ 740 typedef enum pool_scrub_cmd { 741 POOL_SCRUB_NORMAL = 0, 742 POOL_SCRUB_PAUSE, 743 POOL_SCRUB_FLAGS_END 744 } pool_scrub_cmd_t; 745 746 /* 747 * Initialize functions. 748 */ 749 typedef enum pool_initialize_func { 750 POOL_INITIALIZE_DO, 751 POOL_INITIALIZE_CANCEL, 752 POOL_INITIALIZE_SUSPEND, 753 POOL_INITIALIZE_FUNCS 754 } pool_initialize_func_t; 755 756 /* 757 * ZIO types. Needed to interpret vdev statistics below. 758 */ 759 typedef enum zio_type { 760 ZIO_TYPE_NULL = 0, 761 ZIO_TYPE_READ, 762 ZIO_TYPE_WRITE, 763 ZIO_TYPE_FREE, 764 ZIO_TYPE_CLAIM, 765 ZIO_TYPE_IOCTL, 766 ZIO_TYPES 767 } zio_type_t; 768 769 /* 770 * Pool statistics. Note: all fields should be 64-bit because this 771 * is passed between kernel and userland as an nvlist uint64 array. 772 */ 773 typedef struct pool_scan_stat { 774 /* values stored on disk */ 775 uint64_t pss_func; /* pool_scan_func_t */ 776 uint64_t pss_state; /* dsl_scan_state_t */ 777 uint64_t pss_start_time; /* scan start time */ 778 uint64_t pss_end_time; /* scan end time */ 779 uint64_t pss_to_examine; /* total bytes to scan */ 780 uint64_t pss_examined; /* total examined bytes */ 781 uint64_t pss_to_process; /* total bytes to process */ 782 uint64_t pss_processed; /* total processed bytes */ 783 uint64_t pss_errors; /* scan errors */ 784 785 /* values not stored on disk */ 786 uint64_t pss_pass_exam; /* examined bytes per scan pass */ 787 uint64_t pss_pass_start; /* start time of a scan pass */ 788 uint64_t pss_pass_scrub_pause; /* pause time of a scurb pass */ 789 /* cumulative time scrub spent paused, needed for rate calculation */ 790 uint64_t pss_pass_scrub_spent_paused; 791 } pool_scan_stat_t; 792 793 typedef struct pool_removal_stat { 794 uint64_t prs_state; /* dsl_scan_state_t */ 795 uint64_t prs_removing_vdev; 796 uint64_t prs_start_time; 797 uint64_t prs_end_time; 798 uint64_t prs_to_copy; /* bytes that need to be copied */ 799 uint64_t prs_copied; /* bytes copied so far */ 800 /* 801 * bytes of memory used for indirect mappings. 802 * This includes all removed vdevs. 803 */ 804 uint64_t prs_mapping_memory; 805 } pool_removal_stat_t; 806 807 typedef enum dsl_scan_state { 808 DSS_NONE, 809 DSS_SCANNING, 810 DSS_FINISHED, 811 DSS_CANCELED, 812 DSS_NUM_STATES 813 } dsl_scan_state_t; 814 815 typedef enum { 816 CS_NONE, 817 CS_CHECKPOINT_EXISTS, 818 CS_CHECKPOINT_DISCARDING, 819 CS_NUM_STATES 820 } checkpoint_state_t; 821 822 typedef struct pool_checkpoint_stat { 823 uint64_t pcs_state; /* checkpoint_state_t */ 824 uint64_t pcs_start_time; /* time checkpoint/discard started */ 825 uint64_t pcs_space; /* checkpointed space */ 826 } pool_checkpoint_stat_t; 827 828 typedef enum { 829 VDEV_INITIALIZE_NONE, 830 VDEV_INITIALIZE_ACTIVE, 831 VDEV_INITIALIZE_CANCELED, 832 VDEV_INITIALIZE_SUSPENDED, 833 VDEV_INITIALIZE_COMPLETE 834 } vdev_initializing_state_t; 835 836 /* 837 * Vdev statistics. Note: all fields should be 64-bit because this 838 * is passed between kernel and userland as an nvlist uint64 array. 839 */ 840 typedef struct vdev_stat { 841 hrtime_t vs_timestamp; /* time since vdev load */ 842 uint64_t vs_state; /* vdev state */ 843 uint64_t vs_aux; /* see vdev_aux_t */ 844 uint64_t vs_alloc; /* space allocated */ 845 uint64_t vs_space; /* total capacity */ 846 uint64_t vs_dspace; /* deflated capacity */ 847 uint64_t vs_rsize; /* replaceable dev size */ 848 uint64_t vs_esize; /* expandable dev size */ 849 uint64_t vs_ops[ZIO_TYPES]; /* operation count */ 850 uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */ 851 uint64_t vs_read_errors; /* read errors */ 852 uint64_t vs_write_errors; /* write errors */ 853 uint64_t vs_checksum_errors; /* checksum errors */ 854 uint64_t vs_initialize_errors; /* initializing errors */ 855 uint64_t vs_self_healed; /* self-healed bytes */ 856 uint64_t vs_scan_removing; /* removing? */ 857 uint64_t vs_scan_processed; /* scan processed bytes */ 858 uint64_t vs_fragmentation; /* device fragmentation */ 859 uint64_t vs_initialize_bytes_done; /* bytes initialized */ 860 uint64_t vs_initialize_bytes_est; /* total bytes to initialize */ 861 uint64_t vs_initialize_state; /* vdev_initialzing_state_t */ 862 uint64_t vs_initialize_action_time; /* time_t */ 863 uint64_t vs_checkpoint_space; /* checkpoint-consumed space */ 864 } vdev_stat_t; 865 866 /* 867 * DDT statistics. Note: all fields should be 64-bit because this 868 * is passed between kernel and userland as an nvlist uint64 array. 869 */ 870 typedef struct ddt_object { 871 uint64_t ddo_count; /* number of elments in ddt */ 872 uint64_t ddo_dspace; /* size of ddt on disk */ 873 uint64_t ddo_mspace; /* size of ddt in-core */ 874 } ddt_object_t; 875 876 typedef struct ddt_stat { 877 uint64_t dds_blocks; /* blocks */ 878 uint64_t dds_lsize; /* logical size */ 879 uint64_t dds_psize; /* physical size */ 880 uint64_t dds_dsize; /* deflated allocated size */ 881 uint64_t dds_ref_blocks; /* referenced blocks */ 882 uint64_t dds_ref_lsize; /* referenced lsize * refcnt */ 883 uint64_t dds_ref_psize; /* referenced psize * refcnt */ 884 uint64_t dds_ref_dsize; /* referenced dsize * refcnt */ 885 } ddt_stat_t; 886 887 typedef struct ddt_histogram { 888 ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */ 889 } ddt_histogram_t; 890 891 #define ZVOL_DRIVER "zvol" 892 #define ZFS_DRIVER "zfs" 893 #define ZFS_DEV "/dev/zfs" 894 #define ZFS_DISK_ROOT "/dev/dsk" 895 #define ZFS_DISK_ROOTD ZFS_DISK_ROOT "/" 896 #define ZFS_RDISK_ROOT "/dev/rdsk" 897 #define ZFS_RDISK_ROOTD ZFS_RDISK_ROOT "/" 898 899 /* general zvol path */ 900 #define ZVOL_DIR "/dev/zvol" 901 /* expansion */ 902 #define ZVOL_PSEUDO_DEV "/devices/pseudo/zfs@0:" 903 /* for dump and swap */ 904 #define ZVOL_FULL_DEV_DIR ZVOL_DIR "/dsk/" 905 #define ZVOL_FULL_RDEV_DIR ZVOL_DIR "/rdsk/" 906 907 #define ZVOL_PROP_NAME "name" 908 #define ZVOL_DEFAULT_BLOCKSIZE 8192 909 910 /* 911 * /dev/zfs ioctl numbers. 912 */ 913 typedef enum zfs_ioc { 914 ZFS_IOC_FIRST = ('Z' << 8), 915 ZFS_IOC = ZFS_IOC_FIRST, 916 ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST, 917 ZFS_IOC_POOL_DESTROY, 918 ZFS_IOC_POOL_IMPORT, 919 ZFS_IOC_POOL_EXPORT, 920 ZFS_IOC_POOL_CONFIGS, 921 ZFS_IOC_POOL_STATS, 922 ZFS_IOC_POOL_TRYIMPORT, 923 ZFS_IOC_POOL_SCAN, 924 ZFS_IOC_POOL_FREEZE, 925 ZFS_IOC_POOL_UPGRADE, 926 ZFS_IOC_POOL_GET_HISTORY, 927 ZFS_IOC_VDEV_ADD, 928 ZFS_IOC_VDEV_REMOVE, 929 ZFS_IOC_VDEV_SET_STATE, 930 ZFS_IOC_VDEV_ATTACH, 931 ZFS_IOC_VDEV_DETACH, 932 ZFS_IOC_VDEV_SETPATH, 933 ZFS_IOC_VDEV_SETFRU, 934 ZFS_IOC_OBJSET_STATS, 935 ZFS_IOC_OBJSET_ZPLPROPS, 936 ZFS_IOC_DATASET_LIST_NEXT, 937 ZFS_IOC_SNAPSHOT_LIST_NEXT, 938 ZFS_IOC_SET_PROP, 939 ZFS_IOC_CREATE, 940 ZFS_IOC_DESTROY, 941 ZFS_IOC_ROLLBACK, 942 ZFS_IOC_RENAME, 943 ZFS_IOC_RECV, 944 ZFS_IOC_SEND, 945 ZFS_IOC_INJECT_FAULT, 946 ZFS_IOC_CLEAR_FAULT, 947 ZFS_IOC_INJECT_LIST_NEXT, 948 ZFS_IOC_ERROR_LOG, 949 ZFS_IOC_CLEAR, 950 ZFS_IOC_PROMOTE, 951 ZFS_IOC_SNAPSHOT, 952 ZFS_IOC_DSOBJ_TO_DSNAME, 953 ZFS_IOC_OBJ_TO_PATH, 954 ZFS_IOC_POOL_SET_PROPS, 955 ZFS_IOC_POOL_GET_PROPS, 956 ZFS_IOC_SET_FSACL, 957 ZFS_IOC_GET_FSACL, 958 ZFS_IOC_SHARE, 959 ZFS_IOC_INHERIT_PROP, 960 ZFS_IOC_SMB_ACL, 961 ZFS_IOC_USERSPACE_ONE, 962 ZFS_IOC_USERSPACE_MANY, 963 ZFS_IOC_USERSPACE_UPGRADE, 964 ZFS_IOC_HOLD, 965 ZFS_IOC_RELEASE, 966 ZFS_IOC_GET_HOLDS, 967 ZFS_IOC_OBJSET_RECVD_PROPS, 968 ZFS_IOC_VDEV_SPLIT, 969 ZFS_IOC_NEXT_OBJ, 970 ZFS_IOC_DIFF, 971 ZFS_IOC_TMP_SNAPSHOT, 972 ZFS_IOC_OBJ_TO_STATS, 973 ZFS_IOC_SPACE_WRITTEN, 974 ZFS_IOC_SPACE_SNAPS, 975 ZFS_IOC_DESTROY_SNAPS, 976 ZFS_IOC_POOL_REGUID, 977 ZFS_IOC_POOL_REOPEN, 978 ZFS_IOC_SEND_PROGRESS, 979 ZFS_IOC_LOG_HISTORY, 980 ZFS_IOC_SEND_NEW, 981 ZFS_IOC_SEND_SPACE, 982 ZFS_IOC_CLONE, 983 ZFS_IOC_BOOKMARK, 984 ZFS_IOC_GET_BOOKMARKS, 985 ZFS_IOC_DESTROY_BOOKMARKS, 986 ZFS_IOC_CHANNEL_PROGRAM, 987 ZFS_IOC_REMAP, 988 ZFS_IOC_POOL_CHECKPOINT, 989 ZFS_IOC_POOL_DISCARD_CHECKPOINT, 990 ZFS_IOC_POOL_INITIALIZE, 991 ZFS_IOC_POOL_SYNC, 992 ZFS_IOC_LAST 993 } zfs_ioc_t; 994 995 /* 996 * ZFS-specific error codes used for returning descriptive errors 997 * to the userland through zfs ioctls. 998 * 999 * The enum implicitly includes all the error codes from errno.h. 1000 * New code should use and extend this enum for errors that are 1001 * not described precisely by generic errno codes. 1002 */ 1003 typedef enum { 1004 ZFS_ERR_CHECKPOINT_EXISTS = 1024, 1005 ZFS_ERR_DISCARDING_CHECKPOINT, 1006 ZFS_ERR_NO_CHECKPOINT, 1007 ZFS_ERR_DEVRM_IN_PROGRESS, 1008 ZFS_ERR_VDEV_TOO_BIG 1009 } zfs_errno_t; 1010 1011 /* 1012 * Internal SPA load state. Used by FMA diagnosis engine. 1013 */ 1014 typedef enum { 1015 SPA_LOAD_NONE, /* no load in progress */ 1016 SPA_LOAD_OPEN, /* normal open */ 1017 SPA_LOAD_IMPORT, /* import in progress */ 1018 SPA_LOAD_TRYIMPORT, /* tryimport in progress */ 1019 SPA_LOAD_RECOVER, /* recovery requested */ 1020 SPA_LOAD_ERROR, /* load failed */ 1021 SPA_LOAD_CREATE /* creation in progress */ 1022 } spa_load_state_t; 1023 1024 /* 1025 * Bookmark name values. 1026 */ 1027 #define ZPOOL_ERR_LIST "error list" 1028 #define ZPOOL_ERR_DATASET "dataset" 1029 #define ZPOOL_ERR_OBJECT "object" 1030 1031 #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) 1032 1033 /* 1034 * The following are names used in the nvlist describing 1035 * the pool's history log. 1036 */ 1037 #define ZPOOL_HIST_RECORD "history record" 1038 #define ZPOOL_HIST_TIME "history time" 1039 #define ZPOOL_HIST_CMD "history command" 1040 #define ZPOOL_HIST_WHO "history who" 1041 #define ZPOOL_HIST_ZONE "history zone" 1042 #define ZPOOL_HIST_HOST "history hostname" 1043 #define ZPOOL_HIST_TXG "history txg" 1044 #define ZPOOL_HIST_INT_EVENT "history internal event" 1045 #define ZPOOL_HIST_INT_STR "history internal str" 1046 #define ZPOOL_HIST_INT_NAME "internal_name" 1047 #define ZPOOL_HIST_IOCTL "ioctl" 1048 #define ZPOOL_HIST_INPUT_NVL "in_nvl" 1049 #define ZPOOL_HIST_OUTPUT_NVL "out_nvl" 1050 #define ZPOOL_HIST_DSNAME "dsname" 1051 #define ZPOOL_HIST_DSID "dsid" 1052 #define ZPOOL_HIST_ERRNO "errno" 1053 1054 /* 1055 * The following are names used when invoking ZFS_IOC_POOL_INITIALIZE. 1056 */ 1057 #define ZPOOL_INITIALIZE_COMMAND "initialize_command" 1058 #define ZPOOL_INITIALIZE_VDEVS "initialize_vdevs" 1059 1060 /* 1061 * Flags for ZFS_IOC_VDEV_SET_STATE 1062 */ 1063 #define ZFS_ONLINE_CHECKREMOVE 0x1 1064 #define ZFS_ONLINE_UNSPARE 0x2 1065 #define ZFS_ONLINE_FORCEFAULT 0x4 1066 #define ZFS_ONLINE_EXPAND 0x8 1067 #define ZFS_OFFLINE_TEMPORARY 0x1 1068 1069 /* 1070 * Flags for ZFS_IOC_POOL_IMPORT 1071 */ 1072 #define ZFS_IMPORT_NORMAL 0x0 1073 #define ZFS_IMPORT_VERBATIM 0x1 1074 #define ZFS_IMPORT_ANY_HOST 0x2 1075 #define ZFS_IMPORT_MISSING_LOG 0x4 1076 #define ZFS_IMPORT_ONLY 0x8 1077 #define ZFS_IMPORT_CHECKPOINT 0x10 1078 #define ZFS_IMPORT_TEMP_NAME 0x20 1079 1080 /* 1081 * Channel program argument/return nvlist keys and defaults. 1082 */ 1083 #define ZCP_ARG_PROGRAM "program" 1084 #define ZCP_ARG_ARGLIST "arg" 1085 #define ZCP_ARG_SYNC "sync" 1086 #define ZCP_ARG_INSTRLIMIT "instrlimit" 1087 #define ZCP_ARG_MEMLIMIT "memlimit" 1088 1089 #define ZCP_ARG_CLIARGV "argv" 1090 1091 #define ZCP_RET_ERROR "error" 1092 #define ZCP_RET_RETURN "return" 1093 1094 #define ZCP_DEFAULT_INSTRLIMIT (10 * 1000 * 1000) 1095 #define ZCP_MAX_INSTRLIMIT (10 * ZCP_DEFAULT_INSTRLIMIT) 1096 #define ZCP_DEFAULT_MEMLIMIT (10 * 1024 * 1024) 1097 #define ZCP_MAX_MEMLIMIT (10 * ZCP_DEFAULT_MEMLIMIT) 1098 1099 /* 1100 * Sysevent payload members. ZFS will generate the following sysevents with the 1101 * given payloads: 1102 * 1103 * ESC_ZFS_RESILVER_START 1104 * ESC_ZFS_RESILVER_END 1105 * ESC_ZFS_POOL_DESTROY 1106 * ESC_ZFS_POOL_REGUID 1107 * 1108 * ZFS_EV_POOL_NAME DATA_TYPE_STRING 1109 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 1110 * 1111 * ESC_ZFS_VDEV_REMOVE 1112 * ESC_ZFS_VDEV_CLEAR 1113 * ESC_ZFS_VDEV_CHECK 1114 * 1115 * ZFS_EV_POOL_NAME DATA_TYPE_STRING 1116 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 1117 * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) 1118 * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 1119 * 1120 * ESC_ZFS_HISTORY_EVENT 1121 * 1122 * ZFS_EV_POOL_NAME DATA_TYPE_STRING 1123 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 1124 * ZFS_EV_HIST_TIME DATA_TYPE_UINT64 (optional) 1125 * ZFS_EV_HIST_CMD DATA_TYPE_STRING (optional) 1126 * ZFS_EV_HIST_WHO DATA_TYPE_UINT64 (optional) 1127 * ZFS_EV_HIST_ZONE DATA_TYPE_STRING (optional) 1128 * ZFS_EV_HIST_HOST DATA_TYPE_STRING (optional) 1129 * ZFS_EV_HIST_TXG DATA_TYPE_UINT64 (optional) 1130 * ZFS_EV_HIST_INT_EVENT DATA_TYPE_UINT64 (optional) 1131 * ZFS_EV_HIST_INT_STR DATA_TYPE_STRING (optional) 1132 * ZFS_EV_HIST_INT_NAME DATA_TYPE_STRING (optional) 1133 * ZFS_EV_HIST_IOCTL DATA_TYPE_STRING (optional) 1134 * ZFS_EV_HIST_DSNAME DATA_TYPE_STRING (optional) 1135 * ZFS_EV_HIST_DSID DATA_TYPE_UINT64 (optional) 1136 * 1137 * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the 1138 * history log nvlist. The keynames will be free of any spaces or other 1139 * characters that could be potentially unexpected to consumers of the 1140 * sysevents. 1141 */ 1142 #define ZFS_EV_POOL_NAME "pool_name" 1143 #define ZFS_EV_POOL_GUID "pool_guid" 1144 #define ZFS_EV_VDEV_PATH "vdev_path" 1145 #define ZFS_EV_VDEV_GUID "vdev_guid" 1146 #define ZFS_EV_HIST_TIME "history_time" 1147 #define ZFS_EV_HIST_CMD "history_command" 1148 #define ZFS_EV_HIST_WHO "history_who" 1149 #define ZFS_EV_HIST_ZONE "history_zone" 1150 #define ZFS_EV_HIST_HOST "history_hostname" 1151 #define ZFS_EV_HIST_TXG "history_txg" 1152 #define ZFS_EV_HIST_INT_EVENT "history_internal_event" 1153 #define ZFS_EV_HIST_INT_STR "history_internal_str" 1154 #define ZFS_EV_HIST_INT_NAME "history_internal_name" 1155 #define ZFS_EV_HIST_IOCTL "history_ioctl" 1156 #define ZFS_EV_HIST_DSNAME "history_dsname" 1157 #define ZFS_EV_HIST_DSID "history_dsid" 1158 1159 #ifdef __cplusplus 1160 } 1161 #endif 1162 1163 #endif /* _SYS_FS_ZFS_H */ 1164