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 50fa9e4066Sahrens #define ZFS_TYPE_ANY \ 51fa9e4066Sahrens (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) 52fa9e4066Sahrens 53fa9e4066Sahrens /* 5466e2aaccSgw * Properties are identified by these constants and must be added to the 553d7072f8Seschrock * end of this list to ensure that external consumers are not affected 5666e2aaccSgw * by the change. The property list also determines how 'zfs get' will 5766e2aaccSgw * display them. If you make any changes to this list, be sure to update 5866e2aaccSgw * the property table in usr/src/common/zfs/zfs_prop.c. 59fa9e4066Sahrens */ 60fa9e4066Sahrens typedef enum { 6166e2aaccSgw ZFS_PROP_CONT = -2, 62fa9e4066Sahrens ZFS_PROP_INVAL = -1, 63fa9e4066Sahrens ZFS_PROP_TYPE, 64fa9e4066Sahrens ZFS_PROP_CREATION, 65fa9e4066Sahrens ZFS_PROP_USED, 66fa9e4066Sahrens ZFS_PROP_AVAILABLE, 67fa9e4066Sahrens ZFS_PROP_REFERENCED, 68fa9e4066Sahrens ZFS_PROP_COMPRESSRATIO, 69fa9e4066Sahrens ZFS_PROP_MOUNTED, 70fa9e4066Sahrens ZFS_PROP_ORIGIN, 71fa9e4066Sahrens ZFS_PROP_QUOTA, 72fa9e4066Sahrens ZFS_PROP_RESERVATION, 73fa9e4066Sahrens ZFS_PROP_VOLSIZE, 74fa9e4066Sahrens ZFS_PROP_VOLBLOCKSIZE, 75fa9e4066Sahrens ZFS_PROP_RECORDSIZE, 76fa9e4066Sahrens ZFS_PROP_MOUNTPOINT, 77fa9e4066Sahrens ZFS_PROP_SHARENFS, 78fa9e4066Sahrens ZFS_PROP_CHECKSUM, 79fa9e4066Sahrens ZFS_PROP_COMPRESSION, 80fa9e4066Sahrens ZFS_PROP_ATIME, 81fa9e4066Sahrens ZFS_PROP_DEVICES, 82fa9e4066Sahrens ZFS_PROP_EXEC, 83fa9e4066Sahrens ZFS_PROP_SETUID, 84fa9e4066Sahrens ZFS_PROP_READONLY, 85fa9e4066Sahrens ZFS_PROP_ZONED, 86fa9e4066Sahrens ZFS_PROP_SNAPDIR, 87fa9e4066Sahrens ZFS_PROP_ACLMODE, 88fa9e4066Sahrens ZFS_PROP_ACLINHERIT, 8966e2aaccSgw ZFS_PROP_CREATETXG, /* not exposed to the user */ 9066e2aaccSgw ZFS_PROP_NAME, /* not exposed to the user */ 91e9dbad6fSeschrock ZFS_PROP_CANMOUNT, 9266e2aaccSgw ZFS_PROP_SHAREISCSI, 9366e2aaccSgw ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */ 947b55fa8eSck ZFS_PROP_XATTR, 95d0ad202dSahrens ZFS_PROP_NUMCLONES, /* not exposed to the user */ 96b1b8ab34Slling ZFS_PROP_COPIES, 973d7072f8Seschrock ZPOOL_PROP_BOOTFS, 983d7072f8Seschrock ZPOOL_PROP_AUTOREPLACE, 99ecd6cf80Smarks ZPOOL_PROP_DELEGATION, 100*e7437265Sahrens ZFS_PROP_VERSION, 101*e7437265Sahrens ZPOOL_PROP_NAME /* XXX must be last! */ 102fa9e4066Sahrens } zfs_prop_t; 103fa9e4066Sahrens 104b1b8ab34Slling typedef zfs_prop_t zpool_prop_t; 105b1b8ab34Slling 1063d7072f8Seschrock #define ZPOOL_PROP_CONT ZFS_PROP_CONT 1073d7072f8Seschrock #define ZPOOL_PROP_INVAL ZFS_PROP_INVAL 1083d7072f8Seschrock 1097f7322feSeschrock #define ZFS_PROP_VALUE "value" 1107f7322feSeschrock #define ZFS_PROP_SOURCE "source" 1117f7322feSeschrock 112b1b8ab34Slling typedef enum { 113b1b8ab34Slling ZFS_SRC_NONE = 0x1, 114b1b8ab34Slling ZFS_SRC_DEFAULT = 0x2, 115b1b8ab34Slling ZFS_SRC_TEMPORARY = 0x4, 116b1b8ab34Slling ZFS_SRC_LOCAL = 0x8, 117b1b8ab34Slling ZFS_SRC_INHERITED = 0x10 118b1b8ab34Slling } zfs_source_t; 119b1b8ab34Slling 120b1b8ab34Slling #define ZFS_SRC_ALL 0x1f 121b1b8ab34Slling 122ecd6cf80Smarks typedef enum { 123ecd6cf80Smarks ZFS_DELEG_WHO_UNKNOWN = 0, 124ecd6cf80Smarks ZFS_DELEG_USER = 'u', 125ecd6cf80Smarks ZFS_DELEG_USER_SETS = 'U', 126ecd6cf80Smarks ZFS_DELEG_GROUP = 'g', 127ecd6cf80Smarks ZFS_DELEG_GROUP_SETS = 'G', 128ecd6cf80Smarks ZFS_DELEG_EVERYONE = 'e', 129ecd6cf80Smarks ZFS_DELEG_EVERYONE_SETS = 'E', 130ecd6cf80Smarks ZFS_DELEG_CREATE = 'c', 131ecd6cf80Smarks ZFS_DELEG_CREATE_SETS = 'C', 132ecd6cf80Smarks ZFS_DELEG_NAMED_SET = 's', 133ecd6cf80Smarks ZFS_DELEG_NAMED_SET_SETS = 'S' 134ecd6cf80Smarks } zfs_deleg_who_type_t; 135ecd6cf80Smarks 136ecd6cf80Smarks typedef enum { 137ecd6cf80Smarks ZFS_DELEG_NONE = 0, 138ecd6cf80Smarks ZFS_DELEG_PERM_LOCAL = 1, 139ecd6cf80Smarks ZFS_DELEG_PERM_DESCENDENT = 2, 140ecd6cf80Smarks ZFS_DELEG_PERM_LOCALDESCENDENT = 3, 141ecd6cf80Smarks ZFS_DELEG_PERM_CREATE = 4 142ecd6cf80Smarks } zfs_deleg_inherit_t; 143ecd6cf80Smarks 144ecd6cf80Smarks #define ZFS_DELEG_PERM_UID "uid" 145ecd6cf80Smarks #define ZFS_DELEG_PERM_GID "gid" 146ecd6cf80Smarks #define ZFS_DELEG_PERM_GROUPS "groups" 147ecd6cf80Smarks 148fa9e4066Sahrens /* 149fa9e4066Sahrens * The following functions are shared between libzfs and the kernel. 150fa9e4066Sahrens */ 151fa9e4066Sahrens zfs_prop_t zfs_name_to_prop(const char *); 152b1b8ab34Slling zpool_prop_t zpool_name_to_prop(const char *); 153e9dbad6fSeschrock boolean_t zfs_prop_user(const char *); 154fa9e4066Sahrens int zfs_prop_readonly(zfs_prop_t); 1557f7322feSeschrock const char *zfs_prop_default_string(zfs_prop_t); 156e9dbad6fSeschrock const char *zfs_prop_to_name(zfs_prop_t); 1573d7072f8Seschrock const char *zpool_prop_to_name(zpool_prop_t); 158fa9e4066Sahrens uint64_t zfs_prop_default_numeric(zfs_prop_t); 159e9dbad6fSeschrock int zfs_prop_inheritable(zfs_prop_t); 160acd76fe5Seschrock int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *); 161acd76fe5Seschrock int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); 1623d7072f8Seschrock uint64_t zpool_prop_default_numeric(zpool_prop_t); 163ecd6cf80Smarks const char *zfs_prop_perm(zfs_prop_t); 16499653d4eSeschrock 16566e2aaccSgw /* 16666e2aaccSgw * Property Iterator 16766e2aaccSgw */ 16866e2aaccSgw typedef zfs_prop_t (*zfs_prop_f)(zfs_prop_t, void *); 1693d7072f8Seschrock typedef zpool_prop_t (*zpool_prop_f)(zpool_prop_t, void *); 17066e2aaccSgw extern zfs_prop_t zfs_prop_iter(zfs_prop_f, void *, boolean_t); 171b1b8ab34Slling extern zpool_prop_t zpool_prop_iter(zpool_prop_f, void *, boolean_t); 17266e2aaccSgw 173eaca9bbdSeschrock /* 17499653d4eSeschrock * On-disk version number. 175eaca9bbdSeschrock */ 176*e7437265Sahrens #define SPA_VERSION_1 1ULL 177*e7437265Sahrens #define SPA_VERSION_2 2ULL 178*e7437265Sahrens #define SPA_VERSION_3 3ULL 179*e7437265Sahrens #define SPA_VERSION_4 4ULL 180*e7437265Sahrens #define SPA_VERSION_5 5ULL 181*e7437265Sahrens #define SPA_VERSION_6 6ULL 182*e7437265Sahrens #define SPA_VERSION_7 7ULL 183*e7437265Sahrens #define SPA_VERSION_8 8ULL 184b1b8ab34Slling /* 185*e7437265Sahrens * When bumping up SPA_VERSION, make sure GRUB ZFS understand the on-disk 186b1b8ab34Slling * format change. Go to usr/src/grub/grub-0.95/stage2/{zfs-include/, fsys_zfs*}, 187b1b8ab34Slling * and do the appropriate changes. 188b1b8ab34Slling */ 189*e7437265Sahrens #define SPA_VERSION SPA_VERSION_8 190*e7437265Sahrens #define SPA_VERSION_STRING "8" 19144cd46caSbillm 19244cd46caSbillm /* 193*e7437265Sahrens * Symbolic names for the changes that caused a SPA_VERSION switch. 19444cd46caSbillm * Used in the code when checking for presence or absence of a feature. 19544cd46caSbillm * Feel free to define multiple symbolic names for each version if there 19644cd46caSbillm * were multiple changes to on-disk structures during that version. 19744cd46caSbillm * 198*e7437265Sahrens * NOTE: When checking the current SPA_VERSION in your code, be sure 19944cd46caSbillm * to use spa_version() since it reports the version of the 20044cd46caSbillm * last synced uberblock. Checking the in-flight version can 20144cd46caSbillm * be dangerous in some cases. 20244cd46caSbillm */ 203*e7437265Sahrens #define SPA_VERSION_INITIAL SPA_VERSION_1 204*e7437265Sahrens #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 205*e7437265Sahrens #define SPA_VERSION_SPARES SPA_VERSION_3 206*e7437265Sahrens #define SPA_VERSION_RAID6 SPA_VERSION_3 207*e7437265Sahrens #define SPA_VERSION_BPLIST_ACCOUNT SPA_VERSION_3 208*e7437265Sahrens #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 209*e7437265Sahrens #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 210*e7437265Sahrens #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 211*e7437265Sahrens #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 212*e7437265Sahrens #define SPA_VERSION_BOOTFS SPA_VERSION_6 213*e7437265Sahrens #define ZFS_VERSION_SLOGS SPA_VERSION_7 214*e7437265Sahrens #define ZFS_VERSION_DELEGATED_PERMS SPA_VERSION_8 215*e7437265Sahrens 216*e7437265Sahrens /* 217*e7437265Sahrens * ZPL version - rev'd whenever an incompatible on-disk format change 218*e7437265Sahrens * occurs. This is independent of SPA/DMU/ZAP versioning. You must 219*e7437265Sahrens * also update the version_table[] and help message in zfs_prop.c. 220*e7437265Sahrens * 221*e7437265Sahrens * When changing, be sure to teach GRUB how to read the new format! 222*e7437265Sahrens * See usr/src/grub/grub-0.95/stage2/{zfs-include/,fsys_zfs*} 223*e7437265Sahrens */ 224*e7437265Sahrens #define ZPL_VERSION_1 1ULL 225*e7437265Sahrens #define ZPL_VERSION_2 2ULL 226*e7437265Sahrens #define ZPL_VERSION ZPL_VERSION_2 227*e7437265Sahrens #define ZPL_VERSION_STRING "2" 228*e7437265Sahrens 229*e7437265Sahrens #define ZPL_VERSION_INITIAL ZPL_VERSION_1 230*e7437265Sahrens #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 231eaca9bbdSeschrock 232fa9e4066Sahrens /* 233fa9e4066Sahrens * The following are configuration names used in the nvlist describing a pool's 234fa9e4066Sahrens * configuration. 235fa9e4066Sahrens */ 236fa9e4066Sahrens #define ZPOOL_CONFIG_VERSION "version" 237fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_NAME "name" 238fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_STATE "state" 239fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_TXG "txg" 240fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_GUID "pool_guid" 241fa9e4066Sahrens #define ZPOOL_CONFIG_CREATE_TXG "create_txg" 242fa9e4066Sahrens #define ZPOOL_CONFIG_TOP_GUID "top_guid" 243fa9e4066Sahrens #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" 244fa9e4066Sahrens #define ZPOOL_CONFIG_TYPE "type" 245fa9e4066Sahrens #define ZPOOL_CONFIG_CHILDREN "children" 246fa9e4066Sahrens #define ZPOOL_CONFIG_ID "id" 247fa9e4066Sahrens #define ZPOOL_CONFIG_GUID "guid" 248fa9e4066Sahrens #define ZPOOL_CONFIG_PATH "path" 249fa9e4066Sahrens #define ZPOOL_CONFIG_DEVID "devid" 250fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" 251fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" 252fa9e4066Sahrens #define ZPOOL_CONFIG_ASHIFT "ashift" 253fa9e4066Sahrens #define ZPOOL_CONFIG_ASIZE "asize" 254fa9e4066Sahrens #define ZPOOL_CONFIG_DTL "DTL" 255fa9e4066Sahrens #define ZPOOL_CONFIG_STATS "stats" 256afefbcddSeschrock #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" 257ea8dc4b6Seschrock #define ZPOOL_CONFIG_ERRCOUNT "error_count" 258ea8dc4b6Seschrock #define ZPOOL_CONFIG_NOT_PRESENT "not_present" 25999653d4eSeschrock #define ZPOOL_CONFIG_SPARES "spares" 26099653d4eSeschrock #define ZPOOL_CONFIG_IS_SPARE "is_spare" 26199653d4eSeschrock #define ZPOOL_CONFIG_NPARITY "nparity" 26295173954Sek #define ZPOOL_CONFIG_HOSTID "hostid" 26395173954Sek #define ZPOOL_CONFIG_HOSTNAME "hostname" 26495173954Sek #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ 2653d7072f8Seschrock #define ZPOOL_CONFIG_UNSPARE "unspare" 2663d7072f8Seschrock #define ZPOOL_CONFIG_PHYS_PATH "phys_path" 2678654d025Sperrin #define ZPOOL_CONFIG_IS_LOG "is_log" 2683d7072f8Seschrock /* 2693d7072f8Seschrock * The persistent vdev state is stored as separate values rather than a single 2703d7072f8Seschrock * 'vdev_state' entry. This is because a device can be in multiple states, such 2713d7072f8Seschrock * as offline and degraded. 2723d7072f8Seschrock */ 2733d7072f8Seschrock #define ZPOOL_CONFIG_OFFLINE "offline" 2743d7072f8Seschrock #define ZPOOL_CONFIG_FAULTED "faulted" 2753d7072f8Seschrock #define ZPOOL_CONFIG_DEGRADED "degraded" 2763d7072f8Seschrock #define ZPOOL_CONFIG_REMOVED "removed" 277fa9e4066Sahrens 278fa9e4066Sahrens #define VDEV_TYPE_ROOT "root" 279fa9e4066Sahrens #define VDEV_TYPE_MIRROR "mirror" 280fa9e4066Sahrens #define VDEV_TYPE_REPLACING "replacing" 281fa9e4066Sahrens #define VDEV_TYPE_RAIDZ "raidz" 282fa9e4066Sahrens #define VDEV_TYPE_DISK "disk" 283fa9e4066Sahrens #define VDEV_TYPE_FILE "file" 284fa9e4066Sahrens #define VDEV_TYPE_MISSING "missing" 28599653d4eSeschrock #define VDEV_TYPE_SPARE "spare" 2868654d025Sperrin #define VDEV_TYPE_LOG "log" 287fa9e4066Sahrens 288fa9e4066Sahrens /* 289fa9e4066Sahrens * This is needed in userland to report the minimum necessary device size. 290fa9e4066Sahrens */ 291fa9e4066Sahrens #define SPA_MINDEVSIZE (64ULL << 20) 292fa9e4066Sahrens 293fa9e4066Sahrens /* 294fa9e4066Sahrens * The location of the pool configuration repository, shared between kernel and 295fa9e4066Sahrens * userland. 296fa9e4066Sahrens */ 297fa9e4066Sahrens #define ZPOOL_CACHE_DIR "/etc/zfs" 298fa9e4066Sahrens #define ZPOOL_CACHE_FILE "zpool.cache" 299fa9e4066Sahrens #define ZPOOL_CACHE_TMP ".zpool.cache" 300fa9e4066Sahrens 301fa9e4066Sahrens #define ZPOOL_CACHE ZPOOL_CACHE_DIR "/" ZPOOL_CACHE_FILE 302fa9e4066Sahrens 303fa9e4066Sahrens /* 304fa9e4066Sahrens * vdev states are ordered from least to most healthy. 305fa9e4066Sahrens * A vdev that's CANT_OPEN or below is considered unusable. 306fa9e4066Sahrens */ 307fa9e4066Sahrens typedef enum vdev_state { 308fa9e4066Sahrens VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ 309fa9e4066Sahrens VDEV_STATE_CLOSED, /* Not currently open */ 310fa9e4066Sahrens VDEV_STATE_OFFLINE, /* Not allowed to open */ 3113d7072f8Seschrock VDEV_STATE_REMOVED, /* Explicitly removed from system */ 312fa9e4066Sahrens VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ 3133d7072f8Seschrock VDEV_STATE_FAULTED, /* External request to fault device */ 314fa9e4066Sahrens VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ 315fa9e4066Sahrens VDEV_STATE_HEALTHY /* Presumed good */ 316fa9e4066Sahrens } vdev_state_t; 317fa9e4066Sahrens 3183d7072f8Seschrock #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY 3193d7072f8Seschrock 320fa9e4066Sahrens /* 321fa9e4066Sahrens * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field 322fa9e4066Sahrens * of the vdev stats structure uses these constants to distinguish why. 323fa9e4066Sahrens */ 324fa9e4066Sahrens typedef enum vdev_aux { 325fa9e4066Sahrens VDEV_AUX_NONE, /* no error */ 326fa9e4066Sahrens VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ 327fa9e4066Sahrens VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ 328fa9e4066Sahrens VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ 329fa9e4066Sahrens VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ 330fa9e4066Sahrens VDEV_AUX_TOO_SMALL, /* vdev size is too small */ 331eaca9bbdSeschrock VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ 332eaca9bbdSeschrock VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ 33399653d4eSeschrock VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ 3343d7072f8Seschrock VDEV_AUX_SPARED, /* hot spare used in another pool */ 3353d7072f8Seschrock VDEV_AUX_ERR_EXCEEDED /* too many errors */ 336fa9e4066Sahrens } vdev_aux_t; 337fa9e4066Sahrens 338fa9e4066Sahrens /* 33946a2abf2Seschrock * pool state. The following states are written to disk as part of the normal 34099653d4eSeschrock * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE. The remaining states are 34146a2abf2Seschrock * software abstractions used at various levels to communicate pool state. 342fa9e4066Sahrens */ 343fa9e4066Sahrens typedef enum pool_state { 344fa9e4066Sahrens POOL_STATE_ACTIVE = 0, /* In active use */ 345fa9e4066Sahrens POOL_STATE_EXPORTED, /* Explicitly exported */ 346fa9e4066Sahrens POOL_STATE_DESTROYED, /* Explicitly destroyed */ 34799653d4eSeschrock POOL_STATE_SPARE, /* Reserved for hot spare use */ 348fa9e4066Sahrens POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ 34946a2abf2Seschrock POOL_STATE_UNAVAIL, /* Internal libzfs state */ 35046a2abf2Seschrock POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ 351fa9e4066Sahrens } pool_state_t; 352fa9e4066Sahrens 353fa9e4066Sahrens /* 354fa9e4066Sahrens * Scrub types. 355fa9e4066Sahrens */ 356fa9e4066Sahrens typedef enum pool_scrub_type { 357fa9e4066Sahrens POOL_SCRUB_NONE, 358fa9e4066Sahrens POOL_SCRUB_RESILVER, 359fa9e4066Sahrens POOL_SCRUB_EVERYTHING, 360fa9e4066Sahrens POOL_SCRUB_TYPES 361fa9e4066Sahrens } pool_scrub_type_t; 362fa9e4066Sahrens 363fa9e4066Sahrens /* 364fa9e4066Sahrens * ZIO types. Needed to interpret vdev statistics below. 365fa9e4066Sahrens */ 366fa9e4066Sahrens typedef enum zio_type { 367fa9e4066Sahrens ZIO_TYPE_NULL = 0, 368fa9e4066Sahrens ZIO_TYPE_READ, 369fa9e4066Sahrens ZIO_TYPE_WRITE, 370fa9e4066Sahrens ZIO_TYPE_FREE, 371fa9e4066Sahrens ZIO_TYPE_CLAIM, 372fa9e4066Sahrens ZIO_TYPE_IOCTL, 373fa9e4066Sahrens ZIO_TYPES 374fa9e4066Sahrens } zio_type_t; 375fa9e4066Sahrens 376fa9e4066Sahrens /* 377fa9e4066Sahrens * Vdev statistics. Note: all fields should be 64-bit because this 378fa9e4066Sahrens * is passed between kernel and userland as an nvlist uint64 array. 379fa9e4066Sahrens */ 380fa9e4066Sahrens typedef struct vdev_stat { 381fa9e4066Sahrens hrtime_t vs_timestamp; /* time since vdev load */ 382fa9e4066Sahrens uint64_t vs_state; /* vdev state */ 383fa9e4066Sahrens uint64_t vs_aux; /* see vdev_aux_t */ 384fa9e4066Sahrens uint64_t vs_alloc; /* space allocated */ 385fa9e4066Sahrens uint64_t vs_space; /* total capacity */ 38699653d4eSeschrock uint64_t vs_dspace; /* deflated capacity */ 3872a79c5feSlling uint64_t vs_rsize; /* replaceable dev size */ 388fa9e4066Sahrens uint64_t vs_ops[ZIO_TYPES]; /* operation count */ 389fa9e4066Sahrens uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */ 390fa9e4066Sahrens uint64_t vs_read_errors; /* read errors */ 391fa9e4066Sahrens uint64_t vs_write_errors; /* write errors */ 392fa9e4066Sahrens uint64_t vs_checksum_errors; /* checksum errors */ 393fa9e4066Sahrens uint64_t vs_self_healed; /* self-healed bytes */ 394fa9e4066Sahrens uint64_t vs_scrub_type; /* pool_scrub_type_t */ 395fa9e4066Sahrens uint64_t vs_scrub_complete; /* completed? */ 396fa9e4066Sahrens uint64_t vs_scrub_examined; /* bytes examined; top */ 397fa9e4066Sahrens uint64_t vs_scrub_repaired; /* bytes repaired; leaf */ 398fa9e4066Sahrens uint64_t vs_scrub_errors; /* errors during scrub */ 399fa9e4066Sahrens uint64_t vs_scrub_start; /* UTC scrub start time */ 400fa9e4066Sahrens uint64_t vs_scrub_end; /* UTC scrub end time */ 401fa9e4066Sahrens } vdev_stat_t; 402fa9e4066Sahrens 403fa9e4066Sahrens #define ZFS_DRIVER "zfs" 404fa9e4066Sahrens #define ZFS_DEV "/dev/zfs" 405fa9e4066Sahrens 406fa9e4066Sahrens /* 407fa9e4066Sahrens * zvol paths. Irritatingly, the devfsadm interfaces want all these 408fa9e4066Sahrens * paths without the /dev prefix, but for some things, we want the 409fa9e4066Sahrens * /dev prefix. Below are the names without /dev. 410fa9e4066Sahrens */ 411fa9e4066Sahrens #define ZVOL_DEV_DIR "zvol/dsk" 412fa9e4066Sahrens #define ZVOL_RDEV_DIR "zvol/rdsk" 413fa9e4066Sahrens 414fa9e4066Sahrens /* 415fa9e4066Sahrens * And here are the things we need with /dev, etc. in front of them. 416fa9e4066Sahrens */ 417fa9e4066Sahrens #define ZVOL_PSEUDO_DEV "/devices/pseudo/zvol@0:" 418fa9e4066Sahrens #define ZVOL_FULL_DEV_DIR "/dev/" ZVOL_DEV_DIR 419fa9e4066Sahrens 420fa9e4066Sahrens #define ZVOL_PROP_NAME "name" 421fa9e4066Sahrens 422fa9e4066Sahrens /* 423fa9e4066Sahrens * /dev/zfs ioctl numbers. 424fa9e4066Sahrens */ 425fa9e4066Sahrens #define ZFS_IOC ('Z' << 8) 426fa9e4066Sahrens 427fa9e4066Sahrens typedef enum zfs_ioc { 428fa9e4066Sahrens ZFS_IOC_POOL_CREATE = ZFS_IOC, 429fa9e4066Sahrens ZFS_IOC_POOL_DESTROY, 430fa9e4066Sahrens ZFS_IOC_POOL_IMPORT, 431fa9e4066Sahrens ZFS_IOC_POOL_EXPORT, 432fa9e4066Sahrens ZFS_IOC_POOL_CONFIGS, 433fa9e4066Sahrens ZFS_IOC_POOL_STATS, 434fa9e4066Sahrens ZFS_IOC_POOL_TRYIMPORT, 435fa9e4066Sahrens ZFS_IOC_POOL_SCRUB, 436fa9e4066Sahrens ZFS_IOC_POOL_FREEZE, 437eaca9bbdSeschrock ZFS_IOC_POOL_UPGRADE, 43806eeb2adSek ZFS_IOC_POOL_GET_HISTORY, 439fa9e4066Sahrens ZFS_IOC_VDEV_ADD, 440fa9e4066Sahrens ZFS_IOC_VDEV_REMOVE, 4413d7072f8Seschrock ZFS_IOC_VDEV_SET_STATE, 442fa9e4066Sahrens ZFS_IOC_VDEV_ATTACH, 443fa9e4066Sahrens ZFS_IOC_VDEV_DETACH, 444c67d9675Seschrock ZFS_IOC_VDEV_SETPATH, 445fa9e4066Sahrens ZFS_IOC_OBJSET_STATS, 446fa9e4066Sahrens ZFS_IOC_DATASET_LIST_NEXT, 447fa9e4066Sahrens ZFS_IOC_SNAPSHOT_LIST_NEXT, 448fa9e4066Sahrens ZFS_IOC_SET_PROP, 449fa9e4066Sahrens ZFS_IOC_CREATE_MINOR, 450fa9e4066Sahrens ZFS_IOC_REMOVE_MINOR, 451fa9e4066Sahrens ZFS_IOC_CREATE, 452fa9e4066Sahrens ZFS_IOC_DESTROY, 453fa9e4066Sahrens ZFS_IOC_ROLLBACK, 454fa9e4066Sahrens ZFS_IOC_RENAME, 455fa9e4066Sahrens ZFS_IOC_RECVBACKUP, 456ea8dc4b6Seschrock ZFS_IOC_SENDBACKUP, 457ea8dc4b6Seschrock ZFS_IOC_INJECT_FAULT, 458ea8dc4b6Seschrock ZFS_IOC_CLEAR_FAULT, 459ea8dc4b6Seschrock ZFS_IOC_INJECT_LIST_NEXT, 460ea8dc4b6Seschrock ZFS_IOC_ERROR_LOG, 461ea8dc4b6Seschrock ZFS_IOC_CLEAR, 4621d452cf5Sahrens ZFS_IOC_PROMOTE, 4631d452cf5Sahrens ZFS_IOC_DESTROY_SNAPS, 46455434c77Sek ZFS_IOC_SNAPSHOT, 46555434c77Sek ZFS_IOC_DSOBJ_TO_DSNAME, 466b1b8ab34Slling ZFS_IOC_OBJ_TO_PATH, 467b1b8ab34Slling ZFS_IOC_POOL_SET_PROPS, 468ecd6cf80Smarks ZFS_IOC_POOL_GET_PROPS, 469ecd6cf80Smarks ZFS_IOC_SET_FSACL, 470ecd6cf80Smarks ZFS_IOC_GET_FSACL, 471ecd6cf80Smarks ZFS_IOC_ISCSI_PERM_CHECK, 472ecd6cf80Smarks ZFS_IOC_SHARE 473fa9e4066Sahrens } zfs_ioc_t; 474fa9e4066Sahrens 475ea8dc4b6Seschrock /* 476ea8dc4b6Seschrock * Internal SPA load state. Used by FMA diagnosis engine. 477ea8dc4b6Seschrock */ 478ea8dc4b6Seschrock typedef enum { 479ea8dc4b6Seschrock SPA_LOAD_NONE, /* no load in progress */ 480ea8dc4b6Seschrock SPA_LOAD_OPEN, /* normal open */ 481ea8dc4b6Seschrock SPA_LOAD_IMPORT, /* import in progress */ 482ea8dc4b6Seschrock SPA_LOAD_TRYIMPORT /* tryimport in progress */ 483ea8dc4b6Seschrock } spa_load_state_t; 484ea8dc4b6Seschrock 485e9dbad6fSeschrock /* 486e9dbad6fSeschrock * Bookmark name values. 487e9dbad6fSeschrock */ 48855434c77Sek #define ZPOOL_ERR_LIST "error list" 489e9dbad6fSeschrock #define ZPOOL_ERR_DATASET "dataset" 490e9dbad6fSeschrock #define ZPOOL_ERR_OBJECT "object" 491e9dbad6fSeschrock 49206eeb2adSek #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) 49306eeb2adSek 49406eeb2adSek /* 49506eeb2adSek * The following are names used in the nvlist describing 49606eeb2adSek * the pool's history log. 49706eeb2adSek */ 49806eeb2adSek #define ZPOOL_HIST_RECORD "history record" 49906eeb2adSek #define ZPOOL_HIST_TIME "history time" 50006eeb2adSek #define ZPOOL_HIST_CMD "history command" 501ecd6cf80Smarks #define ZPOOL_HIST_WHO "history who" 502ecd6cf80Smarks #define ZPOOL_HIST_ZONE "history zone" 503ecd6cf80Smarks #define ZPOOL_HIST_HOST "history hostname" 504ecd6cf80Smarks #define ZPOOL_HIST_TXG "history txg" 505ecd6cf80Smarks #define ZPOOL_HIST_INT_EVENT "history internal event" 506ecd6cf80Smarks #define ZPOOL_HIST_INT_STR "history internal str" 50706eeb2adSek 5083d7072f8Seschrock /* 5093d7072f8Seschrock * Flags for ZFS_IOC_VDEV_SET_STATE 5103d7072f8Seschrock */ 5113d7072f8Seschrock #define ZFS_ONLINE_CHECKREMOVE 0x1 5123d7072f8Seschrock #define ZFS_ONLINE_UNSPARE 0x2 5133d7072f8Seschrock #define ZFS_ONLINE_FORCEFAULT 0x4 5143d7072f8Seschrock #define ZFS_OFFLINE_TEMPORARY 0x1 5153d7072f8Seschrock 5163d7072f8Seschrock /* 5173d7072f8Seschrock * Sysevent payload members. ZFS will generate the following sysevents with the 5183d7072f8Seschrock * given payloads: 5193d7072f8Seschrock * 5203d7072f8Seschrock * ESC_ZFS_RESILVER_START 5213d7072f8Seschrock * ESC_ZFS_RESILVER_END 5223d7072f8Seschrock * ESC_ZFS_POOL_DESTROY 5233d7072f8Seschrock * 5243d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 5253d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 5263d7072f8Seschrock * 5273d7072f8Seschrock * ESC_ZFS_VDEV_REMOVE 5283d7072f8Seschrock * ESC_ZFS_VDEV_CLEAR 5293d7072f8Seschrock * ESC_ZFS_VDEV_CHECK 5303d7072f8Seschrock * 5313d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 5323d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 5333d7072f8Seschrock * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) 5343d7072f8Seschrock * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 5353d7072f8Seschrock */ 5363d7072f8Seschrock #define ZFS_EV_POOL_NAME "pool_name" 5373d7072f8Seschrock #define ZFS_EV_POOL_GUID "pool_guid" 5383d7072f8Seschrock #define ZFS_EV_VDEV_PATH "vdev_path" 5393d7072f8Seschrock #define ZFS_EV_VDEV_GUID "vdev_guid" 5403d7072f8Seschrock 541ecd6cf80Smarks typedef enum history_internal_events { 542ecd6cf80Smarks LOG_NO_EVENT = 0, 543ecd6cf80Smarks LOG_POOL_CREATE, 544ecd6cf80Smarks LOG_POOL_VDEV_ADD, 545ecd6cf80Smarks LOG_POOL_REMOVE, 546ecd6cf80Smarks LOG_POOL_DESTROY, 547ecd6cf80Smarks LOG_POOL_EXPORT, 548ecd6cf80Smarks LOG_POOL_IMPORT, 549ecd6cf80Smarks LOG_POOL_VDEV_ATTACH, 550ecd6cf80Smarks LOG_POOL_VDEV_REPLACE, 551ecd6cf80Smarks LOG_POOL_VDEV_DETACH, 552ecd6cf80Smarks LOG_POOL_VDEV_ONLINE, 553ecd6cf80Smarks LOG_POOL_VDEV_OFFLINE, 554ecd6cf80Smarks LOG_POOL_UPGRADE, 555ecd6cf80Smarks LOG_POOL_CLEAR, 556ecd6cf80Smarks LOG_POOL_SCRUB, 557ecd6cf80Smarks LOG_POOL_PROPSET, 558ecd6cf80Smarks LOG_DS_CREATE, 559ecd6cf80Smarks LOG_DS_CLONE, 560ecd6cf80Smarks LOG_DS_DESTROY, 561ecd6cf80Smarks LOG_DS_DESTROY_BEGIN, 562ecd6cf80Smarks LOG_DS_INHERIT, 563ecd6cf80Smarks LOG_DS_PROPSET, 564ecd6cf80Smarks LOG_DS_QUOTA, 565ecd6cf80Smarks LOG_DS_PERM_UPDATE, 566ecd6cf80Smarks LOG_DS_PERM_REMOVE, 567ecd6cf80Smarks LOG_DS_PERM_WHO_REMOVE, 568ecd6cf80Smarks LOG_DS_PROMOTE, 569ecd6cf80Smarks LOG_DS_RECEIVE, 570ecd6cf80Smarks LOG_DS_RENAME, 571ecd6cf80Smarks LOG_DS_RESERVATION, 572ecd6cf80Smarks LOG_DS_REPLAY_INC_SYNC, 573ecd6cf80Smarks LOG_DS_REPLAY_FULL_SYNC, 574ecd6cf80Smarks LOG_DS_ROLLBACK, 575ecd6cf80Smarks LOG_DS_SNAPSHOT, 576*e7437265Sahrens LOG_DS_UPGRADE, 577ecd6cf80Smarks LOG_END 578ecd6cf80Smarks } history_internal_events_t; 579ecd6cf80Smarks 580fa9e4066Sahrens #ifdef __cplusplus 581fa9e4066Sahrens } 582fa9e4066Sahrens #endif 583fa9e4066Sahrens 584fa9e4066Sahrens #endif /* _SYS_FS_ZFS_H */ 585