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 /* 2239c23413Seschrock * Copyright 2007 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 50*990b4856Slling #define ZFS_TYPE_DATASET \ 51fa9e4066Sahrens (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) 52fa9e4066Sahrens 53fa9e4066Sahrens /* 54*990b4856Slling * Dataset properties are identified by these constants and must be added to 55*990b4856Slling * the end of this list to ensure that external consumers are not affected 56*990b4856Slling * 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, 9591ebeef5Sahrens ZFS_NUM_PROPS 96fa9e4066Sahrens } zfs_prop_t; 97fa9e4066Sahrens 98*990b4856Slling /* 99*990b4856Slling * Pool properties are identified by these constants and must be added to the 100*990b4856Slling * end of this list to ensure that external conumsers are not affected 101*990b4856Slling * by the change. If you make any changes to this list, be sure to update 102*990b4856Slling * the property table in usr/src/common/zfs/zpool_prop.c. 103*990b4856Slling */ 104*990b4856Slling typedef enum { 105*990b4856Slling ZPOOL_PROP_NAME, 106*990b4856Slling ZPOOL_PROP_SIZE, 107*990b4856Slling ZPOOL_PROP_USED, 108*990b4856Slling ZPOOL_PROP_AVAILABLE, 109*990b4856Slling ZPOOL_PROP_CAPACITY, 110*990b4856Slling ZPOOL_PROP_ALTROOT, 111*990b4856Slling ZPOOL_PROP_HEALTH, 112*990b4856Slling ZPOOL_PROP_GUID, 113*990b4856Slling ZPOOL_PROP_VERSION, 114*990b4856Slling ZPOOL_PROP_BOOTFS, 115*990b4856Slling ZPOOL_PROP_DELEGATION, 116*990b4856Slling ZPOOL_PROP_AUTOREPLACE, 117*990b4856Slling ZPOOL_PROP_TEMPORARY, 118*990b4856Slling ZPOOL_NUM_PROPS 119*990b4856Slling } zpool_prop_t; 120b1b8ab34Slling 121*990b4856Slling #define ZPROP_CONT -2 122*990b4856Slling #define ZPROP_INVAL -1 1233d7072f8Seschrock 124*990b4856Slling #define ZPROP_VALUE "value" 125*990b4856Slling #define ZPROP_SOURCE "source" 1267f7322feSeschrock 127b1b8ab34Slling typedef enum { 128*990b4856Slling ZPROP_SRC_NONE = 0x1, 129*990b4856Slling ZPROP_SRC_DEFAULT = 0x2, 130*990b4856Slling ZPROP_SRC_TEMPORARY = 0x4, 131*990b4856Slling ZPROP_SRC_LOCAL = 0x8, 132*990b4856Slling ZPROP_SRC_INHERITED = 0x10 133*990b4856Slling } zprop_source_t; 134*990b4856Slling 135*990b4856Slling #define ZPROP_SRC_ALL 0x1f 136*990b4856Slling 137*990b4856Slling typedef int (*zprop_func)(int, void *); 138*990b4856Slling 139*990b4856Slling /* 140*990b4856Slling * Dataset property functions shared between libzfs and kernel. 141*990b4856Slling */ 142*990b4856Slling const char *zfs_prop_default_string(zfs_prop_t); 143*990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t); 144*990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t); 145*990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t); 146*990b4856Slling const char *zfs_prop_to_name(zfs_prop_t); 147*990b4856Slling zfs_prop_t zfs_name_to_prop(const char *); 148*990b4856Slling boolean_t zfs_prop_user(const char *); 149*990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); 150*990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *); 151b1b8ab34Slling 152*990b4856Slling /* 153*990b4856Slling * Pool property functions shared between libzfs and kernel. 154*990b4856Slling */ 155*990b4856Slling zpool_prop_t zpool_name_to_prop(const char *); 156*990b4856Slling const char *zpool_prop_to_name(zpool_prop_t); 157*990b4856Slling const char *zpool_prop_default_string(zpool_prop_t); 158*990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t); 159*990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t); 160*990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **); 161*990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *); 162b1b8ab34Slling 163*990b4856Slling /* 164*990b4856Slling * Definitions for the Delegation. 165*990b4856Slling */ 166ecd6cf80Smarks typedef enum { 167ecd6cf80Smarks ZFS_DELEG_WHO_UNKNOWN = 0, 168ecd6cf80Smarks ZFS_DELEG_USER = 'u', 169ecd6cf80Smarks ZFS_DELEG_USER_SETS = 'U', 170ecd6cf80Smarks ZFS_DELEG_GROUP = 'g', 171ecd6cf80Smarks ZFS_DELEG_GROUP_SETS = 'G', 172ecd6cf80Smarks ZFS_DELEG_EVERYONE = 'e', 173ecd6cf80Smarks ZFS_DELEG_EVERYONE_SETS = 'E', 174ecd6cf80Smarks ZFS_DELEG_CREATE = 'c', 175ecd6cf80Smarks ZFS_DELEG_CREATE_SETS = 'C', 176ecd6cf80Smarks ZFS_DELEG_NAMED_SET = 's', 177ecd6cf80Smarks ZFS_DELEG_NAMED_SET_SETS = 'S' 178ecd6cf80Smarks } zfs_deleg_who_type_t; 179ecd6cf80Smarks 180ecd6cf80Smarks typedef enum { 181ecd6cf80Smarks ZFS_DELEG_NONE = 0, 182ecd6cf80Smarks ZFS_DELEG_PERM_LOCAL = 1, 183ecd6cf80Smarks ZFS_DELEG_PERM_DESCENDENT = 2, 184ecd6cf80Smarks ZFS_DELEG_PERM_LOCALDESCENDENT = 3, 185ecd6cf80Smarks ZFS_DELEG_PERM_CREATE = 4 186ecd6cf80Smarks } zfs_deleg_inherit_t; 187ecd6cf80Smarks 188ecd6cf80Smarks #define ZFS_DELEG_PERM_UID "uid" 189ecd6cf80Smarks #define ZFS_DELEG_PERM_GID "gid" 190ecd6cf80Smarks #define ZFS_DELEG_PERM_GROUPS "groups" 191ecd6cf80Smarks 192eaca9bbdSeschrock /* 19399653d4eSeschrock * On-disk version number. 194eaca9bbdSeschrock */ 195e7437265Sahrens #define SPA_VERSION_1 1ULL 196e7437265Sahrens #define SPA_VERSION_2 2ULL 197e7437265Sahrens #define SPA_VERSION_3 3ULL 198e7437265Sahrens #define SPA_VERSION_4 4ULL 199e7437265Sahrens #define SPA_VERSION_5 5ULL 200e7437265Sahrens #define SPA_VERSION_6 6ULL 201e7437265Sahrens #define SPA_VERSION_7 7ULL 202e7437265Sahrens #define SPA_VERSION_8 8ULL 203b1b8ab34Slling /* 204e7437265Sahrens * When bumping up SPA_VERSION, make sure GRUB ZFS understand the on-disk 205b1b8ab34Slling * format change. Go to usr/src/grub/grub-0.95/stage2/{zfs-include/, fsys_zfs*}, 206b1b8ab34Slling * and do the appropriate changes. 207b1b8ab34Slling */ 208e7437265Sahrens #define SPA_VERSION SPA_VERSION_8 209e7437265Sahrens #define SPA_VERSION_STRING "8" 21044cd46caSbillm 21144cd46caSbillm /* 212e7437265Sahrens * Symbolic names for the changes that caused a SPA_VERSION switch. 21344cd46caSbillm * Used in the code when checking for presence or absence of a feature. 21444cd46caSbillm * Feel free to define multiple symbolic names for each version if there 21544cd46caSbillm * were multiple changes to on-disk structures during that version. 21644cd46caSbillm * 217e7437265Sahrens * NOTE: When checking the current SPA_VERSION in your code, be sure 21844cd46caSbillm * to use spa_version() since it reports the version of the 21944cd46caSbillm * last synced uberblock. Checking the in-flight version can 22044cd46caSbillm * be dangerous in some cases. 22144cd46caSbillm */ 222e7437265Sahrens #define SPA_VERSION_INITIAL SPA_VERSION_1 223e7437265Sahrens #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 224e7437265Sahrens #define SPA_VERSION_SPARES SPA_VERSION_3 225e7437265Sahrens #define SPA_VERSION_RAID6 SPA_VERSION_3 226e7437265Sahrens #define SPA_VERSION_BPLIST_ACCOUNT SPA_VERSION_3 227e7437265Sahrens #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 228e7437265Sahrens #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 229e7437265Sahrens #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 230e7437265Sahrens #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 231e7437265Sahrens #define SPA_VERSION_BOOTFS SPA_VERSION_6 232*990b4856Slling #define SPA_VERSION_SLOGS SPA_VERSION_7 233*990b4856Slling #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8 234e7437265Sahrens 235e7437265Sahrens /* 236e7437265Sahrens * ZPL version - rev'd whenever an incompatible on-disk format change 237e7437265Sahrens * occurs. This is independent of SPA/DMU/ZAP versioning. You must 238e7437265Sahrens * also update the version_table[] and help message in zfs_prop.c. 239e7437265Sahrens * 240e7437265Sahrens * When changing, be sure to teach GRUB how to read the new format! 241e7437265Sahrens * See usr/src/grub/grub-0.95/stage2/{zfs-include/,fsys_zfs*} 242e7437265Sahrens */ 243e7437265Sahrens #define ZPL_VERSION_1 1ULL 244e7437265Sahrens #define ZPL_VERSION_2 2ULL 245e7437265Sahrens #define ZPL_VERSION ZPL_VERSION_2 246e7437265Sahrens #define ZPL_VERSION_STRING "2" 247e7437265Sahrens 248e7437265Sahrens #define ZPL_VERSION_INITIAL ZPL_VERSION_1 249e7437265Sahrens #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 250eaca9bbdSeschrock 251fa9e4066Sahrens /* 252fa9e4066Sahrens * The following are configuration names used in the nvlist describing a pool's 253fa9e4066Sahrens * configuration. 254fa9e4066Sahrens */ 255fa9e4066Sahrens #define ZPOOL_CONFIG_VERSION "version" 256fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_NAME "name" 257fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_STATE "state" 258fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_TXG "txg" 259fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_GUID "pool_guid" 260fa9e4066Sahrens #define ZPOOL_CONFIG_CREATE_TXG "create_txg" 261fa9e4066Sahrens #define ZPOOL_CONFIG_TOP_GUID "top_guid" 262fa9e4066Sahrens #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" 263fa9e4066Sahrens #define ZPOOL_CONFIG_TYPE "type" 264fa9e4066Sahrens #define ZPOOL_CONFIG_CHILDREN "children" 265fa9e4066Sahrens #define ZPOOL_CONFIG_ID "id" 266fa9e4066Sahrens #define ZPOOL_CONFIG_GUID "guid" 267fa9e4066Sahrens #define ZPOOL_CONFIG_PATH "path" 268fa9e4066Sahrens #define ZPOOL_CONFIG_DEVID "devid" 269fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" 270fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" 271fa9e4066Sahrens #define ZPOOL_CONFIG_ASHIFT "ashift" 272fa9e4066Sahrens #define ZPOOL_CONFIG_ASIZE "asize" 273fa9e4066Sahrens #define ZPOOL_CONFIG_DTL "DTL" 274fa9e4066Sahrens #define ZPOOL_CONFIG_STATS "stats" 275afefbcddSeschrock #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" 276ea8dc4b6Seschrock #define ZPOOL_CONFIG_ERRCOUNT "error_count" 277ea8dc4b6Seschrock #define ZPOOL_CONFIG_NOT_PRESENT "not_present" 27899653d4eSeschrock #define ZPOOL_CONFIG_SPARES "spares" 27999653d4eSeschrock #define ZPOOL_CONFIG_IS_SPARE "is_spare" 28099653d4eSeschrock #define ZPOOL_CONFIG_NPARITY "nparity" 28195173954Sek #define ZPOOL_CONFIG_HOSTID "hostid" 28295173954Sek #define ZPOOL_CONFIG_HOSTNAME "hostname" 28395173954Sek #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ 2843d7072f8Seschrock #define ZPOOL_CONFIG_UNSPARE "unspare" 2853d7072f8Seschrock #define ZPOOL_CONFIG_PHYS_PATH "phys_path" 2868654d025Sperrin #define ZPOOL_CONFIG_IS_LOG "is_log" 2873d7072f8Seschrock /* 2883d7072f8Seschrock * The persistent vdev state is stored as separate values rather than a single 2893d7072f8Seschrock * 'vdev_state' entry. This is because a device can be in multiple states, such 2903d7072f8Seschrock * as offline and degraded. 2913d7072f8Seschrock */ 2923d7072f8Seschrock #define ZPOOL_CONFIG_OFFLINE "offline" 2933d7072f8Seschrock #define ZPOOL_CONFIG_FAULTED "faulted" 2943d7072f8Seschrock #define ZPOOL_CONFIG_DEGRADED "degraded" 2953d7072f8Seschrock #define ZPOOL_CONFIG_REMOVED "removed" 296fa9e4066Sahrens 297fa9e4066Sahrens #define VDEV_TYPE_ROOT "root" 298fa9e4066Sahrens #define VDEV_TYPE_MIRROR "mirror" 299fa9e4066Sahrens #define VDEV_TYPE_REPLACING "replacing" 300fa9e4066Sahrens #define VDEV_TYPE_RAIDZ "raidz" 301fa9e4066Sahrens #define VDEV_TYPE_DISK "disk" 302fa9e4066Sahrens #define VDEV_TYPE_FILE "file" 303fa9e4066Sahrens #define VDEV_TYPE_MISSING "missing" 30499653d4eSeschrock #define VDEV_TYPE_SPARE "spare" 3058654d025Sperrin #define VDEV_TYPE_LOG "log" 306fa9e4066Sahrens 307fa9e4066Sahrens /* 308fa9e4066Sahrens * This is needed in userland to report the minimum necessary device size. 309fa9e4066Sahrens */ 310fa9e4066Sahrens #define SPA_MINDEVSIZE (64ULL << 20) 311fa9e4066Sahrens 312fa9e4066Sahrens /* 313fa9e4066Sahrens * The location of the pool configuration repository, shared between kernel and 314fa9e4066Sahrens * userland. 315fa9e4066Sahrens */ 316fa9e4066Sahrens #define ZPOOL_CACHE_DIR "/etc/zfs" 317fa9e4066Sahrens #define ZPOOL_CACHE_FILE "zpool.cache" 318fa9e4066Sahrens #define ZPOOL_CACHE_TMP ".zpool.cache" 319fa9e4066Sahrens 320fa9e4066Sahrens #define ZPOOL_CACHE ZPOOL_CACHE_DIR "/" ZPOOL_CACHE_FILE 321fa9e4066Sahrens 322fa9e4066Sahrens /* 323fa9e4066Sahrens * vdev states are ordered from least to most healthy. 324fa9e4066Sahrens * A vdev that's CANT_OPEN or below is considered unusable. 325fa9e4066Sahrens */ 326fa9e4066Sahrens typedef enum vdev_state { 327fa9e4066Sahrens VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ 328fa9e4066Sahrens VDEV_STATE_CLOSED, /* Not currently open */ 329fa9e4066Sahrens VDEV_STATE_OFFLINE, /* Not allowed to open */ 3303d7072f8Seschrock VDEV_STATE_REMOVED, /* Explicitly removed from system */ 331fa9e4066Sahrens VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ 3323d7072f8Seschrock VDEV_STATE_FAULTED, /* External request to fault device */ 333fa9e4066Sahrens VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ 334fa9e4066Sahrens VDEV_STATE_HEALTHY /* Presumed good */ 335fa9e4066Sahrens } vdev_state_t; 336fa9e4066Sahrens 3373d7072f8Seschrock #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY 3383d7072f8Seschrock 339fa9e4066Sahrens /* 340fa9e4066Sahrens * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field 341fa9e4066Sahrens * of the vdev stats structure uses these constants to distinguish why. 342fa9e4066Sahrens */ 343fa9e4066Sahrens typedef enum vdev_aux { 344fa9e4066Sahrens VDEV_AUX_NONE, /* no error */ 345fa9e4066Sahrens VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ 346fa9e4066Sahrens VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ 347fa9e4066Sahrens VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ 348fa9e4066Sahrens VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ 349fa9e4066Sahrens VDEV_AUX_TOO_SMALL, /* vdev size is too small */ 350eaca9bbdSeschrock VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ 351eaca9bbdSeschrock VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ 35299653d4eSeschrock VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ 3533d7072f8Seschrock VDEV_AUX_SPARED, /* hot spare used in another pool */ 3543d7072f8Seschrock VDEV_AUX_ERR_EXCEEDED /* too many errors */ 355fa9e4066Sahrens } vdev_aux_t; 356fa9e4066Sahrens 357fa9e4066Sahrens /* 35846a2abf2Seschrock * pool state. The following states are written to disk as part of the normal 35999653d4eSeschrock * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE. The remaining states are 36046a2abf2Seschrock * software abstractions used at various levels to communicate pool state. 361fa9e4066Sahrens */ 362fa9e4066Sahrens typedef enum pool_state { 363fa9e4066Sahrens POOL_STATE_ACTIVE = 0, /* In active use */ 364fa9e4066Sahrens POOL_STATE_EXPORTED, /* Explicitly exported */ 365fa9e4066Sahrens POOL_STATE_DESTROYED, /* Explicitly destroyed */ 36699653d4eSeschrock POOL_STATE_SPARE, /* Reserved for hot spare use */ 367fa9e4066Sahrens POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ 36846a2abf2Seschrock POOL_STATE_UNAVAIL, /* Internal libzfs state */ 36946a2abf2Seschrock POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ 370fa9e4066Sahrens } pool_state_t; 371fa9e4066Sahrens 372fa9e4066Sahrens /* 373fa9e4066Sahrens * Scrub types. 374fa9e4066Sahrens */ 375fa9e4066Sahrens typedef enum pool_scrub_type { 376fa9e4066Sahrens POOL_SCRUB_NONE, 377fa9e4066Sahrens POOL_SCRUB_RESILVER, 378fa9e4066Sahrens POOL_SCRUB_EVERYTHING, 379fa9e4066Sahrens POOL_SCRUB_TYPES 380fa9e4066Sahrens } pool_scrub_type_t; 381fa9e4066Sahrens 382fa9e4066Sahrens /* 383fa9e4066Sahrens * ZIO types. Needed to interpret vdev statistics below. 384fa9e4066Sahrens */ 385fa9e4066Sahrens typedef enum zio_type { 386fa9e4066Sahrens ZIO_TYPE_NULL = 0, 387fa9e4066Sahrens ZIO_TYPE_READ, 388fa9e4066Sahrens ZIO_TYPE_WRITE, 389fa9e4066Sahrens ZIO_TYPE_FREE, 390fa9e4066Sahrens ZIO_TYPE_CLAIM, 391fa9e4066Sahrens ZIO_TYPE_IOCTL, 392fa9e4066Sahrens ZIO_TYPES 393fa9e4066Sahrens } zio_type_t; 394fa9e4066Sahrens 395fa9e4066Sahrens /* 396fa9e4066Sahrens * Vdev statistics. Note: all fields should be 64-bit because this 397fa9e4066Sahrens * is passed between kernel and userland as an nvlist uint64 array. 398fa9e4066Sahrens */ 399fa9e4066Sahrens typedef struct vdev_stat { 400fa9e4066Sahrens hrtime_t vs_timestamp; /* time since vdev load */ 401fa9e4066Sahrens uint64_t vs_state; /* vdev state */ 402fa9e4066Sahrens uint64_t vs_aux; /* see vdev_aux_t */ 403fa9e4066Sahrens uint64_t vs_alloc; /* space allocated */ 404fa9e4066Sahrens uint64_t vs_space; /* total capacity */ 40599653d4eSeschrock uint64_t vs_dspace; /* deflated capacity */ 4062a79c5feSlling uint64_t vs_rsize; /* replaceable dev size */ 407fa9e4066Sahrens uint64_t vs_ops[ZIO_TYPES]; /* operation count */ 408fa9e4066Sahrens uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */ 409fa9e4066Sahrens uint64_t vs_read_errors; /* read errors */ 410fa9e4066Sahrens uint64_t vs_write_errors; /* write errors */ 411fa9e4066Sahrens uint64_t vs_checksum_errors; /* checksum errors */ 412fa9e4066Sahrens uint64_t vs_self_healed; /* self-healed bytes */ 413fa9e4066Sahrens uint64_t vs_scrub_type; /* pool_scrub_type_t */ 414fa9e4066Sahrens uint64_t vs_scrub_complete; /* completed? */ 415fa9e4066Sahrens uint64_t vs_scrub_examined; /* bytes examined; top */ 416fa9e4066Sahrens uint64_t vs_scrub_repaired; /* bytes repaired; leaf */ 417fa9e4066Sahrens uint64_t vs_scrub_errors; /* errors during scrub */ 418fa9e4066Sahrens uint64_t vs_scrub_start; /* UTC scrub start time */ 419fa9e4066Sahrens uint64_t vs_scrub_end; /* UTC scrub end time */ 420fa9e4066Sahrens } vdev_stat_t; 421fa9e4066Sahrens 422fa9e4066Sahrens #define ZFS_DRIVER "zfs" 423fa9e4066Sahrens #define ZFS_DEV "/dev/zfs" 424fa9e4066Sahrens 425fa9e4066Sahrens /* 426fa9e4066Sahrens * zvol paths. Irritatingly, the devfsadm interfaces want all these 427fa9e4066Sahrens * paths without the /dev prefix, but for some things, we want the 428fa9e4066Sahrens * /dev prefix. Below are the names without /dev. 429fa9e4066Sahrens */ 430fa9e4066Sahrens #define ZVOL_DEV_DIR "zvol/dsk" 431fa9e4066Sahrens #define ZVOL_RDEV_DIR "zvol/rdsk" 432fa9e4066Sahrens 433fa9e4066Sahrens /* 434fa9e4066Sahrens * And here are the things we need with /dev, etc. in front of them. 435fa9e4066Sahrens */ 436fa9e4066Sahrens #define ZVOL_PSEUDO_DEV "/devices/pseudo/zvol@0:" 437fa9e4066Sahrens #define ZVOL_FULL_DEV_DIR "/dev/" ZVOL_DEV_DIR 438fa9e4066Sahrens 439fa9e4066Sahrens #define ZVOL_PROP_NAME "name" 440fa9e4066Sahrens 441fa9e4066Sahrens /* 442fa9e4066Sahrens * /dev/zfs ioctl numbers. 443fa9e4066Sahrens */ 444fa9e4066Sahrens #define ZFS_IOC ('Z' << 8) 445fa9e4066Sahrens 446fa9e4066Sahrens typedef enum zfs_ioc { 447fa9e4066Sahrens ZFS_IOC_POOL_CREATE = ZFS_IOC, 448fa9e4066Sahrens ZFS_IOC_POOL_DESTROY, 449fa9e4066Sahrens ZFS_IOC_POOL_IMPORT, 450fa9e4066Sahrens ZFS_IOC_POOL_EXPORT, 451fa9e4066Sahrens ZFS_IOC_POOL_CONFIGS, 452fa9e4066Sahrens ZFS_IOC_POOL_STATS, 453fa9e4066Sahrens ZFS_IOC_POOL_TRYIMPORT, 454fa9e4066Sahrens ZFS_IOC_POOL_SCRUB, 455fa9e4066Sahrens ZFS_IOC_POOL_FREEZE, 456eaca9bbdSeschrock ZFS_IOC_POOL_UPGRADE, 45706eeb2adSek ZFS_IOC_POOL_GET_HISTORY, 458fa9e4066Sahrens ZFS_IOC_VDEV_ADD, 459fa9e4066Sahrens ZFS_IOC_VDEV_REMOVE, 4603d7072f8Seschrock ZFS_IOC_VDEV_SET_STATE, 461fa9e4066Sahrens ZFS_IOC_VDEV_ATTACH, 462fa9e4066Sahrens ZFS_IOC_VDEV_DETACH, 463c67d9675Seschrock ZFS_IOC_VDEV_SETPATH, 464fa9e4066Sahrens ZFS_IOC_OBJSET_STATS, 465fa9e4066Sahrens ZFS_IOC_DATASET_LIST_NEXT, 466fa9e4066Sahrens ZFS_IOC_SNAPSHOT_LIST_NEXT, 467fa9e4066Sahrens ZFS_IOC_SET_PROP, 468fa9e4066Sahrens ZFS_IOC_CREATE_MINOR, 469fa9e4066Sahrens ZFS_IOC_REMOVE_MINOR, 470fa9e4066Sahrens ZFS_IOC_CREATE, 471fa9e4066Sahrens ZFS_IOC_DESTROY, 472fa9e4066Sahrens ZFS_IOC_ROLLBACK, 473fa9e4066Sahrens ZFS_IOC_RENAME, 474fa9e4066Sahrens ZFS_IOC_RECVBACKUP, 475ea8dc4b6Seschrock ZFS_IOC_SENDBACKUP, 476ea8dc4b6Seschrock ZFS_IOC_INJECT_FAULT, 477ea8dc4b6Seschrock ZFS_IOC_CLEAR_FAULT, 478ea8dc4b6Seschrock ZFS_IOC_INJECT_LIST_NEXT, 479ea8dc4b6Seschrock ZFS_IOC_ERROR_LOG, 480ea8dc4b6Seschrock ZFS_IOC_CLEAR, 4811d452cf5Sahrens ZFS_IOC_PROMOTE, 4821d452cf5Sahrens ZFS_IOC_DESTROY_SNAPS, 48355434c77Sek ZFS_IOC_SNAPSHOT, 48455434c77Sek ZFS_IOC_DSOBJ_TO_DSNAME, 485b1b8ab34Slling ZFS_IOC_OBJ_TO_PATH, 486b1b8ab34Slling ZFS_IOC_POOL_SET_PROPS, 487ecd6cf80Smarks ZFS_IOC_POOL_GET_PROPS, 488ecd6cf80Smarks ZFS_IOC_SET_FSACL, 489ecd6cf80Smarks ZFS_IOC_GET_FSACL, 490ecd6cf80Smarks ZFS_IOC_ISCSI_PERM_CHECK, 491e45ce728Sahrens ZFS_IOC_SHARE, 492e45ce728Sahrens ZFS_IOC_INHERIT_PROP 493fa9e4066Sahrens } zfs_ioc_t; 494fa9e4066Sahrens 495ea8dc4b6Seschrock /* 496ea8dc4b6Seschrock * Internal SPA load state. Used by FMA diagnosis engine. 497ea8dc4b6Seschrock */ 498ea8dc4b6Seschrock typedef enum { 499ea8dc4b6Seschrock SPA_LOAD_NONE, /* no load in progress */ 500ea8dc4b6Seschrock SPA_LOAD_OPEN, /* normal open */ 501ea8dc4b6Seschrock SPA_LOAD_IMPORT, /* import in progress */ 502ea8dc4b6Seschrock SPA_LOAD_TRYIMPORT /* tryimport in progress */ 503ea8dc4b6Seschrock } spa_load_state_t; 504ea8dc4b6Seschrock 505e9dbad6fSeschrock /* 506e9dbad6fSeschrock * Bookmark name values. 507e9dbad6fSeschrock */ 50855434c77Sek #define ZPOOL_ERR_LIST "error list" 509e9dbad6fSeschrock #define ZPOOL_ERR_DATASET "dataset" 510e9dbad6fSeschrock #define ZPOOL_ERR_OBJECT "object" 511e9dbad6fSeschrock 51206eeb2adSek #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) 51306eeb2adSek 51406eeb2adSek /* 51506eeb2adSek * The following are names used in the nvlist describing 51606eeb2adSek * the pool's history log. 51706eeb2adSek */ 51806eeb2adSek #define ZPOOL_HIST_RECORD "history record" 51906eeb2adSek #define ZPOOL_HIST_TIME "history time" 52006eeb2adSek #define ZPOOL_HIST_CMD "history command" 521ecd6cf80Smarks #define ZPOOL_HIST_WHO "history who" 522ecd6cf80Smarks #define ZPOOL_HIST_ZONE "history zone" 523ecd6cf80Smarks #define ZPOOL_HIST_HOST "history hostname" 524ecd6cf80Smarks #define ZPOOL_HIST_TXG "history txg" 525ecd6cf80Smarks #define ZPOOL_HIST_INT_EVENT "history internal event" 526ecd6cf80Smarks #define ZPOOL_HIST_INT_STR "history internal str" 52706eeb2adSek 5283d7072f8Seschrock /* 5293d7072f8Seschrock * Flags for ZFS_IOC_VDEV_SET_STATE 5303d7072f8Seschrock */ 5313d7072f8Seschrock #define ZFS_ONLINE_CHECKREMOVE 0x1 5323d7072f8Seschrock #define ZFS_ONLINE_UNSPARE 0x2 5333d7072f8Seschrock #define ZFS_ONLINE_FORCEFAULT 0x4 5343d7072f8Seschrock #define ZFS_OFFLINE_TEMPORARY 0x1 5353d7072f8Seschrock 5363d7072f8Seschrock /* 5373d7072f8Seschrock * Sysevent payload members. ZFS will generate the following sysevents with the 5383d7072f8Seschrock * given payloads: 5393d7072f8Seschrock * 5403d7072f8Seschrock * ESC_ZFS_RESILVER_START 5413d7072f8Seschrock * ESC_ZFS_RESILVER_END 5423d7072f8Seschrock * ESC_ZFS_POOL_DESTROY 5433d7072f8Seschrock * 5443d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 5453d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 5463d7072f8Seschrock * 5473d7072f8Seschrock * ESC_ZFS_VDEV_REMOVE 5483d7072f8Seschrock * ESC_ZFS_VDEV_CLEAR 5493d7072f8Seschrock * ESC_ZFS_VDEV_CHECK 5503d7072f8Seschrock * 5513d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 5523d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 5533d7072f8Seschrock * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) 5543d7072f8Seschrock * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 5553d7072f8Seschrock */ 5563d7072f8Seschrock #define ZFS_EV_POOL_NAME "pool_name" 5573d7072f8Seschrock #define ZFS_EV_POOL_GUID "pool_guid" 5583d7072f8Seschrock #define ZFS_EV_VDEV_PATH "vdev_path" 5593d7072f8Seschrock #define ZFS_EV_VDEV_GUID "vdev_guid" 5603d7072f8Seschrock 561ecd6cf80Smarks typedef enum history_internal_events { 562ecd6cf80Smarks LOG_NO_EVENT = 0, 563ecd6cf80Smarks LOG_POOL_CREATE, 564ecd6cf80Smarks LOG_POOL_VDEV_ADD, 565ecd6cf80Smarks LOG_POOL_REMOVE, 566ecd6cf80Smarks LOG_POOL_DESTROY, 567ecd6cf80Smarks LOG_POOL_EXPORT, 568ecd6cf80Smarks LOG_POOL_IMPORT, 569ecd6cf80Smarks LOG_POOL_VDEV_ATTACH, 570ecd6cf80Smarks LOG_POOL_VDEV_REPLACE, 571ecd6cf80Smarks LOG_POOL_VDEV_DETACH, 572ecd6cf80Smarks LOG_POOL_VDEV_ONLINE, 573ecd6cf80Smarks LOG_POOL_VDEV_OFFLINE, 574ecd6cf80Smarks LOG_POOL_UPGRADE, 575ecd6cf80Smarks LOG_POOL_CLEAR, 576ecd6cf80Smarks LOG_POOL_SCRUB, 577ecd6cf80Smarks LOG_POOL_PROPSET, 578ecd6cf80Smarks LOG_DS_CREATE, 579ecd6cf80Smarks LOG_DS_CLONE, 580ecd6cf80Smarks LOG_DS_DESTROY, 581ecd6cf80Smarks LOG_DS_DESTROY_BEGIN, 582ecd6cf80Smarks LOG_DS_INHERIT, 583ecd6cf80Smarks LOG_DS_PROPSET, 584ecd6cf80Smarks LOG_DS_QUOTA, 585ecd6cf80Smarks LOG_DS_PERM_UPDATE, 586ecd6cf80Smarks LOG_DS_PERM_REMOVE, 587ecd6cf80Smarks LOG_DS_PERM_WHO_REMOVE, 588ecd6cf80Smarks LOG_DS_PROMOTE, 589ecd6cf80Smarks LOG_DS_RECEIVE, 590ecd6cf80Smarks LOG_DS_RENAME, 591ecd6cf80Smarks LOG_DS_RESERVATION, 592ecd6cf80Smarks LOG_DS_REPLAY_INC_SYNC, 593ecd6cf80Smarks LOG_DS_REPLAY_FULL_SYNC, 594ecd6cf80Smarks LOG_DS_ROLLBACK, 595ecd6cf80Smarks LOG_DS_SNAPSHOT, 596e7437265Sahrens LOG_DS_UPGRADE, 597ecd6cf80Smarks LOG_END 598ecd6cf80Smarks } history_internal_events_t; 599ecd6cf80Smarks 600fa9e4066Sahrens #ifdef __cplusplus 601fa9e4066Sahrens } 602fa9e4066Sahrens #endif 603fa9e4066Sahrens 604fa9e4066Sahrens #endif /* _SYS_FS_ZFS_H */ 605