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. 24*187d6ac0SMatt Ahrens * Copyright (c) 2011 by Delphix. All rights reserved. 25fa9e4066Sahrens */ 26fa9e4066Sahrens 2755da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */ 2855da60b9SMark J Musante 29fa9e4066Sahrens #ifndef _SYS_FS_ZFS_H 30fa9e4066Sahrens #define _SYS_FS_ZFS_H 31fa9e4066Sahrens 32842727c2SChris Kirby #include <sys/time.h> 33842727c2SChris Kirby 34fa9e4066Sahrens #ifdef __cplusplus 35fa9e4066Sahrens extern "C" { 36fa9e4066Sahrens #endif 37fa9e4066Sahrens 38fa9e4066Sahrens /* 39fa9e4066Sahrens * Types and constants shared between userland and the kernel. 40fa9e4066Sahrens */ 41fa9e4066Sahrens 42fa9e4066Sahrens /* 43fa9e4066Sahrens * Each dataset can be one of the following types. These constants can be 44fa9e4066Sahrens * combined into masks that can be passed to various functions. 45fa9e4066Sahrens */ 46fa9e4066Sahrens typedef enum { 47fa9e4066Sahrens ZFS_TYPE_FILESYSTEM = 0x1, 48fa9e4066Sahrens ZFS_TYPE_SNAPSHOT = 0x2, 49b1b8ab34Slling ZFS_TYPE_VOLUME = 0x4, 50b1b8ab34Slling ZFS_TYPE_POOL = 0x8 51fa9e4066Sahrens } zfs_type_t; 52fa9e4066Sahrens 53990b4856Slling #define ZFS_TYPE_DATASET \ 54fa9e4066Sahrens (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT) 55fa9e4066Sahrens 56478ed9adSEric Taylor #define ZAP_MAXNAMELEN 256 57478ed9adSEric Taylor #define ZAP_MAXVALUELEN (1024 * 8) 58478ed9adSEric Taylor #define ZAP_OLDMAXVALUELEN 1024 59478ed9adSEric Taylor 60fa9e4066Sahrens /* 61990b4856Slling * Dataset properties are identified by these constants and must be added to 62990b4856Slling * the end of this list to ensure that external consumers are not affected 63990b4856Slling * by the change. If you make any changes to this list, be sure to update 6466e2aaccSgw * the property table in usr/src/common/zfs/zfs_prop.c. 65fa9e4066Sahrens */ 66fa9e4066Sahrens typedef enum { 67fa9e4066Sahrens ZFS_PROP_TYPE, 68fa9e4066Sahrens ZFS_PROP_CREATION, 69fa9e4066Sahrens ZFS_PROP_USED, 70fa9e4066Sahrens ZFS_PROP_AVAILABLE, 71fa9e4066Sahrens ZFS_PROP_REFERENCED, 72fa9e4066Sahrens ZFS_PROP_COMPRESSRATIO, 73fa9e4066Sahrens ZFS_PROP_MOUNTED, 74fa9e4066Sahrens ZFS_PROP_ORIGIN, 75fa9e4066Sahrens ZFS_PROP_QUOTA, 76fa9e4066Sahrens ZFS_PROP_RESERVATION, 77fa9e4066Sahrens ZFS_PROP_VOLSIZE, 78fa9e4066Sahrens ZFS_PROP_VOLBLOCKSIZE, 79fa9e4066Sahrens ZFS_PROP_RECORDSIZE, 80fa9e4066Sahrens ZFS_PROP_MOUNTPOINT, 81fa9e4066Sahrens ZFS_PROP_SHARENFS, 82fa9e4066Sahrens ZFS_PROP_CHECKSUM, 83fa9e4066Sahrens ZFS_PROP_COMPRESSION, 84fa9e4066Sahrens ZFS_PROP_ATIME, 85fa9e4066Sahrens ZFS_PROP_DEVICES, 86fa9e4066Sahrens ZFS_PROP_EXEC, 87fa9e4066Sahrens ZFS_PROP_SETUID, 88fa9e4066Sahrens ZFS_PROP_READONLY, 89fa9e4066Sahrens ZFS_PROP_ZONED, 90fa9e4066Sahrens ZFS_PROP_SNAPDIR, 91a3c49ce1SAlbert Lee ZFS_PROP_ACLMODE, 92fa9e4066Sahrens ZFS_PROP_ACLINHERIT, 9366e2aaccSgw ZFS_PROP_CREATETXG, /* not exposed to the user */ 9466e2aaccSgw ZFS_PROP_NAME, /* not exposed to the user */ 95e9dbad6fSeschrock ZFS_PROP_CANMOUNT, 9666e2aaccSgw ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */ 977b55fa8eSck ZFS_PROP_XATTR, 98d0ad202dSahrens ZFS_PROP_NUMCLONES, /* not exposed to the user */ 99b1b8ab34Slling ZFS_PROP_COPIES, 100e7437265Sahrens ZFS_PROP_VERSION, 101da6c28aaSamw ZFS_PROP_UTF8ONLY, 102da6c28aaSamw ZFS_PROP_NORMALIZE, 103da6c28aaSamw ZFS_PROP_CASE, 104da6c28aaSamw ZFS_PROP_VSCAN, 105da6c28aaSamw ZFS_PROP_NBMAND, 106da6c28aaSamw ZFS_PROP_SHARESMB, 107a9799022Sck ZFS_PROP_REFQUOTA, 108a9799022Sck ZFS_PROP_REFRESERVATION, 109c5904d13Seschrock ZFS_PROP_GUID, 1103baa08fcSek ZFS_PROP_PRIMARYCACHE, 1113baa08fcSek ZFS_PROP_SECONDARYCACHE, 11274e7dc98SMatthew Ahrens ZFS_PROP_USEDSNAP, 11374e7dc98SMatthew Ahrens ZFS_PROP_USEDDS, 11474e7dc98SMatthew Ahrens ZFS_PROP_USEDCHILD, 11574e7dc98SMatthew Ahrens ZFS_PROP_USEDREFRESERV, 11614843421SMatthew Ahrens ZFS_PROP_USERACCOUNTING, /* not exposed to the user */ 117478ed9adSEric Taylor ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */ 118842727c2SChris Kirby ZFS_PROP_DEFER_DESTROY, 119842727c2SChris Kirby ZFS_PROP_USERREFS, 120e09fa4daSNeil Perrin ZFS_PROP_LOGBIAS, 1211d713200SEric Schrock ZFS_PROP_UNIQUE, /* not exposed to the user */ 1221d713200SEric Schrock ZFS_PROP_OBJSETID, /* not exposed to the user */ 123b24ab676SJeff Bonwick ZFS_PROP_DEDUP, 1244201a95eSRic Aleshire ZFS_PROP_MLSLABEL, 12555da60b9SMark J Musante ZFS_PROP_SYNC, 126*187d6ac0SMatt Ahrens ZFS_PROP_REFRATIO, 12791ebeef5Sahrens ZFS_NUM_PROPS 128fa9e4066Sahrens } zfs_prop_t; 129fa9e4066Sahrens 13014843421SMatthew Ahrens typedef enum { 13114843421SMatthew Ahrens ZFS_PROP_USERUSED, 13214843421SMatthew Ahrens ZFS_PROP_USERQUOTA, 13314843421SMatthew Ahrens ZFS_PROP_GROUPUSED, 13414843421SMatthew Ahrens ZFS_PROP_GROUPQUOTA, 13514843421SMatthew Ahrens ZFS_NUM_USERQUOTA_PROPS 13614843421SMatthew Ahrens } zfs_userquota_prop_t; 13714843421SMatthew Ahrens 13814843421SMatthew Ahrens extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS]; 13914843421SMatthew Ahrens 140990b4856Slling /* 141990b4856Slling * Pool properties are identified by these constants and must be added to the 142b87f3af3Sperrin * end of this list to ensure that external consumers are not affected 143990b4856Slling * by the change. If you make any changes to this list, be sure to update 144990b4856Slling * the property table in usr/src/common/zfs/zpool_prop.c. 145990b4856Slling */ 146990b4856Slling typedef enum { 147990b4856Slling ZPOOL_PROP_NAME, 148990b4856Slling ZPOOL_PROP_SIZE, 149990b4856Slling ZPOOL_PROP_CAPACITY, 150990b4856Slling ZPOOL_PROP_ALTROOT, 151990b4856Slling ZPOOL_PROP_HEALTH, 152990b4856Slling ZPOOL_PROP_GUID, 153990b4856Slling ZPOOL_PROP_VERSION, 154990b4856Slling ZPOOL_PROP_BOOTFS, 155990b4856Slling ZPOOL_PROP_DELEGATION, 156990b4856Slling ZPOOL_PROP_AUTOREPLACE, 1572f8aaab3Seschrock ZPOOL_PROP_CACHEFILE, 1580a4e9518Sgw ZPOOL_PROP_FAILUREMODE, 159d5b5bb25SRich Morris ZPOOL_PROP_LISTSNAPS, 160573ca77eSGeorge Wilson ZPOOL_PROP_AUTOEXPAND, 161b24ab676SJeff Bonwick ZPOOL_PROP_DEDUPDITTO, 162b24ab676SJeff Bonwick ZPOOL_PROP_DEDUPRATIO, 163485bbbf5SGeorge Wilson ZPOOL_PROP_FREE, 164485bbbf5SGeorge Wilson ZPOOL_PROP_ALLOCATED, 165f9af39baSGeorge Wilson ZPOOL_PROP_READONLY, 166990b4856Slling ZPOOL_NUM_PROPS 167990b4856Slling } zpool_prop_t; 168b1b8ab34Slling 169990b4856Slling #define ZPROP_CONT -2 170990b4856Slling #define ZPROP_INVAL -1 1713d7072f8Seschrock 172990b4856Slling #define ZPROP_VALUE "value" 173990b4856Slling #define ZPROP_SOURCE "source" 1747f7322feSeschrock 175b1b8ab34Slling typedef enum { 176990b4856Slling ZPROP_SRC_NONE = 0x1, 177990b4856Slling ZPROP_SRC_DEFAULT = 0x2, 178990b4856Slling ZPROP_SRC_TEMPORARY = 0x4, 179990b4856Slling ZPROP_SRC_LOCAL = 0x8, 18092241e0bSTom Erickson ZPROP_SRC_INHERITED = 0x10, 18192241e0bSTom Erickson ZPROP_SRC_RECEIVED = 0x20 182990b4856Slling } zprop_source_t; 183990b4856Slling 18492241e0bSTom Erickson #define ZPROP_SRC_ALL 0x3f 18592241e0bSTom Erickson 18692241e0bSTom Erickson #define ZPROP_SOURCE_VAL_RECVD "$recvd" 18792241e0bSTom Erickson #define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS" 18892241e0bSTom Erickson /* 18992241e0bSTom Erickson * Dataset flag implemented as a special entry in the props zap object 19092241e0bSTom Erickson * indicating that the dataset has received properties on or after 19192241e0bSTom Erickson * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties 19292241e0bSTom Erickson * just as it did in earlier versions, and thereafter, local properties are 19392241e0bSTom Erickson * preserved. 19492241e0bSTom Erickson */ 19592241e0bSTom Erickson #define ZPROP_HAS_RECVD "$hasrecvd" 19692241e0bSTom Erickson 19792241e0bSTom Erickson typedef enum { 19892241e0bSTom Erickson ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */ 19992241e0bSTom Erickson ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */ 20092241e0bSTom Erickson } zprop_errflags_t; 201990b4856Slling 202990b4856Slling typedef int (*zprop_func)(int, void *); 203990b4856Slling 2040a48a24eStimh /* 2050a48a24eStimh * Properties to be set on the root file system of a new pool 2060a48a24eStimh * are stuffed into their own nvlist, which is then included in 2070a48a24eStimh * the properties nvlist with the pool properties. 2080a48a24eStimh */ 2090a48a24eStimh #define ZPOOL_ROOTFS_PROPS "root-props-nvl" 2100a48a24eStimh 211990b4856Slling /* 212990b4856Slling * Dataset property functions shared between libzfs and kernel. 213990b4856Slling */ 214990b4856Slling const char *zfs_prop_default_string(zfs_prop_t); 215990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t); 216990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t); 217990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t); 218da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t); 219990b4856Slling const char *zfs_prop_to_name(zfs_prop_t); 220990b4856Slling zfs_prop_t zfs_name_to_prop(const char *); 221990b4856Slling boolean_t zfs_prop_user(const char *); 22292241e0bSTom Erickson boolean_t zfs_prop_userquota(const char *); 223990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **); 224990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *); 225b24ab676SJeff Bonwick uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed); 2264853e976Sgw boolean_t zfs_prop_valid_for_type(int, zfs_type_t); 227b1b8ab34Slling 228990b4856Slling /* 229990b4856Slling * Pool property functions shared between libzfs and kernel. 230990b4856Slling */ 231990b4856Slling zpool_prop_t zpool_name_to_prop(const char *); 232990b4856Slling const char *zpool_prop_to_name(zpool_prop_t); 233990b4856Slling const char *zpool_prop_default_string(zpool_prop_t); 234990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t); 235990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t); 236990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **); 237990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *); 238b24ab676SJeff Bonwick uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed); 239b1b8ab34Slling 240990b4856Slling /* 241990b4856Slling * Definitions for the Delegation. 242990b4856Slling */ 243ecd6cf80Smarks typedef enum { 244ecd6cf80Smarks ZFS_DELEG_WHO_UNKNOWN = 0, 245ecd6cf80Smarks ZFS_DELEG_USER = 'u', 246ecd6cf80Smarks ZFS_DELEG_USER_SETS = 'U', 247ecd6cf80Smarks ZFS_DELEG_GROUP = 'g', 248ecd6cf80Smarks ZFS_DELEG_GROUP_SETS = 'G', 249ecd6cf80Smarks ZFS_DELEG_EVERYONE = 'e', 250ecd6cf80Smarks ZFS_DELEG_EVERYONE_SETS = 'E', 251ecd6cf80Smarks ZFS_DELEG_CREATE = 'c', 252ecd6cf80Smarks ZFS_DELEG_CREATE_SETS = 'C', 253ecd6cf80Smarks ZFS_DELEG_NAMED_SET = 's', 254ecd6cf80Smarks ZFS_DELEG_NAMED_SET_SETS = 'S' 255ecd6cf80Smarks } zfs_deleg_who_type_t; 256ecd6cf80Smarks 257ecd6cf80Smarks typedef enum { 258ecd6cf80Smarks ZFS_DELEG_NONE = 0, 259ecd6cf80Smarks ZFS_DELEG_PERM_LOCAL = 1, 260ecd6cf80Smarks ZFS_DELEG_PERM_DESCENDENT = 2, 261ecd6cf80Smarks ZFS_DELEG_PERM_LOCALDESCENDENT = 3, 262ecd6cf80Smarks ZFS_DELEG_PERM_CREATE = 4 263ecd6cf80Smarks } zfs_deleg_inherit_t; 264ecd6cf80Smarks 265ecd6cf80Smarks #define ZFS_DELEG_PERM_UID "uid" 266ecd6cf80Smarks #define ZFS_DELEG_PERM_GID "gid" 267ecd6cf80Smarks #define ZFS_DELEG_PERM_GROUPS "groups" 268ecd6cf80Smarks 2694201a95eSRic Aleshire #define ZFS_MLSLABEL_DEFAULT "none" 2704201a95eSRic Aleshire 271743a77edSAlan Wright #define ZFS_SMB_ACL_SRC "src" 272743a77edSAlan Wright #define ZFS_SMB_ACL_TARGET "target" 273743a77edSAlan Wright 274a227b7f4Shs typedef enum { 275a227b7f4Shs ZFS_CANMOUNT_OFF = 0, 276a227b7f4Shs ZFS_CANMOUNT_ON = 1, 277a227b7f4Shs ZFS_CANMOUNT_NOAUTO = 2 278a227b7f4Shs } zfs_canmount_type_t; 279a227b7f4Shs 280e09fa4daSNeil Perrin typedef enum { 281e09fa4daSNeil Perrin ZFS_LOGBIAS_LATENCY = 0, 282e09fa4daSNeil Perrin ZFS_LOGBIAS_THROUGHPUT = 1 283e09fa4daSNeil Perrin } zfs_logbias_op_t; 284e09fa4daSNeil Perrin 285da6c28aaSamw typedef enum zfs_share_op { 286da6c28aaSamw ZFS_SHARE_NFS = 0, 287da6c28aaSamw ZFS_UNSHARE_NFS = 1, 288da6c28aaSamw ZFS_SHARE_SMB = 2, 289da6c28aaSamw ZFS_UNSHARE_SMB = 3 290da6c28aaSamw } zfs_share_op_t; 291da6c28aaSamw 292743a77edSAlan Wright typedef enum zfs_smb_acl_op { 293743a77edSAlan Wright ZFS_SMB_ACL_ADD, 294743a77edSAlan Wright ZFS_SMB_ACL_REMOVE, 295743a77edSAlan Wright ZFS_SMB_ACL_RENAME, 296743a77edSAlan Wright ZFS_SMB_ACL_PURGE 297743a77edSAlan Wright } zfs_smb_acl_op_t; 298743a77edSAlan Wright 2993baa08fcSek typedef enum zfs_cache_type { 3003baa08fcSek ZFS_CACHE_NONE = 0, 3013baa08fcSek ZFS_CACHE_METADATA = 1, 3023baa08fcSek ZFS_CACHE_ALL = 2 3033baa08fcSek } zfs_cache_type_t; 3043baa08fcSek 30555da60b9SMark J Musante typedef enum { 30655da60b9SMark J Musante ZFS_SYNC_STANDARD = 0, 30755da60b9SMark J Musante ZFS_SYNC_ALWAYS = 1, 30855da60b9SMark J Musante ZFS_SYNC_DISABLED = 2 30955da60b9SMark J Musante } zfs_sync_type_t; 31055da60b9SMark J Musante 3113baa08fcSek 312eaca9bbdSeschrock /* 31399653d4eSeschrock * On-disk version number. 314eaca9bbdSeschrock */ 315e7437265Sahrens #define SPA_VERSION_1 1ULL 316e7437265Sahrens #define SPA_VERSION_2 2ULL 317e7437265Sahrens #define SPA_VERSION_3 3ULL 318e7437265Sahrens #define SPA_VERSION_4 4ULL 319e7437265Sahrens #define SPA_VERSION_5 5ULL 320e7437265Sahrens #define SPA_VERSION_6 6ULL 321e7437265Sahrens #define SPA_VERSION_7 7ULL 322e7437265Sahrens #define SPA_VERSION_8 8ULL 323da6c28aaSamw #define SPA_VERSION_9 9ULL 324fa94a07fSbrendan #define SPA_VERSION_10 10ULL 325088f3894Sahrens #define SPA_VERSION_11 11ULL 326bb0ade09Sahrens #define SPA_VERSION_12 12ULL 32774e7dc98SMatthew Ahrens #define SPA_VERSION_13 13ULL 328d0f3f37eSMark Shellenbaum #define SPA_VERSION_14 14ULL 32914843421SMatthew Ahrens #define SPA_VERSION_15 15ULL 330478ed9adSEric Taylor #define SPA_VERSION_16 16ULL 331f94275ceSAdam Leventhal #define SPA_VERSION_17 17ULL 332842727c2SChris Kirby #define SPA_VERSION_18 18ULL 33388ecc943SGeorge Wilson #define SPA_VERSION_19 19ULL 334b24ab676SJeff Bonwick #define SPA_VERSION_20 20ULL 335b24ab676SJeff Bonwick #define SPA_VERSION_21 21ULL 33692241e0bSTom Erickson #define SPA_VERSION_22 22ULL 3376e1f5caaSNeil Perrin #define SPA_VERSION_23 23ULL 3380a586ceaSMark Shellenbaum #define SPA_VERSION_24 24ULL 3393f9d6ad7SLin Ling #define SPA_VERSION_25 25ULL 340cde58dbcSMatthew Ahrens #define SPA_VERSION_26 26ULL 3416e0cbcaaSMatthew Ahrens #define SPA_VERSION_27 27ULL 342cb04b873SMark J Musante #define SPA_VERSION_28 28ULL 343cb04b873SMark J Musante 344b1b8ab34Slling /* 345e7cbe64fSgw * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk 346478ed9adSEric Taylor * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*}, 34714843421SMatthew Ahrens * and do the appropriate changes. Also bump the version number in 34814843421SMatthew Ahrens * usr/src/grub/capability. 349b1b8ab34Slling */ 350cb04b873SMark J Musante #define SPA_VERSION SPA_VERSION_28 351cb04b873SMark J Musante #define SPA_VERSION_STRING "28" 35244cd46caSbillm 35344cd46caSbillm /* 354e7437265Sahrens * Symbolic names for the changes that caused a SPA_VERSION switch. 35544cd46caSbillm * Used in the code when checking for presence or absence of a feature. 35644cd46caSbillm * Feel free to define multiple symbolic names for each version if there 35744cd46caSbillm * were multiple changes to on-disk structures during that version. 35844cd46caSbillm * 359e7437265Sahrens * NOTE: When checking the current SPA_VERSION in your code, be sure 36044cd46caSbillm * to use spa_version() since it reports the version of the 36144cd46caSbillm * last synced uberblock. Checking the in-flight version can 36244cd46caSbillm * be dangerous in some cases. 36344cd46caSbillm */ 364e7437265Sahrens #define SPA_VERSION_INITIAL SPA_VERSION_1 365e7437265Sahrens #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2 366e7437265Sahrens #define SPA_VERSION_SPARES SPA_VERSION_3 367f94275ceSAdam Leventhal #define SPA_VERSION_RAIDZ2 SPA_VERSION_3 368cde58dbcSMatthew Ahrens #define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3 369e7437265Sahrens #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3 370e7437265Sahrens #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3 371e7437265Sahrens #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4 372e7437265Sahrens #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5 373e7437265Sahrens #define SPA_VERSION_BOOTFS SPA_VERSION_6 374990b4856Slling #define SPA_VERSION_SLOGS SPA_VERSION_7 375990b4856Slling #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8 376da6c28aaSamw #define SPA_VERSION_FUID SPA_VERSION_9 377a9799022Sck #define SPA_VERSION_REFRESERVATION SPA_VERSION_9 378a9799022Sck #define SPA_VERSION_REFQUOTA SPA_VERSION_9 379a9799022Sck #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9 380fa94a07fSbrendan #define SPA_VERSION_L2CACHE SPA_VERSION_10 381088f3894Sahrens #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11 382088f3894Sahrens #define SPA_VERSION_ORIGIN SPA_VERSION_11 383088f3894Sahrens #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11 384bb0ade09Sahrens #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12 38574e7dc98SMatthew Ahrens #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13 386d0f3f37eSMark Shellenbaum #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14 38714843421SMatthew Ahrens #define SPA_VERSION_USERSPACE SPA_VERSION_15 388478ed9adSEric Taylor #define SPA_VERSION_STMF_PROP SPA_VERSION_16 389f94275ceSAdam Leventhal #define SPA_VERSION_RAIDZ3 SPA_VERSION_17 390842727c2SChris Kirby #define SPA_VERSION_USERREFS SPA_VERSION_18 39188ecc943SGeorge Wilson #define SPA_VERSION_HOLES SPA_VERSION_19 392b24ab676SJeff Bonwick #define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20 393b24ab676SJeff Bonwick #define SPA_VERSION_DEDUP SPA_VERSION_21 39492241e0bSTom Erickson #define SPA_VERSION_RECVD_PROPS SPA_VERSION_22 3956e1f5caaSNeil Perrin #define SPA_VERSION_SLIM_ZIL SPA_VERSION_23 3960a586ceaSMark Shellenbaum #define SPA_VERSION_SA SPA_VERSION_24 3973f9d6ad7SLin Ling #define SPA_VERSION_SCAN SPA_VERSION_25 398cde58dbcSMatthew Ahrens #define SPA_VERSION_DIR_CLONES SPA_VERSION_26 399cde58dbcSMatthew Ahrens #define SPA_VERSION_DEADLISTS SPA_VERSION_26 4006e0cbcaaSMatthew Ahrens #define SPA_VERSION_FAST_SNAP SPA_VERSION_27 401cb04b873SMark J Musante #define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28 402e7437265Sahrens 403e7437265Sahrens /* 404e7437265Sahrens * ZPL version - rev'd whenever an incompatible on-disk format change 405e7437265Sahrens * occurs. This is independent of SPA/DMU/ZAP versioning. You must 406e7437265Sahrens * also update the version_table[] and help message in zfs_prop.c. 407e7437265Sahrens * 408e7437265Sahrens * When changing, be sure to teach GRUB how to read the new format! 409478ed9adSEric Taylor * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*} 410e7437265Sahrens */ 411e7437265Sahrens #define ZPL_VERSION_1 1ULL 412e7437265Sahrens #define ZPL_VERSION_2 2ULL 413da6c28aaSamw #define ZPL_VERSION_3 3ULL 41414843421SMatthew Ahrens #define ZPL_VERSION_4 4ULL 4150a586ceaSMark Shellenbaum #define ZPL_VERSION_5 5ULL 4160a586ceaSMark Shellenbaum #define ZPL_VERSION ZPL_VERSION_5 4170a586ceaSMark Shellenbaum #define ZPL_VERSION_STRING "5" 418e7437265Sahrens 419e7437265Sahrens #define ZPL_VERSION_INITIAL ZPL_VERSION_1 420e7437265Sahrens #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 421da6c28aaSamw #define ZPL_VERSION_FUID ZPL_VERSION_3 422de8267e0Stimh #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3 423da6c28aaSamw #define ZPL_VERSION_SYSATTR ZPL_VERSION_3 42414843421SMatthew Ahrens #define ZPL_VERSION_USERSPACE ZPL_VERSION_4 4250a586ceaSMark Shellenbaum #define ZPL_VERSION_SA ZPL_VERSION_5 426eaca9bbdSeschrock 427468c413aSTim Haley /* Rewind request information */ 428c8ee1847SVictor Latushkin #define ZPOOL_NO_REWIND 1 /* No policy - default behavior */ 429c8ee1847SVictor Latushkin #define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */ 430c8ee1847SVictor Latushkin #define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */ 431c8ee1847SVictor Latushkin #define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */ 432c8ee1847SVictor Latushkin #define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */ 433c8ee1847SVictor Latushkin #define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */ 434c8ee1847SVictor Latushkin #define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */ 435468c413aSTim Haley 436468c413aSTim Haley typedef struct zpool_rewind_policy { 437468c413aSTim Haley uint32_t zrp_request; /* rewind behavior requested */ 438c8ee1847SVictor Latushkin uint64_t zrp_maxmeta; /* max acceptable meta-data errors */ 439c8ee1847SVictor Latushkin uint64_t zrp_maxdata; /* max acceptable data errors */ 440468c413aSTim Haley uint64_t zrp_txg; /* specific txg to load */ 441468c413aSTim Haley } zpool_rewind_policy_t; 442468c413aSTim Haley 443fa9e4066Sahrens /* 444fa9e4066Sahrens * The following are configuration names used in the nvlist describing a pool's 445fa9e4066Sahrens * configuration. 446fa9e4066Sahrens */ 447fa9e4066Sahrens #define ZPOOL_CONFIG_VERSION "version" 448fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_NAME "name" 449fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_STATE "state" 450fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_TXG "txg" 451fa9e4066Sahrens #define ZPOOL_CONFIG_POOL_GUID "pool_guid" 452fa9e4066Sahrens #define ZPOOL_CONFIG_CREATE_TXG "create_txg" 453fa9e4066Sahrens #define ZPOOL_CONFIG_TOP_GUID "top_guid" 454fa9e4066Sahrens #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" 455fa9e4066Sahrens #define ZPOOL_CONFIG_TYPE "type" 456fa9e4066Sahrens #define ZPOOL_CONFIG_CHILDREN "children" 457fa9e4066Sahrens #define ZPOOL_CONFIG_ID "id" 458fa9e4066Sahrens #define ZPOOL_CONFIG_GUID "guid" 459fa9e4066Sahrens #define ZPOOL_CONFIG_PATH "path" 460fa9e4066Sahrens #define ZPOOL_CONFIG_DEVID "devid" 461fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" 462fa9e4066Sahrens #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" 463fa9e4066Sahrens #define ZPOOL_CONFIG_ASHIFT "ashift" 464fa9e4066Sahrens #define ZPOOL_CONFIG_ASIZE "asize" 465fa9e4066Sahrens #define ZPOOL_CONFIG_DTL "DTL" 4663f9d6ad7SLin Ling #define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */ 4673f9d6ad7SLin Ling #define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */ 468afefbcddSeschrock #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" 469ea8dc4b6Seschrock #define ZPOOL_CONFIG_ERRCOUNT "error_count" 470ea8dc4b6Seschrock #define ZPOOL_CONFIG_NOT_PRESENT "not_present" 47199653d4eSeschrock #define ZPOOL_CONFIG_SPARES "spares" 47299653d4eSeschrock #define ZPOOL_CONFIG_IS_SPARE "is_spare" 47399653d4eSeschrock #define ZPOOL_CONFIG_NPARITY "nparity" 47495173954Sek #define ZPOOL_CONFIG_HOSTID "hostid" 47595173954Sek #define ZPOOL_CONFIG_HOSTNAME "hostname" 47611027bc7STim Haley #define ZPOOL_CONFIG_LOADED_TIME "initial_load_time" 4773d7072f8Seschrock #define ZPOOL_CONFIG_UNSPARE "unspare" 4783d7072f8Seschrock #define ZPOOL_CONFIG_PHYS_PATH "phys_path" 4798654d025Sperrin #define ZPOOL_CONFIG_IS_LOG "is_log" 480fa94a07fSbrendan #define ZPOOL_CONFIG_L2CACHE "l2cache" 48188ecc943SGeorge Wilson #define ZPOOL_CONFIG_HOLE_ARRAY "hole_array" 48288ecc943SGeorge Wilson #define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children" 48388ecc943SGeorge Wilson #define ZPOOL_CONFIG_IS_HOLE "is_hole" 4849eb19f4dSGeorge Wilson #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram" 4859eb19f4dSGeorge Wilson #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats" 4869eb19f4dSGeorge Wilson #define ZPOOL_CONFIG_DDT_STATS "ddt_stats" 4871195e687SMark J Musante #define ZPOOL_CONFIG_SPLIT "splitcfg" 4881195e687SMark J Musante #define ZPOOL_CONFIG_ORIG_GUID "orig_guid" 4891195e687SMark J Musante #define ZPOOL_CONFIG_SPLIT_GUID "split_guid" 4901195e687SMark J Musante #define ZPOOL_CONFIG_SPLIT_LIST "guid_list" 4913f9d6ad7SLin Ling #define ZPOOL_CONFIG_REMOVING "removing" 492cb04b873SMark J Musante #define ZPOOL_CONFIG_RESILVERING "resilvering" 493e14bb325SJeff Bonwick #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */ 494e7cbe64fSgw #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */ 495e7cbe64fSgw #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */ 4964b964adaSGeorge Wilson #define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */ 4974b964adaSGeorge Wilson #define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */ 4983d7072f8Seschrock /* 4993d7072f8Seschrock * The persistent vdev state is stored as separate values rather than a single 5003d7072f8Seschrock * 'vdev_state' entry. This is because a device can be in multiple states, such 5013d7072f8Seschrock * as offline and degraded. 5023d7072f8Seschrock */ 5033d7072f8Seschrock #define ZPOOL_CONFIG_OFFLINE "offline" 5043d7072f8Seschrock #define ZPOOL_CONFIG_FAULTED "faulted" 5053d7072f8Seschrock #define ZPOOL_CONFIG_DEGRADED "degraded" 5063d7072f8Seschrock #define ZPOOL_CONFIG_REMOVED "removed" 5076809eb4eSEric Schrock #define ZPOOL_CONFIG_FRU "fru" 508069f55e2SEric Schrock #define ZPOOL_CONFIG_AUX_STATE "aux_state" 509fa9e4066Sahrens 510468c413aSTim Haley /* Rewind policy parameters */ 511468c413aSTim Haley #define ZPOOL_REWIND_POLICY "rewind-policy" 512468c413aSTim Haley #define ZPOOL_REWIND_REQUEST "rewind-request" 513468c413aSTim Haley #define ZPOOL_REWIND_REQUEST_TXG "rewind-request-txg" 514468c413aSTim Haley #define ZPOOL_REWIND_META_THRESH "rewind-meta-thresh" 515468c413aSTim Haley #define ZPOOL_REWIND_DATA_THRESH "rewind-data-thresh" 516468c413aSTim Haley 517468c413aSTim Haley /* Rewind data discovered */ 518468c413aSTim Haley #define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts" 519468c413aSTim Haley #define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors" 520468c413aSTim Haley #define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind" 521468c413aSTim Haley 522fa9e4066Sahrens #define VDEV_TYPE_ROOT "root" 523fa9e4066Sahrens #define VDEV_TYPE_MIRROR "mirror" 524fa9e4066Sahrens #define VDEV_TYPE_REPLACING "replacing" 525fa9e4066Sahrens #define VDEV_TYPE_RAIDZ "raidz" 526fa9e4066Sahrens #define VDEV_TYPE_DISK "disk" 527fa9e4066Sahrens #define VDEV_TYPE_FILE "file" 528fa9e4066Sahrens #define VDEV_TYPE_MISSING "missing" 52988ecc943SGeorge Wilson #define VDEV_TYPE_HOLE "hole" 53099653d4eSeschrock #define VDEV_TYPE_SPARE "spare" 5318654d025Sperrin #define VDEV_TYPE_LOG "log" 532fa94a07fSbrendan #define VDEV_TYPE_L2CACHE "l2cache" 533fa9e4066Sahrens 534fa9e4066Sahrens /* 535fa9e4066Sahrens * This is needed in userland to report the minimum necessary device size. 536fa9e4066Sahrens */ 537fa9e4066Sahrens #define SPA_MINDEVSIZE (64ULL << 20) 538fa9e4066Sahrens 539fa9e4066Sahrens /* 540fa9e4066Sahrens * The location of the pool configuration repository, shared between kernel and 541fa9e4066Sahrens * userland. 542fa9e4066Sahrens */ 543c5904d13Seschrock #define ZPOOL_CACHE "/etc/zfs/zpool.cache" 544fa9e4066Sahrens 545fa9e4066Sahrens /* 546fa9e4066Sahrens * vdev states are ordered from least to most healthy. 547fa9e4066Sahrens * A vdev that's CANT_OPEN or below is considered unusable. 548fa9e4066Sahrens */ 549fa9e4066Sahrens typedef enum vdev_state { 550fa9e4066Sahrens VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */ 551fa9e4066Sahrens VDEV_STATE_CLOSED, /* Not currently open */ 552fa9e4066Sahrens VDEV_STATE_OFFLINE, /* Not allowed to open */ 5533d7072f8Seschrock VDEV_STATE_REMOVED, /* Explicitly removed from system */ 554fa9e4066Sahrens VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */ 5553d7072f8Seschrock VDEV_STATE_FAULTED, /* External request to fault device */ 556fa9e4066Sahrens VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */ 557fa9e4066Sahrens VDEV_STATE_HEALTHY /* Presumed good */ 558fa9e4066Sahrens } vdev_state_t; 559fa9e4066Sahrens 5603d7072f8Seschrock #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY 5613d7072f8Seschrock 562fa9e4066Sahrens /* 563fa9e4066Sahrens * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field 564fa9e4066Sahrens * of the vdev stats structure uses these constants to distinguish why. 565fa9e4066Sahrens */ 566fa9e4066Sahrens typedef enum vdev_aux { 567fa9e4066Sahrens VDEV_AUX_NONE, /* no error */ 568fa9e4066Sahrens VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */ 569fa9e4066Sahrens VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */ 570fa9e4066Sahrens VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */ 571fa9e4066Sahrens VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */ 572fa9e4066Sahrens VDEV_AUX_TOO_SMALL, /* vdev size is too small */ 573eaca9bbdSeschrock VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */ 574eaca9bbdSeschrock VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */ 57599653d4eSeschrock VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */ 5763d7072f8Seschrock VDEV_AUX_SPARED, /* hot spare used in another pool */ 57732b87932Sek VDEV_AUX_ERR_EXCEEDED, /* too many errors */ 578b87f3af3Sperrin VDEV_AUX_IO_FAILURE, /* experienced I/O failure */ 579069f55e2SEric Schrock VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */ 5801195e687SMark J Musante VDEV_AUX_EXTERNAL, /* external diagnosis */ 5811195e687SMark J Musante VDEV_AUX_SPLIT_POOL /* vdev was split off into another pool */ 582fa9e4066Sahrens } vdev_aux_t; 583fa9e4066Sahrens 584fa9e4066Sahrens /* 58546a2abf2Seschrock * pool state. The following states are written to disk as part of the normal 586fa94a07fSbrendan * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining 587fa94a07fSbrendan * states are software abstractions used at various levels to communicate 588fa94a07fSbrendan * pool state. 589fa9e4066Sahrens */ 590fa9e4066Sahrens typedef enum pool_state { 591fa9e4066Sahrens POOL_STATE_ACTIVE = 0, /* In active use */ 592fa9e4066Sahrens POOL_STATE_EXPORTED, /* Explicitly exported */ 593fa9e4066Sahrens POOL_STATE_DESTROYED, /* Explicitly destroyed */ 59499653d4eSeschrock POOL_STATE_SPARE, /* Reserved for hot spare use */ 595fa94a07fSbrendan POOL_STATE_L2CACHE, /* Level 2 ARC device */ 596fa9e4066Sahrens POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ 59746a2abf2Seschrock POOL_STATE_UNAVAIL, /* Internal libzfs state */ 59846a2abf2Seschrock POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ 599fa9e4066Sahrens } pool_state_t; 600fa9e4066Sahrens 601fa9e4066Sahrens /* 6023f9d6ad7SLin Ling * Scan Functions. 603fa9e4066Sahrens */ 6043f9d6ad7SLin Ling typedef enum pool_scan_func { 6053f9d6ad7SLin Ling POOL_SCAN_NONE, 6063f9d6ad7SLin Ling POOL_SCAN_SCRUB, 6073f9d6ad7SLin Ling POOL_SCAN_RESILVER, 6083f9d6ad7SLin Ling POOL_SCAN_FUNCS 6093f9d6ad7SLin Ling } pool_scan_func_t; 610fa9e4066Sahrens 611fa9e4066Sahrens /* 612fa9e4066Sahrens * ZIO types. Needed to interpret vdev statistics below. 613fa9e4066Sahrens */ 614fa9e4066Sahrens typedef enum zio_type { 615fa9e4066Sahrens ZIO_TYPE_NULL = 0, 616fa9e4066Sahrens ZIO_TYPE_READ, 617fa9e4066Sahrens ZIO_TYPE_WRITE, 618fa9e4066Sahrens ZIO_TYPE_FREE, 619fa9e4066Sahrens ZIO_TYPE_CLAIM, 620fa9e4066Sahrens ZIO_TYPE_IOCTL, 621fa9e4066Sahrens ZIO_TYPES 622fa9e4066Sahrens } zio_type_t; 623fa9e4066Sahrens 6243f9d6ad7SLin Ling /* 6253f9d6ad7SLin Ling * Pool statistics. Note: all fields should be 64-bit because this 6263f9d6ad7SLin Ling * is passed between kernel and userland as an nvlist uint64 array. 6273f9d6ad7SLin Ling */ 6283f9d6ad7SLin Ling typedef struct pool_scan_stat { 6293f9d6ad7SLin Ling /* values stored on disk */ 6303f9d6ad7SLin Ling uint64_t pss_func; /* pool_scan_func_t */ 6313f9d6ad7SLin Ling uint64_t pss_state; /* dsl_scan_state_t */ 6323f9d6ad7SLin Ling uint64_t pss_start_time; /* scan start time */ 6333f9d6ad7SLin Ling uint64_t pss_end_time; /* scan end time */ 6343f9d6ad7SLin Ling uint64_t pss_to_examine; /* total bytes to scan */ 6353f9d6ad7SLin Ling uint64_t pss_examined; /* total examined bytes */ 6363f9d6ad7SLin Ling uint64_t pss_to_process; /* total bytes to process */ 6373f9d6ad7SLin Ling uint64_t pss_processed; /* total processed bytes */ 6383f9d6ad7SLin Ling uint64_t pss_errors; /* scan errors */ 6393f9d6ad7SLin Ling 6403f9d6ad7SLin Ling /* values not stored on disk */ 6413f9d6ad7SLin Ling uint64_t pss_pass_exam; /* examined bytes per scan pass */ 6423f9d6ad7SLin Ling uint64_t pss_pass_start; /* start time of a scan pass */ 6433f9d6ad7SLin Ling } pool_scan_stat_t; 6443f9d6ad7SLin Ling 6453f9d6ad7SLin Ling typedef enum dsl_scan_state { 6463f9d6ad7SLin Ling DSS_NONE, 6473f9d6ad7SLin Ling DSS_SCANNING, 6483f9d6ad7SLin Ling DSS_FINISHED, 6493f9d6ad7SLin Ling DSS_CANCELED, 6503f9d6ad7SLin Ling DSS_NUM_STATES 6513f9d6ad7SLin Ling } dsl_scan_state_t; 6523f9d6ad7SLin Ling 6533f9d6ad7SLin Ling 654fa9e4066Sahrens /* 655fa9e4066Sahrens * Vdev statistics. Note: all fields should be 64-bit because this 656fa9e4066Sahrens * is passed between kernel and userland as an nvlist uint64 array. 657fa9e4066Sahrens */ 658fa9e4066Sahrens typedef struct vdev_stat { 659fa9e4066Sahrens hrtime_t vs_timestamp; /* time since vdev load */ 660fa9e4066Sahrens uint64_t vs_state; /* vdev state */ 661fa9e4066Sahrens uint64_t vs_aux; /* see vdev_aux_t */ 662fa9e4066Sahrens uint64_t vs_alloc; /* space allocated */ 663fa9e4066Sahrens uint64_t vs_space; /* total capacity */ 66499653d4eSeschrock uint64_t vs_dspace; /* deflated capacity */ 6652a79c5feSlling uint64_t vs_rsize; /* replaceable dev size */ 666fa9e4066Sahrens uint64_t vs_ops[ZIO_TYPES]; /* operation count */ 667fa9e4066Sahrens uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */ 668fa9e4066Sahrens uint64_t vs_read_errors; /* read errors */ 669fa9e4066Sahrens uint64_t vs_write_errors; /* write errors */ 670fa9e4066Sahrens uint64_t vs_checksum_errors; /* checksum errors */ 671fa9e4066Sahrens uint64_t vs_self_healed; /* self-healed bytes */ 6723f9d6ad7SLin Ling uint64_t vs_scan_removing; /* removing? */ 6733f9d6ad7SLin Ling uint64_t vs_scan_processed; /* scan processed bytes */ 674fa9e4066Sahrens } vdev_stat_t; 675fa9e4066Sahrens 6769eb19f4dSGeorge Wilson /* 6779eb19f4dSGeorge Wilson * DDT statistics. Note: all fields should be 64-bit because this 6789eb19f4dSGeorge Wilson * is passed between kernel and userland as an nvlist uint64 array. 6799eb19f4dSGeorge Wilson */ 6809eb19f4dSGeorge Wilson typedef struct ddt_object { 6819eb19f4dSGeorge Wilson uint64_t ddo_count; /* number of elments in ddt */ 6829eb19f4dSGeorge Wilson uint64_t ddo_dspace; /* size of ddt on disk */ 6839eb19f4dSGeorge Wilson uint64_t ddo_mspace; /* size of ddt in-core */ 6849eb19f4dSGeorge Wilson } ddt_object_t; 6859eb19f4dSGeorge Wilson 6869eb19f4dSGeorge Wilson typedef struct ddt_stat { 6879eb19f4dSGeorge Wilson uint64_t dds_blocks; /* blocks */ 6889eb19f4dSGeorge Wilson uint64_t dds_lsize; /* logical size */ 6899eb19f4dSGeorge Wilson uint64_t dds_psize; /* physical size */ 6909eb19f4dSGeorge Wilson uint64_t dds_dsize; /* deflated allocated size */ 6919eb19f4dSGeorge Wilson uint64_t dds_ref_blocks; /* referenced blocks */ 6929eb19f4dSGeorge Wilson uint64_t dds_ref_lsize; /* referenced lsize * refcnt */ 6939eb19f4dSGeorge Wilson uint64_t dds_ref_psize; /* referenced psize * refcnt */ 6949eb19f4dSGeorge Wilson uint64_t dds_ref_dsize; /* referenced dsize * refcnt */ 6959eb19f4dSGeorge Wilson } ddt_stat_t; 6969eb19f4dSGeorge Wilson 6979eb19f4dSGeorge Wilson typedef struct ddt_histogram { 6989eb19f4dSGeorge Wilson ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */ 6999eb19f4dSGeorge Wilson } ddt_histogram_t; 7009eb19f4dSGeorge Wilson 701e7cbe64fSgw #define ZVOL_DRIVER "zvol" 702fa9e4066Sahrens #define ZFS_DRIVER "zfs" 703fa9e4066Sahrens #define ZFS_DEV "/dev/zfs" 704fa9e4066Sahrens 705681d9761SEric Taylor /* general zvol path */ 706681d9761SEric Taylor #define ZVOL_DIR "/dev/zvol" 707681d9761SEric Taylor /* expansion */ 708573ca77eSGeorge Wilson #define ZVOL_PSEUDO_DEV "/devices/pseudo/zfs@0:" 709681d9761SEric Taylor /* for dump and swap */ 710681d9761SEric Taylor #define ZVOL_FULL_DEV_DIR ZVOL_DIR "/dsk/" 711681d9761SEric Taylor #define ZVOL_FULL_RDEV_DIR ZVOL_DIR "/rdsk/" 712fa9e4066Sahrens 713fa9e4066Sahrens #define ZVOL_PROP_NAME "name" 714c1449561SEric Taylor #define ZVOL_DEFAULT_BLOCKSIZE 8192 715fa9e4066Sahrens 716fa9e4066Sahrens /* 717fa9e4066Sahrens * /dev/zfs ioctl numbers. 718fa9e4066Sahrens */ 719fa9e4066Sahrens #define ZFS_IOC ('Z' << 8) 720fa9e4066Sahrens 721fa9e4066Sahrens typedef enum zfs_ioc { 722fa9e4066Sahrens ZFS_IOC_POOL_CREATE = ZFS_IOC, 723fa9e4066Sahrens ZFS_IOC_POOL_DESTROY, 724fa9e4066Sahrens ZFS_IOC_POOL_IMPORT, 725fa9e4066Sahrens ZFS_IOC_POOL_EXPORT, 726fa9e4066Sahrens ZFS_IOC_POOL_CONFIGS, 727fa9e4066Sahrens ZFS_IOC_POOL_STATS, 728fa9e4066Sahrens ZFS_IOC_POOL_TRYIMPORT, 7293f9d6ad7SLin Ling ZFS_IOC_POOL_SCAN, 730fa9e4066Sahrens ZFS_IOC_POOL_FREEZE, 731eaca9bbdSeschrock ZFS_IOC_POOL_UPGRADE, 73206eeb2adSek ZFS_IOC_POOL_GET_HISTORY, 733fa9e4066Sahrens ZFS_IOC_VDEV_ADD, 734fa9e4066Sahrens ZFS_IOC_VDEV_REMOVE, 7353d7072f8Seschrock ZFS_IOC_VDEV_SET_STATE, 736fa9e4066Sahrens ZFS_IOC_VDEV_ATTACH, 737fa9e4066Sahrens ZFS_IOC_VDEV_DETACH, 738c67d9675Seschrock ZFS_IOC_VDEV_SETPATH, 7396809eb4eSEric Schrock ZFS_IOC_VDEV_SETFRU, 740fa9e4066Sahrens ZFS_IOC_OBJSET_STATS, 741de8267e0Stimh ZFS_IOC_OBJSET_ZPLPROPS, 742fa9e4066Sahrens ZFS_IOC_DATASET_LIST_NEXT, 743fa9e4066Sahrens ZFS_IOC_SNAPSHOT_LIST_NEXT, 744fa9e4066Sahrens ZFS_IOC_SET_PROP, 745fa9e4066Sahrens ZFS_IOC_CREATE, 746fa9e4066Sahrens ZFS_IOC_DESTROY, 747fa9e4066Sahrens ZFS_IOC_ROLLBACK, 748fa9e4066Sahrens ZFS_IOC_RENAME, 7493cb34c60Sahrens ZFS_IOC_RECV, 7503cb34c60Sahrens ZFS_IOC_SEND, 751ea8dc4b6Seschrock ZFS_IOC_INJECT_FAULT, 752ea8dc4b6Seschrock ZFS_IOC_CLEAR_FAULT, 753ea8dc4b6Seschrock ZFS_IOC_INJECT_LIST_NEXT, 754ea8dc4b6Seschrock ZFS_IOC_ERROR_LOG, 755ea8dc4b6Seschrock ZFS_IOC_CLEAR, 7561d452cf5Sahrens ZFS_IOC_PROMOTE, 7571d452cf5Sahrens ZFS_IOC_DESTROY_SNAPS, 75855434c77Sek ZFS_IOC_SNAPSHOT, 75955434c77Sek ZFS_IOC_DSOBJ_TO_DSNAME, 760b1b8ab34Slling ZFS_IOC_OBJ_TO_PATH, 761b1b8ab34Slling ZFS_IOC_POOL_SET_PROPS, 762ecd6cf80Smarks ZFS_IOC_POOL_GET_PROPS, 763ecd6cf80Smarks ZFS_IOC_SET_FSACL, 764ecd6cf80Smarks ZFS_IOC_GET_FSACL, 765e45ce728Sahrens ZFS_IOC_SHARE, 766743a77edSAlan Wright ZFS_IOC_INHERIT_PROP, 76714843421SMatthew Ahrens ZFS_IOC_SMB_ACL, 76814843421SMatthew Ahrens ZFS_IOC_USERSPACE_ONE, 76914843421SMatthew Ahrens ZFS_IOC_USERSPACE_MANY, 770842727c2SChris Kirby ZFS_IOC_USERSPACE_UPGRADE, 771842727c2SChris Kirby ZFS_IOC_HOLD, 772842727c2SChris Kirby ZFS_IOC_RELEASE, 77392241e0bSTom Erickson ZFS_IOC_GET_HOLDS, 7741195e687SMark J Musante ZFS_IOC_OBJSET_RECVD_PROPS, 77599d5e173STim Haley ZFS_IOC_VDEV_SPLIT, 77699d5e173STim Haley ZFS_IOC_NEXT_OBJ, 77799d5e173STim Haley ZFS_IOC_DIFF, 77899d5e173STim Haley ZFS_IOC_TMP_SNAPSHOT, 77999d5e173STim Haley ZFS_IOC_OBJ_TO_STATS 780fa9e4066Sahrens } zfs_ioc_t; 781fa9e4066Sahrens 782ea8dc4b6Seschrock /* 783ea8dc4b6Seschrock * Internal SPA load state. Used by FMA diagnosis engine. 784ea8dc4b6Seschrock */ 785ea8dc4b6Seschrock typedef enum { 7869eb19f4dSGeorge Wilson SPA_LOAD_NONE, /* no load in progress */ 7879eb19f4dSGeorge Wilson SPA_LOAD_OPEN, /* normal open */ 7889eb19f4dSGeorge Wilson SPA_LOAD_IMPORT, /* import in progress */ 789468c413aSTim Haley SPA_LOAD_TRYIMPORT, /* tryimport in progress */ 7909eb19f4dSGeorge Wilson SPA_LOAD_RECOVER, /* recovery requested */ 7919eb19f4dSGeorge Wilson SPA_LOAD_ERROR /* load failed */ 792ea8dc4b6Seschrock } spa_load_state_t; 793ea8dc4b6Seschrock 794e9dbad6fSeschrock /* 795e9dbad6fSeschrock * Bookmark name values. 796e9dbad6fSeschrock */ 79755434c77Sek #define ZPOOL_ERR_LIST "error list" 798e9dbad6fSeschrock #define ZPOOL_ERR_DATASET "dataset" 799e9dbad6fSeschrock #define ZPOOL_ERR_OBJECT "object" 800e9dbad6fSeschrock 80106eeb2adSek #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1) 80206eeb2adSek 80306eeb2adSek /* 80406eeb2adSek * The following are names used in the nvlist describing 80506eeb2adSek * the pool's history log. 80606eeb2adSek */ 80706eeb2adSek #define ZPOOL_HIST_RECORD "history record" 80806eeb2adSek #define ZPOOL_HIST_TIME "history time" 80906eeb2adSek #define ZPOOL_HIST_CMD "history command" 810ecd6cf80Smarks #define ZPOOL_HIST_WHO "history who" 811ecd6cf80Smarks #define ZPOOL_HIST_ZONE "history zone" 812ecd6cf80Smarks #define ZPOOL_HIST_HOST "history hostname" 813ecd6cf80Smarks #define ZPOOL_HIST_TXG "history txg" 814ecd6cf80Smarks #define ZPOOL_HIST_INT_EVENT "history internal event" 815ecd6cf80Smarks #define ZPOOL_HIST_INT_STR "history internal str" 81606eeb2adSek 8173d7072f8Seschrock /* 8183d7072f8Seschrock * Flags for ZFS_IOC_VDEV_SET_STATE 8193d7072f8Seschrock */ 8203d7072f8Seschrock #define ZFS_ONLINE_CHECKREMOVE 0x1 8213d7072f8Seschrock #define ZFS_ONLINE_UNSPARE 0x2 8223d7072f8Seschrock #define ZFS_ONLINE_FORCEFAULT 0x4 823573ca77eSGeorge Wilson #define ZFS_ONLINE_EXPAND 0x8 8243d7072f8Seschrock #define ZFS_OFFLINE_TEMPORARY 0x1 8253d7072f8Seschrock 8264b964adaSGeorge Wilson /* 8274b964adaSGeorge Wilson * Flags for ZFS_IOC_POOL_IMPORT 8284b964adaSGeorge Wilson */ 8294b964adaSGeorge Wilson #define ZFS_IMPORT_NORMAL 0x0 8304b964adaSGeorge Wilson #define ZFS_IMPORT_VERBATIM 0x1 8314b964adaSGeorge Wilson #define ZFS_IMPORT_ANY_HOST 0x2 8324b964adaSGeorge Wilson #define ZFS_IMPORT_MISSING_LOG 0x4 833f9af39baSGeorge Wilson #define ZFS_IMPORT_ONLY 0x8 8344b964adaSGeorge Wilson 8353d7072f8Seschrock /* 8363d7072f8Seschrock * Sysevent payload members. ZFS will generate the following sysevents with the 8373d7072f8Seschrock * given payloads: 8383d7072f8Seschrock * 8393d7072f8Seschrock * ESC_ZFS_RESILVER_START 8403d7072f8Seschrock * ESC_ZFS_RESILVER_END 8413d7072f8Seschrock * ESC_ZFS_POOL_DESTROY 8423d7072f8Seschrock * 8433d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 8443d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 8453d7072f8Seschrock * 8463d7072f8Seschrock * ESC_ZFS_VDEV_REMOVE 8473d7072f8Seschrock * ESC_ZFS_VDEV_CLEAR 8483d7072f8Seschrock * ESC_ZFS_VDEV_CHECK 8493d7072f8Seschrock * 8503d7072f8Seschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING 8513d7072f8Seschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64 8523d7072f8Seschrock * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional) 8533d7072f8Seschrock * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64 8543d7072f8Seschrock */ 8553d7072f8Seschrock #define ZFS_EV_POOL_NAME "pool_name" 8563d7072f8Seschrock #define ZFS_EV_POOL_GUID "pool_guid" 8573d7072f8Seschrock #define ZFS_EV_VDEV_PATH "vdev_path" 8583d7072f8Seschrock #define ZFS_EV_VDEV_GUID "vdev_guid" 8593d7072f8Seschrock 860088f3894Sahrens /* 861088f3894Sahrens * Note: This is encoded on-disk, so new events must be added to the 862088f3894Sahrens * end, and unused events can not be removed. Be sure to edit 8638f18d1faSGeorge Wilson * libzfs_pool.c: hist_event_table[]. 864088f3894Sahrens */ 865ecd6cf80Smarks typedef enum history_internal_events { 866ecd6cf80Smarks LOG_NO_EVENT = 0, 867ecd6cf80Smarks LOG_POOL_CREATE, 868ecd6cf80Smarks LOG_POOL_VDEV_ADD, 869ecd6cf80Smarks LOG_POOL_REMOVE, 870ecd6cf80Smarks LOG_POOL_DESTROY, 871ecd6cf80Smarks LOG_POOL_EXPORT, 872ecd6cf80Smarks LOG_POOL_IMPORT, 873ecd6cf80Smarks LOG_POOL_VDEV_ATTACH, 874ecd6cf80Smarks LOG_POOL_VDEV_REPLACE, 875ecd6cf80Smarks LOG_POOL_VDEV_DETACH, 876ecd6cf80Smarks LOG_POOL_VDEV_ONLINE, 877ecd6cf80Smarks LOG_POOL_VDEV_OFFLINE, 878ecd6cf80Smarks LOG_POOL_UPGRADE, 879ecd6cf80Smarks LOG_POOL_CLEAR, 8803f9d6ad7SLin Ling LOG_POOL_SCAN, 881ecd6cf80Smarks LOG_POOL_PROPSET, 882ecd6cf80Smarks LOG_DS_CREATE, 883ecd6cf80Smarks LOG_DS_CLONE, 884ecd6cf80Smarks LOG_DS_DESTROY, 885ecd6cf80Smarks LOG_DS_DESTROY_BEGIN, 886ecd6cf80Smarks LOG_DS_INHERIT, 887ecd6cf80Smarks LOG_DS_PROPSET, 888ecd6cf80Smarks LOG_DS_QUOTA, 889ecd6cf80Smarks LOG_DS_PERM_UPDATE, 890ecd6cf80Smarks LOG_DS_PERM_REMOVE, 891ecd6cf80Smarks LOG_DS_PERM_WHO_REMOVE, 892ecd6cf80Smarks LOG_DS_PROMOTE, 893ecd6cf80Smarks LOG_DS_RECEIVE, 894ecd6cf80Smarks LOG_DS_RENAME, 895ecd6cf80Smarks LOG_DS_RESERVATION, 896ecd6cf80Smarks LOG_DS_REPLAY_INC_SYNC, 897ecd6cf80Smarks LOG_DS_REPLAY_FULL_SYNC, 898ecd6cf80Smarks LOG_DS_ROLLBACK, 899ecd6cf80Smarks LOG_DS_SNAPSHOT, 900e7437265Sahrens LOG_DS_UPGRADE, 901a9799022Sck LOG_DS_REFQUOTA, 902a9799022Sck LOG_DS_REFRESERV, 9033f9d6ad7SLin Ling LOG_POOL_SCAN_DONE, 904842727c2SChris Kirby LOG_DS_USER_HOLD, 905842727c2SChris Kirby LOG_DS_USER_RELEASE, 9061195e687SMark J Musante LOG_POOL_SPLIT, 907ecd6cf80Smarks LOG_END 908ecd6cf80Smarks } history_internal_events_t; 909ecd6cf80Smarks 910fa9e4066Sahrens #ifdef __cplusplus 911fa9e4066Sahrens } 912fa9e4066Sahrens #endif 913fa9e4066Sahrens 914fa9e4066Sahrens #endif /* _SYS_FS_ZFS_H */ 915