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. 24469a3d62SMatthew Ahrens * Copyright (c) 2011, 2014 by Delphix. All rights reserved. 25bc93cffdSJerry Jelinek * Copyright (c) 2013, Joyent, Inc. All rights reserved. 26d5de1674SSaso Kiselkov * Copyright (c) 2013, Saso Kiselkov. All rights reserved. 27d5de1674SSaso Kiselkov * Copyright 2011, 2015 Nexenta Systems, Inc. All rights reserved. 28fa9e4066Sahrens */ 29fa9e4066Sahrens 3055da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */ 3155da60b9SMark J Musante 32fa9e4066Sahrens #ifndef _SYS_FS_ZFS_H 33fa9e4066Sahrens #define _SYS_FS_ZFS_H 34fa9e4066Sahrens 35842727c2SChris Kirby #include <sys/time.h> 36842727c2SChris Kirby 37fa9e4066Sahrens #ifdef __cplusplus 38fa9e4066Sahrens extern "C" { 39fa9e4066Sahrens #endif 40fa9e4066Sahrens 41fa9e4066Sahrens /* 42fa9e4066Sahrens * Types and constants shared between userland and the kernel. 43fa9e4066Sahrens */ 44fa9e4066Sahrens 45fa9e4066Sahrens /* 46fa9e4066Sahrens * Each dataset can be one of the following types. These constants can be 47fa9e4066Sahrens * combined into masks that can be passed to various functions. 48fa9e4066Sahrens */ 49fa9e4066Sahrens typedef enum { 50e69d9941SMatthew Ahrens ZFS_TYPE_FILESYSTEM = (1 << 0), 51e69d9941SMatthew Ahrens ZFS_TYPE_SNAPSHOT = (1 << 1), 52e69d9941SMatthew Ahrens ZFS_TYPE_VOLUME = (1 << 2), 53e69d9941SMatthew Ahrens ZFS_TYPE_POOL = (1 << 3), 54e69d9941SMatthew Ahrens ZFS_TYPE_BOOKMARK = (1 << 4) 55fa9e4066Sahrens } zfs_type_t; 56fa9e4066Sahrens 574445fffbSMatthew Ahrens typedef enum dmu_objset_type { 584445fffbSMatthew Ahrens DMU_OST_NONE, 594445fffbSMatthew Ahrens DMU_OST_META, 604445fffbSMatthew Ahrens DMU_OST_ZFS, 614445fffbSMatthew Ahrens DMU_OST_ZVOL, 624445fffbSMatthew Ahrens DMU_OST_OTHER, /* For testing only! */ 634445fffbSMatthew Ahrens DMU_OST_ANY, /* Be careful! */ 644445fffbSMatthew Ahrens DMU_OST_NUMTYPES 654445fffbSMatthew Ahrens } dmu_objset_type_t; 664445fffbSMatthew Ahrens 67990b4856Slling #define ZFS_TYPE_DATASET \ 68fa9e4066Sahrens (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) 69fa9e4066Sahrens 70*ac8a8f05SMarcel Telka /* 71*ac8a8f05SMarcel Telka * All of these include the terminating NUL byte. 72*ac8a8f05SMarcel Telka */ 73478ed9adSEric Taylor #define ZAP_MAXNAMELEN 256 74478ed9adSEric Taylor #define ZAP_MAXVALUELEN (1024 * 8) 75478ed9adSEric Taylor #define ZAP_OLDMAXVALUELEN 1024 76*ac8a8f05SMarcel Telka #define ZFS_MAX_DATASET_NAME_LEN 256 77478ed9adSEric Taylor 78fa9e4066Sahrens /* 79990b4856Slling * Dataset properties are identified by these constants and must be added to 80990b4856Slling * the end of this list to ensure that external consumers are not affected 81990b4856Slling * by the change. If you make any changes to this list, be sure to update 8266e2aaccSgw25295 * the property table in usr/src/common/zfs/zfs_prop.c. 83fa9e4066Sahrens */ 84fa9e4066Sahrens typedef enum { 85fa9e4066Sahrens ZFS_PROP_TYPE, 86fa9e4066Sahrens ZFS_PROP_CREATION, 87fa9e4066Sahrens ZFS_PROP_USED, 88fa9e4066Sahrens ZFS_PROP_AVAILABLE, 89fa9e4066Sahrens ZFS_PROP_REFERENCED, 90fa9e4066Sahrens ZFS_PROP_COMPRESSRATIO, 91fa9e4066Sahrens ZFS_PROP_MOUNTED, 92fa9e4066Sahrens ZFS_PROP_ORIGIN, 93fa9e4066Sahrens ZFS_PROP_QUOTA, 94fa9e4066Sahrens ZFS_PROP_RESERVATION, 95fa9e4066Sahrens ZFS_PROP_VOLSIZE, 96fa9e4066Sahrens ZFS_PROP_VOLBLOCKSIZE, 97fa9e4066Sahrens ZFS_PROP_RECORDSIZE, 98fa9e4066Sahrens ZFS_PROP_MOUNTPOINT, 99fa9e4066Sahrens ZFS_PROP_SHARENFS, 100fa9e4066Sahrens ZFS_PROP_CHECKSUM, 101fa9e4066Sahrens ZFS_PROP_COMPRESSION, 102fa9e4066Sahrens ZFS_PROP_ATIME, 103fa9e4066Sahrens ZFS_PROP_DEVICES, 104fa9e4066Sahrens ZFS_PROP_EXEC, 105fa9e4066Sahrens ZFS_PROP_SETUID, 106fa9e4066Sahrens ZFS_PROP_READONLY, 107fa9e4066Sahrens ZFS_PROP_ZONED, 108fa9e4066Sahrens ZFS_PROP_SNAPDIR, 109a3c49ce1SAlbert Lee ZFS_PROP_ACLMODE, 110fa9e4066Sahrens ZFS_PROP_ACLINHERIT, 11166e2aaccSgw25295 ZFS_PROP_CREATETXG, /* not exposed to the user */ 11266e2aaccSgw25295 ZFS_PROP_NAME, /* not exposed to the user */ 113e9dbad6fSeschrock ZFS_PROP_CANMOUNT, 11466e2aaccSgw25295 ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */ 1157b55fa8eSck153898 ZFS_PROP_XATTR, 116d0ad202dSahrens ZFS_PROP_NUMCLONES, /* not exposed to the user */ 117b1b8ab34Slling ZFS_PROP_COPIES, 118e7437265Sahrens ZFS_PROP_VERSION, 119da6c28aaSamw ZFS_PROP_UTF8ONLY, 120da6c28aaSamw ZFS_PROP_NORMALIZE, 121da6c28aaSamw ZFS_PROP_CASE, 122da6c28aaSamw ZFS_PROP_VSCAN, 123da6c28aaSamw ZFS_PROP_NBMAND, 124da6c28aaSamw ZFS_PROP_SHARESMB, 125a9799022Sck153898 ZFS_PROP_REFQUOTA, 126a9799022Sck153898 ZFS_PROP_REFRESERVATION, 127c5904d13Seschrock ZFS_PROP_GUID, 1283baa08fcSek110237 ZFS_PROP_PRIMARYCACHE, 1293baa08fcSek110237 ZFS_PROP_SECONDARYCACHE, 13074e7dc98SMatthew Ahrens ZFS_PROP_USEDSNAP, 13174e7dc98SMatthew Ahrens ZFS_PROP_USEDDS, 13274e7dc98SMatthew Ahrens ZFS_PROP_USEDCHILD, 13374e7dc98SMatthew Ahrens ZFS_PROP_USEDREFRESERV, 13414843421SMatthew Ahrens ZFS_PROP_USERACCOUNTING, /* not exposed to the user */ 135478ed9adSEric Taylor ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */ 136842727c2SChris Kirby ZFS_PROP_DEFER_DESTROY, 137842727c2SChris Kirby ZFS_PROP_USERREFS, 138e09fa4daSNeil Perrin ZFS_PROP_LOGBIAS, 1391d713200SEric Schrock ZFS_PROP_UNIQUE, /* not exposed to the user */ 1401d713200SEric Schrock ZFS_PROP_OBJSETID, /* not exposed to the user */ 141b24ab676SJeff Bonwick ZFS_PROP_DEDUP, 1424201a95eSRic Aleshire ZFS_PROP_MLSLABEL, 14355da60b9SMark J Musante ZFS_PROP_SYNC, 144187d6ac0SMatt Ahrens ZFS_PROP_REFRATIO, 14519b94df9SMatthew Ahrens ZFS_PROP_WRITTEN, 14619b94df9SMatthew Ahrens ZFS_PROP_CLONES, 14777372cb0SMatthew Ahrens ZFS_PROP_LOGICALUSED, 14877372cb0SMatthew Ahrens ZFS_PROP_LOGICALREFERENCED, 149ca48f36fSKeith M Wesolowski ZFS_PROP_INCONSISTENT, /* not exposed to the user */ 150bc93cffdSJerry Jelinek ZFS_PROP_FILESYSTEM_LIMIT, 151bc93cffdSJerry Jelinek ZFS_PROP_SNAPSHOT_LIMIT, 152bc93cffdSJerry Jelinek ZFS_PROP_FILESYSTEM_COUNT, 153bc93cffdSJerry Jelinek ZFS_PROP_SNAPSHOT_COUNT, 154469a3d62SMatthew Ahrens ZFS_PROP_REDUNDANT_METADATA, 155ee69a30fSMatthew Ahrens ZFS_PROP_PREV_SNAP, 1568429b235SMatthew Ahrens ZFS_PROP_RECEIVE_RESUME_TOKEN, 15791ebeef5Sahrens ZFS_NUM_PROPS 158fa9e4066Sahrens } zfs_prop_t; 159fa9e4066Sahrens 16014843421SMatthew Ahrens typedef enum { 16114843421SMatthew Ahrens ZFS_PROP_USERUSED, 16214843421SMatthew Ahrens ZFS_PROP_USERQUOTA, 16314843421SMatthew Ahrens ZFS_PROP_GROUPUSED, 16414843421SMatthew Ahrens ZFS_PROP_GROUPQUOTA, 16514843421SMatthew Ahrens ZFS_NUM_USERQUOTA_PROPS 16614843421SMatthew Ahrens } zfs_userquota_prop_t; 16714843421SMatthew Ahrens 16814843421SMatthew Ahrens extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS]; 16914843421SMatthew Ahrens 170990b4856Slling /* 171990b4856Slling * Pool properties are identified by these constants and must be added to the 172b87f3af3Sperrin * end of this list to ensure that external consumers are not affected 173990b4856Slling * by the change. If you make any changes to this list, be sure to update 174990b4856Slling * the property table in usr/src/common/zfs/zpool_prop.c. 175990b4856Slling */ 176990b4856Slling typedef enum { 177990b4856Slling ZPOOL_PROP_NAME, 178990b4856Slling ZPOOL_PROP_SIZE, 179990b4856Slling ZPOOL_PROP_CAPACITY, 180990b4856Slling ZPOOL_PROP_ALTROOT, 181990b4856Slling ZPOOL_PROP_HEALTH, 182990b4856Slling ZPOOL_PROP_GUID, 183990b4856Slling ZPOOL_PROP_VERSION, 184990b4856Slling ZPOOL_PROP_BOOTFS, 185990b4856Slling ZPOOL_PROP_DELEGATION, 186990b4856Slling ZPOOL_PROP_AUTOREPLACE, 1872f8aaab3Seschrock ZPOOL_PROP_CACHEFILE, 1880a4e9518Sgw25295 ZPOOL_PROP_FAILUREMODE, 189d5b5bb25SRich Morris ZPOOL_PROP_LISTSNAPS, 190573ca77eSGeorge Wilson ZPOOL_PROP_AUTOEXPAND, 191b24ab676SJeff Bonwick ZPOOL_PROP_DEDUPDITTO, 192b24ab676SJeff Bonwick ZPOOL_PROP_DEDUPRATIO, 193485bbbf5SGeorge Wilson ZPOOL_PROP_FREE, 194485bbbf5SGeorge Wilson ZPOOL_PROP_ALLOCATED, 195f9af39baSGeorge Wilson ZPOOL_PROP_READONLY, 1968704186eSDan McDonald ZPOOL_PROP_COMMENT, 1974263d13fSGeorge Wilson ZPOOL_PROP_EXPANDSZ, 198ad135b5dSChristopher Siden ZPOOL_PROP_FREEING, 19902b647c5SGeorge Wilson ZPOOL_PROP_FRAGMENTATION, 200994617e7SMatthew Ahrens ZPOOL_PROP_LEAKED, 201d1a98260SMatthew Ahrens ZPOOL_PROP_MAXBLOCKSIZE, 202990b4856Slling ZPOOL_NUM_PROPS 203990b4856Slling } zpool_prop_t; 204b1b8ab34Slling 2058704186eSDan McDonald /* Small enough to not hog a whole line of printout in zpool(1M). */ 2068704186eSDan McDonald #define ZPROP_MAX_COMMENT 32 2078704186eSDan McDonald 208990b4856Slling #define ZPROP_CONT -2 209990b4856Slling #define ZPROP_INVAL -1 2103d7072f8Seschrock 211990b4856Slling #define ZPROP_VALUE "value" 212990b4856Slling #define ZPROP_SOURCE "source" 2137f7322feSeschrock 214b1b8ab34Slling typedef enum { 215990b4856Slling ZPROP_SRC_NONE = 0x1, 216990b4856Slling ZPROP_SRC_DEFAULT = 0x2, 217990b4856Slling ZPROP_SRC_TEMPORARY = 0x4, 218990b4856Slling ZPROP_SRC_LOCAL = 0x8, 21992241e0bSTom Erickson ZPROP_SRC_INHERITED = 0x10, 22092241e0bSTom Erickson ZPROP_SRC_RECEIVED = 0x20 221990b4856Slling } zprop_source_t; 222b1b8ab34Slling 22392241e0bSTom Erickson #define ZPROP_SRC_ALL 0x3f 22492241e0bSTom Erickson 22592241e0bSTom Erickson #define ZPROP_SOURCE_VAL_RECVD "$recvd" 22692241e0bSTom Erickson #define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS" 22792241e0bSTom Erickson /* 22892241e0bSTom Erickson * Dataset flag implemented as a special entry in the props zap object 22992241e0bSTom Erickson * indicating that the dataset has received properties on or after 23092241e0bSTom Erickson * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties 23192241e0bSTom Erickson * just as it did in earlier versions, and thereafter, local properties are 23292241e0bSTom Erickson * preserved. 23392241e0bSTom Erickson */ 23492241e0bSTom Erickson #define ZPROP_HAS_RECVD "$hasrecvd" 23592241e0bSTom Erickson 23692241e0bSTom Erickson typedef enum { 23792241e0bSTom Erickson ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */ 23892241e0bSTom Erickson ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */ 23992241e0bSTom Erickson } zprop_errflags_t; 240b1b8ab34Slling 241990b4856Slling typedef int (*zprop_func)(int, void *); 242990b4856Slling 243990b4856Slling /* 2440a48a24eStimh * Properties to be set on the root file system of a new pool 2450a48a24eStimh * are stuffed into their own nvlist, which is then included in 2460a48a24eStimh * the properties nvlist with the pool properties. 2470a48a24eStimh */ 2480a48a24eStimh #define ZPOOL_ROOTFS_PROPS "root-props-nvl" 2490a48a24eStimh 2500a48a24eStimh /* 251990b4856Slling * Dataset property functions shared between libzfs and kernel. 252990b4856Slling */ 253990b4856Slling const char *zfs_prop_default_string(zfs_prop_t); 254990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t); 255990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t); 256990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t); 257da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t); 258990b4856Slling const char *zfs_prop_to_name(zfs_prop_t); 259990b4856Slling zfs_prop_t zfs_name_to_prop(const char *); 260990b4856Slling boolean_t zfs_prop_user(const char *); 26192241e0bSTom Erickson boolean_t zfs_prop_userquota(const char *); 26219b94df9SMatthew Ahrens boolean_t zfs_prop_written(const char *); 263990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); 264990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *); 265b24ab676SJeff Bonwick uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed); 2664853e976Sgw25295 boolean_t zfs_prop_valid_for_type(int, zfs_type_t); 267990b4856Slling 268990b4856Slling /* 269990b4856Slling * Pool property functions shared between libzfs and kernel. 270990b4856Slling */ 271990b4856Slling zpool_prop_t zpool_name_to_prop(const char *); 272990b4856Slling const char *zpool_prop_to_name(zpool_prop_t); 273990b4856Slling const char *zpool_prop_default_string(zpool_prop_t); 274990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t); 275990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t); 276ad135b5dSChristopher Siden boolean_t zpool_prop_feature(const char *); 277ad135b5dSChristopher Siden boolean_t zpool_prop_unsupported(const char *name); 278990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **); 279990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *); 280b24ab676SJeff Bonwick uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed); 281990b4856Slling 282990b4856Slling /* 283990b4856Slling * Definitions for the Delegation. 284990b4856Slling */ 285ecd6cf80Smarks typedef enum { 286ecd6cf80Smarks ZFS_DELEG_WHO_UNKNOWN = 0, 287ecd6cf80Smarks ZFS_DELEG_USER = 'u', 288ecd6cf80Smarks ZFS_DELEG_USER_SETS = 'U', 289ecd6cf80Smarks ZFS_DELEG_GROUP = 'g', 290ecd6cf80Smarks ZFS_DELEG_GROUP_SETS = 'G', 291ecd6cf80Smarks ZFS_DELEG_EVERYONE = 'e', 292ecd6cf80Smarks ZFS_DELEG_EVERYONE_SETS = 'E', 293ecd6cf80Smarks ZFS_DELEG_CREATE = 'c', 294ecd6cf80Smarks ZFS_DELEG_CREATE_SETS = 'C', 295ecd6cf80Smarks ZFS_DELEG_NAMED_SET = 's', 296ecd6cf80Smarks ZFS_DELEG_NAMED_SET_SETS = 'S' 297ecd6cf80Smarks } zfs_deleg_who_type_t; 298ecd6cf80Smarks 299ecd6cf80Smarks typedef enum { 300ecd6cf80Smarks ZFS_DELEG_NONE = 0, 301ecd6cf80Smarks ZFS_DELEG_PERM_LOCAL = 1, 302ecd6cf80Smarks ZFS_DELEG_PERM_DESCENDENT = 2, 303ecd6cf80Smarks ZFS_DELEG_PERM_LOCALDESCENDENT = 3, 304ecd6cf80Smarks ZFS_DELEG_PERM_CREATE = 4 305ecd6cf80Smarks } zfs_deleg_inherit_t; 306ecd6cf80Smarks 307ecd6cf80Smarks #define ZFS_DELEG_PERM_UID "uid" 308ecd6cf80Smarks #define ZFS_DELEG_PERM_GID "gid" 309ecd6cf80Smarks #define ZFS_DELEG_PERM_GROUPS "groups" 310ecd6cf80Smarks 3114201a95eSRic Aleshire #define ZFS_MLSLABEL_DEFAULT "none" 3124201a95eSRic Aleshire 313743a77edSAlan Wright #define ZFS_SMB_ACL_SRC "src" 314743a77edSAlan Wright #define ZFS_SMB_ACL_TARGET "target" 315743a77edSAlan Wright 316a227b7f4Shs24103 typedef enum { 317a227b7f4Shs24103 ZFS_CANMOUNT_OFF = 0, 318a227b7f4Shs24103 ZFS_CANMOUNT_ON = 1, 319a227b7f4Shs24103 ZFS_CANMOUNT_NOAUTO = 2 320a227b7f4Shs24103 } zfs_canmount_type_t; 321a227b7f4Shs24103 322e09fa4daSNeil Perrin typedef enum { 323e09fa4daSNeil Perrin ZFS_LOGBIAS_LATENCY = 0, 324e09fa4daSNeil Perrin ZFS_LOGBIAS_THROUGHPUT = 1 325e09fa4daSNeil Perrin } zfs_logbias_op_t; 326e09fa4daSNeil Perrin 327da6c28aaSamw typedef enum zfs_share_op { 328da6c28aaSamw ZFS_SHARE_NFS = 0, 329da6c28aaSamw ZFS_UNSHARE_NFS = 1, 330da6c28aaSamw ZFS_SHARE_SMB = 2, 331da6c28aaSamw ZFS_UNSHARE_SMB = 3 332da6c28aaSamw } zfs_share_op_t; 333da6c28aaSamw 334743a77edSAlan Wright typedef enum zfs_smb_acl_op { 335743a77edSAlan Wright ZFS_SMB_ACL_ADD, 336743a77edSAlan Wright ZFS_SMB_ACL_REMOVE, 337743a77edSAlan Wright ZFS_SMB_ACL_RENAME, 338743a77edSAlan Wright ZFS_SMB_ACL_PURGE 339743a77edSAlan Wright } zfs_smb_acl_op_t; 340743a77edSAlan Wright 3413baa08fcSek110237 typedef enum zfs_cache_type { 3423baa08fcSek110237 ZFS_CACHE_NONE = 0, 3433baa08fcSek110237 ZFS_CACHE_METADATA = 1, 3443baa08fcSek110237 ZFS_CACHE_ALL = 2 3453baa08fcSek110237 } zfs_cache_type_t; 3463baa08fcSek110237 34755da60b9SMark J Musante typedef enum { 34855da60b9SMark J Musante ZFS_SYNC_STANDARD = 0, 34955da60b9SMark J Musante ZFS_SYNC_ALWAYS = 1, 35055da60b9SMark J Musante ZFS_SYNC_DISABLED = 2 35155da60b9SMark J Musante } zfs_sync_type_t; 35255da60b9SMark J Musante 353469a3d62SMatthew Ahrens typedef enum { 354469a3d62SMatthew Ahrens ZFS_REDUNDANT_METADATA_ALL, 355469a3d62SMatthew Ahrens ZFS_REDUNDANT_METADATA_MOST 356469a3d62SMatthew Ahrens } zfs_redundant_metadata_type_t; 3573baa08fcSek110237 358fa9e4066Sahrens /* 35999653d4eSeschrock * On-disk version number. 360eaca9bbdSeschrock */ 361e7437265Sahrens #define SPA_VERSION_1 1ULL 362e7437265Sahrens #define SPA_VERSION_2 2ULL 363e7437265Sahrens #define SPA_VERSION_3 3ULL 364e7437265Sahrens #define SPA_VERSION_4 4ULL 365e7437265Sahrens #define SPA_VERSION_5 5ULL 366e7437265Sahrens #define SPA_VERSION_6 6ULL 367e7437265Sahrens #define SPA_VERSION_7 7ULL 368e7437265Sahrens #define SPA_VERSION_8 8ULL 369da6c28aaSamw #define SPA_VERSION_9 9ULL 370fa94a07fSbrendan #define SPA_VERSION_10 10ULL 371088f3894Sahrens #define SPA_VERSION_11 11ULL 372bb0ade09Sahrens #define SPA_VERSION_12 12ULL 37374e7dc98SMatthew Ahrens #define SPA_VERSION_13 13ULL 374d0f3f37eSMark Shellenbaum #define SPA_VERSION_14 14ULL 37514843421SMatthew Ahrens #define SPA_VERSION_15 15ULL 376478ed9adSEric Taylor #define SPA_VERSION_16 16ULL 377f94275ceSAdam Leventhal #define SPA_VERSION_17 17ULL 378842727c2SChris Kirby #define SPA_VERSION_18 18ULL 37988ecc943SGeorge Wilson #define SPA_VERSION_19 19ULL 380b24ab676SJeff Bonwick #define SPA_VERSION_20 20ULL 381b24ab676SJeff Bonwick #define SPA_VERSION_21 21ULL 38292241e0bSTom Erickson #define SPA_VERSION_22 22ULL 3836e1f5caaSNeil Perrin #define SPA_VERSION_23 23ULL 3840a586ceaSMark Shellenbaum #define SPA_VERSION_24 24ULL 3853f9d6ad7SLin Ling #define SPA_VERSION_25 25ULL 386cde58dbcSMatthew Ahrens #define SPA_VERSION_26 26ULL 3876e0cbcaaSMatthew Ahrens #define SPA_VERSION_27 27ULL 388cb04b873SMark J Musante #define SPA_VERSION_28 28ULL 389ad135b5dSChristopher Siden #define SPA_VERSION_5000 5000ULL 390cb04b873SMark J Musante 391b1b8ab34Slling /* 392e7cbe64fSgw25295 * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk 393478ed9adSEric Taylor * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*}, 39414843421SMatthew Ahrens * and do the appropriate changes. Also bump the version number in 39514843421SMatthew Ahrens * usr/src/grub/capability. 396b1b8ab34Slling */ 397ad135b5dSChristopher Siden #define SPA_VERSION SPA_VERSION_5000 398ad135b5dSChristopher Siden #define SPA_VERSION_STRING "5000" 39944cd46caSbillm 40044cd46caSbillm /* 401e7437265Sahrens * Symbolic names for the changes that caused a SPA_VERSION switch. 40244cd46caSbillm * Used in the code when checking for presence or absence of a feature. 40344cd46caSbillm * Feel free to define multiple symbolic names for each version if there 40444cd46caSbillm * were multiple changes to on-disk structures during that version. 40544cd46caSbillm * 406e7437265Sahrens * NOTE: When checking the current SPA_VERSION in your code, be sure 40744cd46caSbillm * to use spa_version() since it reports the version of the 40844cd46caSbillm * last synced uberblock. Checking the in-flight version can 40944cd46caSbillm * be dangerous in some cases. 41044cd46caSbillm */ 411e7437265Sahrens #define SPA_VERSION_INITIAL SPA_VERSION_1 412e7437265Sahrens #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 413e7437265Sahrens #define SPA_VERSION_SPARES SPA_VERSION_3 414f94275ceSAdam Leventhal #define SPA_VERSION_RAIDZ2 SPA_VERSION_3 415cde58dbcSMatthew Ahrens #define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3 416e7437265Sahrens #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 417e7437265Sahrens #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 418e7437265Sahrens #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 419e7437265Sahrens #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 420e7437265Sahrens #define SPA_VERSION_BOOTFS SPA_VERSION_6 421990b4856Slling #define SPA_VERSION_SLOGS SPA_VERSION_7 422990b4856Slling #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8 423da6c28aaSamw #define SPA_VERSION_FUID SPA_VERSION_9 424a9799022Sck153898 #define SPA_VERSION_REFRESERVATION SPA_VERSION_9 425a9799022Sck153898 #define SPA_VERSION_REFQUOTA SPA_VERSION_9 426a9799022Sck153898 #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9 427fa94a07fSbrendan #define SPA_VERSION_L2CACHE SPA_VERSION_10 428088f3894Sahrens #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11 429088f3894Sahrens #define SPA_VERSION_ORIGIN SPA_VERSION_11 430088f3894Sahrens #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11 431bb0ade09Sahrens #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12 43274e7dc98SMatthew Ahrens #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13 433d0f3f37eSMark Shellenbaum #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14 43414843421SMatthew Ahrens #define SPA_VERSION_USERSPACE SPA_VERSION_15 435478ed9adSEric Taylor #define SPA_VERSION_STMF_PROP SPA_VERSION_16 436f94275ceSAdam Leventhal #define SPA_VERSION_RAIDZ3 SPA_VERSION_17 437842727c2SChris Kirby #define SPA_VERSION_USERREFS SPA_VERSION_18 43888ecc943SGeorge Wilson #define SPA_VERSION_HOLES SPA_VERSION_19 439b24ab676SJeff Bonwick #define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20 440b24ab676SJeff Bonwick #define SPA_VERSION_DEDUP SPA_VERSION_21 44192241e0bSTom Erickson #define SPA_VERSION_RECVD_PROPS SPA_VERSION_22 4426e1f5caaSNeil Perrin #define SPA_VERSION_SLIM_ZIL SPA_VERSION_23 4430a586ceaSMark Shellenbaum #define SPA_VERSION_SA SPA_VERSION_24 4443f9d6ad7SLin Ling #define SPA_VERSION_SCAN SPA_VERSION_25 445cde58dbcSMatthew Ahrens #define SPA_VERSION_DIR_CLONES SPA_VERSION_26 446cde58dbcSMatthew Ahrens #define SPA_VERSION_DEADLISTS SPA_VERSION_26 4476e0cbcaaSMatthew Ahrens #define SPA_VERSION_FAST_SNAP SPA_VERSION_27 448cb04b873SMark J Musante #define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28 449ad135b5dSChristopher Siden #define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28 450ad135b5dSChristopher Siden #define SPA_VERSION_FEATURES SPA_VERSION_5000 451ad135b5dSChristopher Siden 452ad135b5dSChristopher Siden #define SPA_VERSION_IS_SUPPORTED(v) \ 453ad135b5dSChristopher Siden (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \ 454ad135b5dSChristopher Siden ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION)) 455e7437265Sahrens 456e7437265Sahrens /* 457e7437265Sahrens * ZPL version - rev'd whenever an incompatible on-disk format change 458e7437265Sahrens * occurs. This is independent of SPA/DMU/ZAP versioning. You must 459e7437265Sahrens * also update the version_table[] and help message in zfs_prop.c. 460e7437265Sahrens * 461e7437265Sahrens * When changing, be sure to teach GRUB how to read the new format! 462478ed9adSEric Taylor * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*} 463e7437265Sahrens */ 464e7437265Sahrens #define ZPL_VERSION_1 1ULL 465e7437265Sahrens #define ZPL_VERSION_2 2ULL 466da6c28aaSamw #define ZPL_VERSION_3 3ULL 46714843421SMatthew Ahrens #define ZPL_VERSION_4 4ULL 4680a586ceaSMark Shellenbaum #define ZPL_VERSION_5 5ULL 4690a586ceaSMark Shellenbaum #define ZPL_VERSION ZPL_VERSION_5 4700a586ceaSMark Shellenbaum #define ZPL_VERSION_STRING "5" 471e7437265Sahrens 472e7437265Sahrens #define ZPL_VERSION_INITIAL ZPL_VERSION_1 473e7437265Sahrens #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 474da6c28aaSamw #define ZPL_VERSION_FUID ZPL_VERSION_3 475de8267e0Stimh #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3 476da6c28aaSamw #define ZPL_VERSION_SYSATTR ZPL_VERSION_3 47714843421SMatthew Ahrens #define ZPL_VERSION_USERSPACE ZPL_VERSION_4 4780a586ceaSMark Shellenbaum #define ZPL_VERSION_SA ZPL_VERSION_5 479eaca9bbdSeschrock 480468c413aSTim Haley /* Rewind request information */ 481c8ee1847SVictor Latushkin #define ZPOOL_NO_REWIND 1 /* No policy - default behavior */ 482c8ee1847SVictor Latushkin #define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */ 483c8ee1847SVictor Latushkin #define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */ 484c8ee1847SVictor Latushkin #define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */ 485c8ee1847SVictor Latushkin #define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */ 486c8ee1847SVictor Latushkin #define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */ 487c8ee1847SVictor Latushkin #define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */ 488468c413aSTim Haley 489468c413aSTim Haley typedef struct zpool_rewind_policy { 490468c413aSTim Haley uint32_t zrp_request; /* rewind behavior requested */ 491c8ee1847SVictor Latushkin uint64_t zrp_maxmeta; /* max acceptable meta-data errors */ 492c8ee1847SVictor Latushkin uint64_t zrp_maxdata; /* max acceptable data errors */ 493468c413aSTim Haley uint64_t zrp_txg; /* specific txg to load */ 494468c413aSTim Haley } zpool_rewind_policy_t; 495468c413aSTim Haley 496eaca9bbdSeschrock /* 497fa9e4066Sahrens * The following are configuration names used in the nvlist describing a pool's 498fa9e4066Sahrens * configuration. 499fa9e4066Sahrens */ 500fa9e4066Sahrens #define ZPOOL_CONFIG_VERSION "version" 501fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_NAME "name" 502fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_STATE "state" 503fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_TXG "txg" 504fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_GUID "pool_guid" 505fa9e4066Sahrens #define ZPOOL_CONFIG_CREATE_TXG "create_txg" 506fa9e4066Sahrens #define ZPOOL_CONFIG_TOP_GUID "top_guid" 507fa9e4066Sahrens #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" 508fa9e4066Sahrens #define ZPOOL_CONFIG_TYPE "type" 509fa9e4066Sahrens #define ZPOOL_CONFIG_CHILDREN "children" 510fa9e4066Sahrens #define ZPOOL_CONFIG_ID "id" 511fa9e4066Sahrens #define ZPOOL_CONFIG_GUID "guid" 512fa9e4066Sahrens #define ZPOOL_CONFIG_PATH "path" 513fa9e4066Sahrens #define ZPOOL_CONFIG_DEVID "devid" 514fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" 515fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" 516fa9e4066Sahrens #define ZPOOL_CONFIG_ASHIFT "ashift" 517fa9e4066Sahrens #define ZPOOL_CONFIG_ASIZE "asize" 518fa9e4066Sahrens #define ZPOOL_CONFIG_DTL "DTL" 5193f9d6ad7SLin Ling #define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */ 5203f9d6ad7SLin Ling #define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */ 521afefbcddSeschrock #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" 522ea8dc4b6Seschrock #define ZPOOL_CONFIG_ERRCOUNT "error_count" 523ea8dc4b6Seschrock #define ZPOOL_CONFIG_NOT_PRESENT "not_present" 52499653d4eSeschrock #define ZPOOL_CONFIG_SPARES "spares" 52599653d4eSeschrock #define ZPOOL_CONFIG_IS_SPARE "is_spare" 52699653d4eSeschrock #define ZPOOL_CONFIG_NPARITY "nparity" 52795173954Sek110237 #define ZPOOL_CONFIG_HOSTID "hostid" 52895173954Sek110237 #define ZPOOL_CONFIG_HOSTNAME "hostname" 52911027bc7STim Haley #define ZPOOL_CONFIG_LOADED_TIME "initial_load_time" 5303d7072f8Seschrock #define ZPOOL_CONFIG_UNSPARE "unspare" 5313d7072f8Seschrock #define ZPOOL_CONFIG_PHYS_PATH "phys_path" 5328654d025Sperrin #define ZPOOL_CONFIG_IS_LOG "is_log" 533fa94a07fSbrendan #define ZPOOL_CONFIG_L2CACHE "l2cache" 534d5de1674SSaso Kiselkov #define ZPOOL_CONFIG_L2CACHE_PERSISTENT "l2cache_persistent" 53588ecc943SGeorge Wilson #define ZPOOL_CONFIG_HOLE_ARRAY "hole_array" 53688ecc943SGeorge Wilson #define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children" 53788ecc943SGeorge Wilson #define ZPOOL_CONFIG_IS_HOLE "is_hole" 5389eb19f4dSGeorge Wilson #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram" 5399eb19f4dSGeorge Wilson #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats" 5409eb19f4dSGeorge Wilson #define ZPOOL_CONFIG_DDT_STATS "ddt_stats" 5411195e687SMark J Musante #define ZPOOL_CONFIG_SPLIT "splitcfg" 5421195e687SMark J Musante #define ZPOOL_CONFIG_ORIG_GUID "orig_guid" 5431195e687SMark J Musante #define ZPOOL_CONFIG_SPLIT_GUID "split_guid" 5441195e687SMark J Musante #define ZPOOL_CONFIG_SPLIT_LIST "guid_list" 5453f9d6ad7SLin Ling #define ZPOOL_CONFIG_REMOVING "removing" 546b4952e17SGeorge Wilson #define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg" 5478704186eSDan McDonald #define ZPOOL_CONFIG_COMMENT "comment" 548e14bb325SJeff Bonwick #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */ 549e7cbe64fSgw25295 #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ 550e7cbe64fSgw25295 #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */ 5514b964adaSGeorge Wilson #define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */ 5524b964adaSGeorge Wilson #define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */ 553ad135b5dSChristopher Siden #define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */ 554ad135b5dSChristopher Siden #define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */ 55557221772SChristopher Siden #define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */ 556ad135b5dSChristopher Siden #define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */ 557ad135b5dSChristopher Siden #define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read" 558ad135b5dSChristopher Siden #define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */ 5593d7072f8Seschrock /* 5603d7072f8Seschrock * The persistent vdev state is stored as separate values rather than a single 5613d7072f8Seschrock * 'vdev_state' entry. This is because a device can be in multiple states, such 5623d7072f8Seschrock * as offline and degraded. 5633d7072f8Seschrock */ 5643d7072f8Seschrock #define ZPOOL_CONFIG_OFFLINE "offline" 5653d7072f8Seschrock #define ZPOOL_CONFIG_FAULTED "faulted" 5663d7072f8Seschrock #define ZPOOL_CONFIG_DEGRADED "degraded" 5673d7072f8Seschrock #define ZPOOL_CONFIG_REMOVED "removed" 5686809eb4eSEric Schrock #define ZPOOL_CONFIG_FRU "fru" 569069f55e2SEric Schrock #define ZPOOL_CONFIG_AUX_STATE "aux_state" 570fa9e4066Sahrens 571468c413aSTim Haley /* Rewind policy parameters */ 572468c413aSTim Haley #define ZPOOL_REWIND_POLICY "rewind-policy" 573468c413aSTim Haley #define ZPOOL_REWIND_REQUEST "rewind-request" 574468c413aSTim Haley #define ZPOOL_REWIND_REQUEST_TXG "rewind-request-txg" 575468c413aSTim Haley #define ZPOOL_REWIND_META_THRESH "rewind-meta-thresh" 576468c413aSTim Haley #define ZPOOL_REWIND_DATA_THRESH "rewind-data-thresh" 577468c413aSTim Haley 578468c413aSTim Haley /* Rewind data discovered */ 579468c413aSTim Haley #define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts" 580468c413aSTim Haley #define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors" 581468c413aSTim Haley #define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind" 582468c413aSTim Haley 583fa9e4066Sahrens #define VDEV_TYPE_ROOT "root" 584fa9e4066Sahrens #define VDEV_TYPE_MIRROR "mirror" 585fa9e4066Sahrens #define VDEV_TYPE_REPLACING "replacing" 586fa9e4066Sahrens #define VDEV_TYPE_RAIDZ "raidz" 587fa9e4066Sahrens #define VDEV_TYPE_DISK "disk" 588fa9e4066Sahrens #define VDEV_TYPE_FILE "file" 589fa9e4066Sahrens #define VDEV_TYPE_MISSING "missing" 59088ecc943SGeorge Wilson #define VDEV_TYPE_HOLE "hole" 59199653d4eSeschrock #define VDEV_TYPE_SPARE "spare" 5928654d025Sperrin #define VDEV_TYPE_LOG "log" 593fa94a07fSbrendan #define VDEV_TYPE_L2CACHE "l2cache" 594fa9e4066Sahrens 595fa9e4066Sahrens /* 596fa9e4066Sahrens * This is needed in userland to report the minimum necessary device size. 597fa9e4066Sahrens */ 598fa9e4066Sahrens #define SPA_MINDEVSIZE (64ULL << 20) 599fa9e4066Sahrens 600fa9e4066Sahrens /* 60102b647c5SGeorge Wilson * Set if the fragmentation has not yet been calculated. This can happen 60202b647c5SGeorge Wilson * because the space maps have not been upgraded or the histogram feature 60302b647c5SGeorge Wilson * is not enabled. 60402b647c5SGeorge Wilson */ 60502b647c5SGeorge Wilson #define ZFS_FRAG_INVALID UINT64_MAX 60602b647c5SGeorge Wilson 60702b647c5SGeorge Wilson /* 608fa9e4066Sahrens * The location of the pool configuration repository, shared between kernel and 609fa9e4066Sahrens * userland. 610fa9e4066Sahrens */ 611c5904d13Seschrock #define ZPOOL_CACHE "/etc/zfs/zpool.cache" 612fa9e4066Sahrens 613fa9e4066Sahrens /* 614fa9e4066Sahrens * vdev states are ordered from least to most healthy. 615fa9e4066Sahrens * A vdev that's CANT_OPEN or below is considered unusable. 616fa9e4066Sahrens */ 617fa9e4066Sahrens typedef enum vdev_state { 618fa9e4066Sahrens VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ 619fa9e4066Sahrens VDEV_STATE_CLOSED, /* Not currently open */ 620fa9e4066Sahrens VDEV_STATE_OFFLINE, /* Not allowed to open */ 6213d7072f8Seschrock VDEV_STATE_REMOVED, /* Explicitly removed from system */ 622fa9e4066Sahrens VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ 6233d7072f8Seschrock VDEV_STATE_FAULTED, /* External request to fault device */ 624fa9e4066Sahrens VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ 625fa9e4066Sahrens VDEV_STATE_HEALTHY /* Presumed good */ 626fa9e4066Sahrens } vdev_state_t; 627fa9e4066Sahrens 6283d7072f8Seschrock #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY 6293d7072f8Seschrock 630fa9e4066Sahrens /* 631fa9e4066Sahrens * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field 632fa9e4066Sahrens * of the vdev stats structure uses these constants to distinguish why. 633fa9e4066Sahrens */ 634fa9e4066Sahrens typedef enum vdev_aux { 635fa9e4066Sahrens VDEV_AUX_NONE, /* no error */ 636fa9e4066Sahrens VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ 637fa9e4066Sahrens VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ 638fa9e4066Sahrens VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ 639fa9e4066Sahrens VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ 640fa9e4066Sahrens VDEV_AUX_TOO_SMALL, /* vdev size is too small */ 641eaca9bbdSeschrock VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ 642eaca9bbdSeschrock VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ 64399653d4eSeschrock VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ 644ad135b5dSChristopher Siden VDEV_AUX_UNSUP_FEAT, /* unsupported features */ 6453d7072f8Seschrock VDEV_AUX_SPARED, /* hot spare used in another pool */ 64632b87932Sek110237 VDEV_AUX_ERR_EXCEEDED, /* too many errors */ 647b87f3af3Sperrin VDEV_AUX_IO_FAILURE, /* experienced I/O failure */ 648069f55e2SEric Schrock VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */ 6491195e687SMark J Musante VDEV_AUX_EXTERNAL, /* external diagnosis */ 6501195e687SMark J Musante VDEV_AUX_SPLIT_POOL /* vdev was split off into another pool */ 651fa9e4066Sahrens } vdev_aux_t; 652fa9e4066Sahrens 653fa9e4066Sahrens /* 65446a2abf2Seschrock * pool state. The following states are written to disk as part of the normal 655fa94a07fSbrendan * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining 656fa94a07fSbrendan * states are software abstractions used at various levels to communicate 657fa94a07fSbrendan * pool state. 658fa9e4066Sahrens */ 659fa9e4066Sahrens typedef enum pool_state { 660fa9e4066Sahrens POOL_STATE_ACTIVE = 0, /* In active use */ 661fa9e4066Sahrens POOL_STATE_EXPORTED, /* Explicitly exported */ 662fa9e4066Sahrens POOL_STATE_DESTROYED, /* Explicitly destroyed */ 66399653d4eSeschrock POOL_STATE_SPARE, /* Reserved for hot spare use */ 664fa94a07fSbrendan POOL_STATE_L2CACHE, /* Level 2 ARC device */ 665fa9e4066Sahrens POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ 66646a2abf2Seschrock POOL_STATE_UNAVAIL, /* Internal libzfs state */ 66746a2abf2Seschrock POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ 668fa9e4066Sahrens } pool_state_t; 669fa9e4066Sahrens 670fa9e4066Sahrens /* 6713f9d6ad7SLin Ling * Scan Functions. 672fa9e4066Sahrens */ 6733f9d6ad7SLin Ling typedef enum pool_scan_func { 6743f9d6ad7SLin Ling POOL_SCAN_NONE, 6753f9d6ad7SLin Ling POOL_SCAN_SCRUB, 6763f9d6ad7SLin Ling POOL_SCAN_RESILVER, 6773f9d6ad7SLin Ling POOL_SCAN_FUNCS 6783f9d6ad7SLin Ling } pool_scan_func_t; 679fa9e4066Sahrens 680fa9e4066Sahrens /* 681fa9e4066Sahrens * ZIO types. Needed to interpret vdev statistics below. 682fa9e4066Sahrens */ 683fa9e4066Sahrens typedef enum zio_type { 684fa9e4066Sahrens ZIO_TYPE_NULL = 0, 685fa9e4066Sahrens ZIO_TYPE_READ, 686fa9e4066Sahrens ZIO_TYPE_WRITE, 687fa9e4066Sahrens ZIO_TYPE_FREE, 688fa9e4066Sahrens ZIO_TYPE_CLAIM, 689fa9e4066Sahrens ZIO_TYPE_IOCTL, 690fa9e4066Sahrens ZIO_TYPES 691fa9e4066Sahrens } zio_type_t; 692fa9e4066Sahrens 693fa9e4066Sahrens /* 6943f9d6ad7SLin Ling * Pool statistics. Note: all fields should be 64-bit because this 6953f9d6ad7SLin Ling * is passed between kernel and userland as an nvlist uint64 array. 6963f9d6ad7SLin Ling */ 6973f9d6ad7SLin Ling typedef struct pool_scan_stat { 6983f9d6ad7SLin Ling /* values stored on disk */ 6993f9d6ad7SLin Ling uint64_t pss_func; /* pool_scan_func_t */ 7003f9d6ad7SLin Ling uint64_t pss_state; /* dsl_scan_state_t */ 7013f9d6ad7SLin Ling uint64_t pss_start_time; /* scan start time */ 7023f9d6ad7SLin Ling uint64_t pss_end_time; /* scan end time */ 7033f9d6ad7SLin Ling uint64_t pss_to_examine; /* total bytes to scan */ 7043f9d6ad7SLin Ling uint64_t pss_examined; /* total examined bytes */ 7053f9d6ad7SLin Ling uint64_t pss_to_process; /* total bytes to process */ 7063f9d6ad7SLin Ling uint64_t pss_processed; /* total processed bytes */ 7073f9d6ad7SLin Ling uint64_t pss_errors; /* scan errors */ 7083f9d6ad7SLin Ling 7093f9d6ad7SLin Ling /* values not stored on disk */ 7103f9d6ad7SLin Ling uint64_t pss_pass_exam; /* examined bytes per scan pass */ 7113f9d6ad7SLin Ling uint64_t pss_pass_start; /* start time of a scan pass */ 7123f9d6ad7SLin Ling } pool_scan_stat_t; 7133f9d6ad7SLin Ling 7143f9d6ad7SLin Ling typedef enum dsl_scan_state { 7153f9d6ad7SLin Ling DSS_NONE, 7163f9d6ad7SLin Ling DSS_SCANNING, 7173f9d6ad7SLin Ling DSS_FINISHED, 7183f9d6ad7SLin Ling DSS_CANCELED, 7193f9d6ad7SLin Ling DSS_NUM_STATES 7203f9d6ad7SLin Ling } dsl_scan_state_t; 7213f9d6ad7SLin Ling 7223f9d6ad7SLin Ling 7233f9d6ad7SLin Ling /* 724fa9e4066Sahrens * Vdev statistics. Note: all fields should be 64-bit because this 725fa9e4066Sahrens * is passed between kernel and userland as an nvlist uint64 array. 726fa9e4066Sahrens */ 727fa9e4066Sahrens typedef struct vdev_stat { 728fa9e4066Sahrens hrtime_t vs_timestamp; /* time since vdev load */ 729fa9e4066Sahrens uint64_t vs_state; /* vdev state */ 730fa9e4066Sahrens uint64_t vs_aux; /* see vdev_aux_t */ 731fa9e4066Sahrens uint64_t vs_alloc; /* space allocated */ 732fa9e4066Sahrens uint64_t vs_space; /* total capacity */ 73399653d4eSeschrock uint64_t vs_dspace; /* deflated capacity */ 7342a79c5feSlling uint64_t vs_rsize; /* replaceable dev size */ 7354263d13fSGeorge Wilson uint64_t vs_esize; /* expandable dev size */ 736fa9e4066Sahrens uint64_t vs_ops[ZIO_TYPES]; /* operation count */ 737fa9e4066Sahrens uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */ 738fa9e4066Sahrens uint64_t vs_read_errors; /* read errors */ 739fa9e4066Sahrens uint64_t vs_write_errors; /* write errors */ 740fa9e4066Sahrens uint64_t vs_checksum_errors; /* checksum errors */ 741fa9e4066Sahrens uint64_t vs_self_healed; /* self-healed bytes */ 7423f9d6ad7SLin Ling uint64_t vs_scan_removing; /* removing? */ 7433f9d6ad7SLin Ling uint64_t vs_scan_processed; /* scan processed bytes */ 74402b647c5SGeorge Wilson uint64_t vs_fragmentation; /* device fragmentation */ 745fa9e4066Sahrens } vdev_stat_t; 746fa9e4066Sahrens 7479eb19f4dSGeorge Wilson /* 7489eb19f4dSGeorge Wilson * DDT statistics. Note: all fields should be 64-bit because this 7499eb19f4dSGeorge Wilson * is passed between kernel and userland as an nvlist uint64 array. 7509eb19f4dSGeorge Wilson */ 7519eb19f4dSGeorge Wilson typedef struct ddt_object { 7529eb19f4dSGeorge Wilson uint64_t ddo_count; /* number of elments in ddt */ 7539eb19f4dSGeorge Wilson uint64_t ddo_dspace; /* size of ddt on disk */ 7549eb19f4dSGeorge Wilson uint64_t ddo_mspace; /* size of ddt in-core */ 7559eb19f4dSGeorge Wilson } ddt_object_t; 7569eb19f4dSGeorge Wilson 7579eb19f4dSGeorge Wilson typedef struct ddt_stat { 7589eb19f4dSGeorge Wilson uint64_t dds_blocks; /* blocks */ 7599eb19f4dSGeorge Wilson uint64_t dds_lsize; /* logical size */ 7609eb19f4dSGeorge Wilson uint64_t dds_psize; /* physical size */ 7619eb19f4dSGeorge Wilson uint64_t dds_dsize; /* deflated allocated size */ 7629eb19f4dSGeorge Wilson uint64_t dds_ref_blocks; /* referenced blocks */ 7639eb19f4dSGeorge Wilson uint64_t dds_ref_lsize; /* referenced lsize * refcnt */ 7649eb19f4dSGeorge Wilson uint64_t dds_ref_psize; /* referenced psize * refcnt */ 7659eb19f4dSGeorge Wilson uint64_t dds_ref_dsize; /* referenced dsize * refcnt */ 7669eb19f4dSGeorge Wilson } ddt_stat_t; 7679eb19f4dSGeorge Wilson 7689eb19f4dSGeorge Wilson typedef struct ddt_histogram { 7699eb19f4dSGeorge Wilson ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */ 7709eb19f4dSGeorge Wilson } ddt_histogram_t; 7719eb19f4dSGeorge Wilson 772e7cbe64fSgw25295 #define ZVOL_DRIVER "zvol" 773fa9e4066Sahrens #define ZFS_DRIVER "zfs" 774fa9e4066Sahrens #define ZFS_DEV "/dev/zfs" 775fa9e4066Sahrens 776681d9761SEric Taylor /* general zvol path */ 777681d9761SEric Taylor #define ZVOL_DIR "/dev/zvol" 778681d9761SEric Taylor /* expansion */ 779573ca77eSGeorge Wilson #define ZVOL_PSEUDO_DEV "/devices/pseudo/zfs@0:" 780681d9761SEric Taylor /* for dump and swap */ 781681d9761SEric Taylor #define ZVOL_FULL_DEV_DIR ZVOL_DIR "/dsk/" 782681d9761SEric Taylor #define ZVOL_FULL_RDEV_DIR ZVOL_DIR "/rdsk/" 783fa9e4066Sahrens 784fa9e4066Sahrens #define ZVOL_PROP_NAME "name" 785c1449561SEric Taylor #define ZVOL_DEFAULT_BLOCKSIZE 8192 786fa9e4066Sahrens 787fa9e4066Sahrens /* 788fa9e4066Sahrens * /dev/zfs ioctl numbers. 789fa9e4066Sahrens */ 790fa9e4066Sahrens typedef enum zfs_ioc { 7914445fffbSMatthew Ahrens ZFS_IOC_FIRST = ('Z' << 8), 7924445fffbSMatthew Ahrens ZFS_IOC = ZFS_IOC_FIRST, 7934445fffbSMatthew Ahrens ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST, 794fa9e4066Sahrens ZFS_IOC_POOL_DESTROY, 795fa9e4066Sahrens ZFS_IOC_POOL_IMPORT, 796fa9e4066Sahrens ZFS_IOC_POOL_EXPORT, 797fa9e4066Sahrens ZFS_IOC_POOL_CONFIGS, 798fa9e4066Sahrens ZFS_IOC_POOL_STATS, 799fa9e4066Sahrens ZFS_IOC_POOL_TRYIMPORT, 8003f9d6ad7SLin Ling ZFS_IOC_POOL_SCAN, 801fa9e4066Sahrens ZFS_IOC_POOL_FREEZE, 802eaca9bbdSeschrock ZFS_IOC_POOL_UPGRADE, 80306eeb2adSek110237 ZFS_IOC_POOL_GET_HISTORY, 804fa9e4066Sahrens ZFS_IOC_VDEV_ADD, 805fa9e4066Sahrens ZFS_IOC_VDEV_REMOVE, 8063d7072f8Seschrock ZFS_IOC_VDEV_SET_STATE, 807fa9e4066Sahrens ZFS_IOC_VDEV_ATTACH, 808fa9e4066Sahrens ZFS_IOC_VDEV_DETACH, 809c67d9675Seschrock ZFS_IOC_VDEV_SETPATH, 8106809eb4eSEric Schrock ZFS_IOC_VDEV_SETFRU, 811fa9e4066Sahrens ZFS_IOC_OBJSET_STATS, 812de8267e0Stimh ZFS_IOC_OBJSET_ZPLPROPS, 813fa9e4066Sahrens ZFS_IOC_DATASET_LIST_NEXT, 814fa9e4066Sahrens ZFS_IOC_SNAPSHOT_LIST_NEXT, 815fa9e4066Sahrens ZFS_IOC_SET_PROP, 816fa9e4066Sahrens ZFS_IOC_CREATE, 817fa9e4066Sahrens ZFS_IOC_DESTROY, 818fa9e4066Sahrens ZFS_IOC_ROLLBACK, 819fa9e4066Sahrens ZFS_IOC_RENAME, 8203cb34c60Sahrens ZFS_IOC_RECV, 8213cb34c60Sahrens ZFS_IOC_SEND, 822ea8dc4b6Seschrock ZFS_IOC_INJECT_FAULT, 823ea8dc4b6Seschrock ZFS_IOC_CLEAR_FAULT, 824ea8dc4b6Seschrock ZFS_IOC_INJECT_LIST_NEXT, 825ea8dc4b6Seschrock ZFS_IOC_ERROR_LOG, 826ea8dc4b6Seschrock ZFS_IOC_CLEAR, 8271d452cf5Sahrens ZFS_IOC_PROMOTE, 82855434c77Sek110237 ZFS_IOC_SNAPSHOT, 82955434c77Sek110237 ZFS_IOC_DSOBJ_TO_DSNAME, 830b1b8ab34Slling ZFS_IOC_OBJ_TO_PATH, 831b1b8ab34Slling ZFS_IOC_POOL_SET_PROPS, 832ecd6cf80Smarks ZFS_IOC_POOL_GET_PROPS, 833ecd6cf80Smarks ZFS_IOC_SET_FSACL, 834ecd6cf80Smarks ZFS_IOC_GET_FSACL, 835e45ce728Sahrens ZFS_IOC_SHARE, 836743a77edSAlan Wright ZFS_IOC_INHERIT_PROP, 83714843421SMatthew Ahrens ZFS_IOC_SMB_ACL, 83814843421SMatthew Ahrens ZFS_IOC_USERSPACE_ONE, 83914843421SMatthew Ahrens ZFS_IOC_USERSPACE_MANY, 840842727c2SChris Kirby ZFS_IOC_USERSPACE_UPGRADE, 841842727c2SChris Kirby ZFS_IOC_HOLD, 842842727c2SChris Kirby ZFS_IOC_RELEASE, 84392241e0bSTom Erickson ZFS_IOC_GET_HOLDS, 8441195e687SMark J Musante ZFS_IOC_OBJSET_RECVD_PROPS, 84599d5e173STim Haley ZFS_IOC_VDEV_SPLIT, 84699d5e173STim Haley ZFS_IOC_NEXT_OBJ, 84799d5e173STim Haley ZFS_IOC_DIFF, 84899d5e173STim Haley ZFS_IOC_TMP_SNAPSHOT, 849e9103aaeSGarrett D'Amore ZFS_IOC_OBJ_TO_STATS, 85019b94df9SMatthew Ahrens ZFS_IOC_SPACE_WRITTEN, 85119b94df9SMatthew Ahrens ZFS_IOC_SPACE_SNAPS, 8524445fffbSMatthew Ahrens ZFS_IOC_DESTROY_SNAPS, 8534263d13fSGeorge Wilson ZFS_IOC_POOL_REGUID, 8544e3c9f44SBill Pijewski ZFS_IOC_POOL_REOPEN, 8554445fffbSMatthew Ahrens ZFS_IOC_SEND_PROGRESS, 8564445fffbSMatthew Ahrens ZFS_IOC_LOG_HISTORY, 8574445fffbSMatthew Ahrens ZFS_IOC_SEND_NEW, 8584445fffbSMatthew Ahrens ZFS_IOC_SEND_SPACE, 8594445fffbSMatthew Ahrens ZFS_IOC_CLONE, 860aa075980SAndreas Jaekel ZFS_IOC_SET_ZEV_CALLBACKS, 861aa075980SAndreas Jaekel ZFS_IOC_UNSET_ZEV_CALLBACKS, 862e69d9941SMatthew Ahrens ZFS_IOC_BOOKMARK, 863e69d9941SMatthew Ahrens ZFS_IOC_GET_BOOKMARKS, 864e69d9941SMatthew Ahrens ZFS_IOC_DESTROY_BOOKMARKS, 865a8c92b49SArne Jansen ZFS_IOC_ARC_INFO, 8664445fffbSMatthew Ahrens ZFS_IOC_LAST 867fa9e4066Sahrens } zfs_ioc_t; 868fa9e4066Sahrens 869ea8dc4b6Seschrock /* 870ea8dc4b6Seschrock * Internal SPA load state. Used by FMA diagnosis engine. 871ea8dc4b6Seschrock */ 872ea8dc4b6Seschrock typedef enum { 873ea8dc4b6Seschrock SPA_LOAD_NONE, /* no load in progress */ 874ea8dc4b6Seschrock SPA_LOAD_OPEN, /* normal open */ 875ea8dc4b6Seschrock SPA_LOAD_IMPORT, /* import in progress */ 876468c413aSTim Haley SPA_LOAD_TRYIMPORT, /* tryimport in progress */ 8779eb19f4dSGeorge Wilson SPA_LOAD_RECOVER, /* recovery requested */ 8789eb19f4dSGeorge Wilson SPA_LOAD_ERROR /* load failed */ 879ea8dc4b6Seschrock } spa_load_state_t; 880ea8dc4b6Seschrock 881e9dbad6fSeschrock /* 882e9dbad6fSeschrock * Bookmark name values. 883e9dbad6fSeschrock */ 88455434c77Sek110237 #define ZPOOL_ERR_LIST "error list" 885e9dbad6fSeschrock #define ZPOOL_ERR_DATASET "dataset" 886e9dbad6fSeschrock #define ZPOOL_ERR_OBJECT "object" 887e9dbad6fSeschrock 88806eeb2adSek110237 #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) 88906eeb2adSek110237 89006eeb2adSek110237 /* 89106eeb2adSek110237 * The following are names used in the nvlist describing 89206eeb2adSek110237 * the pool's history log. 89306eeb2adSek110237 */ 89406eeb2adSek110237 #define ZPOOL_HIST_RECORD "history record" 89506eeb2adSek110237 #define ZPOOL_HIST_TIME "history time" 89606eeb2adSek110237 #define ZPOOL_HIST_CMD "history command" 897ecd6cf80Smarks #define ZPOOL_HIST_WHO "history who" 898ecd6cf80Smarks #define ZPOOL_HIST_ZONE "history zone" 899ecd6cf80Smarks #define ZPOOL_HIST_HOST "history hostname" 900ecd6cf80Smarks #define ZPOOL_HIST_TXG "history txg" 901ecd6cf80Smarks #define ZPOOL_HIST_INT_EVENT "history internal event" 902ecd6cf80Smarks #define ZPOOL_HIST_INT_STR "history internal str" 9034445fffbSMatthew Ahrens #define ZPOOL_HIST_INT_NAME "internal_name" 9044445fffbSMatthew Ahrens #define ZPOOL_HIST_IOCTL "ioctl" 9054445fffbSMatthew Ahrens #define ZPOOL_HIST_INPUT_NVL "in_nvl" 9064445fffbSMatthew Ahrens #define ZPOOL_HIST_OUTPUT_NVL "out_nvl" 9074445fffbSMatthew Ahrens #define ZPOOL_HIST_DSNAME "dsname" 9084445fffbSMatthew Ahrens #define ZPOOL_HIST_DSID "dsid" 90906eeb2adSek110237 9103d7072f8Seschrock /* 9113d7072f8Seschrock * Flags for ZFS_IOC_VDEV_SET_STATE 9123d7072f8Seschrock */ 9133d7072f8Seschrock #define ZFS_ONLINE_CHECKREMOVE 0x1 9143d7072f8Seschrock #define ZFS_ONLINE_UNSPARE 0x2 9153d7072f8Seschrock #define ZFS_ONLINE_FORCEFAULT 0x4 916573ca77eSGeorge Wilson #define ZFS_ONLINE_EXPAND 0x8 9173d7072f8Seschrock #define ZFS_OFFLINE_TEMPORARY 0x1 9183d7072f8Seschrock 9193d7072f8Seschrock /* 9204b964adaSGeorge Wilson * Flags for ZFS_IOC_POOL_IMPORT 9214b964adaSGeorge Wilson */ 9224b964adaSGeorge Wilson #define ZFS_IMPORT_NORMAL 0x0 9234b964adaSGeorge Wilson #define ZFS_IMPORT_VERBATIM 0x1 9244b964adaSGeorge Wilson #define ZFS_IMPORT_ANY_HOST 0x2 9254b964adaSGeorge Wilson #define ZFS_IMPORT_MISSING_LOG 0x4 926f9af39baSGeorge Wilson #define ZFS_IMPORT_ONLY 0x8 9274b964adaSGeorge Wilson 9284b964adaSGeorge Wilson /* 9293d7072f8Seschrock * Sysevent payload members. ZFS will generate the following sysevents with the 9303d7072f8Seschrock * given payloads: 9313d7072f8Seschrock * 9323d7072f8Seschrock * ESC_ZFS_RESILVER_START 9333d7072f8Seschrock * ESC_ZFS_RESILVER_END 9343d7072f8Seschrock * ESC_ZFS_POOL_DESTROY 935e9103aaeSGarrett D'Amore * ESC_ZFS_POOL_REGUID 9363d7072f8Seschrock * 9373d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 9383d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 9393d7072f8Seschrock * 9403d7072f8Seschrock * ESC_ZFS_VDEV_REMOVE 9413d7072f8Seschrock * ESC_ZFS_VDEV_CLEAR 9423d7072f8Seschrock * ESC_ZFS_VDEV_CHECK 9433d7072f8Seschrock * 9443d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 9453d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 9463d7072f8Seschrock * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) 9473d7072f8Seschrock * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 9483d7072f8Seschrock */ 9493d7072f8Seschrock #define ZFS_EV_POOL_NAME "pool_name" 9503d7072f8Seschrock #define ZFS_EV_POOL_GUID "pool_guid" 9513d7072f8Seschrock #define ZFS_EV_VDEV_PATH "vdev_path" 9523d7072f8Seschrock #define ZFS_EV_VDEV_GUID "vdev_guid" 9533d7072f8Seschrock 954fa9e4066Sahrens #ifdef __cplusplus 955fa9e4066Sahrens } 956fa9e4066Sahrens #endif 957fa9e4066Sahrens 958fa9e4066Sahrens #endif /* _SYS_FS_ZFS_H */ 959