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 */ 21f94275ceSAdam Leventhal 22fa9e4066Sahrens /* 2327dd1e87SMark Shellenbaum * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24edf345e6SMatthew Ahrens * Copyright (c) 2011, 2014 by Delphix. All rights reserved. 25e9103aaeSGarrett D'Amore * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 26a2afb611SJerry Jelinek * Copyright (c) 2013, Joyent, Inc. All rights reserved. 27fa9e4066Sahrens */ 28fa9e4066Sahrens 2955da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */ 3055da60b9SMark J Musante 31fa9e4066Sahrens #ifndef _SYS_FS_ZFS_H 32fa9e4066Sahrens #define _SYS_FS_ZFS_H 33fa9e4066Sahrens 34842727c2SChris Kirby #include <sys/time.h> 35842727c2SChris Kirby 36fa9e4066Sahrens #ifdef __cplusplus 37fa9e4066Sahrens extern "C" { 38fa9e4066Sahrens #endif 39fa9e4066Sahrens 40fa9e4066Sahrens /* 41fa9e4066Sahrens * Types and constants shared between userland and the kernel. 42fa9e4066Sahrens */ 43fa9e4066Sahrens 44fa9e4066Sahrens /* 45fa9e4066Sahrens * Each dataset can be one of the following types. These constants can be 46fa9e4066Sahrens * combined into masks that can be passed to various functions. 47fa9e4066Sahrens */ 48fa9e4066Sahrens typedef enum { 4978f17100SMatthew Ahrens ZFS_TYPE_FILESYSTEM = (1 << 0), 5078f17100SMatthew Ahrens ZFS_TYPE_SNAPSHOT = (1 << 1), 5178f17100SMatthew Ahrens ZFS_TYPE_VOLUME = (1 << 2), 5278f17100SMatthew Ahrens ZFS_TYPE_POOL = (1 << 3), 5378f17100SMatthew Ahrens ZFS_TYPE_BOOKMARK = (1 << 4) 54fa9e4066Sahrens } zfs_type_t; 55fa9e4066Sahrens 564445fffbSMatthew Ahrens typedef enum dmu_objset_type { 574445fffbSMatthew Ahrens DMU_OST_NONE, 584445fffbSMatthew Ahrens DMU_OST_META, 594445fffbSMatthew Ahrens DMU_OST_ZFS, 604445fffbSMatthew Ahrens DMU_OST_ZVOL, 614445fffbSMatthew Ahrens DMU_OST_OTHER, /* For testing only! */ 624445fffbSMatthew Ahrens DMU_OST_ANY, /* Be careful! */ 634445fffbSMatthew Ahrens DMU_OST_NUMTYPES 644445fffbSMatthew Ahrens } dmu_objset_type_t; 654445fffbSMatthew Ahrens 66990b4856Slling #define ZFS_TYPE_DATASET \ 67fa9e4066Sahrens (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) 68fa9e4066Sahrens 69478ed9adSEric Taylor #define ZAP_MAXNAMELEN 256 70478ed9adSEric Taylor #define ZAP_MAXVALUELEN (1024 * 8) 71478ed9adSEric Taylor #define ZAP_OLDMAXVALUELEN 1024 72478ed9adSEric Taylor 73fa9e4066Sahrens /* 74990b4856Slling * Dataset properties are identified by these constants and must be added to 75990b4856Slling * the end of this list to ensure that external consumers are not affected 76990b4856Slling * by the change. If you make any changes to this list, be sure to update 7766e2aaccSgw * the property table in usr/src/common/zfs/zfs_prop.c. 78fa9e4066Sahrens */ 79fa9e4066Sahrens typedef enum { 80fa9e4066Sahrens ZFS_PROP_TYPE, 81fa9e4066Sahrens ZFS_PROP_CREATION, 82fa9e4066Sahrens ZFS_PROP_USED, 83fa9e4066Sahrens ZFS_PROP_AVAILABLE, 84fa9e4066Sahrens ZFS_PROP_REFERENCED, 85fa9e4066Sahrens ZFS_PROP_COMPRESSRATIO, 86fa9e4066Sahrens ZFS_PROP_MOUNTED, 87fa9e4066Sahrens ZFS_PROP_ORIGIN, 88fa9e4066Sahrens ZFS_PROP_QUOTA, 89fa9e4066Sahrens ZFS_PROP_RESERVATION, 90fa9e4066Sahrens ZFS_PROP_VOLSIZE, 91fa9e4066Sahrens ZFS_PROP_VOLBLOCKSIZE, 92fa9e4066Sahrens ZFS_PROP_RECORDSIZE, 93fa9e4066Sahrens ZFS_PROP_MOUNTPOINT, 94fa9e4066Sahrens ZFS_PROP_SHARENFS, 95fa9e4066Sahrens ZFS_PROP_CHECKSUM, 96fa9e4066Sahrens ZFS_PROP_COMPRESSION, 97fa9e4066Sahrens ZFS_PROP_ATIME, 98fa9e4066Sahrens ZFS_PROP_DEVICES, 99fa9e4066Sahrens ZFS_PROP_EXEC, 100fa9e4066Sahrens ZFS_PROP_SETUID, 101fa9e4066Sahrens ZFS_PROP_READONLY, 102fa9e4066Sahrens ZFS_PROP_ZONED, 103fa9e4066Sahrens ZFS_PROP_SNAPDIR, 104a3c49ce1SAlbert Lee ZFS_PROP_ACLMODE, 105fa9e4066Sahrens ZFS_PROP_ACLINHERIT, 10666e2aaccSgw ZFS_PROP_CREATETXG, /* not exposed to the user */ 10766e2aaccSgw ZFS_PROP_NAME, /* not exposed to the user */ 108e9dbad6fSeschrock ZFS_PROP_CANMOUNT, 10966e2aaccSgw ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */ 1107b55fa8eSck ZFS_PROP_XATTR, 111d0ad202dSahrens ZFS_PROP_NUMCLONES, /* not exposed to the user */ 112b1b8ab34Slling ZFS_PROP_COPIES, 113e7437265Sahrens ZFS_PROP_VERSION, 114da6c28aaSamw ZFS_PROP_UTF8ONLY, 115da6c28aaSamw ZFS_PROP_NORMALIZE, 116da6c28aaSamw ZFS_PROP_CASE, 117da6c28aaSamw ZFS_PROP_VSCAN, 118da6c28aaSamw ZFS_PROP_NBMAND, 119da6c28aaSamw ZFS_PROP_SHARESMB, 120a9799022Sck ZFS_PROP_REFQUOTA, 121a9799022Sck ZFS_PROP_REFRESERVATION, 122c5904d13Seschrock ZFS_PROP_GUID, 1233baa08fcSek ZFS_PROP_PRIMARYCACHE, 1243baa08fcSek ZFS_PROP_SECONDARYCACHE, 12574e7dc98SMatthew Ahrens ZFS_PROP_USEDSNAP, 12674e7dc98SMatthew Ahrens ZFS_PROP_USEDDS, 12774e7dc98SMatthew Ahrens ZFS_PROP_USEDCHILD, 12874e7dc98SMatthew Ahrens ZFS_PROP_USEDREFRESERV, 12914843421SMatthew Ahrens ZFS_PROP_USERACCOUNTING, /* not exposed to the user */ 130478ed9adSEric Taylor ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */ 131842727c2SChris Kirby ZFS_PROP_DEFER_DESTROY, 132842727c2SChris Kirby ZFS_PROP_USERREFS, 133e09fa4daSNeil Perrin ZFS_PROP_LOGBIAS, 1341d713200SEric Schrock ZFS_PROP_UNIQUE, /* not exposed to the user */ 1351d713200SEric Schrock ZFS_PROP_OBJSETID, /* not exposed to the user */ 136b24ab676SJeff Bonwick ZFS_PROP_DEDUP, 1374201a95eSRic Aleshire ZFS_PROP_MLSLABEL, 13855da60b9SMark J Musante ZFS_PROP_SYNC, 139187d6ac0SMatt Ahrens ZFS_PROP_REFRATIO, 14019b94df9SMatthew Ahrens ZFS_PROP_WRITTEN, 14119b94df9SMatthew Ahrens ZFS_PROP_CLONES, 14277372cb0SMatthew Ahrens ZFS_PROP_LOGICALUSED, 14377372cb0SMatthew Ahrens ZFS_PROP_LOGICALREFERENCED, 144ca48f36fSKeith M Wesolowski ZFS_PROP_INCONSISTENT, /* not exposed to the user */ 145a2afb611SJerry Jelinek ZFS_PROP_FILESYSTEM_LIMIT, 146a2afb611SJerry Jelinek ZFS_PROP_SNAPSHOT_LIMIT, 147a2afb611SJerry Jelinek ZFS_PROP_FILESYSTEM_COUNT, 148a2afb611SJerry Jelinek ZFS_PROP_SNAPSHOT_COUNT, 149edf345e6SMatthew Ahrens ZFS_PROP_REDUNDANT_METADATA, 15091ebeef5Sahrens ZFS_NUM_PROPS 151fa9e4066Sahrens } zfs_prop_t; 152fa9e4066Sahrens 15314843421SMatthew Ahrens typedef enum { 15414843421SMatthew Ahrens ZFS_PROP_USERUSED, 15514843421SMatthew Ahrens ZFS_PROP_USERQUOTA, 15614843421SMatthew Ahrens ZFS_PROP_GROUPUSED, 15714843421SMatthew Ahrens ZFS_PROP_GROUPQUOTA, 15814843421SMatthew Ahrens ZFS_NUM_USERQUOTA_PROPS 15914843421SMatthew Ahrens } zfs_userquota_prop_t; 16014843421SMatthew Ahrens 16114843421SMatthew Ahrens extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS]; 16214843421SMatthew Ahrens 163990b4856Slling /* 164990b4856Slling * Pool properties are identified by these constants and must be added to the 165b87f3af3Sperrin * end of this list to ensure that external consumers are not affected 166990b4856Slling * by the change. If you make any changes to this list, be sure to update 167990b4856Slling * the property table in usr/src/common/zfs/zpool_prop.c. 168990b4856Slling */ 169990b4856Slling typedef enum { 170990b4856Slling ZPOOL_PROP_NAME, 171990b4856Slling ZPOOL_PROP_SIZE, 172990b4856Slling ZPOOL_PROP_CAPACITY, 173990b4856Slling ZPOOL_PROP_ALTROOT, 174990b4856Slling ZPOOL_PROP_HEALTH, 175990b4856Slling ZPOOL_PROP_GUID, 176990b4856Slling ZPOOL_PROP_VERSION, 177990b4856Slling ZPOOL_PROP_BOOTFS, 178990b4856Slling ZPOOL_PROP_DELEGATION, 179990b4856Slling ZPOOL_PROP_AUTOREPLACE, 1802f8aaab3Seschrock ZPOOL_PROP_CACHEFILE, 1810a4e9518Sgw ZPOOL_PROP_FAILUREMODE, 182d5b5bb25SRich Morris ZPOOL_PROP_LISTSNAPS, 183573ca77eSGeorge Wilson ZPOOL_PROP_AUTOEXPAND, 184b24ab676SJeff Bonwick ZPOOL_PROP_DEDUPDITTO, 185b24ab676SJeff Bonwick ZPOOL_PROP_DEDUPRATIO, 186485bbbf5SGeorge Wilson ZPOOL_PROP_FREE, 187485bbbf5SGeorge Wilson ZPOOL_PROP_ALLOCATED, 188f9af39baSGeorge Wilson ZPOOL_PROP_READONLY, 1898704186eSDan McDonald ZPOOL_PROP_COMMENT, 1904263d13fSGeorge Wilson ZPOOL_PROP_EXPANDSZ, 191ad135b5dSChristopher Siden ZPOOL_PROP_FREEING, 192*7fd05ac4SMatthew Ahrens ZPOOL_PROP_LEAKED, 193990b4856Slling ZPOOL_NUM_PROPS 194990b4856Slling } zpool_prop_t; 195b1b8ab34Slling 1968704186eSDan McDonald /* Small enough to not hog a whole line of printout in zpool(1M). */ 1978704186eSDan McDonald #define ZPROP_MAX_COMMENT 32 1988704186eSDan McDonald 199990b4856Slling #define ZPROP_CONT -2 200990b4856Slling #define ZPROP_INVAL -1 2013d7072f8Seschrock 202990b4856Slling #define ZPROP_VALUE "value" 203990b4856Slling #define ZPROP_SOURCE "source" 2047f7322feSeschrock 205b1b8ab34Slling typedef enum { 206990b4856Slling ZPROP_SRC_NONE = 0x1, 207990b4856Slling ZPROP_SRC_DEFAULT = 0x2, 208990b4856Slling ZPROP_SRC_TEMPORARY = 0x4, 209990b4856Slling ZPROP_SRC_LOCAL = 0x8, 21092241e0bSTom Erickson ZPROP_SRC_INHERITED = 0x10, 21192241e0bSTom Erickson ZPROP_SRC_RECEIVED = 0x20 212990b4856Slling } zprop_source_t; 213990b4856Slling 21492241e0bSTom Erickson #define ZPROP_SRC_ALL 0x3f 21592241e0bSTom Erickson 21692241e0bSTom Erickson #define ZPROP_SOURCE_VAL_RECVD "$recvd" 21792241e0bSTom Erickson #define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS" 21892241e0bSTom Erickson /* 21992241e0bSTom Erickson * Dataset flag implemented as a special entry in the props zap object 22092241e0bSTom Erickson * indicating that the dataset has received properties on or after 22192241e0bSTom Erickson * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties 22292241e0bSTom Erickson * just as it did in earlier versions, and thereafter, local properties are 22392241e0bSTom Erickson * preserved. 22492241e0bSTom Erickson */ 22592241e0bSTom Erickson #define ZPROP_HAS_RECVD "$hasrecvd" 22692241e0bSTom Erickson 22792241e0bSTom Erickson typedef enum { 22892241e0bSTom Erickson ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */ 22992241e0bSTom Erickson ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */ 23092241e0bSTom Erickson } zprop_errflags_t; 231990b4856Slling 232990b4856Slling typedef int (*zprop_func)(int, void *); 233990b4856Slling 2340a48a24eStimh /* 2350a48a24eStimh * Properties to be set on the root file system of a new pool 2360a48a24eStimh * are stuffed into their own nvlist, which is then included in 2370a48a24eStimh * the properties nvlist with the pool properties. 2380a48a24eStimh */ 2390a48a24eStimh #define ZPOOL_ROOTFS_PROPS "root-props-nvl" 2400a48a24eStimh 241990b4856Slling /* 242990b4856Slling * Dataset property functions shared between libzfs and kernel. 243990b4856Slling */ 244990b4856Slling const char *zfs_prop_default_string(zfs_prop_t); 245990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t); 246990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t); 247990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t); 248da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t); 249990b4856Slling const char *zfs_prop_to_name(zfs_prop_t); 250990b4856Slling zfs_prop_t zfs_name_to_prop(const char *); 251990b4856Slling boolean_t zfs_prop_user(const char *); 25292241e0bSTom Erickson boolean_t zfs_prop_userquota(const char *); 25319b94df9SMatthew Ahrens boolean_t zfs_prop_written(const char *); 254990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); 255990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *); 256b24ab676SJeff Bonwick uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed); 2574853e976Sgw boolean_t zfs_prop_valid_for_type(int, zfs_type_t); 258b1b8ab34Slling 259990b4856Slling /* 260990b4856Slling * Pool property functions shared between libzfs and kernel. 261990b4856Slling */ 262990b4856Slling zpool_prop_t zpool_name_to_prop(const char *); 263990b4856Slling const char *zpool_prop_to_name(zpool_prop_t); 264990b4856Slling const char *zpool_prop_default_string(zpool_prop_t); 265990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t); 266990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t); 267ad135b5dSChristopher Siden boolean_t zpool_prop_feature(const char *); 268ad135b5dSChristopher Siden boolean_t zpool_prop_unsupported(const char *name); 269990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **); 270990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *); 271b24ab676SJeff Bonwick uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed); 272b1b8ab34Slling 273990b4856Slling /* 274990b4856Slling * Definitions for the Delegation. 275990b4856Slling */ 276ecd6cf80Smarks typedef enum { 277ecd6cf80Smarks ZFS_DELEG_WHO_UNKNOWN = 0, 278ecd6cf80Smarks ZFS_DELEG_USER = 'u', 279ecd6cf80Smarks ZFS_DELEG_USER_SETS = 'U', 280ecd6cf80Smarks ZFS_DELEG_GROUP = 'g', 281ecd6cf80Smarks ZFS_DELEG_GROUP_SETS = 'G', 282ecd6cf80Smarks ZFS_DELEG_EVERYONE = 'e', 283ecd6cf80Smarks ZFS_DELEG_EVERYONE_SETS = 'E', 284ecd6cf80Smarks ZFS_DELEG_CREATE = 'c', 285ecd6cf80Smarks ZFS_DELEG_CREATE_SETS = 'C', 286ecd6cf80Smarks ZFS_DELEG_NAMED_SET = 's', 287ecd6cf80Smarks ZFS_DELEG_NAMED_SET_SETS = 'S' 288ecd6cf80Smarks } zfs_deleg_who_type_t; 289ecd6cf80Smarks 290ecd6cf80Smarks typedef enum { 291ecd6cf80Smarks ZFS_DELEG_NONE = 0, 292ecd6cf80Smarks ZFS_DELEG_PERM_LOCAL = 1, 293ecd6cf80Smarks ZFS_DELEG_PERM_DESCENDENT = 2, 294ecd6cf80Smarks ZFS_DELEG_PERM_LOCALDESCENDENT = 3, 295ecd6cf80Smarks ZFS_DELEG_PERM_CREATE = 4 296ecd6cf80Smarks } zfs_deleg_inherit_t; 297ecd6cf80Smarks 298ecd6cf80Smarks #define ZFS_DELEG_PERM_UID "uid" 299ecd6cf80Smarks #define ZFS_DELEG_PERM_GID "gid" 300ecd6cf80Smarks #define ZFS_DELEG_PERM_GROUPS "groups" 301ecd6cf80Smarks 3024201a95eSRic Aleshire #define ZFS_MLSLABEL_DEFAULT "none" 3034201a95eSRic Aleshire 304743a77edSAlan Wright #define ZFS_SMB_ACL_SRC "src" 305743a77edSAlan Wright #define ZFS_SMB_ACL_TARGET "target" 306743a77edSAlan Wright 307a227b7f4Shs typedef enum { 308a227b7f4Shs ZFS_CANMOUNT_OFF = 0, 309a227b7f4Shs ZFS_CANMOUNT_ON = 1, 310a227b7f4Shs ZFS_CANMOUNT_NOAUTO = 2 311a227b7f4Shs } zfs_canmount_type_t; 312a227b7f4Shs 313e09fa4daSNeil Perrin typedef enum { 314e09fa4daSNeil Perrin ZFS_LOGBIAS_LATENCY = 0, 315e09fa4daSNeil Perrin ZFS_LOGBIAS_THROUGHPUT = 1 316e09fa4daSNeil Perrin } zfs_logbias_op_t; 317e09fa4daSNeil Perrin 318da6c28aaSamw typedef enum zfs_share_op { 319da6c28aaSamw ZFS_SHARE_NFS = 0, 320da6c28aaSamw ZFS_UNSHARE_NFS = 1, 321da6c28aaSamw ZFS_SHARE_SMB = 2, 322da6c28aaSamw ZFS_UNSHARE_SMB = 3 323da6c28aaSamw } zfs_share_op_t; 324da6c28aaSamw 325743a77edSAlan Wright typedef enum zfs_smb_acl_op { 326743a77edSAlan Wright ZFS_SMB_ACL_ADD, 327743a77edSAlan Wright ZFS_SMB_ACL_REMOVE, 328743a77edSAlan Wright ZFS_SMB_ACL_RENAME, 329743a77edSAlan Wright ZFS_SMB_ACL_PURGE 330743a77edSAlan Wright } zfs_smb_acl_op_t; 331743a77edSAlan Wright 3323baa08fcSek typedef enum zfs_cache_type { 3333baa08fcSek ZFS_CACHE_NONE = 0, 3343baa08fcSek ZFS_CACHE_METADATA = 1, 3353baa08fcSek ZFS_CACHE_ALL = 2 3363baa08fcSek } zfs_cache_type_t; 3373baa08fcSek 33855da60b9SMark J Musante typedef enum { 33955da60b9SMark J Musante ZFS_SYNC_STANDARD = 0, 34055da60b9SMark J Musante ZFS_SYNC_ALWAYS = 1, 34155da60b9SMark J Musante ZFS_SYNC_DISABLED = 2 34255da60b9SMark J Musante } zfs_sync_type_t; 34355da60b9SMark J Musante 344edf345e6SMatthew Ahrens typedef enum { 345edf345e6SMatthew Ahrens ZFS_REDUNDANT_METADATA_ALL, 346edf345e6SMatthew Ahrens ZFS_REDUNDANT_METADATA_MOST 347edf345e6SMatthew Ahrens } zfs_redundant_metadata_type_t; 3483baa08fcSek 349eaca9bbdSeschrock /* 35099653d4eSeschrock * On-disk version number. 351eaca9bbdSeschrock */ 352e7437265Sahrens #define SPA_VERSION_1 1ULL 353e7437265Sahrens #define SPA_VERSION_2 2ULL 354e7437265Sahrens #define SPA_VERSION_3 3ULL 355e7437265Sahrens #define SPA_VERSION_4 4ULL 356e7437265Sahrens #define SPA_VERSION_5 5ULL 357e7437265Sahrens #define SPA_VERSION_6 6ULL 358e7437265Sahrens #define SPA_VERSION_7 7ULL 359e7437265Sahrens #define SPA_VERSION_8 8ULL 360da6c28aaSamw #define SPA_VERSION_9 9ULL 361fa94a07fSbrendan #define SPA_VERSION_10 10ULL 362088f3894Sahrens #define SPA_VERSION_11 11ULL 363bb0ade09Sahrens #define SPA_VERSION_12 12ULL 36474e7dc98SMatthew Ahrens #define SPA_VERSION_13 13ULL 365d0f3f37eSMark Shellenbaum #define SPA_VERSION_14 14ULL 36614843421SMatthew Ahrens #define SPA_VERSION_15 15ULL 367478ed9adSEric Taylor #define SPA_VERSION_16 16ULL 368f94275ceSAdam Leventhal #define SPA_VERSION_17 17ULL 369842727c2SChris Kirby #define SPA_VERSION_18 18ULL 37088ecc943SGeorge Wilson #define SPA_VERSION_19 19ULL 371b24ab676SJeff Bonwick #define SPA_VERSION_20 20ULL 372b24ab676SJeff Bonwick #define SPA_VERSION_21 21ULL 37392241e0bSTom Erickson #define SPA_VERSION_22 22ULL 3746e1f5caaSNeil Perrin #define SPA_VERSION_23 23ULL 3750a586ceaSMark Shellenbaum #define SPA_VERSION_24 24ULL 3763f9d6ad7SLin Ling #define SPA_VERSION_25 25ULL 377cde58dbcSMatthew Ahrens #define SPA_VERSION_26 26ULL 3786e0cbcaaSMatthew Ahrens #define SPA_VERSION_27 27ULL 379cb04b873SMark J Musante #define SPA_VERSION_28 28ULL 380ad135b5dSChristopher Siden #define SPA_VERSION_5000 5000ULL 381cb04b873SMark J Musante 382b1b8ab34Slling /* 383e7cbe64fSgw * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk 384478ed9adSEric Taylor * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*}, 38514843421SMatthew Ahrens * and do the appropriate changes. Also bump the version number in 38614843421SMatthew Ahrens * usr/src/grub/capability. 387b1b8ab34Slling */ 388ad135b5dSChristopher Siden #define SPA_VERSION SPA_VERSION_5000 389ad135b5dSChristopher Siden #define SPA_VERSION_STRING "5000" 39044cd46caSbillm 39144cd46caSbillm /* 392e7437265Sahrens * Symbolic names for the changes that caused a SPA_VERSION switch. 39344cd46caSbillm * Used in the code when checking for presence or absence of a feature. 39444cd46caSbillm * Feel free to define multiple symbolic names for each version if there 39544cd46caSbillm * were multiple changes to on-disk structures during that version. 39644cd46caSbillm * 397e7437265Sahrens * NOTE: When checking the current SPA_VERSION in your code, be sure 39844cd46caSbillm * to use spa_version() since it reports the version of the 39944cd46caSbillm * last synced uberblock. Checking the in-flight version can 40044cd46caSbillm * be dangerous in some cases. 40144cd46caSbillm */ 402e7437265Sahrens #define SPA_VERSION_INITIAL SPA_VERSION_1 403e7437265Sahrens #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 404e7437265Sahrens #define SPA_VERSION_SPARES SPA_VERSION_3 405f94275ceSAdam Leventhal #define SPA_VERSION_RAIDZ2 SPA_VERSION_3 406cde58dbcSMatthew Ahrens #define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3 407e7437265Sahrens #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 408e7437265Sahrens #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 409e7437265Sahrens #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 410e7437265Sahrens #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 411e7437265Sahrens #define SPA_VERSION_BOOTFS SPA_VERSION_6 412990b4856Slling #define SPA_VERSION_SLOGS SPA_VERSION_7 413990b4856Slling #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8 414da6c28aaSamw #define SPA_VERSION_FUID SPA_VERSION_9 415a9799022Sck #define SPA_VERSION_REFRESERVATION SPA_VERSION_9 416a9799022Sck #define SPA_VERSION_REFQUOTA SPA_VERSION_9 417a9799022Sck #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9 418fa94a07fSbrendan #define SPA_VERSION_L2CACHE SPA_VERSION_10 419088f3894Sahrens #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11 420088f3894Sahrens #define SPA_VERSION_ORIGIN SPA_VERSION_11 421088f3894Sahrens #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11 422bb0ade09Sahrens #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12 42374e7dc98SMatthew Ahrens #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13 424d0f3f37eSMark Shellenbaum #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14 42514843421SMatthew Ahrens #define SPA_VERSION_USERSPACE SPA_VERSION_15 426478ed9adSEric Taylor #define SPA_VERSION_STMF_PROP SPA_VERSION_16 427f94275ceSAdam Leventhal #define SPA_VERSION_RAIDZ3 SPA_VERSION_17 428842727c2SChris Kirby #define SPA_VERSION_USERREFS SPA_VERSION_18 42988ecc943SGeorge Wilson #define SPA_VERSION_HOLES SPA_VERSION_19 430b24ab676SJeff Bonwick #define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20 431b24ab676SJeff Bonwick #define SPA_VERSION_DEDUP SPA_VERSION_21 43292241e0bSTom Erickson #define SPA_VERSION_RECVD_PROPS SPA_VERSION_22 4336e1f5caaSNeil Perrin #define SPA_VERSION_SLIM_ZIL SPA_VERSION_23 4340a586ceaSMark Shellenbaum #define SPA_VERSION_SA SPA_VERSION_24 4353f9d6ad7SLin Ling #define SPA_VERSION_SCAN SPA_VERSION_25 436cde58dbcSMatthew Ahrens #define SPA_VERSION_DIR_CLONES SPA_VERSION_26 437cde58dbcSMatthew Ahrens #define SPA_VERSION_DEADLISTS SPA_VERSION_26 4386e0cbcaaSMatthew Ahrens #define SPA_VERSION_FAST_SNAP SPA_VERSION_27 439cb04b873SMark J Musante #define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28 440ad135b5dSChristopher Siden #define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28 441ad135b5dSChristopher Siden #define SPA_VERSION_FEATURES SPA_VERSION_5000 442ad135b5dSChristopher Siden 443ad135b5dSChristopher Siden #define SPA_VERSION_IS_SUPPORTED(v) \ 444ad135b5dSChristopher Siden (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \ 445ad135b5dSChristopher Siden ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION)) 446e7437265Sahrens 447e7437265Sahrens /* 448e7437265Sahrens * ZPL version - rev'd whenever an incompatible on-disk format change 449e7437265Sahrens * occurs. This is independent of SPA/DMU/ZAP versioning. You must 450e7437265Sahrens * also update the version_table[] and help message in zfs_prop.c. 451e7437265Sahrens * 452e7437265Sahrens * When changing, be sure to teach GRUB how to read the new format! 453478ed9adSEric Taylor * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*} 454e7437265Sahrens */ 455e7437265Sahrens #define ZPL_VERSION_1 1ULL 456e7437265Sahrens #define ZPL_VERSION_2 2ULL 457da6c28aaSamw #define ZPL_VERSION_3 3ULL 45814843421SMatthew Ahrens #define ZPL_VERSION_4 4ULL 4590a586ceaSMark Shellenbaum #define ZPL_VERSION_5 5ULL 4600a586ceaSMark Shellenbaum #define ZPL_VERSION ZPL_VERSION_5 4610a586ceaSMark Shellenbaum #define ZPL_VERSION_STRING "5" 462e7437265Sahrens 463e7437265Sahrens #define ZPL_VERSION_INITIAL ZPL_VERSION_1 464e7437265Sahrens #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 465da6c28aaSamw #define ZPL_VERSION_FUID ZPL_VERSION_3 466de8267e0Stimh #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3 467da6c28aaSamw #define ZPL_VERSION_SYSATTR ZPL_VERSION_3 46814843421SMatthew Ahrens #define ZPL_VERSION_USERSPACE ZPL_VERSION_4 4690a586ceaSMark Shellenbaum #define ZPL_VERSION_SA ZPL_VERSION_5 470eaca9bbdSeschrock 471468c413aSTim Haley /* Rewind request information */ 472c8ee1847SVictor Latushkin #define ZPOOL_NO_REWIND 1 /* No policy - default behavior */ 473c8ee1847SVictor Latushkin #define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */ 474c8ee1847SVictor Latushkin #define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */ 475c8ee1847SVictor Latushkin #define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */ 476c8ee1847SVictor Latushkin #define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */ 477c8ee1847SVictor Latushkin #define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */ 478c8ee1847SVictor Latushkin #define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */ 479468c413aSTim Haley 480468c413aSTim Haley typedef struct zpool_rewind_policy { 481468c413aSTim Haley uint32_t zrp_request; /* rewind behavior requested */ 482c8ee1847SVictor Latushkin uint64_t zrp_maxmeta; /* max acceptable meta-data errors */ 483c8ee1847SVictor Latushkin uint64_t zrp_maxdata; /* max acceptable data errors */ 484468c413aSTim Haley uint64_t zrp_txg; /* specific txg to load */ 485468c413aSTim Haley } zpool_rewind_policy_t; 486468c413aSTim Haley 487fa9e4066Sahrens /* 488fa9e4066Sahrens * The following are configuration names used in the nvlist describing a pool's 489fa9e4066Sahrens * configuration. 490fa9e4066Sahrens */ 491fa9e4066Sahrens #define ZPOOL_CONFIG_VERSION "version" 492fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_NAME "name" 493fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_STATE "state" 494fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_TXG "txg" 495fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_GUID "pool_guid" 496fa9e4066Sahrens #define ZPOOL_CONFIG_CREATE_TXG "create_txg" 497fa9e4066Sahrens #define ZPOOL_CONFIG_TOP_GUID "top_guid" 498fa9e4066Sahrens #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" 499fa9e4066Sahrens #define ZPOOL_CONFIG_TYPE "type" 500fa9e4066Sahrens #define ZPOOL_CONFIG_CHILDREN "children" 501fa9e4066Sahrens #define ZPOOL_CONFIG_ID "id" 502fa9e4066Sahrens #define ZPOOL_CONFIG_GUID "guid" 503fa9e4066Sahrens #define ZPOOL_CONFIG_PATH "path" 504fa9e4066Sahrens #define ZPOOL_CONFIG_DEVID "devid" 505fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" 506fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" 507fa9e4066Sahrens #define ZPOOL_CONFIG_ASHIFT "ashift" 508fa9e4066Sahrens #define ZPOOL_CONFIG_ASIZE "asize" 509fa9e4066Sahrens #define ZPOOL_CONFIG_DTL "DTL" 5103f9d6ad7SLin Ling #define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */ 5113f9d6ad7SLin Ling #define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */ 512afefbcddSeschrock #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" 513ea8dc4b6Seschrock #define ZPOOL_CONFIG_ERRCOUNT "error_count" 514ea8dc4b6Seschrock #define ZPOOL_CONFIG_NOT_PRESENT "not_present" 51599653d4eSeschrock #define ZPOOL_CONFIG_SPARES "spares" 51699653d4eSeschrock #define ZPOOL_CONFIG_IS_SPARE "is_spare" 51799653d4eSeschrock #define ZPOOL_CONFIG_NPARITY "nparity" 51895173954Sek #define ZPOOL_CONFIG_HOSTID "hostid" 51995173954Sek #define ZPOOL_CONFIG_HOSTNAME "hostname" 52011027bc7STim Haley #define ZPOOL_CONFIG_LOADED_TIME "initial_load_time" 5213d7072f8Seschrock #define ZPOOL_CONFIG_UNSPARE "unspare" 5223d7072f8Seschrock #define ZPOOL_CONFIG_PHYS_PATH "phys_path" 5238654d025Sperrin #define ZPOOL_CONFIG_IS_LOG "is_log" 524fa94a07fSbrendan #define ZPOOL_CONFIG_L2CACHE "l2cache" 52588ecc943SGeorge Wilson #define ZPOOL_CONFIG_HOLE_ARRAY "hole_array" 52688ecc943SGeorge Wilson #define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children" 52788ecc943SGeorge Wilson #define ZPOOL_CONFIG_IS_HOLE "is_hole" 5289eb19f4dSGeorge Wilson #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram" 5299eb19f4dSGeorge Wilson #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats" 5309eb19f4dSGeorge Wilson #define ZPOOL_CONFIG_DDT_STATS "ddt_stats" 5311195e687SMark J Musante #define ZPOOL_CONFIG_SPLIT "splitcfg" 5321195e687SMark J Musante #define ZPOOL_CONFIG_ORIG_GUID "orig_guid" 5331195e687SMark J Musante #define ZPOOL_CONFIG_SPLIT_GUID "split_guid" 5341195e687SMark J Musante #define ZPOOL_CONFIG_SPLIT_LIST "guid_list" 5353f9d6ad7SLin Ling #define ZPOOL_CONFIG_REMOVING "removing" 536b4952e17SGeorge Wilson #define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg" 5378704186eSDan McDonald #define ZPOOL_CONFIG_COMMENT "comment" 538e14bb325SJeff Bonwick #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */ 539e7cbe64fSgw #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ 540e7cbe64fSgw #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */ 5414b964adaSGeorge Wilson #define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */ 5424b964adaSGeorge Wilson #define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */ 543ad135b5dSChristopher Siden #define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */ 544ad135b5dSChristopher Siden #define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */ 54557221772SChristopher Siden #define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */ 546ad135b5dSChristopher Siden #define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */ 547ad135b5dSChristopher Siden #define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read" 548ad135b5dSChristopher Siden #define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */ 5493d7072f8Seschrock /* 5503d7072f8Seschrock * The persistent vdev state is stored as separate values rather than a single 5513d7072f8Seschrock * 'vdev_state' entry. This is because a device can be in multiple states, such 5523d7072f8Seschrock * as offline and degraded. 5533d7072f8Seschrock */ 5543d7072f8Seschrock #define ZPOOL_CONFIG_OFFLINE "offline" 5553d7072f8Seschrock #define ZPOOL_CONFIG_FAULTED "faulted" 5563d7072f8Seschrock #define ZPOOL_CONFIG_DEGRADED "degraded" 5573d7072f8Seschrock #define ZPOOL_CONFIG_REMOVED "removed" 5586809eb4eSEric Schrock #define ZPOOL_CONFIG_FRU "fru" 559069f55e2SEric Schrock #define ZPOOL_CONFIG_AUX_STATE "aux_state" 560fa9e4066Sahrens 561468c413aSTim Haley /* Rewind policy parameters */ 562468c413aSTim Haley #define ZPOOL_REWIND_POLICY "rewind-policy" 563468c413aSTim Haley #define ZPOOL_REWIND_REQUEST "rewind-request" 564468c413aSTim Haley #define ZPOOL_REWIND_REQUEST_TXG "rewind-request-txg" 565468c413aSTim Haley #define ZPOOL_REWIND_META_THRESH "rewind-meta-thresh" 566468c413aSTim Haley #define ZPOOL_REWIND_DATA_THRESH "rewind-data-thresh" 567468c413aSTim Haley 568468c413aSTim Haley /* Rewind data discovered */ 569468c413aSTim Haley #define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts" 570468c413aSTim Haley #define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors" 571468c413aSTim Haley #define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind" 572468c413aSTim Haley 573fa9e4066Sahrens #define VDEV_TYPE_ROOT "root" 574fa9e4066Sahrens #define VDEV_TYPE_MIRROR "mirror" 575fa9e4066Sahrens #define VDEV_TYPE_REPLACING "replacing" 576fa9e4066Sahrens #define VDEV_TYPE_RAIDZ "raidz" 577fa9e4066Sahrens #define VDEV_TYPE_DISK "disk" 578fa9e4066Sahrens #define VDEV_TYPE_FILE "file" 579fa9e4066Sahrens #define VDEV_TYPE_MISSING "missing" 58088ecc943SGeorge Wilson #define VDEV_TYPE_HOLE "hole" 58199653d4eSeschrock #define VDEV_TYPE_SPARE "spare" 5828654d025Sperrin #define VDEV_TYPE_LOG "log" 583fa94a07fSbrendan #define VDEV_TYPE_L2CACHE "l2cache" 584fa9e4066Sahrens 585fa9e4066Sahrens /* 586fa9e4066Sahrens * This is needed in userland to report the minimum necessary device size. 587fa9e4066Sahrens */ 588fa9e4066Sahrens #define SPA_MINDEVSIZE (64ULL << 20) 589fa9e4066Sahrens 590fa9e4066Sahrens /* 591fa9e4066Sahrens * The location of the pool configuration repository, shared between kernel and 592fa9e4066Sahrens * userland. 593fa9e4066Sahrens */ 594c5904d13Seschrock #define ZPOOL_CACHE "/etc/zfs/zpool.cache" 595fa9e4066Sahrens 596fa9e4066Sahrens /* 597fa9e4066Sahrens * vdev states are ordered from least to most healthy. 598fa9e4066Sahrens * A vdev that's CANT_OPEN or below is considered unusable. 599fa9e4066Sahrens */ 600fa9e4066Sahrens typedef enum vdev_state { 601fa9e4066Sahrens VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ 602fa9e4066Sahrens VDEV_STATE_CLOSED, /* Not currently open */ 603fa9e4066Sahrens VDEV_STATE_OFFLINE, /* Not allowed to open */ 6043d7072f8Seschrock VDEV_STATE_REMOVED, /* Explicitly removed from system */ 605fa9e4066Sahrens VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ 6063d7072f8Seschrock VDEV_STATE_FAULTED, /* External request to fault device */ 607fa9e4066Sahrens VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ 608fa9e4066Sahrens VDEV_STATE_HEALTHY /* Presumed good */ 609fa9e4066Sahrens } vdev_state_t; 610fa9e4066Sahrens 6113d7072f8Seschrock #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY 6123d7072f8Seschrock 613fa9e4066Sahrens /* 614fa9e4066Sahrens * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field 615fa9e4066Sahrens * of the vdev stats structure uses these constants to distinguish why. 616fa9e4066Sahrens */ 617fa9e4066Sahrens typedef enum vdev_aux { 618fa9e4066Sahrens VDEV_AUX_NONE, /* no error */ 619fa9e4066Sahrens VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ 620fa9e4066Sahrens VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ 621fa9e4066Sahrens VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ 622fa9e4066Sahrens VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ 623fa9e4066Sahrens VDEV_AUX_TOO_SMALL, /* vdev size is too small */ 624eaca9bbdSeschrock VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ 625eaca9bbdSeschrock VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ 62699653d4eSeschrock VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ 627ad135b5dSChristopher Siden VDEV_AUX_UNSUP_FEAT, /* unsupported features */ 6283d7072f8Seschrock VDEV_AUX_SPARED, /* hot spare used in another pool */ 62932b87932Sek VDEV_AUX_ERR_EXCEEDED, /* too many errors */ 630b87f3af3Sperrin VDEV_AUX_IO_FAILURE, /* experienced I/O failure */ 631069f55e2SEric Schrock VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */ 6321195e687SMark J Musante VDEV_AUX_EXTERNAL, /* external diagnosis */ 6331195e687SMark J Musante VDEV_AUX_SPLIT_POOL /* vdev was split off into another pool */ 634fa9e4066Sahrens } vdev_aux_t; 635fa9e4066Sahrens 636fa9e4066Sahrens /* 63746a2abf2Seschrock * pool state. The following states are written to disk as part of the normal 638fa94a07fSbrendan * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining 639fa94a07fSbrendan * states are software abstractions used at various levels to communicate 640fa94a07fSbrendan * pool state. 641fa9e4066Sahrens */ 642fa9e4066Sahrens typedef enum pool_state { 643fa9e4066Sahrens POOL_STATE_ACTIVE = 0, /* In active use */ 644fa9e4066Sahrens POOL_STATE_EXPORTED, /* Explicitly exported */ 645fa9e4066Sahrens POOL_STATE_DESTROYED, /* Explicitly destroyed */ 64699653d4eSeschrock POOL_STATE_SPARE, /* Reserved for hot spare use */ 647fa94a07fSbrendan POOL_STATE_L2CACHE, /* Level 2 ARC device */ 648fa9e4066Sahrens POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ 64946a2abf2Seschrock POOL_STATE_UNAVAIL, /* Internal libzfs state */ 65046a2abf2Seschrock POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ 651fa9e4066Sahrens } pool_state_t; 652fa9e4066Sahrens 653fa9e4066Sahrens /* 6543f9d6ad7SLin Ling * Scan Functions. 655fa9e4066Sahrens */ 6563f9d6ad7SLin Ling typedef enum pool_scan_func { 6573f9d6ad7SLin Ling POOL_SCAN_NONE, 6583f9d6ad7SLin Ling POOL_SCAN_SCRUB, 6593f9d6ad7SLin Ling POOL_SCAN_RESILVER, 6603f9d6ad7SLin Ling POOL_SCAN_FUNCS 6613f9d6ad7SLin Ling } pool_scan_func_t; 662fa9e4066Sahrens 663fa9e4066Sahrens /* 664fa9e4066Sahrens * ZIO types. Needed to interpret vdev statistics below. 665fa9e4066Sahrens */ 666fa9e4066Sahrens typedef enum zio_type { 667fa9e4066Sahrens ZIO_TYPE_NULL = 0, 668fa9e4066Sahrens ZIO_TYPE_READ, 669fa9e4066Sahrens ZIO_TYPE_WRITE, 670fa9e4066Sahrens ZIO_TYPE_FREE, 671fa9e4066Sahrens ZIO_TYPE_CLAIM, 672fa9e4066Sahrens ZIO_TYPE_IOCTL, 673fa9e4066Sahrens ZIO_TYPES 674fa9e4066Sahrens } zio_type_t; 675fa9e4066Sahrens 6763f9d6ad7SLin Ling /* 6773f9d6ad7SLin Ling * Pool statistics. Note: all fields should be 64-bit because this 6783f9d6ad7SLin Ling * is passed between kernel and userland as an nvlist uint64 array. 6793f9d6ad7SLin Ling */ 6803f9d6ad7SLin Ling typedef struct pool_scan_stat { 6813f9d6ad7SLin Ling /* values stored on disk */ 6823f9d6ad7SLin Ling uint64_t pss_func; /* pool_scan_func_t */ 6833f9d6ad7SLin Ling uint64_t pss_state; /* dsl_scan_state_t */ 6843f9d6ad7SLin Ling uint64_t pss_start_time; /* scan start time */ 6853f9d6ad7SLin Ling uint64_t pss_end_time; /* scan end time */ 6863f9d6ad7SLin Ling uint64_t pss_to_examine; /* total bytes to scan */ 6873f9d6ad7SLin Ling uint64_t pss_examined; /* total examined bytes */ 6883f9d6ad7SLin Ling uint64_t pss_to_process; /* total bytes to process */ 6893f9d6ad7SLin Ling uint64_t pss_processed; /* total processed bytes */ 6903f9d6ad7SLin Ling uint64_t pss_errors; /* scan errors */ 6913f9d6ad7SLin Ling 6923f9d6ad7SLin Ling /* values not stored on disk */ 6933f9d6ad7SLin Ling uint64_t pss_pass_exam; /* examined bytes per scan pass */ 6943f9d6ad7SLin Ling uint64_t pss_pass_start; /* start time of a scan pass */ 6953f9d6ad7SLin Ling } pool_scan_stat_t; 6963f9d6ad7SLin Ling 6973f9d6ad7SLin Ling typedef enum dsl_scan_state { 6983f9d6ad7SLin Ling DSS_NONE, 6993f9d6ad7SLin Ling DSS_SCANNING, 7003f9d6ad7SLin Ling DSS_FINISHED, 7013f9d6ad7SLin Ling DSS_CANCELED, 7023f9d6ad7SLin Ling DSS_NUM_STATES 7033f9d6ad7SLin Ling } dsl_scan_state_t; 7043f9d6ad7SLin Ling 7053f9d6ad7SLin Ling 706fa9e4066Sahrens /* 707fa9e4066Sahrens * Vdev statistics. Note: all fields should be 64-bit because this 708fa9e4066Sahrens * is passed between kernel and userland as an nvlist uint64 array. 709fa9e4066Sahrens */ 710fa9e4066Sahrens typedef struct vdev_stat { 711fa9e4066Sahrens hrtime_t vs_timestamp; /* time since vdev load */ 712fa9e4066Sahrens uint64_t vs_state; /* vdev state */ 713fa9e4066Sahrens uint64_t vs_aux; /* see vdev_aux_t */ 714fa9e4066Sahrens uint64_t vs_alloc; /* space allocated */ 715fa9e4066Sahrens uint64_t vs_space; /* total capacity */ 71699653d4eSeschrock uint64_t vs_dspace; /* deflated capacity */ 7172a79c5feSlling uint64_t vs_rsize; /* replaceable dev size */ 7184263d13fSGeorge Wilson uint64_t vs_esize; /* expandable dev size */ 719fa9e4066Sahrens uint64_t vs_ops[ZIO_TYPES]; /* operation count */ 720fa9e4066Sahrens uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */ 721fa9e4066Sahrens uint64_t vs_read_errors; /* read errors */ 722fa9e4066Sahrens uint64_t vs_write_errors; /* write errors */ 723fa9e4066Sahrens uint64_t vs_checksum_errors; /* checksum errors */ 724fa9e4066Sahrens uint64_t vs_self_healed; /* self-healed bytes */ 7253f9d6ad7SLin Ling uint64_t vs_scan_removing; /* removing? */ 7263f9d6ad7SLin Ling uint64_t vs_scan_processed; /* scan processed bytes */ 727fa9e4066Sahrens } vdev_stat_t; 728fa9e4066Sahrens 7299eb19f4dSGeorge Wilson /* 7309eb19f4dSGeorge Wilson * DDT statistics. Note: all fields should be 64-bit because this 7319eb19f4dSGeorge Wilson * is passed between kernel and userland as an nvlist uint64 array. 7329eb19f4dSGeorge Wilson */ 7339eb19f4dSGeorge Wilson typedef struct ddt_object { 7349eb19f4dSGeorge Wilson uint64_t ddo_count; /* number of elments in ddt */ 7359eb19f4dSGeorge Wilson uint64_t ddo_dspace; /* size of ddt on disk */ 7369eb19f4dSGeorge Wilson uint64_t ddo_mspace; /* size of ddt in-core */ 7379eb19f4dSGeorge Wilson } ddt_object_t; 7389eb19f4dSGeorge Wilson 7399eb19f4dSGeorge Wilson typedef struct ddt_stat { 7409eb19f4dSGeorge Wilson uint64_t dds_blocks; /* blocks */ 7419eb19f4dSGeorge Wilson uint64_t dds_lsize; /* logical size */ 7429eb19f4dSGeorge Wilson uint64_t dds_psize; /* physical size */ 7439eb19f4dSGeorge Wilson uint64_t dds_dsize; /* deflated allocated size */ 7449eb19f4dSGeorge Wilson uint64_t dds_ref_blocks; /* referenced blocks */ 7459eb19f4dSGeorge Wilson uint64_t dds_ref_lsize; /* referenced lsize * refcnt */ 7469eb19f4dSGeorge Wilson uint64_t dds_ref_psize; /* referenced psize * refcnt */ 7479eb19f4dSGeorge Wilson uint64_t dds_ref_dsize; /* referenced dsize * refcnt */ 7489eb19f4dSGeorge Wilson } ddt_stat_t; 7499eb19f4dSGeorge Wilson 7509eb19f4dSGeorge Wilson typedef struct ddt_histogram { 7519eb19f4dSGeorge Wilson ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */ 7529eb19f4dSGeorge Wilson } ddt_histogram_t; 7539eb19f4dSGeorge Wilson 754e7cbe64fSgw #define ZVOL_DRIVER "zvol" 755fa9e4066Sahrens #define ZFS_DRIVER "zfs" 756fa9e4066Sahrens #define ZFS_DEV "/dev/zfs" 757fa9e4066Sahrens 758681d9761SEric Taylor /* general zvol path */ 759681d9761SEric Taylor #define ZVOL_DIR "/dev/zvol" 760681d9761SEric Taylor /* expansion */ 761573ca77eSGeorge Wilson #define ZVOL_PSEUDO_DEV "/devices/pseudo/zfs@0:" 762681d9761SEric Taylor /* for dump and swap */ 763681d9761SEric Taylor #define ZVOL_FULL_DEV_DIR ZVOL_DIR "/dsk/" 764681d9761SEric Taylor #define ZVOL_FULL_RDEV_DIR ZVOL_DIR "/rdsk/" 765fa9e4066Sahrens 766fa9e4066Sahrens #define ZVOL_PROP_NAME "name" 767c1449561SEric Taylor #define ZVOL_DEFAULT_BLOCKSIZE 8192 768fa9e4066Sahrens 769fa9e4066Sahrens /* 770fa9e4066Sahrens * /dev/zfs ioctl numbers. 771fa9e4066Sahrens */ 772fa9e4066Sahrens typedef enum zfs_ioc { 7734445fffbSMatthew Ahrens ZFS_IOC_FIRST = ('Z' << 8), 7744445fffbSMatthew Ahrens ZFS_IOC = ZFS_IOC_FIRST, 7754445fffbSMatthew Ahrens ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST, 776fa9e4066Sahrens ZFS_IOC_POOL_DESTROY, 777fa9e4066Sahrens ZFS_IOC_POOL_IMPORT, 778fa9e4066Sahrens ZFS_IOC_POOL_EXPORT, 779fa9e4066Sahrens ZFS_IOC_POOL_CONFIGS, 780fa9e4066Sahrens ZFS_IOC_POOL_STATS, 781fa9e4066Sahrens ZFS_IOC_POOL_TRYIMPORT, 7823f9d6ad7SLin Ling ZFS_IOC_POOL_SCAN, 783fa9e4066Sahrens ZFS_IOC_POOL_FREEZE, 784eaca9bbdSeschrock ZFS_IOC_POOL_UPGRADE, 78506eeb2adSek ZFS_IOC_POOL_GET_HISTORY, 786fa9e4066Sahrens ZFS_IOC_VDEV_ADD, 787fa9e4066Sahrens ZFS_IOC_VDEV_REMOVE, 7883d7072f8Seschrock ZFS_IOC_VDEV_SET_STATE, 789fa9e4066Sahrens ZFS_IOC_VDEV_ATTACH, 790fa9e4066Sahrens ZFS_IOC_VDEV_DETACH, 791c67d9675Seschrock ZFS_IOC_VDEV_SETPATH, 7926809eb4eSEric Schrock ZFS_IOC_VDEV_SETFRU, 793fa9e4066Sahrens ZFS_IOC_OBJSET_STATS, 794de8267e0Stimh ZFS_IOC_OBJSET_ZPLPROPS, 795fa9e4066Sahrens ZFS_IOC_DATASET_LIST_NEXT, 796fa9e4066Sahrens ZFS_IOC_SNAPSHOT_LIST_NEXT, 797fa9e4066Sahrens ZFS_IOC_SET_PROP, 798fa9e4066Sahrens ZFS_IOC_CREATE, 799fa9e4066Sahrens ZFS_IOC_DESTROY, 800fa9e4066Sahrens ZFS_IOC_ROLLBACK, 801fa9e4066Sahrens ZFS_IOC_RENAME, 8023cb34c60Sahrens ZFS_IOC_RECV, 8033cb34c60Sahrens ZFS_IOC_SEND, 804ea8dc4b6Seschrock ZFS_IOC_INJECT_FAULT, 805ea8dc4b6Seschrock ZFS_IOC_CLEAR_FAULT, 806ea8dc4b6Seschrock ZFS_IOC_INJECT_LIST_NEXT, 807ea8dc4b6Seschrock ZFS_IOC_ERROR_LOG, 808ea8dc4b6Seschrock ZFS_IOC_CLEAR, 8091d452cf5Sahrens ZFS_IOC_PROMOTE, 81055434c77Sek ZFS_IOC_SNAPSHOT, 81155434c77Sek ZFS_IOC_DSOBJ_TO_DSNAME, 812b1b8ab34Slling ZFS_IOC_OBJ_TO_PATH, 813b1b8ab34Slling ZFS_IOC_POOL_SET_PROPS, 814ecd6cf80Smarks ZFS_IOC_POOL_GET_PROPS, 815ecd6cf80Smarks ZFS_IOC_SET_FSACL, 816ecd6cf80Smarks ZFS_IOC_GET_FSACL, 817e45ce728Sahrens ZFS_IOC_SHARE, 818743a77edSAlan Wright ZFS_IOC_INHERIT_PROP, 81914843421SMatthew Ahrens ZFS_IOC_SMB_ACL, 82014843421SMatthew Ahrens ZFS_IOC_USERSPACE_ONE, 82114843421SMatthew Ahrens ZFS_IOC_USERSPACE_MANY, 822842727c2SChris Kirby ZFS_IOC_USERSPACE_UPGRADE, 823842727c2SChris Kirby ZFS_IOC_HOLD, 824842727c2SChris Kirby ZFS_IOC_RELEASE, 82592241e0bSTom Erickson ZFS_IOC_GET_HOLDS, 8261195e687SMark J Musante ZFS_IOC_OBJSET_RECVD_PROPS, 82799d5e173STim Haley ZFS_IOC_VDEV_SPLIT, 82899d5e173STim Haley ZFS_IOC_NEXT_OBJ, 82999d5e173STim Haley ZFS_IOC_DIFF, 83099d5e173STim Haley ZFS_IOC_TMP_SNAPSHOT, 831e9103aaeSGarrett D'Amore ZFS_IOC_OBJ_TO_STATS, 83219b94df9SMatthew Ahrens ZFS_IOC_SPACE_WRITTEN, 83319b94df9SMatthew Ahrens ZFS_IOC_SPACE_SNAPS, 8344445fffbSMatthew Ahrens ZFS_IOC_DESTROY_SNAPS, 8354263d13fSGeorge Wilson ZFS_IOC_POOL_REGUID, 8364e3c9f44SBill Pijewski ZFS_IOC_POOL_REOPEN, 8374445fffbSMatthew Ahrens ZFS_IOC_SEND_PROGRESS, 8384445fffbSMatthew Ahrens ZFS_IOC_LOG_HISTORY, 8394445fffbSMatthew Ahrens ZFS_IOC_SEND_NEW, 8404445fffbSMatthew Ahrens ZFS_IOC_SEND_SPACE, 8414445fffbSMatthew Ahrens ZFS_IOC_CLONE, 84278f17100SMatthew Ahrens ZFS_IOC_BOOKMARK, 84378f17100SMatthew Ahrens ZFS_IOC_GET_BOOKMARKS, 84478f17100SMatthew Ahrens ZFS_IOC_DESTROY_BOOKMARKS, 8454445fffbSMatthew Ahrens ZFS_IOC_LAST 846fa9e4066Sahrens } zfs_ioc_t; 847fa9e4066Sahrens 848ea8dc4b6Seschrock /* 849ea8dc4b6Seschrock * Internal SPA load state. Used by FMA diagnosis engine. 850ea8dc4b6Seschrock */ 851ea8dc4b6Seschrock typedef enum { 8529eb19f4dSGeorge Wilson SPA_LOAD_NONE, /* no load in progress */ 8539eb19f4dSGeorge Wilson SPA_LOAD_OPEN, /* normal open */ 8549eb19f4dSGeorge Wilson SPA_LOAD_IMPORT, /* import in progress */ 855468c413aSTim Haley SPA_LOAD_TRYIMPORT, /* tryimport in progress */ 8569eb19f4dSGeorge Wilson SPA_LOAD_RECOVER, /* recovery requested */ 8579eb19f4dSGeorge Wilson SPA_LOAD_ERROR /* load failed */ 858ea8dc4b6Seschrock } spa_load_state_t; 859ea8dc4b6Seschrock 860e9dbad6fSeschrock /* 861e9dbad6fSeschrock * Bookmark name values. 862e9dbad6fSeschrock */ 86355434c77Sek #define ZPOOL_ERR_LIST "error list" 864e9dbad6fSeschrock #define ZPOOL_ERR_DATASET "dataset" 865e9dbad6fSeschrock #define ZPOOL_ERR_OBJECT "object" 866e9dbad6fSeschrock 86706eeb2adSek #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) 86806eeb2adSek 86906eeb2adSek /* 87006eeb2adSek * The following are names used in the nvlist describing 87106eeb2adSek * the pool's history log. 87206eeb2adSek */ 87306eeb2adSek #define ZPOOL_HIST_RECORD "history record" 87406eeb2adSek #define ZPOOL_HIST_TIME "history time" 87506eeb2adSek #define ZPOOL_HIST_CMD "history command" 876ecd6cf80Smarks #define ZPOOL_HIST_WHO "history who" 877ecd6cf80Smarks #define ZPOOL_HIST_ZONE "history zone" 878ecd6cf80Smarks #define ZPOOL_HIST_HOST "history hostname" 879ecd6cf80Smarks #define ZPOOL_HIST_TXG "history txg" 880ecd6cf80Smarks #define ZPOOL_HIST_INT_EVENT "history internal event" 881ecd6cf80Smarks #define ZPOOL_HIST_INT_STR "history internal str" 8824445fffbSMatthew Ahrens #define ZPOOL_HIST_INT_NAME "internal_name" 8834445fffbSMatthew Ahrens #define ZPOOL_HIST_IOCTL "ioctl" 8844445fffbSMatthew Ahrens #define ZPOOL_HIST_INPUT_NVL "in_nvl" 8854445fffbSMatthew Ahrens #define ZPOOL_HIST_OUTPUT_NVL "out_nvl" 8864445fffbSMatthew Ahrens #define ZPOOL_HIST_DSNAME "dsname" 8874445fffbSMatthew Ahrens #define ZPOOL_HIST_DSID "dsid" 88806eeb2adSek 8893d7072f8Seschrock /* 8903d7072f8Seschrock * Flags for ZFS_IOC_VDEV_SET_STATE 8913d7072f8Seschrock */ 8923d7072f8Seschrock #define ZFS_ONLINE_CHECKREMOVE 0x1 8933d7072f8Seschrock #define ZFS_ONLINE_UNSPARE 0x2 8943d7072f8Seschrock #define ZFS_ONLINE_FORCEFAULT 0x4 895573ca77eSGeorge Wilson #define ZFS_ONLINE_EXPAND 0x8 8963d7072f8Seschrock #define ZFS_OFFLINE_TEMPORARY 0x1 8973d7072f8Seschrock 8984b964adaSGeorge Wilson /* 8994b964adaSGeorge Wilson * Flags for ZFS_IOC_POOL_IMPORT 9004b964adaSGeorge Wilson */ 9014b964adaSGeorge Wilson #define ZFS_IMPORT_NORMAL 0x0 9024b964adaSGeorge Wilson #define ZFS_IMPORT_VERBATIM 0x1 9034b964adaSGeorge Wilson #define ZFS_IMPORT_ANY_HOST 0x2 9044b964adaSGeorge Wilson #define ZFS_IMPORT_MISSING_LOG 0x4 905f9af39baSGeorge Wilson #define ZFS_IMPORT_ONLY 0x8 9064b964adaSGeorge Wilson 9073d7072f8Seschrock /* 9083d7072f8Seschrock * Sysevent payload members. ZFS will generate the following sysevents with the 9093d7072f8Seschrock * given payloads: 9103d7072f8Seschrock * 9113d7072f8Seschrock * ESC_ZFS_RESILVER_START 9123d7072f8Seschrock * ESC_ZFS_RESILVER_END 9133d7072f8Seschrock * ESC_ZFS_POOL_DESTROY 914e9103aaeSGarrett D'Amore * ESC_ZFS_POOL_REGUID 9153d7072f8Seschrock * 9163d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 9173d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 9183d7072f8Seschrock * 9193d7072f8Seschrock * ESC_ZFS_VDEV_REMOVE 9203d7072f8Seschrock * ESC_ZFS_VDEV_CLEAR 9213d7072f8Seschrock * ESC_ZFS_VDEV_CHECK 9223d7072f8Seschrock * 9233d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 9243d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 9253d7072f8Seschrock * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) 9263d7072f8Seschrock * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 9273d7072f8Seschrock */ 9283d7072f8Seschrock #define ZFS_EV_POOL_NAME "pool_name" 9293d7072f8Seschrock #define ZFS_EV_POOL_GUID "pool_guid" 9303d7072f8Seschrock #define ZFS_EV_VDEV_PATH "vdev_path" 9313d7072f8Seschrock #define ZFS_EV_VDEV_GUID "vdev_guid" 9323d7072f8Seschrock 933fa9e4066Sahrens #ifdef __cplusplus 934fa9e4066Sahrens } 935fa9e4066Sahrens #endif 936fa9e4066Sahrens 937fa9e4066Sahrens #endif /* _SYS_FS_ZFS_H */ 938