1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5441d80aaSlling * Common Development and Distribution License (the "License"). 6441d80aaSlling * You may not use this file except in compliance with the License. 7fa9e4066Sahrens * 8fa9e4066Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fa9e4066Sahrens * or http://www.opensolaris.org/os/licensing. 10fa9e4066Sahrens * See the License for the specific language governing permissions 11fa9e4066Sahrens * and limitations under the License. 12fa9e4066Sahrens * 13fa9e4066Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14fa9e4066Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fa9e4066Sahrens * If applicable, add the following below this CDDL HEADER, with the 16fa9e4066Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17fa9e4066Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18fa9e4066Sahrens * 19fa9e4066Sahrens * CDDL HEADER END 20fa9e4066Sahrens */ 21fa9e4066Sahrens /* 22a227b7f4Shs * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23fa9e4066Sahrens * Use is subject to license terms. 24fa9e4066Sahrens */ 25fa9e4066Sahrens 26fa9e4066Sahrens #ifndef _SYS_FS_ZFS_H 27fa9e4066Sahrens #define _SYS_FS_ZFS_H 28fa9e4066Sahrens 29fa9e4066Sahrens #pragma ident "%Z%%M% %I% %E% SMI" 30fa9e4066Sahrens 31fa9e4066Sahrens #ifdef __cplusplus 32fa9e4066Sahrens extern "C" { 33fa9e4066Sahrens #endif 34fa9e4066Sahrens 35fa9e4066Sahrens /* 36fa9e4066Sahrens * Types and constants shared between userland and the kernel. 37fa9e4066Sahrens */ 38fa9e4066Sahrens 39fa9e4066Sahrens /* 40fa9e4066Sahrens * Each dataset can be one of the following types. These constants can be 41fa9e4066Sahrens * combined into masks that can be passed to various functions. 42fa9e4066Sahrens */ 43fa9e4066Sahrens typedef enum { 44fa9e4066Sahrens ZFS_TYPE_FILESYSTEM = 0x1, 45fa9e4066Sahrens ZFS_TYPE_SNAPSHOT = 0x2, 46b1b8ab34Slling ZFS_TYPE_VOLUME = 0x4, 47b1b8ab34Slling ZFS_TYPE_POOL = 0x8 48fa9e4066Sahrens } zfs_type_t; 49fa9e4066Sahrens 50990b4856Slling #define ZFS_TYPE_DATASET \ 51fa9e4066Sahrens (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) 52fa9e4066Sahrens 53fa9e4066Sahrens /* 54990b4856Slling * Dataset properties are identified by these constants and must be added to 55990b4856Slling * the end of this list to ensure that external consumers are not affected 56990b4856Slling * by the change. If you make any changes to this list, be sure to update 5766e2aaccSgw * the property table in usr/src/common/zfs/zfs_prop.c. 58fa9e4066Sahrens */ 59fa9e4066Sahrens typedef enum { 60fa9e4066Sahrens ZFS_PROP_TYPE, 61fa9e4066Sahrens ZFS_PROP_CREATION, 62fa9e4066Sahrens ZFS_PROP_USED, 63fa9e4066Sahrens ZFS_PROP_AVAILABLE, 64fa9e4066Sahrens ZFS_PROP_REFERENCED, 65fa9e4066Sahrens ZFS_PROP_COMPRESSRATIO, 66fa9e4066Sahrens ZFS_PROP_MOUNTED, 67fa9e4066Sahrens ZFS_PROP_ORIGIN, 68fa9e4066Sahrens ZFS_PROP_QUOTA, 69fa9e4066Sahrens ZFS_PROP_RESERVATION, 70fa9e4066Sahrens ZFS_PROP_VOLSIZE, 71fa9e4066Sahrens ZFS_PROP_VOLBLOCKSIZE, 72fa9e4066Sahrens ZFS_PROP_RECORDSIZE, 73fa9e4066Sahrens ZFS_PROP_MOUNTPOINT, 74fa9e4066Sahrens ZFS_PROP_SHARENFS, 75fa9e4066Sahrens ZFS_PROP_CHECKSUM, 76fa9e4066Sahrens ZFS_PROP_COMPRESSION, 77fa9e4066Sahrens ZFS_PROP_ATIME, 78fa9e4066Sahrens ZFS_PROP_DEVICES, 79fa9e4066Sahrens ZFS_PROP_EXEC, 80fa9e4066Sahrens ZFS_PROP_SETUID, 81fa9e4066Sahrens ZFS_PROP_READONLY, 82fa9e4066Sahrens ZFS_PROP_ZONED, 83fa9e4066Sahrens ZFS_PROP_SNAPDIR, 84fa9e4066Sahrens ZFS_PROP_ACLMODE, 85fa9e4066Sahrens ZFS_PROP_ACLINHERIT, 8666e2aaccSgw ZFS_PROP_CREATETXG, /* not exposed to the user */ 8766e2aaccSgw ZFS_PROP_NAME, /* not exposed to the user */ 88e9dbad6fSeschrock ZFS_PROP_CANMOUNT, 8966e2aaccSgw ZFS_PROP_SHAREISCSI, 9066e2aaccSgw ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */ 917b55fa8eSck ZFS_PROP_XATTR, 92d0ad202dSahrens ZFS_PROP_NUMCLONES, /* not exposed to the user */ 93b1b8ab34Slling ZFS_PROP_COPIES, 94e7437265Sahrens ZFS_PROP_VERSION, 95da6c28aaSamw ZFS_PROP_UTF8ONLY, 96da6c28aaSamw ZFS_PROP_NORMALIZE, 97da6c28aaSamw ZFS_PROP_CASE, 98da6c28aaSamw ZFS_PROP_VSCAN, 99da6c28aaSamw ZFS_PROP_NBMAND, 100da6c28aaSamw ZFS_PROP_SHARESMB, 101a9799022Sck ZFS_PROP_REFQUOTA, 102a9799022Sck ZFS_PROP_REFRESERVATION, 103c5904d13Seschrock ZFS_PROP_GUID, 104*3baa08fcSek ZFS_PROP_PRIMARYCACHE, 105*3baa08fcSek ZFS_PROP_SECONDARYCACHE, 10691ebeef5Sahrens ZFS_NUM_PROPS 107fa9e4066Sahrens } zfs_prop_t; 108fa9e4066Sahrens 109990b4856Slling /* 110990b4856Slling * Pool properties are identified by these constants and must be added to the 111990b4856Slling * end of this list to ensure that external conumsers are not affected 112990b4856Slling * by the change. If you make any changes to this list, be sure to update 113990b4856Slling * the property table in usr/src/common/zfs/zpool_prop.c. 114990b4856Slling */ 115990b4856Slling typedef enum { 116990b4856Slling ZPOOL_PROP_NAME, 117990b4856Slling ZPOOL_PROP_SIZE, 118990b4856Slling ZPOOL_PROP_USED, 119990b4856Slling ZPOOL_PROP_AVAILABLE, 120990b4856Slling ZPOOL_PROP_CAPACITY, 121990b4856Slling ZPOOL_PROP_ALTROOT, 122990b4856Slling ZPOOL_PROP_HEALTH, 123990b4856Slling ZPOOL_PROP_GUID, 124990b4856Slling ZPOOL_PROP_VERSION, 125990b4856Slling ZPOOL_PROP_BOOTFS, 126990b4856Slling ZPOOL_PROP_DELEGATION, 127990b4856Slling ZPOOL_PROP_AUTOREPLACE, 1282f8aaab3Seschrock ZPOOL_PROP_CACHEFILE, 1290a4e9518Sgw ZPOOL_PROP_FAILUREMODE, 130990b4856Slling ZPOOL_NUM_PROPS 131990b4856Slling } zpool_prop_t; 132b1b8ab34Slling 133990b4856Slling #define ZPROP_CONT -2 134990b4856Slling #define ZPROP_INVAL -1 1353d7072f8Seschrock 136990b4856Slling #define ZPROP_VALUE "value" 137990b4856Slling #define ZPROP_SOURCE "source" 1387f7322feSeschrock 139b1b8ab34Slling typedef enum { 140990b4856Slling ZPROP_SRC_NONE = 0x1, 141990b4856Slling ZPROP_SRC_DEFAULT = 0x2, 142990b4856Slling ZPROP_SRC_TEMPORARY = 0x4, 143990b4856Slling ZPROP_SRC_LOCAL = 0x8, 144990b4856Slling ZPROP_SRC_INHERITED = 0x10 145990b4856Slling } zprop_source_t; 146990b4856Slling 147990b4856Slling #define ZPROP_SRC_ALL 0x1f 148990b4856Slling 149990b4856Slling typedef int (*zprop_func)(int, void *); 150990b4856Slling 1510a48a24eStimh /* 1520a48a24eStimh * Properties to be set on the root file system of a new pool 1530a48a24eStimh * are stuffed into their own nvlist, which is then included in 1540a48a24eStimh * the properties nvlist with the pool properties. 1550a48a24eStimh */ 1560a48a24eStimh #define ZPOOL_ROOTFS_PROPS "root-props-nvl" 1570a48a24eStimh 158990b4856Slling /* 159990b4856Slling * Dataset property functions shared between libzfs and kernel. 160990b4856Slling */ 161990b4856Slling const char *zfs_prop_default_string(zfs_prop_t); 162990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t); 163990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t); 164990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t); 165da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t); 166990b4856Slling const char *zfs_prop_to_name(zfs_prop_t); 167990b4856Slling zfs_prop_t zfs_name_to_prop(const char *); 168990b4856Slling boolean_t zfs_prop_user(const char *); 169990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); 170990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *); 1714853e976Sgw boolean_t zfs_prop_valid_for_type(int, zfs_type_t); 172b1b8ab34Slling 173990b4856Slling /* 174990b4856Slling * Pool property functions shared between libzfs and kernel. 175990b4856Slling */ 176990b4856Slling zpool_prop_t zpool_name_to_prop(const char *); 177990b4856Slling const char *zpool_prop_to_name(zpool_prop_t); 178990b4856Slling const char *zpool_prop_default_string(zpool_prop_t); 179990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t); 180990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t); 181990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **); 182990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *); 183b1b8ab34Slling 184990b4856Slling /* 185990b4856Slling * Definitions for the Delegation. 186990b4856Slling */ 187ecd6cf80Smarks typedef enum { 188ecd6cf80Smarks ZFS_DELEG_WHO_UNKNOWN = 0, 189ecd6cf80Smarks ZFS_DELEG_USER = 'u', 190ecd6cf80Smarks ZFS_DELEG_USER_SETS = 'U', 191ecd6cf80Smarks ZFS_DELEG_GROUP = 'g', 192ecd6cf80Smarks ZFS_DELEG_GROUP_SETS = 'G', 193ecd6cf80Smarks ZFS_DELEG_EVERYONE = 'e', 194ecd6cf80Smarks ZFS_DELEG_EVERYONE_SETS = 'E', 195ecd6cf80Smarks ZFS_DELEG_CREATE = 'c', 196ecd6cf80Smarks ZFS_DELEG_CREATE_SETS = 'C', 197ecd6cf80Smarks ZFS_DELEG_NAMED_SET = 's', 198ecd6cf80Smarks ZFS_DELEG_NAMED_SET_SETS = 'S' 199ecd6cf80Smarks } zfs_deleg_who_type_t; 200ecd6cf80Smarks 201ecd6cf80Smarks typedef enum { 202ecd6cf80Smarks ZFS_DELEG_NONE = 0, 203ecd6cf80Smarks ZFS_DELEG_PERM_LOCAL = 1, 204ecd6cf80Smarks ZFS_DELEG_PERM_DESCENDENT = 2, 205ecd6cf80Smarks ZFS_DELEG_PERM_LOCALDESCENDENT = 3, 206ecd6cf80Smarks ZFS_DELEG_PERM_CREATE = 4 207ecd6cf80Smarks } zfs_deleg_inherit_t; 208ecd6cf80Smarks 209ecd6cf80Smarks #define ZFS_DELEG_PERM_UID "uid" 210ecd6cf80Smarks #define ZFS_DELEG_PERM_GID "gid" 211ecd6cf80Smarks #define ZFS_DELEG_PERM_GROUPS "groups" 212ecd6cf80Smarks 213a227b7f4Shs typedef enum { 214a227b7f4Shs ZFS_CANMOUNT_OFF = 0, 215a227b7f4Shs ZFS_CANMOUNT_ON = 1, 216a227b7f4Shs ZFS_CANMOUNT_NOAUTO = 2 217a227b7f4Shs } zfs_canmount_type_t; 218a227b7f4Shs 219da6c28aaSamw typedef enum zfs_share_op { 220da6c28aaSamw ZFS_SHARE_NFS = 0, 221da6c28aaSamw ZFS_UNSHARE_NFS = 1, 222da6c28aaSamw ZFS_SHARE_SMB = 2, 223da6c28aaSamw ZFS_UNSHARE_SMB = 3 224da6c28aaSamw } zfs_share_op_t; 225da6c28aaSamw 226*3baa08fcSek typedef enum zfs_cache_type { 227*3baa08fcSek ZFS_CACHE_NONE = 0, 228*3baa08fcSek ZFS_CACHE_METADATA = 1, 229*3baa08fcSek ZFS_CACHE_ALL = 2 230*3baa08fcSek } zfs_cache_type_t; 231*3baa08fcSek 232*3baa08fcSek 233eaca9bbdSeschrock /* 23499653d4eSeschrock * On-disk version number. 235eaca9bbdSeschrock */ 236e7437265Sahrens #define SPA_VERSION_1 1ULL 237e7437265Sahrens #define SPA_VERSION_2 2ULL 238e7437265Sahrens #define SPA_VERSION_3 3ULL 239e7437265Sahrens #define SPA_VERSION_4 4ULL 240e7437265Sahrens #define SPA_VERSION_5 5ULL 241e7437265Sahrens #define SPA_VERSION_6 6ULL 242e7437265Sahrens #define SPA_VERSION_7 7ULL 243e7437265Sahrens #define SPA_VERSION_8 8ULL 244da6c28aaSamw #define SPA_VERSION_9 9ULL 245fa94a07fSbrendan #define SPA_VERSION_10 10ULL 246088f3894Sahrens #define SPA_VERSION_11 11ULL 247b1b8ab34Slling /* 248e7cbe64fSgw * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk 249b1b8ab34Slling * format change. Go to usr/src/grub/grub-0.95/stage2/{zfs-include/, fsys_zfs*}, 250b1b8ab34Slling * and do the appropriate changes. 251b1b8ab34Slling */ 252088f3894Sahrens #define SPA_VERSION SPA_VERSION_11 253088f3894Sahrens #define SPA_VERSION_STRING "11" 25444cd46caSbillm 25544cd46caSbillm /* 256e7437265Sahrens * Symbolic names for the changes that caused a SPA_VERSION switch. 25744cd46caSbillm * Used in the code when checking for presence or absence of a feature. 25844cd46caSbillm * Feel free to define multiple symbolic names for each version if there 25944cd46caSbillm * were multiple changes to on-disk structures during that version. 26044cd46caSbillm * 261e7437265Sahrens * NOTE: When checking the current SPA_VERSION in your code, be sure 26244cd46caSbillm * to use spa_version() since it reports the version of the 26344cd46caSbillm * last synced uberblock. Checking the in-flight version can 26444cd46caSbillm * be dangerous in some cases. 26544cd46caSbillm */ 266e7437265Sahrens #define SPA_VERSION_INITIAL SPA_VERSION_1 267e7437265Sahrens #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 268e7437265Sahrens #define SPA_VERSION_SPARES SPA_VERSION_3 269e7437265Sahrens #define SPA_VERSION_RAID6 SPA_VERSION_3 270e7437265Sahrens #define SPA_VERSION_BPLIST_ACCOUNT SPA_VERSION_3 271e7437265Sahrens #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 272e7437265Sahrens #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 273e7437265Sahrens #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 274e7437265Sahrens #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 275e7437265Sahrens #define SPA_VERSION_BOOTFS SPA_VERSION_6 276990b4856Slling #define SPA_VERSION_SLOGS SPA_VERSION_7 277990b4856Slling #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8 278da6c28aaSamw #define SPA_VERSION_FUID SPA_VERSION_9 279a9799022Sck #define SPA_VERSION_REFRESERVATION SPA_VERSION_9 280a9799022Sck #define SPA_VERSION_REFQUOTA SPA_VERSION_9 281a9799022Sck #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9 282fa94a07fSbrendan #define SPA_VERSION_L2CACHE SPA_VERSION_10 283088f3894Sahrens #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11 284088f3894Sahrens #define SPA_VERSION_ORIGIN SPA_VERSION_11 285088f3894Sahrens #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11 286e7437265Sahrens 287e7437265Sahrens /* 288e7437265Sahrens * ZPL version - rev'd whenever an incompatible on-disk format change 289e7437265Sahrens * occurs. This is independent of SPA/DMU/ZAP versioning. You must 290e7437265Sahrens * also update the version_table[] and help message in zfs_prop.c. 291e7437265Sahrens * 292e7437265Sahrens * When changing, be sure to teach GRUB how to read the new format! 293e7437265Sahrens * See usr/src/grub/grub-0.95/stage2/{zfs-include/,fsys_zfs*} 294e7437265Sahrens */ 295e7437265Sahrens #define ZPL_VERSION_1 1ULL 296e7437265Sahrens #define ZPL_VERSION_2 2ULL 297da6c28aaSamw #define ZPL_VERSION_3 3ULL 298da6c28aaSamw #define ZPL_VERSION ZPL_VERSION_3 299da6c28aaSamw #define ZPL_VERSION_STRING "3" 300e7437265Sahrens 301e7437265Sahrens #define ZPL_VERSION_INITIAL ZPL_VERSION_1 302e7437265Sahrens #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 303da6c28aaSamw #define ZPL_VERSION_FUID ZPL_VERSION_3 304de8267e0Stimh #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3 305da6c28aaSamw #define ZPL_VERSION_SYSATTR ZPL_VERSION_3 306eaca9bbdSeschrock 307fa9e4066Sahrens /* 308fa9e4066Sahrens * The following are configuration names used in the nvlist describing a pool's 309fa9e4066Sahrens * configuration. 310fa9e4066Sahrens */ 311fa9e4066Sahrens #define ZPOOL_CONFIG_VERSION "version" 312fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_NAME "name" 313fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_STATE "state" 314fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_TXG "txg" 315fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_GUID "pool_guid" 316fa9e4066Sahrens #define ZPOOL_CONFIG_CREATE_TXG "create_txg" 317fa9e4066Sahrens #define ZPOOL_CONFIG_TOP_GUID "top_guid" 318fa9e4066Sahrens #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" 319fa9e4066Sahrens #define ZPOOL_CONFIG_TYPE "type" 320fa9e4066Sahrens #define ZPOOL_CONFIG_CHILDREN "children" 321fa9e4066Sahrens #define ZPOOL_CONFIG_ID "id" 322fa9e4066Sahrens #define ZPOOL_CONFIG_GUID "guid" 323fa9e4066Sahrens #define ZPOOL_CONFIG_PATH "path" 324fa9e4066Sahrens #define ZPOOL_CONFIG_DEVID "devid" 325fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" 326fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" 327fa9e4066Sahrens #define ZPOOL_CONFIG_ASHIFT "ashift" 328fa9e4066Sahrens #define ZPOOL_CONFIG_ASIZE "asize" 329fa9e4066Sahrens #define ZPOOL_CONFIG_DTL "DTL" 330fa9e4066Sahrens #define ZPOOL_CONFIG_STATS "stats" 331afefbcddSeschrock #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" 332ea8dc4b6Seschrock #define ZPOOL_CONFIG_ERRCOUNT "error_count" 333ea8dc4b6Seschrock #define ZPOOL_CONFIG_NOT_PRESENT "not_present" 33499653d4eSeschrock #define ZPOOL_CONFIG_SPARES "spares" 33599653d4eSeschrock #define ZPOOL_CONFIG_IS_SPARE "is_spare" 33699653d4eSeschrock #define ZPOOL_CONFIG_NPARITY "nparity" 33795173954Sek #define ZPOOL_CONFIG_HOSTID "hostid" 33895173954Sek #define ZPOOL_CONFIG_HOSTNAME "hostname" 3393d7072f8Seschrock #define ZPOOL_CONFIG_UNSPARE "unspare" 3403d7072f8Seschrock #define ZPOOL_CONFIG_PHYS_PATH "phys_path" 3418654d025Sperrin #define ZPOOL_CONFIG_IS_LOG "is_log" 342fa94a07fSbrendan #define ZPOOL_CONFIG_L2CACHE "l2cache" 343e7cbe64fSgw #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ 344e7cbe64fSgw #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */ 3453d7072f8Seschrock /* 3463d7072f8Seschrock * The persistent vdev state is stored as separate values rather than a single 3473d7072f8Seschrock * 'vdev_state' entry. This is because a device can be in multiple states, such 3483d7072f8Seschrock * as offline and degraded. 3493d7072f8Seschrock */ 3503d7072f8Seschrock #define ZPOOL_CONFIG_OFFLINE "offline" 3513d7072f8Seschrock #define ZPOOL_CONFIG_FAULTED "faulted" 3523d7072f8Seschrock #define ZPOOL_CONFIG_DEGRADED "degraded" 3533d7072f8Seschrock #define ZPOOL_CONFIG_REMOVED "removed" 354fa9e4066Sahrens 355fa9e4066Sahrens #define VDEV_TYPE_ROOT "root" 356fa9e4066Sahrens #define VDEV_TYPE_MIRROR "mirror" 357fa9e4066Sahrens #define VDEV_TYPE_REPLACING "replacing" 358fa9e4066Sahrens #define VDEV_TYPE_RAIDZ "raidz" 359fa9e4066Sahrens #define VDEV_TYPE_DISK "disk" 360fa9e4066Sahrens #define VDEV_TYPE_FILE "file" 361fa9e4066Sahrens #define VDEV_TYPE_MISSING "missing" 36299653d4eSeschrock #define VDEV_TYPE_SPARE "spare" 3638654d025Sperrin #define VDEV_TYPE_LOG "log" 364fa94a07fSbrendan #define VDEV_TYPE_L2CACHE "l2cache" 365fa9e4066Sahrens 366fa9e4066Sahrens /* 367fa9e4066Sahrens * This is needed in userland to report the minimum necessary device size. 368fa9e4066Sahrens */ 369fa9e4066Sahrens #define SPA_MINDEVSIZE (64ULL << 20) 370fa9e4066Sahrens 371fa9e4066Sahrens /* 372fa9e4066Sahrens * The location of the pool configuration repository, shared between kernel and 373fa9e4066Sahrens * userland. 374fa9e4066Sahrens */ 375c5904d13Seschrock #define ZPOOL_CACHE "/etc/zfs/zpool.cache" 376fa9e4066Sahrens 377fa9e4066Sahrens /* 378fa9e4066Sahrens * vdev states are ordered from least to most healthy. 379fa9e4066Sahrens * A vdev that's CANT_OPEN or below is considered unusable. 380fa9e4066Sahrens */ 381fa9e4066Sahrens typedef enum vdev_state { 382fa9e4066Sahrens VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ 383fa9e4066Sahrens VDEV_STATE_CLOSED, /* Not currently open */ 384fa9e4066Sahrens VDEV_STATE_OFFLINE, /* Not allowed to open */ 3853d7072f8Seschrock VDEV_STATE_REMOVED, /* Explicitly removed from system */ 386fa9e4066Sahrens VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ 3873d7072f8Seschrock VDEV_STATE_FAULTED, /* External request to fault device */ 388fa9e4066Sahrens VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ 389fa9e4066Sahrens VDEV_STATE_HEALTHY /* Presumed good */ 390fa9e4066Sahrens } vdev_state_t; 391fa9e4066Sahrens 3923d7072f8Seschrock #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY 3933d7072f8Seschrock 394fa9e4066Sahrens /* 395fa9e4066Sahrens * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field 396fa9e4066Sahrens * of the vdev stats structure uses these constants to distinguish why. 397fa9e4066Sahrens */ 398fa9e4066Sahrens typedef enum vdev_aux { 399fa9e4066Sahrens VDEV_AUX_NONE, /* no error */ 400fa9e4066Sahrens VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ 401fa9e4066Sahrens VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ 402fa9e4066Sahrens VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ 403fa9e4066Sahrens VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ 404fa9e4066Sahrens VDEV_AUX_TOO_SMALL, /* vdev size is too small */ 405eaca9bbdSeschrock VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ 406eaca9bbdSeschrock VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ 40799653d4eSeschrock VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ 4083d7072f8Seschrock VDEV_AUX_SPARED, /* hot spare used in another pool */ 40932b87932Sek VDEV_AUX_ERR_EXCEEDED, /* too many errors */ 41032b87932Sek VDEV_AUX_IO_FAILURE /* experienced I/O failure */ 411fa9e4066Sahrens } vdev_aux_t; 412fa9e4066Sahrens 413fa9e4066Sahrens /* 41446a2abf2Seschrock * pool state. The following states are written to disk as part of the normal 415fa94a07fSbrendan * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining 416fa94a07fSbrendan * states are software abstractions used at various levels to communicate 417fa94a07fSbrendan * pool state. 418fa9e4066Sahrens */ 419fa9e4066Sahrens typedef enum pool_state { 420fa9e4066Sahrens POOL_STATE_ACTIVE = 0, /* In active use */ 421fa9e4066Sahrens POOL_STATE_EXPORTED, /* Explicitly exported */ 422fa9e4066Sahrens POOL_STATE_DESTROYED, /* Explicitly destroyed */ 42399653d4eSeschrock POOL_STATE_SPARE, /* Reserved for hot spare use */ 424fa94a07fSbrendan POOL_STATE_L2CACHE, /* Level 2 ARC device */ 425fa9e4066Sahrens POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ 4260a4e9518Sgw POOL_STATE_IO_FAILURE, /* Internal pool state */ 42746a2abf2Seschrock POOL_STATE_UNAVAIL, /* Internal libzfs state */ 42846a2abf2Seschrock POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ 429fa9e4066Sahrens } pool_state_t; 430fa9e4066Sahrens 431fa9e4066Sahrens /* 432fa9e4066Sahrens * Scrub types. 433fa9e4066Sahrens */ 434fa9e4066Sahrens typedef enum pool_scrub_type { 435fa9e4066Sahrens POOL_SCRUB_NONE, 436fa9e4066Sahrens POOL_SCRUB_RESILVER, 437fa9e4066Sahrens POOL_SCRUB_EVERYTHING, 438fa9e4066Sahrens POOL_SCRUB_TYPES 439fa9e4066Sahrens } pool_scrub_type_t; 440fa9e4066Sahrens 441fa9e4066Sahrens /* 442fa9e4066Sahrens * ZIO types. Needed to interpret vdev statistics below. 443fa9e4066Sahrens */ 444fa9e4066Sahrens typedef enum zio_type { 445fa9e4066Sahrens ZIO_TYPE_NULL = 0, 446fa9e4066Sahrens ZIO_TYPE_READ, 447fa9e4066Sahrens ZIO_TYPE_WRITE, 448fa9e4066Sahrens ZIO_TYPE_FREE, 449fa9e4066Sahrens ZIO_TYPE_CLAIM, 450fa9e4066Sahrens ZIO_TYPE_IOCTL, 451fa9e4066Sahrens ZIO_TYPES 452fa9e4066Sahrens } zio_type_t; 453fa9e4066Sahrens 454fa9e4066Sahrens /* 455fa9e4066Sahrens * Vdev statistics. Note: all fields should be 64-bit because this 456fa9e4066Sahrens * is passed between kernel and userland as an nvlist uint64 array. 457fa9e4066Sahrens */ 458fa9e4066Sahrens typedef struct vdev_stat { 459fa9e4066Sahrens hrtime_t vs_timestamp; /* time since vdev load */ 460fa9e4066Sahrens uint64_t vs_state; /* vdev state */ 461fa9e4066Sahrens uint64_t vs_aux; /* see vdev_aux_t */ 462fa9e4066Sahrens uint64_t vs_alloc; /* space allocated */ 463fa9e4066Sahrens uint64_t vs_space; /* total capacity */ 46499653d4eSeschrock uint64_t vs_dspace; /* deflated capacity */ 4652a79c5feSlling uint64_t vs_rsize; /* replaceable dev size */ 466fa9e4066Sahrens uint64_t vs_ops[ZIO_TYPES]; /* operation count */ 467fa9e4066Sahrens uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */ 468fa9e4066Sahrens uint64_t vs_read_errors; /* read errors */ 469fa9e4066Sahrens uint64_t vs_write_errors; /* write errors */ 470fa9e4066Sahrens uint64_t vs_checksum_errors; /* checksum errors */ 471fa9e4066Sahrens uint64_t vs_self_healed; /* self-healed bytes */ 472fa9e4066Sahrens uint64_t vs_scrub_type; /* pool_scrub_type_t */ 473fa9e4066Sahrens uint64_t vs_scrub_complete; /* completed? */ 474fa9e4066Sahrens uint64_t vs_scrub_examined; /* bytes examined; top */ 475fa9e4066Sahrens uint64_t vs_scrub_repaired; /* bytes repaired; leaf */ 476fa9e4066Sahrens uint64_t vs_scrub_errors; /* errors during scrub */ 477fa9e4066Sahrens uint64_t vs_scrub_start; /* UTC scrub start time */ 478fa9e4066Sahrens uint64_t vs_scrub_end; /* UTC scrub end time */ 479fa9e4066Sahrens } vdev_stat_t; 480fa9e4066Sahrens 481e7cbe64fSgw #define ZVOL_DRIVER "zvol" 482fa9e4066Sahrens #define ZFS_DRIVER "zfs" 483fa9e4066Sahrens #define ZFS_DEV "/dev/zfs" 484fa9e4066Sahrens 485fa9e4066Sahrens /* 486fa9e4066Sahrens * zvol paths. Irritatingly, the devfsadm interfaces want all these 487fa9e4066Sahrens * paths without the /dev prefix, but for some things, we want the 488fa9e4066Sahrens * /dev prefix. Below are the names without /dev. 489fa9e4066Sahrens */ 490fa9e4066Sahrens #define ZVOL_DEV_DIR "zvol/dsk" 491fa9e4066Sahrens #define ZVOL_RDEV_DIR "zvol/rdsk" 492fa9e4066Sahrens 493fa9e4066Sahrens /* 494fa9e4066Sahrens * And here are the things we need with /dev, etc. in front of them. 495fa9e4066Sahrens */ 496fa9e4066Sahrens #define ZVOL_PSEUDO_DEV "/devices/pseudo/zvol@0:" 497e7cbe64fSgw #define ZVOL_FULL_DEV_DIR "/dev/" ZVOL_DEV_DIR "/" 498fa9e4066Sahrens 499fa9e4066Sahrens #define ZVOL_PROP_NAME "name" 500fa9e4066Sahrens 501fa9e4066Sahrens /* 502fa9e4066Sahrens * /dev/zfs ioctl numbers. 503fa9e4066Sahrens */ 504fa9e4066Sahrens #define ZFS_IOC ('Z' << 8) 505fa9e4066Sahrens 506fa9e4066Sahrens typedef enum zfs_ioc { 507fa9e4066Sahrens ZFS_IOC_POOL_CREATE = ZFS_IOC, 508fa9e4066Sahrens ZFS_IOC_POOL_DESTROY, 509fa9e4066Sahrens ZFS_IOC_POOL_IMPORT, 510fa9e4066Sahrens ZFS_IOC_POOL_EXPORT, 511fa9e4066Sahrens ZFS_IOC_POOL_CONFIGS, 512fa9e4066Sahrens ZFS_IOC_POOL_STATS, 513fa9e4066Sahrens ZFS_IOC_POOL_TRYIMPORT, 514fa9e4066Sahrens ZFS_IOC_POOL_SCRUB, 515fa9e4066Sahrens ZFS_IOC_POOL_FREEZE, 516eaca9bbdSeschrock ZFS_IOC_POOL_UPGRADE, 51706eeb2adSek ZFS_IOC_POOL_GET_HISTORY, 518fa9e4066Sahrens ZFS_IOC_VDEV_ADD, 519fa9e4066Sahrens ZFS_IOC_VDEV_REMOVE, 5203d7072f8Seschrock ZFS_IOC_VDEV_SET_STATE, 521fa9e4066Sahrens ZFS_IOC_VDEV_ATTACH, 522fa9e4066Sahrens ZFS_IOC_VDEV_DETACH, 523c67d9675Seschrock ZFS_IOC_VDEV_SETPATH, 524fa9e4066Sahrens ZFS_IOC_OBJSET_STATS, 525de8267e0Stimh ZFS_IOC_OBJSET_ZPLPROPS, 526fa9e4066Sahrens ZFS_IOC_DATASET_LIST_NEXT, 527fa9e4066Sahrens ZFS_IOC_SNAPSHOT_LIST_NEXT, 528fa9e4066Sahrens ZFS_IOC_SET_PROP, 529fa9e4066Sahrens ZFS_IOC_CREATE_MINOR, 530fa9e4066Sahrens ZFS_IOC_REMOVE_MINOR, 531fa9e4066Sahrens ZFS_IOC_CREATE, 532fa9e4066Sahrens ZFS_IOC_DESTROY, 533fa9e4066Sahrens ZFS_IOC_ROLLBACK, 534fa9e4066Sahrens ZFS_IOC_RENAME, 5353cb34c60Sahrens ZFS_IOC_RECV, 5363cb34c60Sahrens ZFS_IOC_SEND, 537ea8dc4b6Seschrock ZFS_IOC_INJECT_FAULT, 538ea8dc4b6Seschrock ZFS_IOC_CLEAR_FAULT, 539ea8dc4b6Seschrock ZFS_IOC_INJECT_LIST_NEXT, 540ea8dc4b6Seschrock ZFS_IOC_ERROR_LOG, 541ea8dc4b6Seschrock ZFS_IOC_CLEAR, 5421d452cf5Sahrens ZFS_IOC_PROMOTE, 5431d452cf5Sahrens ZFS_IOC_DESTROY_SNAPS, 54455434c77Sek ZFS_IOC_SNAPSHOT, 54555434c77Sek ZFS_IOC_DSOBJ_TO_DSNAME, 546b1b8ab34Slling ZFS_IOC_OBJ_TO_PATH, 547b1b8ab34Slling ZFS_IOC_POOL_SET_PROPS, 548ecd6cf80Smarks ZFS_IOC_POOL_GET_PROPS, 549ecd6cf80Smarks ZFS_IOC_SET_FSACL, 550ecd6cf80Smarks ZFS_IOC_GET_FSACL, 551ecd6cf80Smarks ZFS_IOC_ISCSI_PERM_CHECK, 552e45ce728Sahrens ZFS_IOC_SHARE, 553e45ce728Sahrens ZFS_IOC_INHERIT_PROP 554fa9e4066Sahrens } zfs_ioc_t; 555fa9e4066Sahrens 556ea8dc4b6Seschrock /* 557ea8dc4b6Seschrock * Internal SPA load state. Used by FMA diagnosis engine. 558ea8dc4b6Seschrock */ 559ea8dc4b6Seschrock typedef enum { 560ea8dc4b6Seschrock SPA_LOAD_NONE, /* no load in progress */ 561ea8dc4b6Seschrock SPA_LOAD_OPEN, /* normal open */ 562ea8dc4b6Seschrock SPA_LOAD_IMPORT, /* import in progress */ 563ea8dc4b6Seschrock SPA_LOAD_TRYIMPORT /* tryimport in progress */ 564ea8dc4b6Seschrock } spa_load_state_t; 565ea8dc4b6Seschrock 566e9dbad6fSeschrock /* 567e9dbad6fSeschrock * Bookmark name values. 568e9dbad6fSeschrock */ 56955434c77Sek #define ZPOOL_ERR_LIST "error list" 570e9dbad6fSeschrock #define ZPOOL_ERR_DATASET "dataset" 571e9dbad6fSeschrock #define ZPOOL_ERR_OBJECT "object" 572e9dbad6fSeschrock 57306eeb2adSek #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) 57406eeb2adSek 57506eeb2adSek /* 57606eeb2adSek * The following are names used in the nvlist describing 57706eeb2adSek * the pool's history log. 57806eeb2adSek */ 57906eeb2adSek #define ZPOOL_HIST_RECORD "history record" 58006eeb2adSek #define ZPOOL_HIST_TIME "history time" 58106eeb2adSek #define ZPOOL_HIST_CMD "history command" 582ecd6cf80Smarks #define ZPOOL_HIST_WHO "history who" 583ecd6cf80Smarks #define ZPOOL_HIST_ZONE "history zone" 584ecd6cf80Smarks #define ZPOOL_HIST_HOST "history hostname" 585ecd6cf80Smarks #define ZPOOL_HIST_TXG "history txg" 586ecd6cf80Smarks #define ZPOOL_HIST_INT_EVENT "history internal event" 587ecd6cf80Smarks #define ZPOOL_HIST_INT_STR "history internal str" 58806eeb2adSek 5893d7072f8Seschrock /* 5903d7072f8Seschrock * Flags for ZFS_IOC_VDEV_SET_STATE 5913d7072f8Seschrock */ 5923d7072f8Seschrock #define ZFS_ONLINE_CHECKREMOVE 0x1 5933d7072f8Seschrock #define ZFS_ONLINE_UNSPARE 0x2 5943d7072f8Seschrock #define ZFS_ONLINE_FORCEFAULT 0x4 5953d7072f8Seschrock #define ZFS_OFFLINE_TEMPORARY 0x1 5963d7072f8Seschrock 5973d7072f8Seschrock /* 5983d7072f8Seschrock * Sysevent payload members. ZFS will generate the following sysevents with the 5993d7072f8Seschrock * given payloads: 6003d7072f8Seschrock * 6013d7072f8Seschrock * ESC_ZFS_RESILVER_START 6023d7072f8Seschrock * ESC_ZFS_RESILVER_END 6033d7072f8Seschrock * ESC_ZFS_POOL_DESTROY 6043d7072f8Seschrock * 6053d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 6063d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 6073d7072f8Seschrock * 6083d7072f8Seschrock * ESC_ZFS_VDEV_REMOVE 6093d7072f8Seschrock * ESC_ZFS_VDEV_CLEAR 6103d7072f8Seschrock * ESC_ZFS_VDEV_CHECK 6113d7072f8Seschrock * 6123d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 6133d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 6143d7072f8Seschrock * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) 6153d7072f8Seschrock * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 6163d7072f8Seschrock */ 6173d7072f8Seschrock #define ZFS_EV_POOL_NAME "pool_name" 6183d7072f8Seschrock #define ZFS_EV_POOL_GUID "pool_guid" 6193d7072f8Seschrock #define ZFS_EV_VDEV_PATH "vdev_path" 6203d7072f8Seschrock #define ZFS_EV_VDEV_GUID "vdev_guid" 6213d7072f8Seschrock 622088f3894Sahrens /* 623088f3894Sahrens * Note: This is encoded on-disk, so new events must be added to the 624088f3894Sahrens * end, and unused events can not be removed. Be sure to edit 625088f3894Sahrens * zpool_main.c: hist_event_table[]. 626088f3894Sahrens */ 627ecd6cf80Smarks typedef enum history_internal_events { 628ecd6cf80Smarks LOG_NO_EVENT = 0, 629ecd6cf80Smarks LOG_POOL_CREATE, 630ecd6cf80Smarks LOG_POOL_VDEV_ADD, 631ecd6cf80Smarks LOG_POOL_REMOVE, 632ecd6cf80Smarks LOG_POOL_DESTROY, 633ecd6cf80Smarks LOG_POOL_EXPORT, 634ecd6cf80Smarks LOG_POOL_IMPORT, 635ecd6cf80Smarks LOG_POOL_VDEV_ATTACH, 636ecd6cf80Smarks LOG_POOL_VDEV_REPLACE, 637ecd6cf80Smarks LOG_POOL_VDEV_DETACH, 638ecd6cf80Smarks LOG_POOL_VDEV_ONLINE, 639ecd6cf80Smarks LOG_POOL_VDEV_OFFLINE, 640ecd6cf80Smarks LOG_POOL_UPGRADE, 641ecd6cf80Smarks LOG_POOL_CLEAR, 642ecd6cf80Smarks LOG_POOL_SCRUB, 643ecd6cf80Smarks LOG_POOL_PROPSET, 644ecd6cf80Smarks LOG_DS_CREATE, 645ecd6cf80Smarks LOG_DS_CLONE, 646ecd6cf80Smarks LOG_DS_DESTROY, 647ecd6cf80Smarks LOG_DS_DESTROY_BEGIN, 648ecd6cf80Smarks LOG_DS_INHERIT, 649ecd6cf80Smarks LOG_DS_PROPSET, 650ecd6cf80Smarks LOG_DS_QUOTA, 651ecd6cf80Smarks LOG_DS_PERM_UPDATE, 652ecd6cf80Smarks LOG_DS_PERM_REMOVE, 653ecd6cf80Smarks LOG_DS_PERM_WHO_REMOVE, 654ecd6cf80Smarks LOG_DS_PROMOTE, 655ecd6cf80Smarks LOG_DS_RECEIVE, 656ecd6cf80Smarks LOG_DS_RENAME, 657ecd6cf80Smarks LOG_DS_RESERVATION, 658ecd6cf80Smarks LOG_DS_REPLAY_INC_SYNC, 659ecd6cf80Smarks LOG_DS_REPLAY_FULL_SYNC, 660ecd6cf80Smarks LOG_DS_ROLLBACK, 661ecd6cf80Smarks LOG_DS_SNAPSHOT, 662e7437265Sahrens LOG_DS_UPGRADE, 663a9799022Sck LOG_DS_REFQUOTA, 664a9799022Sck LOG_DS_REFRESERV, 665088f3894Sahrens LOG_POOL_SCRUB_DONE, 666ecd6cf80Smarks LOG_END 667ecd6cf80Smarks } history_internal_events_t; 668ecd6cf80Smarks 669fa9e4066Sahrens #ifdef __cplusplus 670fa9e4066Sahrens } 671fa9e4066Sahrens #endif 672fa9e4066Sahrens 673fa9e4066Sahrens #endif /* _SYS_FS_ZFS_H */ 674