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 /* 22*743a77edSAlan Wright * Copyright 2009 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 #ifdef __cplusplus 30fa9e4066Sahrens extern "C" { 31fa9e4066Sahrens #endif 32fa9e4066Sahrens 33fa9e4066Sahrens /* 34fa9e4066Sahrens * Types and constants shared between userland and the kernel. 35fa9e4066Sahrens */ 36fa9e4066Sahrens 37fa9e4066Sahrens /* 38fa9e4066Sahrens * Each dataset can be one of the following types. These constants can be 39fa9e4066Sahrens * combined into masks that can be passed to various functions. 40fa9e4066Sahrens */ 41fa9e4066Sahrens typedef enum { 42fa9e4066Sahrens ZFS_TYPE_FILESYSTEM = 0x1, 43fa9e4066Sahrens ZFS_TYPE_SNAPSHOT = 0x2, 44b1b8ab34Slling ZFS_TYPE_VOLUME = 0x4, 45b1b8ab34Slling ZFS_TYPE_POOL = 0x8 46fa9e4066Sahrens } zfs_type_t; 47fa9e4066Sahrens 48990b4856Slling #define ZFS_TYPE_DATASET \ 49fa9e4066Sahrens (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) 50fa9e4066Sahrens 51fa9e4066Sahrens /* 52990b4856Slling * Dataset properties are identified by these constants and must be added to 53990b4856Slling * the end of this list to ensure that external consumers are not affected 54990b4856Slling * by the change. If you make any changes to this list, be sure to update 5566e2aaccSgw * the property table in usr/src/common/zfs/zfs_prop.c. 56fa9e4066Sahrens */ 57fa9e4066Sahrens typedef enum { 58fa9e4066Sahrens ZFS_PROP_TYPE, 59fa9e4066Sahrens ZFS_PROP_CREATION, 60fa9e4066Sahrens ZFS_PROP_USED, 61fa9e4066Sahrens ZFS_PROP_AVAILABLE, 62fa9e4066Sahrens ZFS_PROP_REFERENCED, 63fa9e4066Sahrens ZFS_PROP_COMPRESSRATIO, 64fa9e4066Sahrens ZFS_PROP_MOUNTED, 65fa9e4066Sahrens ZFS_PROP_ORIGIN, 66fa9e4066Sahrens ZFS_PROP_QUOTA, 67fa9e4066Sahrens ZFS_PROP_RESERVATION, 68fa9e4066Sahrens ZFS_PROP_VOLSIZE, 69fa9e4066Sahrens ZFS_PROP_VOLBLOCKSIZE, 70fa9e4066Sahrens ZFS_PROP_RECORDSIZE, 71fa9e4066Sahrens ZFS_PROP_MOUNTPOINT, 72fa9e4066Sahrens ZFS_PROP_SHARENFS, 73fa9e4066Sahrens ZFS_PROP_CHECKSUM, 74fa9e4066Sahrens ZFS_PROP_COMPRESSION, 75fa9e4066Sahrens ZFS_PROP_ATIME, 76fa9e4066Sahrens ZFS_PROP_DEVICES, 77fa9e4066Sahrens ZFS_PROP_EXEC, 78fa9e4066Sahrens ZFS_PROP_SETUID, 79fa9e4066Sahrens ZFS_PROP_READONLY, 80fa9e4066Sahrens ZFS_PROP_ZONED, 81fa9e4066Sahrens ZFS_PROP_SNAPDIR, 82fa9e4066Sahrens ZFS_PROP_ACLMODE, 83fa9e4066Sahrens ZFS_PROP_ACLINHERIT, 8466e2aaccSgw ZFS_PROP_CREATETXG, /* not exposed to the user */ 8566e2aaccSgw ZFS_PROP_NAME, /* not exposed to the user */ 86e9dbad6fSeschrock ZFS_PROP_CANMOUNT, 8766e2aaccSgw ZFS_PROP_SHAREISCSI, 8866e2aaccSgw ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */ 897b55fa8eSck ZFS_PROP_XATTR, 90d0ad202dSahrens ZFS_PROP_NUMCLONES, /* not exposed to the user */ 91b1b8ab34Slling ZFS_PROP_COPIES, 92e7437265Sahrens ZFS_PROP_VERSION, 93da6c28aaSamw ZFS_PROP_UTF8ONLY, 94da6c28aaSamw ZFS_PROP_NORMALIZE, 95da6c28aaSamw ZFS_PROP_CASE, 96da6c28aaSamw ZFS_PROP_VSCAN, 97da6c28aaSamw ZFS_PROP_NBMAND, 98da6c28aaSamw ZFS_PROP_SHARESMB, 99a9799022Sck ZFS_PROP_REFQUOTA, 100a9799022Sck ZFS_PROP_REFRESERVATION, 101c5904d13Seschrock ZFS_PROP_GUID, 1023baa08fcSek ZFS_PROP_PRIMARYCACHE, 1033baa08fcSek ZFS_PROP_SECONDARYCACHE, 10474e7dc98SMatthew Ahrens ZFS_PROP_USEDSNAP, 10574e7dc98SMatthew Ahrens ZFS_PROP_USEDDS, 10674e7dc98SMatthew Ahrens ZFS_PROP_USEDCHILD, 10774e7dc98SMatthew Ahrens ZFS_PROP_USEDREFRESERV, 10891ebeef5Sahrens ZFS_NUM_PROPS 109fa9e4066Sahrens } zfs_prop_t; 110fa9e4066Sahrens 111990b4856Slling /* 112990b4856Slling * Pool properties are identified by these constants and must be added to the 113b87f3af3Sperrin * end of this list to ensure that external consumers are not affected 114990b4856Slling * by the change. If you make any changes to this list, be sure to update 115990b4856Slling * the property table in usr/src/common/zfs/zpool_prop.c. 116990b4856Slling */ 117990b4856Slling typedef enum { 118990b4856Slling ZPOOL_PROP_NAME, 119990b4856Slling ZPOOL_PROP_SIZE, 120990b4856Slling ZPOOL_PROP_USED, 121990b4856Slling ZPOOL_PROP_AVAILABLE, 122990b4856Slling ZPOOL_PROP_CAPACITY, 123990b4856Slling ZPOOL_PROP_ALTROOT, 124990b4856Slling ZPOOL_PROP_HEALTH, 125990b4856Slling ZPOOL_PROP_GUID, 126990b4856Slling ZPOOL_PROP_VERSION, 127990b4856Slling ZPOOL_PROP_BOOTFS, 128990b4856Slling ZPOOL_PROP_DELEGATION, 129990b4856Slling ZPOOL_PROP_AUTOREPLACE, 1302f8aaab3Seschrock ZPOOL_PROP_CACHEFILE, 1310a4e9518Sgw ZPOOL_PROP_FAILUREMODE, 132d5b5bb25SRich Morris ZPOOL_PROP_LISTSNAPS, 133990b4856Slling ZPOOL_NUM_PROPS 134990b4856Slling } zpool_prop_t; 135b1b8ab34Slling 136990b4856Slling #define ZPROP_CONT -2 137990b4856Slling #define ZPROP_INVAL -1 1383d7072f8Seschrock 139990b4856Slling #define ZPROP_VALUE "value" 140990b4856Slling #define ZPROP_SOURCE "source" 1417f7322feSeschrock 142b1b8ab34Slling typedef enum { 143990b4856Slling ZPROP_SRC_NONE = 0x1, 144990b4856Slling ZPROP_SRC_DEFAULT = 0x2, 145990b4856Slling ZPROP_SRC_TEMPORARY = 0x4, 146990b4856Slling ZPROP_SRC_LOCAL = 0x8, 147990b4856Slling ZPROP_SRC_INHERITED = 0x10 148990b4856Slling } zprop_source_t; 149990b4856Slling 150990b4856Slling #define ZPROP_SRC_ALL 0x1f 151990b4856Slling 152990b4856Slling typedef int (*zprop_func)(int, void *); 153990b4856Slling 1540a48a24eStimh /* 1550a48a24eStimh * Properties to be set on the root file system of a new pool 1560a48a24eStimh * are stuffed into their own nvlist, which is then included in 1570a48a24eStimh * the properties nvlist with the pool properties. 1580a48a24eStimh */ 1590a48a24eStimh #define ZPOOL_ROOTFS_PROPS "root-props-nvl" 1600a48a24eStimh 161990b4856Slling /* 162990b4856Slling * Dataset property functions shared between libzfs and kernel. 163990b4856Slling */ 164990b4856Slling const char *zfs_prop_default_string(zfs_prop_t); 165990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t); 166990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t); 167990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t); 168da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t); 169990b4856Slling const char *zfs_prop_to_name(zfs_prop_t); 170990b4856Slling zfs_prop_t zfs_name_to_prop(const char *); 171990b4856Slling boolean_t zfs_prop_user(const char *); 172990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); 173990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *); 1744853e976Sgw boolean_t zfs_prop_valid_for_type(int, zfs_type_t); 175b1b8ab34Slling 176990b4856Slling /* 177990b4856Slling * Pool property functions shared between libzfs and kernel. 178990b4856Slling */ 179990b4856Slling zpool_prop_t zpool_name_to_prop(const char *); 180990b4856Slling const char *zpool_prop_to_name(zpool_prop_t); 181990b4856Slling const char *zpool_prop_default_string(zpool_prop_t); 182990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t); 183990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t); 184990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **); 185990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *); 186b1b8ab34Slling 187990b4856Slling /* 188990b4856Slling * Definitions for the Delegation. 189990b4856Slling */ 190ecd6cf80Smarks typedef enum { 191ecd6cf80Smarks ZFS_DELEG_WHO_UNKNOWN = 0, 192ecd6cf80Smarks ZFS_DELEG_USER = 'u', 193ecd6cf80Smarks ZFS_DELEG_USER_SETS = 'U', 194ecd6cf80Smarks ZFS_DELEG_GROUP = 'g', 195ecd6cf80Smarks ZFS_DELEG_GROUP_SETS = 'G', 196ecd6cf80Smarks ZFS_DELEG_EVERYONE = 'e', 197ecd6cf80Smarks ZFS_DELEG_EVERYONE_SETS = 'E', 198ecd6cf80Smarks ZFS_DELEG_CREATE = 'c', 199ecd6cf80Smarks ZFS_DELEG_CREATE_SETS = 'C', 200ecd6cf80Smarks ZFS_DELEG_NAMED_SET = 's', 201ecd6cf80Smarks ZFS_DELEG_NAMED_SET_SETS = 'S' 202ecd6cf80Smarks } zfs_deleg_who_type_t; 203ecd6cf80Smarks 204ecd6cf80Smarks typedef enum { 205ecd6cf80Smarks ZFS_DELEG_NONE = 0, 206ecd6cf80Smarks ZFS_DELEG_PERM_LOCAL = 1, 207ecd6cf80Smarks ZFS_DELEG_PERM_DESCENDENT = 2, 208ecd6cf80Smarks ZFS_DELEG_PERM_LOCALDESCENDENT = 3, 209ecd6cf80Smarks ZFS_DELEG_PERM_CREATE = 4 210ecd6cf80Smarks } zfs_deleg_inherit_t; 211ecd6cf80Smarks 212ecd6cf80Smarks #define ZFS_DELEG_PERM_UID "uid" 213ecd6cf80Smarks #define ZFS_DELEG_PERM_GID "gid" 214ecd6cf80Smarks #define ZFS_DELEG_PERM_GROUPS "groups" 215ecd6cf80Smarks 216*743a77edSAlan Wright #define ZFS_SMB_ACL_SRC "src" 217*743a77edSAlan Wright #define ZFS_SMB_ACL_TARGET "target" 218*743a77edSAlan Wright 219a227b7f4Shs typedef enum { 220a227b7f4Shs ZFS_CANMOUNT_OFF = 0, 221a227b7f4Shs ZFS_CANMOUNT_ON = 1, 222a227b7f4Shs ZFS_CANMOUNT_NOAUTO = 2 223a227b7f4Shs } zfs_canmount_type_t; 224a227b7f4Shs 225da6c28aaSamw typedef enum zfs_share_op { 226da6c28aaSamw ZFS_SHARE_NFS = 0, 227da6c28aaSamw ZFS_UNSHARE_NFS = 1, 228da6c28aaSamw ZFS_SHARE_SMB = 2, 229da6c28aaSamw ZFS_UNSHARE_SMB = 3 230da6c28aaSamw } zfs_share_op_t; 231da6c28aaSamw 232*743a77edSAlan Wright typedef enum zfs_smb_acl_op { 233*743a77edSAlan Wright ZFS_SMB_ACL_ADD, 234*743a77edSAlan Wright ZFS_SMB_ACL_REMOVE, 235*743a77edSAlan Wright ZFS_SMB_ACL_RENAME, 236*743a77edSAlan Wright ZFS_SMB_ACL_PURGE 237*743a77edSAlan Wright } zfs_smb_acl_op_t; 238*743a77edSAlan Wright 2393baa08fcSek typedef enum zfs_cache_type { 2403baa08fcSek ZFS_CACHE_NONE = 0, 2413baa08fcSek ZFS_CACHE_METADATA = 1, 2423baa08fcSek ZFS_CACHE_ALL = 2 2433baa08fcSek } zfs_cache_type_t; 2443baa08fcSek 2453baa08fcSek 246eaca9bbdSeschrock /* 24799653d4eSeschrock * On-disk version number. 248eaca9bbdSeschrock */ 249e7437265Sahrens #define SPA_VERSION_1 1ULL 250e7437265Sahrens #define SPA_VERSION_2 2ULL 251e7437265Sahrens #define SPA_VERSION_3 3ULL 252e7437265Sahrens #define SPA_VERSION_4 4ULL 253e7437265Sahrens #define SPA_VERSION_5 5ULL 254e7437265Sahrens #define SPA_VERSION_6 6ULL 255e7437265Sahrens #define SPA_VERSION_7 7ULL 256e7437265Sahrens #define SPA_VERSION_8 8ULL 257da6c28aaSamw #define SPA_VERSION_9 9ULL 258fa94a07fSbrendan #define SPA_VERSION_10 10ULL 259088f3894Sahrens #define SPA_VERSION_11 11ULL 260bb0ade09Sahrens #define SPA_VERSION_12 12ULL 26174e7dc98SMatthew Ahrens #define SPA_VERSION_13 13ULL 262d0f3f37eSMark Shellenbaum #define SPA_VERSION_14 14ULL 263b1b8ab34Slling /* 264e7cbe64fSgw * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk 265b1b8ab34Slling * format change. Go to usr/src/grub/grub-0.95/stage2/{zfs-include/, fsys_zfs*}, 266b1b8ab34Slling * and do the appropriate changes. 267b1b8ab34Slling */ 268d0f3f37eSMark Shellenbaum #define SPA_VERSION SPA_VERSION_14 269d0f3f37eSMark Shellenbaum #define SPA_VERSION_STRING "14" 27044cd46caSbillm 27144cd46caSbillm /* 272e7437265Sahrens * Symbolic names for the changes that caused a SPA_VERSION switch. 27344cd46caSbillm * Used in the code when checking for presence or absence of a feature. 27444cd46caSbillm * Feel free to define multiple symbolic names for each version if there 27544cd46caSbillm * were multiple changes to on-disk structures during that version. 27644cd46caSbillm * 277e7437265Sahrens * NOTE: When checking the current SPA_VERSION in your code, be sure 27844cd46caSbillm * to use spa_version() since it reports the version of the 27944cd46caSbillm * last synced uberblock. Checking the in-flight version can 28044cd46caSbillm * be dangerous in some cases. 28144cd46caSbillm */ 282e7437265Sahrens #define SPA_VERSION_INITIAL SPA_VERSION_1 283e7437265Sahrens #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 284e7437265Sahrens #define SPA_VERSION_SPARES SPA_VERSION_3 285e7437265Sahrens #define SPA_VERSION_RAID6 SPA_VERSION_3 286e7437265Sahrens #define SPA_VERSION_BPLIST_ACCOUNT SPA_VERSION_3 287e7437265Sahrens #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 288e7437265Sahrens #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 289e7437265Sahrens #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 290e7437265Sahrens #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 291e7437265Sahrens #define SPA_VERSION_BOOTFS SPA_VERSION_6 292990b4856Slling #define SPA_VERSION_SLOGS SPA_VERSION_7 293990b4856Slling #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8 294da6c28aaSamw #define SPA_VERSION_FUID SPA_VERSION_9 295a9799022Sck #define SPA_VERSION_REFRESERVATION SPA_VERSION_9 296a9799022Sck #define SPA_VERSION_REFQUOTA SPA_VERSION_9 297a9799022Sck #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9 298fa94a07fSbrendan #define SPA_VERSION_L2CACHE SPA_VERSION_10 299088f3894Sahrens #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11 300088f3894Sahrens #define SPA_VERSION_ORIGIN SPA_VERSION_11 301088f3894Sahrens #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11 302bb0ade09Sahrens #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12 30374e7dc98SMatthew Ahrens #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13 304d0f3f37eSMark Shellenbaum #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14 305e7437265Sahrens 306e7437265Sahrens /* 307e7437265Sahrens * ZPL version - rev'd whenever an incompatible on-disk format change 308e7437265Sahrens * occurs. This is independent of SPA/DMU/ZAP versioning. You must 309e7437265Sahrens * also update the version_table[] and help message in zfs_prop.c. 310e7437265Sahrens * 311e7437265Sahrens * When changing, be sure to teach GRUB how to read the new format! 312e7437265Sahrens * See usr/src/grub/grub-0.95/stage2/{zfs-include/,fsys_zfs*} 313e7437265Sahrens */ 314e7437265Sahrens #define ZPL_VERSION_1 1ULL 315e7437265Sahrens #define ZPL_VERSION_2 2ULL 316da6c28aaSamw #define ZPL_VERSION_3 3ULL 317da6c28aaSamw #define ZPL_VERSION ZPL_VERSION_3 318da6c28aaSamw #define ZPL_VERSION_STRING "3" 319e7437265Sahrens 320e7437265Sahrens #define ZPL_VERSION_INITIAL ZPL_VERSION_1 321e7437265Sahrens #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 322da6c28aaSamw #define ZPL_VERSION_FUID ZPL_VERSION_3 323de8267e0Stimh #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3 324da6c28aaSamw #define ZPL_VERSION_SYSATTR ZPL_VERSION_3 325eaca9bbdSeschrock 326fa9e4066Sahrens /* 327fa9e4066Sahrens * The following are configuration names used in the nvlist describing a pool's 328fa9e4066Sahrens * configuration. 329fa9e4066Sahrens */ 330fa9e4066Sahrens #define ZPOOL_CONFIG_VERSION "version" 331fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_NAME "name" 332fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_STATE "state" 333fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_TXG "txg" 334fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_GUID "pool_guid" 335fa9e4066Sahrens #define ZPOOL_CONFIG_CREATE_TXG "create_txg" 336fa9e4066Sahrens #define ZPOOL_CONFIG_TOP_GUID "top_guid" 337fa9e4066Sahrens #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" 338fa9e4066Sahrens #define ZPOOL_CONFIG_TYPE "type" 339fa9e4066Sahrens #define ZPOOL_CONFIG_CHILDREN "children" 340fa9e4066Sahrens #define ZPOOL_CONFIG_ID "id" 341fa9e4066Sahrens #define ZPOOL_CONFIG_GUID "guid" 342fa9e4066Sahrens #define ZPOOL_CONFIG_PATH "path" 343fa9e4066Sahrens #define ZPOOL_CONFIG_DEVID "devid" 344fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" 345fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" 346fa9e4066Sahrens #define ZPOOL_CONFIG_ASHIFT "ashift" 347fa9e4066Sahrens #define ZPOOL_CONFIG_ASIZE "asize" 348fa9e4066Sahrens #define ZPOOL_CONFIG_DTL "DTL" 349fa9e4066Sahrens #define ZPOOL_CONFIG_STATS "stats" 350afefbcddSeschrock #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" 351ea8dc4b6Seschrock #define ZPOOL_CONFIG_ERRCOUNT "error_count" 352ea8dc4b6Seschrock #define ZPOOL_CONFIG_NOT_PRESENT "not_present" 35399653d4eSeschrock #define ZPOOL_CONFIG_SPARES "spares" 35499653d4eSeschrock #define ZPOOL_CONFIG_IS_SPARE "is_spare" 35599653d4eSeschrock #define ZPOOL_CONFIG_NPARITY "nparity" 35695173954Sek #define ZPOOL_CONFIG_HOSTID "hostid" 35795173954Sek #define ZPOOL_CONFIG_HOSTNAME "hostname" 3583d7072f8Seschrock #define ZPOOL_CONFIG_UNSPARE "unspare" 3593d7072f8Seschrock #define ZPOOL_CONFIG_PHYS_PATH "phys_path" 3608654d025Sperrin #define ZPOOL_CONFIG_IS_LOG "is_log" 361fa94a07fSbrendan #define ZPOOL_CONFIG_L2CACHE "l2cache" 362e14bb325SJeff Bonwick #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */ 363e7cbe64fSgw #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ 364e7cbe64fSgw #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */ 3653d7072f8Seschrock /* 3663d7072f8Seschrock * The persistent vdev state is stored as separate values rather than a single 3673d7072f8Seschrock * 'vdev_state' entry. This is because a device can be in multiple states, such 3683d7072f8Seschrock * as offline and degraded. 3693d7072f8Seschrock */ 3703d7072f8Seschrock #define ZPOOL_CONFIG_OFFLINE "offline" 3713d7072f8Seschrock #define ZPOOL_CONFIG_FAULTED "faulted" 3723d7072f8Seschrock #define ZPOOL_CONFIG_DEGRADED "degraded" 3733d7072f8Seschrock #define ZPOOL_CONFIG_REMOVED "removed" 374fa9e4066Sahrens 375fa9e4066Sahrens #define VDEV_TYPE_ROOT "root" 376fa9e4066Sahrens #define VDEV_TYPE_MIRROR "mirror" 377fa9e4066Sahrens #define VDEV_TYPE_REPLACING "replacing" 378fa9e4066Sahrens #define VDEV_TYPE_RAIDZ "raidz" 379fa9e4066Sahrens #define VDEV_TYPE_DISK "disk" 380fa9e4066Sahrens #define VDEV_TYPE_FILE "file" 381fa9e4066Sahrens #define VDEV_TYPE_MISSING "missing" 38299653d4eSeschrock #define VDEV_TYPE_SPARE "spare" 3838654d025Sperrin #define VDEV_TYPE_LOG "log" 384fa94a07fSbrendan #define VDEV_TYPE_L2CACHE "l2cache" 385fa9e4066Sahrens 386fa9e4066Sahrens /* 387fa9e4066Sahrens * This is needed in userland to report the minimum necessary device size. 388fa9e4066Sahrens */ 389fa9e4066Sahrens #define SPA_MINDEVSIZE (64ULL << 20) 390fa9e4066Sahrens 391fa9e4066Sahrens /* 392fa9e4066Sahrens * The location of the pool configuration repository, shared between kernel and 393fa9e4066Sahrens * userland. 394fa9e4066Sahrens */ 395c5904d13Seschrock #define ZPOOL_CACHE "/etc/zfs/zpool.cache" 396fa9e4066Sahrens 397fa9e4066Sahrens /* 398fa9e4066Sahrens * vdev states are ordered from least to most healthy. 399fa9e4066Sahrens * A vdev that's CANT_OPEN or below is considered unusable. 400fa9e4066Sahrens */ 401fa9e4066Sahrens typedef enum vdev_state { 402fa9e4066Sahrens VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ 403fa9e4066Sahrens VDEV_STATE_CLOSED, /* Not currently open */ 404fa9e4066Sahrens VDEV_STATE_OFFLINE, /* Not allowed to open */ 4053d7072f8Seschrock VDEV_STATE_REMOVED, /* Explicitly removed from system */ 406fa9e4066Sahrens VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ 4073d7072f8Seschrock VDEV_STATE_FAULTED, /* External request to fault device */ 408fa9e4066Sahrens VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ 409fa9e4066Sahrens VDEV_STATE_HEALTHY /* Presumed good */ 410fa9e4066Sahrens } vdev_state_t; 411fa9e4066Sahrens 4123d7072f8Seschrock #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY 4133d7072f8Seschrock 414fa9e4066Sahrens /* 415fa9e4066Sahrens * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field 416fa9e4066Sahrens * of the vdev stats structure uses these constants to distinguish why. 417fa9e4066Sahrens */ 418fa9e4066Sahrens typedef enum vdev_aux { 419fa9e4066Sahrens VDEV_AUX_NONE, /* no error */ 420fa9e4066Sahrens VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ 421fa9e4066Sahrens VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ 422fa9e4066Sahrens VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ 423fa9e4066Sahrens VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ 424fa9e4066Sahrens VDEV_AUX_TOO_SMALL, /* vdev size is too small */ 425eaca9bbdSeschrock VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ 426eaca9bbdSeschrock VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ 42799653d4eSeschrock VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ 4283d7072f8Seschrock VDEV_AUX_SPARED, /* hot spare used in another pool */ 42932b87932Sek VDEV_AUX_ERR_EXCEEDED, /* too many errors */ 430b87f3af3Sperrin VDEV_AUX_IO_FAILURE, /* experienced I/O failure */ 431b87f3af3Sperrin VDEV_AUX_BAD_LOG /* cannot read log chain(s) */ 432fa9e4066Sahrens } vdev_aux_t; 433fa9e4066Sahrens 434fa9e4066Sahrens /* 43546a2abf2Seschrock * pool state. The following states are written to disk as part of the normal 436fa94a07fSbrendan * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining 437fa94a07fSbrendan * states are software abstractions used at various levels to communicate 438fa94a07fSbrendan * pool state. 439fa9e4066Sahrens */ 440fa9e4066Sahrens typedef enum pool_state { 441fa9e4066Sahrens POOL_STATE_ACTIVE = 0, /* In active use */ 442fa9e4066Sahrens POOL_STATE_EXPORTED, /* Explicitly exported */ 443fa9e4066Sahrens POOL_STATE_DESTROYED, /* Explicitly destroyed */ 44499653d4eSeschrock POOL_STATE_SPARE, /* Reserved for hot spare use */ 445fa94a07fSbrendan POOL_STATE_L2CACHE, /* Level 2 ARC device */ 446fa9e4066Sahrens POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ 44746a2abf2Seschrock POOL_STATE_UNAVAIL, /* Internal libzfs state */ 44846a2abf2Seschrock POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ 449fa9e4066Sahrens } pool_state_t; 450fa9e4066Sahrens 451fa9e4066Sahrens /* 452fa9e4066Sahrens * Scrub types. 453fa9e4066Sahrens */ 454fa9e4066Sahrens typedef enum pool_scrub_type { 455fa9e4066Sahrens POOL_SCRUB_NONE, 456fa9e4066Sahrens POOL_SCRUB_RESILVER, 457fa9e4066Sahrens POOL_SCRUB_EVERYTHING, 458fa9e4066Sahrens POOL_SCRUB_TYPES 459fa9e4066Sahrens } pool_scrub_type_t; 460fa9e4066Sahrens 461fa9e4066Sahrens /* 462fa9e4066Sahrens * ZIO types. Needed to interpret vdev statistics below. 463fa9e4066Sahrens */ 464fa9e4066Sahrens typedef enum zio_type { 465fa9e4066Sahrens ZIO_TYPE_NULL = 0, 466fa9e4066Sahrens ZIO_TYPE_READ, 467fa9e4066Sahrens ZIO_TYPE_WRITE, 468fa9e4066Sahrens ZIO_TYPE_FREE, 469fa9e4066Sahrens ZIO_TYPE_CLAIM, 470fa9e4066Sahrens ZIO_TYPE_IOCTL, 471fa9e4066Sahrens ZIO_TYPES 472fa9e4066Sahrens } zio_type_t; 473fa9e4066Sahrens 474fa9e4066Sahrens /* 475fa9e4066Sahrens * Vdev statistics. Note: all fields should be 64-bit because this 476fa9e4066Sahrens * is passed between kernel and userland as an nvlist uint64 array. 477fa9e4066Sahrens */ 478fa9e4066Sahrens typedef struct vdev_stat { 479fa9e4066Sahrens hrtime_t vs_timestamp; /* time since vdev load */ 480fa9e4066Sahrens uint64_t vs_state; /* vdev state */ 481fa9e4066Sahrens uint64_t vs_aux; /* see vdev_aux_t */ 482fa9e4066Sahrens uint64_t vs_alloc; /* space allocated */ 483fa9e4066Sahrens uint64_t vs_space; /* total capacity */ 48499653d4eSeschrock uint64_t vs_dspace; /* deflated capacity */ 4852a79c5feSlling uint64_t vs_rsize; /* replaceable dev size */ 486fa9e4066Sahrens uint64_t vs_ops[ZIO_TYPES]; /* operation count */ 487fa9e4066Sahrens uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */ 488fa9e4066Sahrens uint64_t vs_read_errors; /* read errors */ 489fa9e4066Sahrens uint64_t vs_write_errors; /* write errors */ 490fa9e4066Sahrens uint64_t vs_checksum_errors; /* checksum errors */ 491fa9e4066Sahrens uint64_t vs_self_healed; /* self-healed bytes */ 492fa9e4066Sahrens uint64_t vs_scrub_type; /* pool_scrub_type_t */ 493fa9e4066Sahrens uint64_t vs_scrub_complete; /* completed? */ 494fa9e4066Sahrens uint64_t vs_scrub_examined; /* bytes examined; top */ 495fa9e4066Sahrens uint64_t vs_scrub_repaired; /* bytes repaired; leaf */ 496fa9e4066Sahrens uint64_t vs_scrub_errors; /* errors during scrub */ 497fa9e4066Sahrens uint64_t vs_scrub_start; /* UTC scrub start time */ 498fa9e4066Sahrens uint64_t vs_scrub_end; /* UTC scrub end time */ 499fa9e4066Sahrens } vdev_stat_t; 500fa9e4066Sahrens 501e7cbe64fSgw #define ZVOL_DRIVER "zvol" 502fa9e4066Sahrens #define ZFS_DRIVER "zfs" 503fa9e4066Sahrens #define ZFS_DEV "/dev/zfs" 504fa9e4066Sahrens 505fa9e4066Sahrens /* 506fa9e4066Sahrens * zvol paths. Irritatingly, the devfsadm interfaces want all these 507fa9e4066Sahrens * paths without the /dev prefix, but for some things, we want the 508fa9e4066Sahrens * /dev prefix. Below are the names without /dev. 509fa9e4066Sahrens */ 510fa9e4066Sahrens #define ZVOL_DEV_DIR "zvol/dsk" 511fa9e4066Sahrens #define ZVOL_RDEV_DIR "zvol/rdsk" 512fa9e4066Sahrens 513fa9e4066Sahrens /* 514fa9e4066Sahrens * And here are the things we need with /dev, etc. in front of them. 515fa9e4066Sahrens */ 516fa9e4066Sahrens #define ZVOL_PSEUDO_DEV "/devices/pseudo/zvol@0:" 517e7cbe64fSgw #define ZVOL_FULL_DEV_DIR "/dev/" ZVOL_DEV_DIR "/" 518fa9e4066Sahrens 519fa9e4066Sahrens #define ZVOL_PROP_NAME "name" 520fa9e4066Sahrens 521fa9e4066Sahrens /* 522fa9e4066Sahrens * /dev/zfs ioctl numbers. 523fa9e4066Sahrens */ 524fa9e4066Sahrens #define ZFS_IOC ('Z' << 8) 525fa9e4066Sahrens 526fa9e4066Sahrens typedef enum zfs_ioc { 527fa9e4066Sahrens ZFS_IOC_POOL_CREATE = ZFS_IOC, 528fa9e4066Sahrens ZFS_IOC_POOL_DESTROY, 529fa9e4066Sahrens ZFS_IOC_POOL_IMPORT, 530fa9e4066Sahrens ZFS_IOC_POOL_EXPORT, 531fa9e4066Sahrens ZFS_IOC_POOL_CONFIGS, 532fa9e4066Sahrens ZFS_IOC_POOL_STATS, 533fa9e4066Sahrens ZFS_IOC_POOL_TRYIMPORT, 534fa9e4066Sahrens ZFS_IOC_POOL_SCRUB, 535fa9e4066Sahrens ZFS_IOC_POOL_FREEZE, 536eaca9bbdSeschrock ZFS_IOC_POOL_UPGRADE, 53706eeb2adSek ZFS_IOC_POOL_GET_HISTORY, 538fa9e4066Sahrens ZFS_IOC_VDEV_ADD, 539fa9e4066Sahrens ZFS_IOC_VDEV_REMOVE, 5403d7072f8Seschrock ZFS_IOC_VDEV_SET_STATE, 541fa9e4066Sahrens ZFS_IOC_VDEV_ATTACH, 542fa9e4066Sahrens ZFS_IOC_VDEV_DETACH, 543c67d9675Seschrock ZFS_IOC_VDEV_SETPATH, 544fa9e4066Sahrens ZFS_IOC_OBJSET_STATS, 545de8267e0Stimh ZFS_IOC_OBJSET_ZPLPROPS, 546fa9e4066Sahrens ZFS_IOC_DATASET_LIST_NEXT, 547fa9e4066Sahrens ZFS_IOC_SNAPSHOT_LIST_NEXT, 548fa9e4066Sahrens ZFS_IOC_SET_PROP, 549fa9e4066Sahrens ZFS_IOC_CREATE_MINOR, 550fa9e4066Sahrens ZFS_IOC_REMOVE_MINOR, 551fa9e4066Sahrens ZFS_IOC_CREATE, 552fa9e4066Sahrens ZFS_IOC_DESTROY, 553fa9e4066Sahrens ZFS_IOC_ROLLBACK, 554fa9e4066Sahrens ZFS_IOC_RENAME, 5553cb34c60Sahrens ZFS_IOC_RECV, 5563cb34c60Sahrens ZFS_IOC_SEND, 557ea8dc4b6Seschrock ZFS_IOC_INJECT_FAULT, 558ea8dc4b6Seschrock ZFS_IOC_CLEAR_FAULT, 559ea8dc4b6Seschrock ZFS_IOC_INJECT_LIST_NEXT, 560ea8dc4b6Seschrock ZFS_IOC_ERROR_LOG, 561ea8dc4b6Seschrock ZFS_IOC_CLEAR, 5621d452cf5Sahrens ZFS_IOC_PROMOTE, 5631d452cf5Sahrens ZFS_IOC_DESTROY_SNAPS, 56455434c77Sek ZFS_IOC_SNAPSHOT, 56555434c77Sek ZFS_IOC_DSOBJ_TO_DSNAME, 566b1b8ab34Slling ZFS_IOC_OBJ_TO_PATH, 567b1b8ab34Slling ZFS_IOC_POOL_SET_PROPS, 568ecd6cf80Smarks ZFS_IOC_POOL_GET_PROPS, 569ecd6cf80Smarks ZFS_IOC_SET_FSACL, 570ecd6cf80Smarks ZFS_IOC_GET_FSACL, 571ecd6cf80Smarks ZFS_IOC_ISCSI_PERM_CHECK, 572e45ce728Sahrens ZFS_IOC_SHARE, 573*743a77edSAlan Wright ZFS_IOC_INHERIT_PROP, 574*743a77edSAlan Wright ZFS_IOC_SMB_ACL 575fa9e4066Sahrens } zfs_ioc_t; 576fa9e4066Sahrens 577ea8dc4b6Seschrock /* 578ea8dc4b6Seschrock * Internal SPA load state. Used by FMA diagnosis engine. 579ea8dc4b6Seschrock */ 580ea8dc4b6Seschrock typedef enum { 581ea8dc4b6Seschrock SPA_LOAD_NONE, /* no load in progress */ 582ea8dc4b6Seschrock SPA_LOAD_OPEN, /* normal open */ 583ea8dc4b6Seschrock SPA_LOAD_IMPORT, /* import in progress */ 584ea8dc4b6Seschrock SPA_LOAD_TRYIMPORT /* tryimport in progress */ 585ea8dc4b6Seschrock } spa_load_state_t; 586ea8dc4b6Seschrock 587e9dbad6fSeschrock /* 588e9dbad6fSeschrock * Bookmark name values. 589e9dbad6fSeschrock */ 59055434c77Sek #define ZPOOL_ERR_LIST "error list" 591e9dbad6fSeschrock #define ZPOOL_ERR_DATASET "dataset" 592e9dbad6fSeschrock #define ZPOOL_ERR_OBJECT "object" 593e9dbad6fSeschrock 59406eeb2adSek #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) 59506eeb2adSek 59606eeb2adSek /* 59706eeb2adSek * The following are names used in the nvlist describing 59806eeb2adSek * the pool's history log. 59906eeb2adSek */ 60006eeb2adSek #define ZPOOL_HIST_RECORD "history record" 60106eeb2adSek #define ZPOOL_HIST_TIME "history time" 60206eeb2adSek #define ZPOOL_HIST_CMD "history command" 603ecd6cf80Smarks #define ZPOOL_HIST_WHO "history who" 604ecd6cf80Smarks #define ZPOOL_HIST_ZONE "history zone" 605ecd6cf80Smarks #define ZPOOL_HIST_HOST "history hostname" 606ecd6cf80Smarks #define ZPOOL_HIST_TXG "history txg" 607ecd6cf80Smarks #define ZPOOL_HIST_INT_EVENT "history internal event" 608ecd6cf80Smarks #define ZPOOL_HIST_INT_STR "history internal str" 60906eeb2adSek 6103d7072f8Seschrock /* 6113d7072f8Seschrock * Flags for ZFS_IOC_VDEV_SET_STATE 6123d7072f8Seschrock */ 6133d7072f8Seschrock #define ZFS_ONLINE_CHECKREMOVE 0x1 6143d7072f8Seschrock #define ZFS_ONLINE_UNSPARE 0x2 6153d7072f8Seschrock #define ZFS_ONLINE_FORCEFAULT 0x4 6163d7072f8Seschrock #define ZFS_OFFLINE_TEMPORARY 0x1 6173d7072f8Seschrock 6183d7072f8Seschrock /* 6193d7072f8Seschrock * Sysevent payload members. ZFS will generate the following sysevents with the 6203d7072f8Seschrock * given payloads: 6213d7072f8Seschrock * 6223d7072f8Seschrock * ESC_ZFS_RESILVER_START 6233d7072f8Seschrock * ESC_ZFS_RESILVER_END 6243d7072f8Seschrock * ESC_ZFS_POOL_DESTROY 6253d7072f8Seschrock * 6263d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 6273d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 6283d7072f8Seschrock * 6293d7072f8Seschrock * ESC_ZFS_VDEV_REMOVE 6303d7072f8Seschrock * ESC_ZFS_VDEV_CLEAR 6313d7072f8Seschrock * ESC_ZFS_VDEV_CHECK 6323d7072f8Seschrock * 6333d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 6343d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 6353d7072f8Seschrock * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) 6363d7072f8Seschrock * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 6373d7072f8Seschrock */ 6383d7072f8Seschrock #define ZFS_EV_POOL_NAME "pool_name" 6393d7072f8Seschrock #define ZFS_EV_POOL_GUID "pool_guid" 6403d7072f8Seschrock #define ZFS_EV_VDEV_PATH "vdev_path" 6413d7072f8Seschrock #define ZFS_EV_VDEV_GUID "vdev_guid" 6423d7072f8Seschrock 643088f3894Sahrens /* 644088f3894Sahrens * Note: This is encoded on-disk, so new events must be added to the 645088f3894Sahrens * end, and unused events can not be removed. Be sure to edit 646088f3894Sahrens * zpool_main.c: hist_event_table[]. 647088f3894Sahrens */ 648ecd6cf80Smarks typedef enum history_internal_events { 649ecd6cf80Smarks LOG_NO_EVENT = 0, 650ecd6cf80Smarks LOG_POOL_CREATE, 651ecd6cf80Smarks LOG_POOL_VDEV_ADD, 652ecd6cf80Smarks LOG_POOL_REMOVE, 653ecd6cf80Smarks LOG_POOL_DESTROY, 654ecd6cf80Smarks LOG_POOL_EXPORT, 655ecd6cf80Smarks LOG_POOL_IMPORT, 656ecd6cf80Smarks LOG_POOL_VDEV_ATTACH, 657ecd6cf80Smarks LOG_POOL_VDEV_REPLACE, 658ecd6cf80Smarks LOG_POOL_VDEV_DETACH, 659ecd6cf80Smarks LOG_POOL_VDEV_ONLINE, 660ecd6cf80Smarks LOG_POOL_VDEV_OFFLINE, 661ecd6cf80Smarks LOG_POOL_UPGRADE, 662ecd6cf80Smarks LOG_POOL_CLEAR, 663ecd6cf80Smarks LOG_POOL_SCRUB, 664ecd6cf80Smarks LOG_POOL_PROPSET, 665ecd6cf80Smarks LOG_DS_CREATE, 666ecd6cf80Smarks LOG_DS_CLONE, 667ecd6cf80Smarks LOG_DS_DESTROY, 668ecd6cf80Smarks LOG_DS_DESTROY_BEGIN, 669ecd6cf80Smarks LOG_DS_INHERIT, 670ecd6cf80Smarks LOG_DS_PROPSET, 671ecd6cf80Smarks LOG_DS_QUOTA, 672ecd6cf80Smarks LOG_DS_PERM_UPDATE, 673ecd6cf80Smarks LOG_DS_PERM_REMOVE, 674ecd6cf80Smarks LOG_DS_PERM_WHO_REMOVE, 675ecd6cf80Smarks LOG_DS_PROMOTE, 676ecd6cf80Smarks LOG_DS_RECEIVE, 677ecd6cf80Smarks LOG_DS_RENAME, 678ecd6cf80Smarks LOG_DS_RESERVATION, 679ecd6cf80Smarks LOG_DS_REPLAY_INC_SYNC, 680ecd6cf80Smarks LOG_DS_REPLAY_FULL_SYNC, 681ecd6cf80Smarks LOG_DS_ROLLBACK, 682ecd6cf80Smarks LOG_DS_SNAPSHOT, 683e7437265Sahrens LOG_DS_UPGRADE, 684a9799022Sck LOG_DS_REFQUOTA, 685a9799022Sck LOG_DS_REFRESERV, 686088f3894Sahrens LOG_POOL_SCRUB_DONE, 687ecd6cf80Smarks LOG_END 688ecd6cf80Smarks } history_internal_events_t; 689ecd6cf80Smarks 690fa9e4066Sahrens #ifdef __cplusplus 691fa9e4066Sahrens } 692fa9e4066Sahrens #endif 693fa9e4066Sahrens 694fa9e4066Sahrens #endif /* _SYS_FS_ZFS_H */ 695