zfs.h revision 236839
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) 2012 by Delphix. All rights reserved. 25 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 26 * Copyright (c) 2012, Joyent, Inc. All rights reserved. 27 * Copyright (c) 2012, Martin Matuska <mm@FreeBSD.org>. All rights reserved. 28 */ 29 30/* Portions Copyright 2010 Robert Milkowski */ 31 32#ifndef _SYS_FS_ZFS_H 33#define _SYS_FS_ZFS_H 34 35#include <sys/types.h> 36#include <sys/ioccom.h> 37#include <sys/time.h> 38 39#ifdef __cplusplus 40extern "C" { 41#endif 42 43/* 44 * Types and constants shared between userland and the kernel. 45 */ 46 47/* 48 * Each dataset can be one of the following types. These constants can be 49 * combined into masks that can be passed to various functions. 50 */ 51typedef enum { 52 ZFS_TYPE_FILESYSTEM = 0x1, 53 ZFS_TYPE_SNAPSHOT = 0x2, 54 ZFS_TYPE_VOLUME = 0x4, 55 ZFS_TYPE_POOL = 0x8 56} zfs_type_t; 57 58#define ZFS_TYPE_DATASET \ 59 (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) 60 61#define ZAP_MAXNAMELEN 256 62#define ZAP_MAXVALUELEN (1024 * 8) 63#define ZAP_OLDMAXVALUELEN 1024 64 65/* 66 * Dataset properties are identified by these constants and must be added to 67 * the end of this list to ensure that external consumers are not affected 68 * by the change. If you make any changes to this list, be sure to update 69 * the property table in usr/src/common/zfs/zfs_prop.c. 70 */ 71typedef enum { 72 ZFS_PROP_TYPE, 73 ZFS_PROP_CREATION, 74 ZFS_PROP_USED, 75 ZFS_PROP_AVAILABLE, 76 ZFS_PROP_REFERENCED, 77 ZFS_PROP_COMPRESSRATIO, 78 ZFS_PROP_MOUNTED, 79 ZFS_PROP_ORIGIN, 80 ZFS_PROP_QUOTA, 81 ZFS_PROP_RESERVATION, 82 ZFS_PROP_VOLSIZE, 83 ZFS_PROP_VOLBLOCKSIZE, 84 ZFS_PROP_RECORDSIZE, 85 ZFS_PROP_MOUNTPOINT, 86 ZFS_PROP_SHARENFS, 87 ZFS_PROP_CHECKSUM, 88 ZFS_PROP_COMPRESSION, 89 ZFS_PROP_ATIME, 90 ZFS_PROP_DEVICES, 91 ZFS_PROP_EXEC, 92 ZFS_PROP_SETUID, 93 ZFS_PROP_READONLY, 94 ZFS_PROP_ZONED, 95 ZFS_PROP_SNAPDIR, 96 ZFS_PROP_ACLMODE, 97 ZFS_PROP_ACLINHERIT, 98 ZFS_PROP_CREATETXG, /* not exposed to the user */ 99 ZFS_PROP_NAME, /* not exposed to the user */ 100 ZFS_PROP_CANMOUNT, 101 ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */ 102 ZFS_PROP_XATTR, 103 ZFS_PROP_NUMCLONES, /* not exposed to the user */ 104 ZFS_PROP_COPIES, 105 ZFS_PROP_VERSION, 106 ZFS_PROP_UTF8ONLY, 107 ZFS_PROP_NORMALIZE, 108 ZFS_PROP_CASE, 109 ZFS_PROP_VSCAN, 110 ZFS_PROP_NBMAND, 111 ZFS_PROP_SHARESMB, 112 ZFS_PROP_REFQUOTA, 113 ZFS_PROP_REFRESERVATION, 114 ZFS_PROP_GUID, 115 ZFS_PROP_PRIMARYCACHE, 116 ZFS_PROP_SECONDARYCACHE, 117 ZFS_PROP_USEDSNAP, 118 ZFS_PROP_USEDDS, 119 ZFS_PROP_USEDCHILD, 120 ZFS_PROP_USEDREFRESERV, 121 ZFS_PROP_USERACCOUNTING, /* not exposed to the user */ 122 ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */ 123 ZFS_PROP_DEFER_DESTROY, 124 ZFS_PROP_USERREFS, 125 ZFS_PROP_LOGBIAS, 126 ZFS_PROP_UNIQUE, /* not exposed to the user */ 127 ZFS_PROP_OBJSETID, /* not exposed to the user */ 128 ZFS_PROP_DEDUP, 129 ZFS_PROP_MLSLABEL, 130 ZFS_PROP_SYNC, 131 ZFS_PROP_REFRATIO, 132 ZFS_PROP_WRITTEN, 133 ZFS_PROP_CLONES, 134 ZFS_NUM_PROPS 135} zfs_prop_t; 136 137typedef enum { 138 ZFS_PROP_USERUSED, 139 ZFS_PROP_USERQUOTA, 140 ZFS_PROP_GROUPUSED, 141 ZFS_PROP_GROUPQUOTA, 142 ZFS_NUM_USERQUOTA_PROPS 143} zfs_userquota_prop_t; 144 145extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS]; 146 147/* 148 * Pool properties are identified by these constants and must be added to the 149 * end of this list to ensure that external consumers are not affected 150 * by the change. If you make any changes to this list, be sure to update 151 * the property table in usr/src/common/zfs/zpool_prop.c. 152 */ 153typedef enum { 154 ZPOOL_PROP_NAME, 155 ZPOOL_PROP_SIZE, 156 ZPOOL_PROP_CAPACITY, 157 ZPOOL_PROP_ALTROOT, 158 ZPOOL_PROP_HEALTH, 159 ZPOOL_PROP_GUID, 160 ZPOOL_PROP_VERSION, 161 ZPOOL_PROP_BOOTFS, 162 ZPOOL_PROP_DELEGATION, 163 ZPOOL_PROP_AUTOREPLACE, 164 ZPOOL_PROP_CACHEFILE, 165 ZPOOL_PROP_FAILUREMODE, 166 ZPOOL_PROP_LISTSNAPS, 167 ZPOOL_PROP_AUTOEXPAND, 168 ZPOOL_PROP_DEDUPDITTO, 169 ZPOOL_PROP_DEDUPRATIO, 170 ZPOOL_PROP_FREE, 171 ZPOOL_PROP_ALLOCATED, 172 ZPOOL_PROP_READONLY, 173 ZPOOL_PROP_COMMENT, 174 ZPOOL_PROP_EXPANDSZ, 175 ZPOOL_NUM_PROPS 176} zpool_prop_t; 177 178/* Small enough to not hog a whole line of printout in zpool(1M). */ 179#define ZPROP_MAX_COMMENT 32 180 181#define ZPROP_CONT -2 182#define ZPROP_INVAL -1 183 184#define ZPROP_VALUE "value" 185#define ZPROP_SOURCE "source" 186 187typedef enum { 188 ZPROP_SRC_NONE = 0x1, 189 ZPROP_SRC_DEFAULT = 0x2, 190 ZPROP_SRC_TEMPORARY = 0x4, 191 ZPROP_SRC_LOCAL = 0x8, 192 ZPROP_SRC_INHERITED = 0x10, 193 ZPROP_SRC_RECEIVED = 0x20 194} zprop_source_t; 195 196#define ZPROP_SRC_ALL 0x3f 197 198#define ZPROP_SOURCE_VAL_RECVD "$recvd" 199#define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS" 200/* 201 * Dataset flag implemented as a special entry in the props zap object 202 * indicating that the dataset has received properties on or after 203 * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties 204 * just as it did in earlier versions, and thereafter, local properties are 205 * preserved. 206 */ 207#define ZPROP_HAS_RECVD "$hasrecvd" 208 209typedef enum { 210 ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */ 211 ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */ 212} zprop_errflags_t; 213 214typedef int (*zprop_func)(int, void *); 215 216/* 217 * Properties to be set on the root file system of a new pool 218 * are stuffed into their own nvlist, which is then included in 219 * the properties nvlist with the pool properties. 220 */ 221#define ZPOOL_ROOTFS_PROPS "root-props-nvl" 222 223/* 224 * Dataset property functions shared between libzfs and kernel. 225 */ 226const char *zfs_prop_default_string(zfs_prop_t); 227uint64_t zfs_prop_default_numeric(zfs_prop_t); 228boolean_t zfs_prop_readonly(zfs_prop_t); 229boolean_t zfs_prop_inheritable(zfs_prop_t); 230boolean_t zfs_prop_setonce(zfs_prop_t); 231const char *zfs_prop_to_name(zfs_prop_t); 232zfs_prop_t zfs_name_to_prop(const char *); 233boolean_t zfs_prop_user(const char *); 234boolean_t zfs_prop_userquota(const char *); 235int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); 236int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *); 237uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed); 238boolean_t zfs_prop_valid_for_type(int, zfs_type_t); 239 240/* 241 * Pool property functions shared between libzfs and kernel. 242 */ 243zpool_prop_t zpool_name_to_prop(const char *); 244const char *zpool_prop_to_name(zpool_prop_t); 245const char *zpool_prop_default_string(zpool_prop_t); 246uint64_t zpool_prop_default_numeric(zpool_prop_t); 247boolean_t zpool_prop_readonly(zpool_prop_t); 248int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **); 249int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *); 250uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed); 251 252/* 253 * Definitions for the Delegation. 254 */ 255typedef enum { 256 ZFS_DELEG_WHO_UNKNOWN = 0, 257 ZFS_DELEG_USER = 'u', 258 ZFS_DELEG_USER_SETS = 'U', 259 ZFS_DELEG_GROUP = 'g', 260 ZFS_DELEG_GROUP_SETS = 'G', 261 ZFS_DELEG_EVERYONE = 'e', 262 ZFS_DELEG_EVERYONE_SETS = 'E', 263 ZFS_DELEG_CREATE = 'c', 264 ZFS_DELEG_CREATE_SETS = 'C', 265 ZFS_DELEG_NAMED_SET = 's', 266 ZFS_DELEG_NAMED_SET_SETS = 'S' 267} zfs_deleg_who_type_t; 268 269typedef enum { 270 ZFS_DELEG_NONE = 0, 271 ZFS_DELEG_PERM_LOCAL = 1, 272 ZFS_DELEG_PERM_DESCENDENT = 2, 273 ZFS_DELEG_PERM_LOCALDESCENDENT = 3, 274 ZFS_DELEG_PERM_CREATE = 4 275} zfs_deleg_inherit_t; 276 277#define ZFS_DELEG_PERM_UID "uid" 278#define ZFS_DELEG_PERM_GID "gid" 279#define ZFS_DELEG_PERM_GROUPS "groups" 280 281#define ZFS_MLSLABEL_DEFAULT "none" 282 283#define ZFS_SMB_ACL_SRC "src" 284#define ZFS_SMB_ACL_TARGET "target" 285 286typedef enum { 287 ZFS_CANMOUNT_OFF = 0, 288 ZFS_CANMOUNT_ON = 1, 289 ZFS_CANMOUNT_NOAUTO = 2 290} zfs_canmount_type_t; 291 292typedef enum { 293 ZFS_LOGBIAS_LATENCY = 0, 294 ZFS_LOGBIAS_THROUGHPUT = 1 295} zfs_logbias_op_t; 296 297typedef enum zfs_share_op { 298 ZFS_SHARE_NFS = 0, 299 ZFS_UNSHARE_NFS = 1, 300 ZFS_SHARE_SMB = 2, 301 ZFS_UNSHARE_SMB = 3 302} zfs_share_op_t; 303 304typedef enum zfs_smb_acl_op { 305 ZFS_SMB_ACL_ADD, 306 ZFS_SMB_ACL_REMOVE, 307 ZFS_SMB_ACL_RENAME, 308 ZFS_SMB_ACL_PURGE 309} zfs_smb_acl_op_t; 310 311typedef enum zfs_cache_type { 312 ZFS_CACHE_NONE = 0, 313 ZFS_CACHE_METADATA = 1, 314 ZFS_CACHE_ALL = 2 315} zfs_cache_type_t; 316 317typedef enum { 318 ZFS_SYNC_STANDARD = 0, 319 ZFS_SYNC_ALWAYS = 1, 320 ZFS_SYNC_DISABLED = 2 321} zfs_sync_type_t; 322 323 324/* 325 * On-disk version number. 326 */ 327#define SPA_VERSION_1 1ULL 328#define SPA_VERSION_2 2ULL 329#define SPA_VERSION_3 3ULL 330#define SPA_VERSION_4 4ULL 331#define SPA_VERSION_5 5ULL 332#define SPA_VERSION_6 6ULL 333#define SPA_VERSION_7 7ULL 334#define SPA_VERSION_8 8ULL 335#define SPA_VERSION_9 9ULL 336#define SPA_VERSION_10 10ULL 337#define SPA_VERSION_11 11ULL 338#define SPA_VERSION_12 12ULL 339#define SPA_VERSION_13 13ULL 340#define SPA_VERSION_14 14ULL 341#define SPA_VERSION_15 15ULL 342#define SPA_VERSION_16 16ULL 343#define SPA_VERSION_17 17ULL 344#define SPA_VERSION_18 18ULL 345#define SPA_VERSION_19 19ULL 346#define SPA_VERSION_20 20ULL 347#define SPA_VERSION_21 21ULL 348#define SPA_VERSION_22 22ULL 349#define SPA_VERSION_23 23ULL 350#define SPA_VERSION_24 24ULL 351#define SPA_VERSION_25 25ULL 352#define SPA_VERSION_26 26ULL 353#define SPA_VERSION_27 27ULL 354#define SPA_VERSION_28 28ULL 355 356/* 357 * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk 358 * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*}, 359 * and do the appropriate changes. Also bump the version number in 360 * usr/src/grub/capability. 361 */ 362#define SPA_VERSION SPA_VERSION_28 363#define SPA_VERSION_STRING "28" 364 365/* 366 * Symbolic names for the changes that caused a SPA_VERSION switch. 367 * Used in the code when checking for presence or absence of a feature. 368 * Feel free to define multiple symbolic names for each version if there 369 * were multiple changes to on-disk structures during that version. 370 * 371 * NOTE: When checking the current SPA_VERSION in your code, be sure 372 * to use spa_version() since it reports the version of the 373 * last synced uberblock. Checking the in-flight version can 374 * be dangerous in some cases. 375 */ 376#define SPA_VERSION_INITIAL SPA_VERSION_1 377#define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 378#define SPA_VERSION_SPARES SPA_VERSION_3 379#define SPA_VERSION_RAIDZ2 SPA_VERSION_3 380#define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3 381#define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 382#define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 383#define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 384#define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 385#define SPA_VERSION_BOOTFS SPA_VERSION_6 386#define SPA_VERSION_SLOGS SPA_VERSION_7 387#define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8 388#define SPA_VERSION_FUID SPA_VERSION_9 389#define SPA_VERSION_REFRESERVATION SPA_VERSION_9 390#define SPA_VERSION_REFQUOTA SPA_VERSION_9 391#define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9 392#define SPA_VERSION_L2CACHE SPA_VERSION_10 393#define SPA_VERSION_NEXT_CLONES SPA_VERSION_11 394#define SPA_VERSION_ORIGIN SPA_VERSION_11 395#define SPA_VERSION_DSL_SCRUB SPA_VERSION_11 396#define SPA_VERSION_SNAP_PROPS SPA_VERSION_12 397#define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13 398#define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14 399#define SPA_VERSION_USERSPACE SPA_VERSION_15 400#define SPA_VERSION_STMF_PROP SPA_VERSION_16 401#define SPA_VERSION_RAIDZ3 SPA_VERSION_17 402#define SPA_VERSION_USERREFS SPA_VERSION_18 403#define SPA_VERSION_HOLES SPA_VERSION_19 404#define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20 405#define SPA_VERSION_DEDUP SPA_VERSION_21 406#define SPA_VERSION_RECVD_PROPS SPA_VERSION_22 407#define SPA_VERSION_SLIM_ZIL SPA_VERSION_23 408#define SPA_VERSION_SA SPA_VERSION_24 409#define SPA_VERSION_SCAN SPA_VERSION_25 410#define SPA_VERSION_DIR_CLONES SPA_VERSION_26 411#define SPA_VERSION_DEADLISTS SPA_VERSION_26 412#define SPA_VERSION_FAST_SNAP SPA_VERSION_27 413#define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28 414 415/* 416 * ZPL version - rev'd whenever an incompatible on-disk format change 417 * occurs. This is independent of SPA/DMU/ZAP versioning. You must 418 * also update the version_table[] and help message in zfs_prop.c. 419 * 420 * When changing, be sure to teach GRUB how to read the new format! 421 * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*} 422 */ 423#define ZPL_VERSION_1 1ULL 424#define ZPL_VERSION_2 2ULL 425#define ZPL_VERSION_3 3ULL 426#define ZPL_VERSION_4 4ULL 427#define ZPL_VERSION_5 5ULL 428#define ZPL_VERSION ZPL_VERSION_5 429#define ZPL_VERSION_STRING "5" 430 431#define ZPL_VERSION_INITIAL ZPL_VERSION_1 432#define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 433#define ZPL_VERSION_FUID ZPL_VERSION_3 434#define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3 435#define ZPL_VERSION_SYSATTR ZPL_VERSION_3 436#define ZPL_VERSION_USERSPACE ZPL_VERSION_4 437#define ZPL_VERSION_SA ZPL_VERSION_5 438 439/* Rewind request information */ 440#define ZPOOL_NO_REWIND 1 /* No policy - default behavior */ 441#define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */ 442#define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */ 443#define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */ 444#define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */ 445#define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */ 446#define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */ 447 448typedef struct zpool_rewind_policy { 449 uint32_t zrp_request; /* rewind behavior requested */ 450 uint64_t zrp_maxmeta; /* max acceptable meta-data errors */ 451 uint64_t zrp_maxdata; /* max acceptable data errors */ 452 uint64_t zrp_txg; /* specific txg to load */ 453} zpool_rewind_policy_t; 454 455/* 456 * The following are configuration names used in the nvlist describing a pool's 457 * configuration. 458 */ 459#define ZPOOL_CONFIG_VERSION "version" 460#define ZPOOL_CONFIG_POOL_NAME "name" 461#define ZPOOL_CONFIG_POOL_STATE "state" 462#define ZPOOL_CONFIG_POOL_TXG "txg" 463#define ZPOOL_CONFIG_POOL_GUID "pool_guid" 464#define ZPOOL_CONFIG_CREATE_TXG "create_txg" 465#define ZPOOL_CONFIG_TOP_GUID "top_guid" 466#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" 467#define ZPOOL_CONFIG_TYPE "type" 468#define ZPOOL_CONFIG_CHILDREN "children" 469#define ZPOOL_CONFIG_ID "id" 470#define ZPOOL_CONFIG_GUID "guid" 471#define ZPOOL_CONFIG_PATH "path" 472#define ZPOOL_CONFIG_DEVID "devid" 473#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" 474#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" 475#define ZPOOL_CONFIG_ASHIFT "ashift" 476#define ZPOOL_CONFIG_ASIZE "asize" 477#define ZPOOL_CONFIG_DTL "DTL" 478#define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */ 479#define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */ 480#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" 481#define ZPOOL_CONFIG_ERRCOUNT "error_count" 482#define ZPOOL_CONFIG_NOT_PRESENT "not_present" 483#define ZPOOL_CONFIG_SPARES "spares" 484#define ZPOOL_CONFIG_IS_SPARE "is_spare" 485#define ZPOOL_CONFIG_NPARITY "nparity" 486#define ZPOOL_CONFIG_HOSTID "hostid" 487#define ZPOOL_CONFIG_HOSTNAME "hostname" 488#define ZPOOL_CONFIG_LOADED_TIME "initial_load_time" 489#define ZPOOL_CONFIG_UNSPARE "unspare" 490#define ZPOOL_CONFIG_PHYS_PATH "phys_path" 491#define ZPOOL_CONFIG_IS_LOG "is_log" 492#define ZPOOL_CONFIG_L2CACHE "l2cache" 493#define ZPOOL_CONFIG_HOLE_ARRAY "hole_array" 494#define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children" 495#define ZPOOL_CONFIG_IS_HOLE "is_hole" 496#define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram" 497#define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats" 498#define ZPOOL_CONFIG_DDT_STATS "ddt_stats" 499#define ZPOOL_CONFIG_SPLIT "splitcfg" 500#define ZPOOL_CONFIG_ORIG_GUID "orig_guid" 501#define ZPOOL_CONFIG_SPLIT_GUID "split_guid" 502#define ZPOOL_CONFIG_SPLIT_LIST "guid_list" 503#define ZPOOL_CONFIG_REMOVING "removing" 504#define ZPOOL_CONFIG_RESILVERING "resilvering" 505#define ZPOOL_CONFIG_COMMENT "comment" 506#define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */ 507#define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ 508#define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */ 509#define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */ 510#define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */ 511/* 512 * The persistent vdev state is stored as separate values rather than a single 513 * 'vdev_state' entry. This is because a device can be in multiple states, such 514 * as offline and degraded. 515 */ 516#define ZPOOL_CONFIG_OFFLINE "offline" 517#define ZPOOL_CONFIG_FAULTED "faulted" 518#define ZPOOL_CONFIG_DEGRADED "degraded" 519#define ZPOOL_CONFIG_REMOVED "removed" 520#define ZPOOL_CONFIG_FRU "fru" 521#define ZPOOL_CONFIG_AUX_STATE "aux_state" 522 523/* Rewind policy parameters */ 524#define ZPOOL_REWIND_POLICY "rewind-policy" 525#define ZPOOL_REWIND_REQUEST "rewind-request" 526#define ZPOOL_REWIND_REQUEST_TXG "rewind-request-txg" 527#define ZPOOL_REWIND_META_THRESH "rewind-meta-thresh" 528#define ZPOOL_REWIND_DATA_THRESH "rewind-data-thresh" 529 530/* Rewind data discovered */ 531#define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts" 532#define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors" 533#define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind" 534 535#define VDEV_TYPE_ROOT "root" 536#define VDEV_TYPE_MIRROR "mirror" 537#define VDEV_TYPE_REPLACING "replacing" 538#define VDEV_TYPE_RAIDZ "raidz" 539#define VDEV_TYPE_DISK "disk" 540#define VDEV_TYPE_FILE "file" 541#define VDEV_TYPE_MISSING "missing" 542#define VDEV_TYPE_HOLE "hole" 543#define VDEV_TYPE_SPARE "spare" 544#define VDEV_TYPE_LOG "log" 545#define VDEV_TYPE_L2CACHE "l2cache" 546 547/* 548 * This is needed in userland to report the minimum necessary device size. 549 */ 550#define SPA_MINDEVSIZE (64ULL << 20) 551 552/* 553 * The location of the pool configuration repository, shared between kernel and 554 * userland. 555 */ 556#define ZPOOL_CACHE "/boot/zfs/zpool.cache" 557 558/* 559 * vdev states are ordered from least to most healthy. 560 * A vdev that's CANT_OPEN or below is considered unusable. 561 */ 562typedef enum vdev_state { 563 VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ 564 VDEV_STATE_CLOSED, /* Not currently open */ 565 VDEV_STATE_OFFLINE, /* Not allowed to open */ 566 VDEV_STATE_REMOVED, /* Explicitly removed from system */ 567 VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ 568 VDEV_STATE_FAULTED, /* External request to fault device */ 569 VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ 570 VDEV_STATE_HEALTHY /* Presumed good */ 571} vdev_state_t; 572 573#define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY 574 575/* 576 * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field 577 * of the vdev stats structure uses these constants to distinguish why. 578 */ 579typedef enum vdev_aux { 580 VDEV_AUX_NONE, /* no error */ 581 VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ 582 VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ 583 VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ 584 VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ 585 VDEV_AUX_TOO_SMALL, /* vdev size is too small */ 586 VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ 587 VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ 588 VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ 589 VDEV_AUX_SPARED, /* hot spare used in another pool */ 590 VDEV_AUX_ERR_EXCEEDED, /* too many errors */ 591 VDEV_AUX_IO_FAILURE, /* experienced I/O failure */ 592 VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */ 593 VDEV_AUX_EXTERNAL, /* external diagnosis */ 594 VDEV_AUX_SPLIT_POOL /* vdev was split off into another pool */ 595} vdev_aux_t; 596 597/* 598 * pool state. The following states are written to disk as part of the normal 599 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining 600 * states are software abstractions used at various levels to communicate 601 * pool state. 602 */ 603typedef enum pool_state { 604 POOL_STATE_ACTIVE = 0, /* In active use */ 605 POOL_STATE_EXPORTED, /* Explicitly exported */ 606 POOL_STATE_DESTROYED, /* Explicitly destroyed */ 607 POOL_STATE_SPARE, /* Reserved for hot spare use */ 608 POOL_STATE_L2CACHE, /* Level 2 ARC device */ 609 POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ 610 POOL_STATE_UNAVAIL, /* Internal libzfs state */ 611 POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ 612} pool_state_t; 613 614/* 615 * Scan Functions. 616 */ 617typedef enum pool_scan_func { 618 POOL_SCAN_NONE, 619 POOL_SCAN_SCRUB, 620 POOL_SCAN_RESILVER, 621 POOL_SCAN_FUNCS 622} pool_scan_func_t; 623 624/* 625 * ZIO types. Needed to interpret vdev statistics below. 626 */ 627typedef enum zio_type { 628 ZIO_TYPE_NULL = 0, 629 ZIO_TYPE_READ, 630 ZIO_TYPE_WRITE, 631 ZIO_TYPE_FREE, 632 ZIO_TYPE_CLAIM, 633 ZIO_TYPE_IOCTL, 634 ZIO_TYPES 635} zio_type_t; 636 637/* 638 * Pool statistics. Note: all fields should be 64-bit because this 639 * is passed between kernel and userland as an nvlist uint64 array. 640 */ 641typedef struct pool_scan_stat { 642 /* values stored on disk */ 643 uint64_t pss_func; /* pool_scan_func_t */ 644 uint64_t pss_state; /* dsl_scan_state_t */ 645 uint64_t pss_start_time; /* scan start time */ 646 uint64_t pss_end_time; /* scan end time */ 647 uint64_t pss_to_examine; /* total bytes to scan */ 648 uint64_t pss_examined; /* total examined bytes */ 649 uint64_t pss_to_process; /* total bytes to process */ 650 uint64_t pss_processed; /* total processed bytes */ 651 uint64_t pss_errors; /* scan errors */ 652 653 /* values not stored on disk */ 654 uint64_t pss_pass_exam; /* examined bytes per scan pass */ 655 uint64_t pss_pass_start; /* start time of a scan pass */ 656} pool_scan_stat_t; 657 658typedef enum dsl_scan_state { 659 DSS_NONE, 660 DSS_SCANNING, 661 DSS_FINISHED, 662 DSS_CANCELED, 663 DSS_NUM_STATES 664} dsl_scan_state_t; 665 666 667/* 668 * Vdev statistics. Note: all fields should be 64-bit because this 669 * is passed between kernel and userland as an nvlist uint64 array. 670 */ 671typedef struct vdev_stat { 672 hrtime_t vs_timestamp; /* time since vdev load */ 673 uint64_t vs_state; /* vdev state */ 674 uint64_t vs_aux; /* see vdev_aux_t */ 675 uint64_t vs_alloc; /* space allocated */ 676 uint64_t vs_space; /* total capacity */ 677 uint64_t vs_dspace; /* deflated capacity */ 678 uint64_t vs_rsize; /* replaceable dev size */ 679 uint64_t vs_esize; /* expandable dev size */ 680 uint64_t vs_ops[ZIO_TYPES]; /* operation count */ 681 uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */ 682 uint64_t vs_read_errors; /* read errors */ 683 uint64_t vs_write_errors; /* write errors */ 684 uint64_t vs_checksum_errors; /* checksum errors */ 685 uint64_t vs_self_healed; /* self-healed bytes */ 686 uint64_t vs_scan_removing; /* removing? */ 687 uint64_t vs_scan_processed; /* scan processed bytes */ 688} vdev_stat_t; 689 690/* 691 * DDT statistics. Note: all fields should be 64-bit because this 692 * is passed between kernel and userland as an nvlist uint64 array. 693 */ 694typedef struct ddt_object { 695 uint64_t ddo_count; /* number of elments in ddt */ 696 uint64_t ddo_dspace; /* size of ddt on disk */ 697 uint64_t ddo_mspace; /* size of ddt in-core */ 698} ddt_object_t; 699 700typedef struct ddt_stat { 701 uint64_t dds_blocks; /* blocks */ 702 uint64_t dds_lsize; /* logical size */ 703 uint64_t dds_psize; /* physical size */ 704 uint64_t dds_dsize; /* deflated allocated size */ 705 uint64_t dds_ref_blocks; /* referenced blocks */ 706 uint64_t dds_ref_lsize; /* referenced lsize * refcnt */ 707 uint64_t dds_ref_psize; /* referenced psize * refcnt */ 708 uint64_t dds_ref_dsize; /* referenced dsize * refcnt */ 709} ddt_stat_t; 710 711typedef struct ddt_histogram { 712 ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */ 713} ddt_histogram_t; 714 715#define ZVOL_DRIVER "zvol" 716#define ZFS_DRIVER "zfs" 717#define ZFS_DEV_NAME "zfs" 718#define ZFS_DEV "/dev/" ZFS_DEV_NAME 719 720/* general zvol path */ 721#define ZVOL_DIR "/dev/zvol" 722/* expansion */ 723#define ZVOL_PSEUDO_DEV "/devices/pseudo/zfs@0:" 724/* for dump and swap */ 725#define ZVOL_FULL_DEV_DIR ZVOL_DIR "/dsk/" 726#define ZVOL_FULL_RDEV_DIR ZVOL_DIR "/rdsk/" 727 728#define ZVOL_PROP_NAME "name" 729#define ZVOL_DEFAULT_BLOCKSIZE 8192 730 731/* 732 * /dev/zfs ioctl numbers. 733 */ 734typedef unsigned long zfs_ioc_t; 735 736#define ZFS_IOC(ioreq) ((ioreq) & 0xff) 737 738#define ZFS_IOC_POOL_CREATE _IOWR('Z', 0, struct zfs_cmd) 739#define ZFS_IOC_POOL_DESTROY _IOWR('Z', 1, struct zfs_cmd) 740#define ZFS_IOC_POOL_IMPORT _IOWR('Z', 2, struct zfs_cmd) 741#define ZFS_IOC_POOL_EXPORT _IOWR('Z', 3, struct zfs_cmd) 742#define ZFS_IOC_POOL_CONFIGS _IOWR('Z', 4, struct zfs_cmd) 743#define ZFS_IOC_POOL_STATS _IOWR('Z', 5, struct zfs_cmd) 744#define ZFS_IOC_POOL_TRYIMPORT _IOWR('Z', 6, struct zfs_cmd) 745#define ZFS_IOC_POOL_SCAN _IOWR('Z', 7, struct zfs_cmd) 746#define ZFS_IOC_POOL_FREEZE _IOWR('Z', 8, struct zfs_cmd) 747#define ZFS_IOC_POOL_UPGRADE _IOWR('Z', 9, struct zfs_cmd) 748#define ZFS_IOC_POOL_GET_HISTORY _IOWR('Z', 10, struct zfs_cmd) 749#define ZFS_IOC_VDEV_ADD _IOWR('Z', 11, struct zfs_cmd) 750#define ZFS_IOC_VDEV_REMOVE _IOWR('Z', 12, struct zfs_cmd) 751#define ZFS_IOC_VDEV_SET_STATE _IOWR('Z', 13, struct zfs_cmd) 752#define ZFS_IOC_VDEV_ATTACH _IOWR('Z', 14, struct zfs_cmd) 753#define ZFS_IOC_VDEV_DETACH _IOWR('Z', 15, struct zfs_cmd) 754#define ZFS_IOC_VDEV_SETPATH _IOWR('Z', 16, struct zfs_cmd) 755#define ZFS_IOC_VDEV_SETFRU _IOWR('Z', 17, struct zfs_cmd) 756#define ZFS_IOC_OBJSET_STATS _IOWR('Z', 18, struct zfs_cmd) 757#define ZFS_IOC_OBJSET_ZPLPROPS _IOWR('Z', 19, struct zfs_cmd) 758#define ZFS_IOC_DATASET_LIST_NEXT _IOWR('Z', 20, struct zfs_cmd) 759#define ZFS_IOC_SNAPSHOT_LIST_NEXT _IOWR('Z', 21, struct zfs_cmd) 760#define ZFS_IOC_SET_PROP _IOWR('Z', 22, struct zfs_cmd) 761#define ZFS_IOC_CREATE _IOWR('Z', 23, struct zfs_cmd) 762#define ZFS_IOC_DESTROY _IOWR('Z', 24, struct zfs_cmd) 763#define ZFS_IOC_ROLLBACK _IOWR('Z', 25, struct zfs_cmd) 764#define ZFS_IOC_RENAME _IOWR('Z', 26, struct zfs_cmd) 765#define ZFS_IOC_RECV _IOWR('Z', 27, struct zfs_cmd) 766#define ZFS_IOC_SEND _IOWR('Z', 28, struct zfs_cmd) 767#define ZFS_IOC_INJECT_FAULT _IOWR('Z', 29, struct zfs_cmd) 768#define ZFS_IOC_CLEAR_FAULT _IOWR('Z', 30, struct zfs_cmd) 769#define ZFS_IOC_INJECT_LIST_NEXT _IOWR('Z', 31, struct zfs_cmd) 770#define ZFS_IOC_ERROR_LOG _IOWR('Z', 32, struct zfs_cmd) 771#define ZFS_IOC_CLEAR _IOWR('Z', 33, struct zfs_cmd) 772#define ZFS_IOC_PROMOTE _IOWR('Z', 34, struct zfs_cmd) 773#define ZFS_IOC_DESTROY_SNAPS_NVL _IOWR('Z', 35, struct zfs_cmd) 774#define ZFS_IOC_SNAPSHOT _IOWR('Z', 36, struct zfs_cmd) 775#define ZFS_IOC_DSOBJ_TO_DSNAME _IOWR('Z', 37, struct zfs_cmd) 776#define ZFS_IOC_OBJ_TO_PATH _IOWR('Z', 38, struct zfs_cmd) 777#define ZFS_IOC_POOL_SET_PROPS _IOWR('Z', 39, struct zfs_cmd) 778#define ZFS_IOC_POOL_GET_PROPS _IOWR('Z', 40, struct zfs_cmd) 779#define ZFS_IOC_SET_FSACL _IOWR('Z', 41, struct zfs_cmd) 780#define ZFS_IOC_GET_FSACL _IOWR('Z', 42, struct zfs_cmd) 781#define ZFS_IOC_SHARE _IOWR('Z', 43, struct zfs_cmd) 782#define ZFS_IOC_INHERIT_PROP _IOWR('Z', 44, struct zfs_cmd) 783#define ZFS_IOC_SMB_ACL _IOWR('Z', 45, struct zfs_cmd) 784#define ZFS_IOC_USERSPACE_ONE _IOWR('Z', 46, struct zfs_cmd) 785#define ZFS_IOC_USERSPACE_MANY _IOWR('Z', 47, struct zfs_cmd) 786#define ZFS_IOC_USERSPACE_UPGRADE _IOWR('Z', 48, struct zfs_cmd) 787#define ZFS_IOC_HOLD _IOWR('Z', 49, struct zfs_cmd) 788#define ZFS_IOC_RELEASE _IOWR('Z', 50, struct zfs_cmd) 789#define ZFS_IOC_GET_HOLDS _IOWR('Z', 51, struct zfs_cmd) 790#define ZFS_IOC_OBJSET_RECVD_PROPS _IOWR('Z', 52, struct zfs_cmd) 791#define ZFS_IOC_VDEV_SPLIT _IOWR('Z', 53, struct zfs_cmd) 792#define ZFS_IOC_NEXT_OBJ _IOWR('Z', 54, struct zfs_cmd) 793#define ZFS_IOC_DIFF _IOWR('Z', 55, struct zfs_cmd) 794#define ZFS_IOC_TMP_SNAPSHOT _IOWR('Z', 56, struct zfs_cmd) 795#define ZFS_IOC_OBJ_TO_STATS _IOWR('Z', 57, struct zfs_cmd) 796#define ZFS_IOC_JAIL _IOWR('Z', 58, struct zfs_cmd) 797#define ZFS_IOC_UNJAIL _IOWR('Z', 59, struct zfs_cmd) 798#define ZFS_IOC_POOL_REGUID _IOWR('Z', 60, struct zfs_cmd) 799#define ZFS_IOC_SPACE_WRITTEN _IOWR('Z', 61, struct zfs_cmd) 800#define ZFS_IOC_SPACE_SNAPS _IOWR('Z', 62, struct zfs_cmd) 801#define ZFS_IOC_SEND_PROGRESS _IOWR('Z', 63, struct zfs_cmd) 802#define ZFS_IOC_POOL_REOPEN _IOWR('Z', 64, struct zfs_cmd) 803 804/* 805 * Internal SPA load state. Used by FMA diagnosis engine. 806 */ 807typedef enum { 808 SPA_LOAD_NONE, /* no load in progress */ 809 SPA_LOAD_OPEN, /* normal open */ 810 SPA_LOAD_IMPORT, /* import in progress */ 811 SPA_LOAD_TRYIMPORT, /* tryimport in progress */ 812 SPA_LOAD_RECOVER, /* recovery requested */ 813 SPA_LOAD_ERROR /* load failed */ 814} spa_load_state_t; 815 816/* 817 * Bookmark name values. 818 */ 819#define ZPOOL_ERR_LIST "error list" 820#define ZPOOL_ERR_DATASET "dataset" 821#define ZPOOL_ERR_OBJECT "object" 822 823#define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) 824 825/* 826 * The following are names used in the nvlist describing 827 * the pool's history log. 828 */ 829#define ZPOOL_HIST_RECORD "history record" 830#define ZPOOL_HIST_TIME "history time" 831#define ZPOOL_HIST_CMD "history command" 832#define ZPOOL_HIST_WHO "history who" 833#define ZPOOL_HIST_ZONE "history zone" 834#define ZPOOL_HIST_HOST "history hostname" 835#define ZPOOL_HIST_TXG "history txg" 836#define ZPOOL_HIST_INT_EVENT "history internal event" 837#define ZPOOL_HIST_INT_STR "history internal str" 838 839/* 840 * Flags for ZFS_IOC_VDEV_SET_STATE 841 */ 842#define ZFS_ONLINE_CHECKREMOVE 0x1 843#define ZFS_ONLINE_UNSPARE 0x2 844#define ZFS_ONLINE_FORCEFAULT 0x4 845#define ZFS_ONLINE_EXPAND 0x8 846#define ZFS_OFFLINE_TEMPORARY 0x1 847 848/* 849 * Flags for ZFS_IOC_POOL_IMPORT 850 */ 851#define ZFS_IMPORT_NORMAL 0x0 852#define ZFS_IMPORT_VERBATIM 0x1 853#define ZFS_IMPORT_ANY_HOST 0x2 854#define ZFS_IMPORT_MISSING_LOG 0x4 855#define ZFS_IMPORT_ONLY 0x8 856 857/* 858 * Sysevent payload members. ZFS will generate the following sysevents with the 859 * given payloads: 860 * 861 * ESC_ZFS_RESILVER_START 862 * ESC_ZFS_RESILVER_END 863 * ESC_ZFS_POOL_DESTROY 864 * ESC_ZFS_POOL_REGUID 865 * 866 * ZFS_EV_POOL_NAME DATA_TYPE_STRING 867 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 868 * 869 * ESC_ZFS_VDEV_REMOVE 870 * ESC_ZFS_VDEV_CLEAR 871 * ESC_ZFS_VDEV_CHECK 872 * 873 * ZFS_EV_POOL_NAME DATA_TYPE_STRING 874 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 875 * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) 876 * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 877 */ 878#define ZFS_EV_POOL_NAME "pool_name" 879#define ZFS_EV_POOL_GUID "pool_guid" 880#define ZFS_EV_VDEV_PATH "vdev_path" 881#define ZFS_EV_VDEV_GUID "vdev_guid" 882 883/* 884 * Note: This is encoded on-disk, so new events must be added to the 885 * end, and unused events can not be removed. Be sure to edit 886 * libzfs_pool.c: hist_event_table[]. 887 */ 888typedef enum history_internal_events { 889 LOG_NO_EVENT = 0, 890 LOG_POOL_CREATE, 891 LOG_POOL_VDEV_ADD, 892 LOG_POOL_REMOVE, 893 LOG_POOL_DESTROY, 894 LOG_POOL_EXPORT, 895 LOG_POOL_IMPORT, 896 LOG_POOL_VDEV_ATTACH, 897 LOG_POOL_VDEV_REPLACE, 898 LOG_POOL_VDEV_DETACH, 899 LOG_POOL_VDEV_ONLINE, 900 LOG_POOL_VDEV_OFFLINE, 901 LOG_POOL_UPGRADE, 902 LOG_POOL_CLEAR, 903 LOG_POOL_SCAN, 904 LOG_POOL_PROPSET, 905 LOG_DS_CREATE, 906 LOG_DS_CLONE, 907 LOG_DS_DESTROY, 908 LOG_DS_DESTROY_BEGIN, 909 LOG_DS_INHERIT, 910 LOG_DS_PROPSET, 911 LOG_DS_QUOTA, 912 LOG_DS_PERM_UPDATE, 913 LOG_DS_PERM_REMOVE, 914 LOG_DS_PERM_WHO_REMOVE, 915 LOG_DS_PROMOTE, 916 LOG_DS_RECEIVE, 917 LOG_DS_RENAME, 918 LOG_DS_RESERVATION, 919 LOG_DS_REPLAY_INC_SYNC, 920 LOG_DS_REPLAY_FULL_SYNC, 921 LOG_DS_ROLLBACK, 922 LOG_DS_SNAPSHOT, 923 LOG_DS_UPGRADE, 924 LOG_DS_REFQUOTA, 925 LOG_DS_REFRESERV, 926 LOG_POOL_SCAN_DONE, 927 LOG_DS_USER_HOLD, 928 LOG_DS_USER_RELEASE, 929 LOG_POOL_SPLIT, 930 LOG_END 931} history_internal_events_t; 932 933#ifdef __cplusplus 934} 935#endif 936 937#endif /* _SYS_FS_ZFS_H */ 938