xref: /illumos-gate/usr/src/uts/common/sys/fs/zfs.h (revision e0f1c0afa46cc84d4b1e40124032a9a87310386e)
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.
24dfc11533SChris Williamson  * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
25e9103aaeSGarrett D'Amore  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
26c3d26abcSMatthew Ahrens  * Copyright (c) 2014 Integros [integros.com]
27ce1577b0SDave Eddy  * Copyright 2017 Joyent, Inc.
281702cce7SAlek Pinchuk  * Copyright (c) 2017 Datto Inc.
29fa9e4066Sahrens  */
30fa9e4066Sahrens 
3155da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */
3255da60b9SMark J Musante 
33fa9e4066Sahrens #ifndef	_SYS_FS_ZFS_H
34fa9e4066Sahrens #define	_SYS_FS_ZFS_H
35fa9e4066Sahrens 
36842727c2SChris Kirby #include <sys/time.h>
37842727c2SChris Kirby 
38fa9e4066Sahrens #ifdef	__cplusplus
39fa9e4066Sahrens extern "C" {
40fa9e4066Sahrens #endif
41fa9e4066Sahrens 
42fa9e4066Sahrens /*
43fa9e4066Sahrens  * Types and constants shared between userland and the kernel.
44fa9e4066Sahrens  */
45fa9e4066Sahrens 
46fa9e4066Sahrens /*
47fa9e4066Sahrens  * Each dataset can be one of the following types.  These constants can be
48fa9e4066Sahrens  * combined into masks that can be passed to various functions.
49fa9e4066Sahrens  */
50fa9e4066Sahrens typedef enum {
5178f17100SMatthew Ahrens 	ZFS_TYPE_FILESYSTEM	= (1 << 0),
5278f17100SMatthew Ahrens 	ZFS_TYPE_SNAPSHOT	= (1 << 1),
5378f17100SMatthew Ahrens 	ZFS_TYPE_VOLUME		= (1 << 2),
5478f17100SMatthew Ahrens 	ZFS_TYPE_POOL		= (1 << 3),
5578f17100SMatthew Ahrens 	ZFS_TYPE_BOOKMARK	= (1 << 4)
56fa9e4066Sahrens } zfs_type_t;
57fa9e4066Sahrens 
5826455f9eSAndriy Gapon /*
5926455f9eSAndriy Gapon  * NB: lzc_dataset_type should be updated whenever a new objset type is added,
6026455f9eSAndriy Gapon  * if it represents a real type of a dataset that can be created from userland.
6126455f9eSAndriy Gapon  */
624445fffbSMatthew Ahrens typedef enum dmu_objset_type {
634445fffbSMatthew Ahrens 	DMU_OST_NONE,
644445fffbSMatthew Ahrens 	DMU_OST_META,
654445fffbSMatthew Ahrens 	DMU_OST_ZFS,
664445fffbSMatthew Ahrens 	DMU_OST_ZVOL,
674445fffbSMatthew Ahrens 	DMU_OST_OTHER,			/* For testing only! */
684445fffbSMatthew Ahrens 	DMU_OST_ANY,			/* Be careful! */
694445fffbSMatthew Ahrens 	DMU_OST_NUMTYPES
704445fffbSMatthew Ahrens } dmu_objset_type_t;
714445fffbSMatthew Ahrens 
72990b4856Slling #define	ZFS_TYPE_DATASET	\
73fa9e4066Sahrens 	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
74fa9e4066Sahrens 
759adfa60dSMatthew Ahrens /*
769adfa60dSMatthew Ahrens  * All of these include the terminating NUL byte.
779adfa60dSMatthew Ahrens  */
78478ed9adSEric Taylor #define	ZAP_MAXNAMELEN 256
79478ed9adSEric Taylor #define	ZAP_MAXVALUELEN (1024 * 8)
80478ed9adSEric Taylor #define	ZAP_OLDMAXVALUELEN 1024
819adfa60dSMatthew Ahrens #define	ZFS_MAX_DATASET_NAME_LEN 256
82478ed9adSEric Taylor 
83fa9e4066Sahrens /*
84990b4856Slling  * Dataset properties are identified by these constants and must be added to
85990b4856Slling  * the end of this list to ensure that external consumers are not affected
86990b4856Slling  * by the change. If you make any changes to this list, be sure to update
8766e2aaccSgw  * the property table in usr/src/common/zfs/zfs_prop.c.
88fa9e4066Sahrens  */
89fa9e4066Sahrens typedef enum {
904ae5f5f0SAlan Somers 	ZPROP_CONT = -2,
914ae5f5f0SAlan Somers 	ZPROP_INVAL = -1,
92c16bcc45SIgor Kozhukhov 	ZFS_PROP_TYPE = 0,
93fa9e4066Sahrens 	ZFS_PROP_CREATION,
94fa9e4066Sahrens 	ZFS_PROP_USED,
95fa9e4066Sahrens 	ZFS_PROP_AVAILABLE,
96fa9e4066Sahrens 	ZFS_PROP_REFERENCED,
97fa9e4066Sahrens 	ZFS_PROP_COMPRESSRATIO,
98fa9e4066Sahrens 	ZFS_PROP_MOUNTED,
99fa9e4066Sahrens 	ZFS_PROP_ORIGIN,
100fa9e4066Sahrens 	ZFS_PROP_QUOTA,
101fa9e4066Sahrens 	ZFS_PROP_RESERVATION,
102fa9e4066Sahrens 	ZFS_PROP_VOLSIZE,
103fa9e4066Sahrens 	ZFS_PROP_VOLBLOCKSIZE,
104fa9e4066Sahrens 	ZFS_PROP_RECORDSIZE,
105fa9e4066Sahrens 	ZFS_PROP_MOUNTPOINT,
106fa9e4066Sahrens 	ZFS_PROP_SHARENFS,
107fa9e4066Sahrens 	ZFS_PROP_CHECKSUM,
108fa9e4066Sahrens 	ZFS_PROP_COMPRESSION,
109fa9e4066Sahrens 	ZFS_PROP_ATIME,
110fa9e4066Sahrens 	ZFS_PROP_DEVICES,
111fa9e4066Sahrens 	ZFS_PROP_EXEC,
112fa9e4066Sahrens 	ZFS_PROP_SETUID,
113fa9e4066Sahrens 	ZFS_PROP_READONLY,
114fa9e4066Sahrens 	ZFS_PROP_ZONED,
115fa9e4066Sahrens 	ZFS_PROP_SNAPDIR,
116a3c49ce1SAlbert Lee 	ZFS_PROP_ACLMODE,
117fa9e4066Sahrens 	ZFS_PROP_ACLINHERIT,
118e8d4a73cSJosh Paetzel 	ZFS_PROP_CREATETXG,
11966e2aaccSgw 	ZFS_PROP_NAME,			/* not exposed to the user */
120e9dbad6fSeschrock 	ZFS_PROP_CANMOUNT,
12166e2aaccSgw 	ZFS_PROP_ISCSIOPTIONS,		/* not exposed to the user */
1227b55fa8eSck 	ZFS_PROP_XATTR,
123d0ad202dSahrens 	ZFS_PROP_NUMCLONES,		/* not exposed to the user */
124b1b8ab34Slling 	ZFS_PROP_COPIES,
125e7437265Sahrens 	ZFS_PROP_VERSION,
126da6c28aaSamw 	ZFS_PROP_UTF8ONLY,
127da6c28aaSamw 	ZFS_PROP_NORMALIZE,
128da6c28aaSamw 	ZFS_PROP_CASE,
129da6c28aaSamw 	ZFS_PROP_VSCAN,
130da6c28aaSamw 	ZFS_PROP_NBMAND,
131da6c28aaSamw 	ZFS_PROP_SHARESMB,
132a9799022Sck 	ZFS_PROP_REFQUOTA,
133a9799022Sck 	ZFS_PROP_REFRESERVATION,
134c5904d13Seschrock 	ZFS_PROP_GUID,
1353baa08fcSek 	ZFS_PROP_PRIMARYCACHE,
1363baa08fcSek 	ZFS_PROP_SECONDARYCACHE,
13774e7dc98SMatthew Ahrens 	ZFS_PROP_USEDSNAP,
13874e7dc98SMatthew Ahrens 	ZFS_PROP_USEDDS,
13974e7dc98SMatthew Ahrens 	ZFS_PROP_USEDCHILD,
14074e7dc98SMatthew Ahrens 	ZFS_PROP_USEDREFRESERV,
14114843421SMatthew Ahrens 	ZFS_PROP_USERACCOUNTING,	/* not exposed to the user */
142478ed9adSEric Taylor 	ZFS_PROP_STMF_SHAREINFO,	/* not exposed to the user */
143842727c2SChris Kirby 	ZFS_PROP_DEFER_DESTROY,
144842727c2SChris Kirby 	ZFS_PROP_USERREFS,
145e09fa4daSNeil Perrin 	ZFS_PROP_LOGBIAS,
1461d713200SEric Schrock 	ZFS_PROP_UNIQUE,		/* not exposed to the user */
1471d713200SEric Schrock 	ZFS_PROP_OBJSETID,		/* not exposed to the user */
148b24ab676SJeff Bonwick 	ZFS_PROP_DEDUP,
1494201a95eSRic Aleshire 	ZFS_PROP_MLSLABEL,
15055da60b9SMark J Musante 	ZFS_PROP_SYNC,
15154811da5SToomas Soome 	ZFS_PROP_DNODESIZE,
152187d6ac0SMatt Ahrens 	ZFS_PROP_REFRATIO,
15319b94df9SMatthew Ahrens 	ZFS_PROP_WRITTEN,
15419b94df9SMatthew Ahrens 	ZFS_PROP_CLONES,
15577372cb0SMatthew Ahrens 	ZFS_PROP_LOGICALUSED,
15677372cb0SMatthew Ahrens 	ZFS_PROP_LOGICALREFERENCED,
157ca48f36fSKeith M Wesolowski 	ZFS_PROP_INCONSISTENT,		/* not exposed to the user */
158a2afb611SJerry Jelinek 	ZFS_PROP_FILESYSTEM_LIMIT,
159a2afb611SJerry Jelinek 	ZFS_PROP_SNAPSHOT_LIMIT,
160a2afb611SJerry Jelinek 	ZFS_PROP_FILESYSTEM_COUNT,
161a2afb611SJerry Jelinek 	ZFS_PROP_SNAPSHOT_COUNT,
162edf345e6SMatthew Ahrens 	ZFS_PROP_REDUNDANT_METADATA,
163b461c746SMatthew Ahrens 	ZFS_PROP_PREV_SNAP,
1649c3fd121SMatthew Ahrens 	ZFS_PROP_RECEIVE_RESUME_TOKEN,
1655cabbc6bSPrashanth Sreenivasa 	ZFS_PROP_REMAPTXG,		/* not exposed to the user */
16691ebeef5Sahrens 	ZFS_NUM_PROPS
167fa9e4066Sahrens } zfs_prop_t;
168fa9e4066Sahrens 
16914843421SMatthew Ahrens typedef enum {
17014843421SMatthew Ahrens 	ZFS_PROP_USERUSED,
17114843421SMatthew Ahrens 	ZFS_PROP_USERQUOTA,
17214843421SMatthew Ahrens 	ZFS_PROP_GROUPUSED,
17314843421SMatthew Ahrens 	ZFS_PROP_GROUPQUOTA,
17414843421SMatthew Ahrens 	ZFS_NUM_USERQUOTA_PROPS
17514843421SMatthew Ahrens } zfs_userquota_prop_t;
17614843421SMatthew Ahrens 
17714843421SMatthew Ahrens extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
17814843421SMatthew Ahrens 
179990b4856Slling /*
180990b4856Slling  * Pool properties are identified by these constants and must be added to the
181b87f3af3Sperrin  * end of this list to ensure that external consumers are not affected
182990b4856Slling  * by the change. If you make any changes to this list, be sure to update
183990b4856Slling  * the property table in usr/src/common/zfs/zpool_prop.c.
184990b4856Slling  */
185990b4856Slling typedef enum {
1864ae5f5f0SAlan Somers 	ZPOOL_PROP_INVAL = -1,
187990b4856Slling 	ZPOOL_PROP_NAME,
188990b4856Slling 	ZPOOL_PROP_SIZE,
189990b4856Slling 	ZPOOL_PROP_CAPACITY,
190990b4856Slling 	ZPOOL_PROP_ALTROOT,
191990b4856Slling 	ZPOOL_PROP_HEALTH,
192990b4856Slling 	ZPOOL_PROP_GUID,
193990b4856Slling 	ZPOOL_PROP_VERSION,
194990b4856Slling 	ZPOOL_PROP_BOOTFS,
195990b4856Slling 	ZPOOL_PROP_DELEGATION,
196990b4856Slling 	ZPOOL_PROP_AUTOREPLACE,
1972f8aaab3Seschrock 	ZPOOL_PROP_CACHEFILE,
1980a4e9518Sgw 	ZPOOL_PROP_FAILUREMODE,
199d5b5bb25SRich Morris 	ZPOOL_PROP_LISTSNAPS,
200573ca77eSGeorge Wilson 	ZPOOL_PROP_AUTOEXPAND,
201b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPDITTO,
202b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPRATIO,
203485bbbf5SGeorge Wilson 	ZPOOL_PROP_FREE,
204485bbbf5SGeorge Wilson 	ZPOOL_PROP_ALLOCATED,
205f9af39baSGeorge Wilson 	ZPOOL_PROP_READONLY,
2068704186eSDan McDonald 	ZPOOL_PROP_COMMENT,
2074263d13fSGeorge Wilson 	ZPOOL_PROP_EXPANDSZ,
208ad135b5dSChristopher Siden 	ZPOOL_PROP_FREEING,
2092e4c9986SGeorge Wilson 	ZPOOL_PROP_FRAGMENTATION,
2107fd05ac4SMatthew Ahrens 	ZPOOL_PROP_LEAKED,
211b5152584SMatthew Ahrens 	ZPOOL_PROP_MAXBLOCKSIZE,
2127855d95bSToomas Soome 	ZPOOL_PROP_BOOTSIZE,
21386714001SSerapheim Dimitropoulos 	ZPOOL_PROP_CHECKPOINT,
21404e56356SAndriy Gapon 	ZPOOL_PROP_TNAME,
21554811da5SToomas Soome 	ZPOOL_PROP_MAXDNODESIZE,
216*e0f1c0afSOlaf Faaland 	ZPOOL_PROP_MULTIHOST,
217990b4856Slling 	ZPOOL_NUM_PROPS
218990b4856Slling } zpool_prop_t;
219b1b8ab34Slling 
2208704186eSDan McDonald /* Small enough to not hog a whole line of printout in zpool(1M). */
2218704186eSDan McDonald #define	ZPROP_MAX_COMMENT	32
2228704186eSDan McDonald 
223990b4856Slling #define	ZPROP_VALUE		"value"
224990b4856Slling #define	ZPROP_SOURCE		"source"
2257f7322feSeschrock 
226b1b8ab34Slling typedef enum {
227990b4856Slling 	ZPROP_SRC_NONE = 0x1,
228990b4856Slling 	ZPROP_SRC_DEFAULT = 0x2,
229990b4856Slling 	ZPROP_SRC_TEMPORARY = 0x4,
230990b4856Slling 	ZPROP_SRC_LOCAL = 0x8,
23192241e0bSTom Erickson 	ZPROP_SRC_INHERITED = 0x10,
23292241e0bSTom Erickson 	ZPROP_SRC_RECEIVED = 0x20
233990b4856Slling } zprop_source_t;
234990b4856Slling 
23592241e0bSTom Erickson #define	ZPROP_SRC_ALL	0x3f
23692241e0bSTom Erickson 
23792241e0bSTom Erickson #define	ZPROP_SOURCE_VAL_RECVD	"$recvd"
23892241e0bSTom Erickson #define	ZPROP_N_MORE_ERRORS	"N_MORE_ERRORS"
23992241e0bSTom Erickson /*
24092241e0bSTom Erickson  * Dataset flag implemented as a special entry in the props zap object
24192241e0bSTom Erickson  * indicating that the dataset has received properties on or after
24292241e0bSTom Erickson  * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
24392241e0bSTom Erickson  * just as it did in earlier versions, and thereafter, local properties are
24492241e0bSTom Erickson  * preserved.
24592241e0bSTom Erickson  */
24692241e0bSTom Erickson #define	ZPROP_HAS_RECVD		"$hasrecvd"
24792241e0bSTom Erickson 
24892241e0bSTom Erickson typedef enum {
24992241e0bSTom Erickson 	ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
25092241e0bSTom Erickson 	ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
25192241e0bSTom Erickson } zprop_errflags_t;
252990b4856Slling 
253990b4856Slling typedef int (*zprop_func)(int, void *);
254990b4856Slling 
2550a48a24eStimh /*
2560a48a24eStimh  * Properties to be set on the root file system of a new pool
2570a48a24eStimh  * are stuffed into their own nvlist, which is then included in
2580a48a24eStimh  * the properties nvlist with the pool properties.
2590a48a24eStimh  */
2600a48a24eStimh #define	ZPOOL_ROOTFS_PROPS	"root-props-nvl"
2610a48a24eStimh 
262dfc11533SChris Williamson /*
263dfc11533SChris Williamson  * Length of 'written@' and 'written#'
264dfc11533SChris Williamson  */
265dfc11533SChris Williamson #define	ZFS_WRITTEN_PROP_PREFIX_LEN	8
266dfc11533SChris Williamson 
267990b4856Slling /*
268990b4856Slling  * Dataset property functions shared between libzfs and kernel.
269990b4856Slling  */
270990b4856Slling const char *zfs_prop_default_string(zfs_prop_t);
271990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t);
272990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t);
273dfc11533SChris Williamson boolean_t zfs_prop_visible(zfs_prop_t prop);
274990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t);
275da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t);
276990b4856Slling const char *zfs_prop_to_name(zfs_prop_t);
277990b4856Slling zfs_prop_t zfs_name_to_prop(const char *);
278990b4856Slling boolean_t zfs_prop_user(const char *);
27992241e0bSTom Erickson boolean_t zfs_prop_userquota(const char *);
28019b94df9SMatthew Ahrens boolean_t zfs_prop_written(const char *);
281990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
282990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
283b24ab676SJeff Bonwick uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
2844853e976Sgw boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
285b1b8ab34Slling 
286990b4856Slling /*
287990b4856Slling  * Pool property functions shared between libzfs and kernel.
288990b4856Slling  */
289990b4856Slling zpool_prop_t zpool_name_to_prop(const char *);
290990b4856Slling const char *zpool_prop_to_name(zpool_prop_t);
291990b4856Slling const char *zpool_prop_default_string(zpool_prop_t);
292990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t);
293990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t);
294ad135b5dSChristopher Siden boolean_t zpool_prop_feature(const char *);
295ad135b5dSChristopher Siden boolean_t zpool_prop_unsupported(const char *name);
296990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
297990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
298b24ab676SJeff Bonwick uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
299b1b8ab34Slling 
300990b4856Slling /*
301990b4856Slling  * Definitions for the Delegation.
302990b4856Slling  */
303ecd6cf80Smarks typedef enum {
304ecd6cf80Smarks 	ZFS_DELEG_WHO_UNKNOWN = 0,
305ecd6cf80Smarks 	ZFS_DELEG_USER = 'u',
306ecd6cf80Smarks 	ZFS_DELEG_USER_SETS = 'U',
307ecd6cf80Smarks 	ZFS_DELEG_GROUP = 'g',
308ecd6cf80Smarks 	ZFS_DELEG_GROUP_SETS = 'G',
309ecd6cf80Smarks 	ZFS_DELEG_EVERYONE = 'e',
310ecd6cf80Smarks 	ZFS_DELEG_EVERYONE_SETS = 'E',
311ecd6cf80Smarks 	ZFS_DELEG_CREATE = 'c',
312ecd6cf80Smarks 	ZFS_DELEG_CREATE_SETS = 'C',
313ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET = 's',
314ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET_SETS = 'S'
315ecd6cf80Smarks } zfs_deleg_who_type_t;
316ecd6cf80Smarks 
317ecd6cf80Smarks typedef enum {
318ecd6cf80Smarks 	ZFS_DELEG_NONE = 0,
319ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCAL = 1,
320ecd6cf80Smarks 	ZFS_DELEG_PERM_DESCENDENT = 2,
321ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
322ecd6cf80Smarks 	ZFS_DELEG_PERM_CREATE = 4
323ecd6cf80Smarks } zfs_deleg_inherit_t;
324ecd6cf80Smarks 
325ecd6cf80Smarks #define	ZFS_DELEG_PERM_UID	"uid"
326ecd6cf80Smarks #define	ZFS_DELEG_PERM_GID	"gid"
327ecd6cf80Smarks #define	ZFS_DELEG_PERM_GROUPS	"groups"
328ecd6cf80Smarks 
3294201a95eSRic Aleshire #define	ZFS_MLSLABEL_DEFAULT	"none"
3304201a95eSRic Aleshire 
331743a77edSAlan Wright #define	ZFS_SMB_ACL_SRC		"src"
332743a77edSAlan Wright #define	ZFS_SMB_ACL_TARGET	"target"
333743a77edSAlan Wright 
334a227b7f4Shs typedef enum {
335a227b7f4Shs 	ZFS_CANMOUNT_OFF = 0,
336a227b7f4Shs 	ZFS_CANMOUNT_ON = 1,
337a227b7f4Shs 	ZFS_CANMOUNT_NOAUTO = 2
338a227b7f4Shs } zfs_canmount_type_t;
339a227b7f4Shs 
340e09fa4daSNeil Perrin typedef enum {
341e09fa4daSNeil Perrin 	ZFS_LOGBIAS_LATENCY = 0,
342e09fa4daSNeil Perrin 	ZFS_LOGBIAS_THROUGHPUT = 1
343e09fa4daSNeil Perrin } zfs_logbias_op_t;
344e09fa4daSNeil Perrin 
345da6c28aaSamw typedef enum zfs_share_op {
346da6c28aaSamw 	ZFS_SHARE_NFS = 0,
347da6c28aaSamw 	ZFS_UNSHARE_NFS = 1,
348da6c28aaSamw 	ZFS_SHARE_SMB = 2,
349da6c28aaSamw 	ZFS_UNSHARE_SMB = 3
350da6c28aaSamw } zfs_share_op_t;
351da6c28aaSamw 
352743a77edSAlan Wright typedef enum zfs_smb_acl_op {
353743a77edSAlan Wright 	ZFS_SMB_ACL_ADD,
354743a77edSAlan Wright 	ZFS_SMB_ACL_REMOVE,
355743a77edSAlan Wright 	ZFS_SMB_ACL_RENAME,
356743a77edSAlan Wright 	ZFS_SMB_ACL_PURGE
357743a77edSAlan Wright } zfs_smb_acl_op_t;
358743a77edSAlan Wright 
3593baa08fcSek typedef enum zfs_cache_type {
3603baa08fcSek 	ZFS_CACHE_NONE = 0,
3613baa08fcSek 	ZFS_CACHE_METADATA = 1,
3623baa08fcSek 	ZFS_CACHE_ALL = 2
3633baa08fcSek } zfs_cache_type_t;
3643baa08fcSek 
36555da60b9SMark J Musante typedef enum {
36655da60b9SMark J Musante 	ZFS_SYNC_STANDARD = 0,
36755da60b9SMark J Musante 	ZFS_SYNC_ALWAYS = 1,
36855da60b9SMark J Musante 	ZFS_SYNC_DISABLED = 2
36955da60b9SMark J Musante } zfs_sync_type_t;
37055da60b9SMark J Musante 
37154811da5SToomas Soome typedef enum {
37254811da5SToomas Soome 	ZFS_DNSIZE_LEGACY = 0,
37354811da5SToomas Soome 	ZFS_DNSIZE_AUTO = 1,
37454811da5SToomas Soome 	ZFS_DNSIZE_1K = 1024,
37554811da5SToomas Soome 	ZFS_DNSIZE_2K = 2048,
37654811da5SToomas Soome 	ZFS_DNSIZE_4K = 4096,
37754811da5SToomas Soome 	ZFS_DNSIZE_8K = 8192,
37854811da5SToomas Soome 	ZFS_DNSIZE_16K = 16384
37954811da5SToomas Soome } zfs_dnsize_type_t;
38054811da5SToomas Soome 
381edf345e6SMatthew Ahrens typedef enum {
382edf345e6SMatthew Ahrens 	ZFS_REDUNDANT_METADATA_ALL,
383edf345e6SMatthew Ahrens 	ZFS_REDUNDANT_METADATA_MOST
384edf345e6SMatthew Ahrens } zfs_redundant_metadata_type_t;
3853baa08fcSek 
386eaca9bbdSeschrock /*
38799653d4eSeschrock  * On-disk version number.
388eaca9bbdSeschrock  */
389e7437265Sahrens #define	SPA_VERSION_1			1ULL
390e7437265Sahrens #define	SPA_VERSION_2			2ULL
391e7437265Sahrens #define	SPA_VERSION_3			3ULL
392e7437265Sahrens #define	SPA_VERSION_4			4ULL
393e7437265Sahrens #define	SPA_VERSION_5			5ULL
394e7437265Sahrens #define	SPA_VERSION_6			6ULL
395e7437265Sahrens #define	SPA_VERSION_7			7ULL
396e7437265Sahrens #define	SPA_VERSION_8			8ULL
397da6c28aaSamw #define	SPA_VERSION_9			9ULL
398fa94a07fSbrendan #define	SPA_VERSION_10			10ULL
399088f3894Sahrens #define	SPA_VERSION_11			11ULL
400bb0ade09Sahrens #define	SPA_VERSION_12			12ULL
40174e7dc98SMatthew Ahrens #define	SPA_VERSION_13			13ULL
402d0f3f37eSMark Shellenbaum #define	SPA_VERSION_14			14ULL
40314843421SMatthew Ahrens #define	SPA_VERSION_15			15ULL
404478ed9adSEric Taylor #define	SPA_VERSION_16			16ULL
405f94275ceSAdam Leventhal #define	SPA_VERSION_17			17ULL
406842727c2SChris Kirby #define	SPA_VERSION_18			18ULL
40788ecc943SGeorge Wilson #define	SPA_VERSION_19			19ULL
408b24ab676SJeff Bonwick #define	SPA_VERSION_20			20ULL
409b24ab676SJeff Bonwick #define	SPA_VERSION_21			21ULL
41092241e0bSTom Erickson #define	SPA_VERSION_22			22ULL
4116e1f5caaSNeil Perrin #define	SPA_VERSION_23			23ULL
4120a586ceaSMark Shellenbaum #define	SPA_VERSION_24			24ULL
4133f9d6ad7SLin Ling #define	SPA_VERSION_25			25ULL
414cde58dbcSMatthew Ahrens #define	SPA_VERSION_26			26ULL
4156e0cbcaaSMatthew Ahrens #define	SPA_VERSION_27			27ULL
416cb04b873SMark J Musante #define	SPA_VERSION_28			28ULL
417ad135b5dSChristopher Siden #define	SPA_VERSION_5000		5000ULL
418cb04b873SMark J Musante 
419b1b8ab34Slling /*
420e7cbe64fSgw  * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
421478ed9adSEric Taylor  * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
42214843421SMatthew Ahrens  * and do the appropriate changes.  Also bump the version number in
42314843421SMatthew Ahrens  * usr/src/grub/capability.
424b1b8ab34Slling  */
425ad135b5dSChristopher Siden #define	SPA_VERSION			SPA_VERSION_5000
426ad135b5dSChristopher Siden #define	SPA_VERSION_STRING		"5000"
42744cd46caSbillm 
42844cd46caSbillm /*
429e7437265Sahrens  * Symbolic names for the changes that caused a SPA_VERSION switch.
43044cd46caSbillm  * Used in the code when checking for presence or absence of a feature.
43144cd46caSbillm  * Feel free to define multiple symbolic names for each version if there
43244cd46caSbillm  * were multiple changes to on-disk structures during that version.
43344cd46caSbillm  *
434e7437265Sahrens  * NOTE: When checking the current SPA_VERSION in your code, be sure
43544cd46caSbillm  *       to use spa_version() since it reports the version of the
43644cd46caSbillm  *       last synced uberblock.  Checking the in-flight version can
43744cd46caSbillm  *       be dangerous in some cases.
43844cd46caSbillm  */
439e7437265Sahrens #define	SPA_VERSION_INITIAL		SPA_VERSION_1
440e7437265Sahrens #define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
441e7437265Sahrens #define	SPA_VERSION_SPARES		SPA_VERSION_3
442f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ2		SPA_VERSION_3
443cde58dbcSMatthew Ahrens #define	SPA_VERSION_BPOBJ_ACCOUNT	SPA_VERSION_3
444e7437265Sahrens #define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
445e7437265Sahrens #define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
446e7437265Sahrens #define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
447e7437265Sahrens #define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
448e7437265Sahrens #define	SPA_VERSION_BOOTFS		SPA_VERSION_6
449990b4856Slling #define	SPA_VERSION_SLOGS		SPA_VERSION_7
450990b4856Slling #define	SPA_VERSION_DELEGATED_PERMS	SPA_VERSION_8
451da6c28aaSamw #define	SPA_VERSION_FUID		SPA_VERSION_9
452a9799022Sck #define	SPA_VERSION_REFRESERVATION	SPA_VERSION_9
453a9799022Sck #define	SPA_VERSION_REFQUOTA		SPA_VERSION_9
454a9799022Sck #define	SPA_VERSION_UNIQUE_ACCURATE	SPA_VERSION_9
455fa94a07fSbrendan #define	SPA_VERSION_L2CACHE		SPA_VERSION_10
456088f3894Sahrens #define	SPA_VERSION_NEXT_CLONES		SPA_VERSION_11
457088f3894Sahrens #define	SPA_VERSION_ORIGIN		SPA_VERSION_11
458088f3894Sahrens #define	SPA_VERSION_DSL_SCRUB		SPA_VERSION_11
459bb0ade09Sahrens #define	SPA_VERSION_SNAP_PROPS		SPA_VERSION_12
46074e7dc98SMatthew Ahrens #define	SPA_VERSION_USED_BREAKDOWN	SPA_VERSION_13
461d0f3f37eSMark Shellenbaum #define	SPA_VERSION_PASSTHROUGH_X	SPA_VERSION_14
46214843421SMatthew Ahrens #define	SPA_VERSION_USERSPACE		SPA_VERSION_15
463478ed9adSEric Taylor #define	SPA_VERSION_STMF_PROP		SPA_VERSION_16
464f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ3		SPA_VERSION_17
465842727c2SChris Kirby #define	SPA_VERSION_USERREFS		SPA_VERSION_18
46688ecc943SGeorge Wilson #define	SPA_VERSION_HOLES		SPA_VERSION_19
467b24ab676SJeff Bonwick #define	SPA_VERSION_ZLE_COMPRESSION	SPA_VERSION_20
468b24ab676SJeff Bonwick #define	SPA_VERSION_DEDUP		SPA_VERSION_21
46992241e0bSTom Erickson #define	SPA_VERSION_RECVD_PROPS		SPA_VERSION_22
4706e1f5caaSNeil Perrin #define	SPA_VERSION_SLIM_ZIL		SPA_VERSION_23
4710a586ceaSMark Shellenbaum #define	SPA_VERSION_SA			SPA_VERSION_24
4723f9d6ad7SLin Ling #define	SPA_VERSION_SCAN		SPA_VERSION_25
473cde58dbcSMatthew Ahrens #define	SPA_VERSION_DIR_CLONES		SPA_VERSION_26
474cde58dbcSMatthew Ahrens #define	SPA_VERSION_DEADLISTS		SPA_VERSION_26
4756e0cbcaaSMatthew Ahrens #define	SPA_VERSION_FAST_SNAP		SPA_VERSION_27
476cb04b873SMark J Musante #define	SPA_VERSION_MULTI_REPLACE	SPA_VERSION_28
477ad135b5dSChristopher Siden #define	SPA_VERSION_BEFORE_FEATURES	SPA_VERSION_28
478ad135b5dSChristopher Siden #define	SPA_VERSION_FEATURES		SPA_VERSION_5000
479ad135b5dSChristopher Siden 
480ad135b5dSChristopher Siden #define	SPA_VERSION_IS_SUPPORTED(v) \
481ad135b5dSChristopher Siden 	(((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
482ad135b5dSChristopher Siden 	((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
483e7437265Sahrens 
484e7437265Sahrens /*
485e7437265Sahrens  * ZPL version - rev'd whenever an incompatible on-disk format change
486e7437265Sahrens  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
487e7437265Sahrens  * also update the version_table[] and help message in zfs_prop.c.
488e7437265Sahrens  *
489e7437265Sahrens  * When changing, be sure to teach GRUB how to read the new format!
490478ed9adSEric Taylor  * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
491e7437265Sahrens  */
492e7437265Sahrens #define	ZPL_VERSION_1			1ULL
493e7437265Sahrens #define	ZPL_VERSION_2			2ULL
494da6c28aaSamw #define	ZPL_VERSION_3			3ULL
49514843421SMatthew Ahrens #define	ZPL_VERSION_4			4ULL
4960a586ceaSMark Shellenbaum #define	ZPL_VERSION_5			5ULL
4970a586ceaSMark Shellenbaum #define	ZPL_VERSION			ZPL_VERSION_5
4980a586ceaSMark Shellenbaum #define	ZPL_VERSION_STRING		"5"
499e7437265Sahrens 
500e7437265Sahrens #define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
501e7437265Sahrens #define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
502da6c28aaSamw #define	ZPL_VERSION_FUID		ZPL_VERSION_3
503de8267e0Stimh #define	ZPL_VERSION_NORMALIZATION	ZPL_VERSION_3
504da6c28aaSamw #define	ZPL_VERSION_SYSATTR		ZPL_VERSION_3
50514843421SMatthew Ahrens #define	ZPL_VERSION_USERSPACE		ZPL_VERSION_4
5060a586ceaSMark Shellenbaum #define	ZPL_VERSION_SA			ZPL_VERSION_5
507eaca9bbdSeschrock 
5085dafeea3SPavel Zakharov /* Rewind policy information */
509c8ee1847SVictor Latushkin #define	ZPOOL_NO_REWIND		1  /* No policy - default behavior */
510c8ee1847SVictor Latushkin #define	ZPOOL_NEVER_REWIND	2  /* Do not search for best txg or rewind */
511c8ee1847SVictor Latushkin #define	ZPOOL_TRY_REWIND	4  /* Search for best txg, but do not rewind */
512c8ee1847SVictor Latushkin #define	ZPOOL_DO_REWIND		8  /* Rewind to best txg w/in deferred frees */
513c8ee1847SVictor Latushkin #define	ZPOOL_EXTREME_REWIND	16 /* Allow extreme measures to find best txg */
514c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_MASK	28 /* All the possible rewind bits */
515c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_POLICIES	31 /* All the possible policy bits */
516468c413aSTim Haley 
5175dafeea3SPavel Zakharov typedef struct zpool_load_policy {
5185dafeea3SPavel Zakharov 	uint32_t	zlp_rewind;	/* rewind policy requested */
5195dafeea3SPavel Zakharov 	uint64_t	zlp_maxmeta;	/* max acceptable meta-data errors */
5205dafeea3SPavel Zakharov 	uint64_t	zlp_maxdata;	/* max acceptable data errors */
5215dafeea3SPavel Zakharov 	uint64_t	zlp_txg;	/* specific txg to load */
5225dafeea3SPavel Zakharov } zpool_load_policy_t;
523468c413aSTim Haley 
524fa9e4066Sahrens /*
525fa9e4066Sahrens  * The following are configuration names used in the nvlist describing a pool's
5265cabbc6bSPrashanth Sreenivasa  * configuration.  New on-disk names should be prefixed with "<reverse-DNS>:"
5275cabbc6bSPrashanth Sreenivasa  * (e.g. "org.open-zfs:") to avoid conflicting names being developed
5285cabbc6bSPrashanth Sreenivasa  * independently.
529fa9e4066Sahrens  */
530fa9e4066Sahrens #define	ZPOOL_CONFIG_VERSION		"version"
531fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_NAME		"name"
532fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_STATE		"state"
533fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_TXG		"txg"
534fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
535fa9e4066Sahrens #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
536fa9e4066Sahrens #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
537fa9e4066Sahrens #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
538fa9e4066Sahrens #define	ZPOOL_CONFIG_TYPE		"type"
539fa9e4066Sahrens #define	ZPOOL_CONFIG_CHILDREN		"children"
540fa9e4066Sahrens #define	ZPOOL_CONFIG_ID			"id"
541fa9e4066Sahrens #define	ZPOOL_CONFIG_GUID		"guid"
5425cabbc6bSPrashanth Sreenivasa #define	ZPOOL_CONFIG_INDIRECT_OBJECT	"com.delphix:indirect_object"
5435cabbc6bSPrashanth Sreenivasa #define	ZPOOL_CONFIG_INDIRECT_BIRTHS	"com.delphix:indirect_births"
5445cabbc6bSPrashanth Sreenivasa #define	ZPOOL_CONFIG_PREV_INDIRECT_VDEV	"com.delphix:prev_indirect_vdev"
545fa9e4066Sahrens #define	ZPOOL_CONFIG_PATH		"path"
546fa9e4066Sahrens #define	ZPOOL_CONFIG_DEVID		"devid"
547fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
548fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
549fa9e4066Sahrens #define	ZPOOL_CONFIG_ASHIFT		"ashift"
550fa9e4066Sahrens #define	ZPOOL_CONFIG_ASIZE		"asize"
551fa9e4066Sahrens #define	ZPOOL_CONFIG_DTL		"DTL"
5523f9d6ad7SLin Ling #define	ZPOOL_CONFIG_SCAN_STATS		"scan_stats"	/* not stored on disk */
5535cabbc6bSPrashanth Sreenivasa #define	ZPOOL_CONFIG_REMOVAL_STATS	"removal_stats"	/* not stored on disk */
55486714001SSerapheim Dimitropoulos #define	ZPOOL_CONFIG_CHECKPOINT_STATS	"checkpoint_stats" /* not on disk */
5553f9d6ad7SLin Ling #define	ZPOOL_CONFIG_VDEV_STATS		"vdev_stats"	/* not stored on disk */
5565cabbc6bSPrashanth Sreenivasa #define	ZPOOL_CONFIG_INDIRECT_SIZE	"indirect_size"	/* not stored on disk */
557afefbcddSeschrock #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
558ea8dc4b6Seschrock #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
559ea8dc4b6Seschrock #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
56099653d4eSeschrock #define	ZPOOL_CONFIG_SPARES		"spares"
56199653d4eSeschrock #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
56299653d4eSeschrock #define	ZPOOL_CONFIG_NPARITY		"nparity"
56395173954Sek #define	ZPOOL_CONFIG_HOSTID		"hostid"
56495173954Sek #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
56511027bc7STim Haley #define	ZPOOL_CONFIG_LOADED_TIME	"initial_load_time"
5663d7072f8Seschrock #define	ZPOOL_CONFIG_UNSPARE		"unspare"
5673d7072f8Seschrock #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
5688654d025Sperrin #define	ZPOOL_CONFIG_IS_LOG		"is_log"
569fa94a07fSbrendan #define	ZPOOL_CONFIG_L2CACHE		"l2cache"
57088ecc943SGeorge Wilson #define	ZPOOL_CONFIG_HOLE_ARRAY		"hole_array"
57188ecc943SGeorge Wilson #define	ZPOOL_CONFIG_VDEV_CHILDREN	"vdev_children"
57288ecc943SGeorge Wilson #define	ZPOOL_CONFIG_IS_HOLE		"is_hole"
5739eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_HISTOGRAM	"ddt_histogram"
5749eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_OBJ_STATS	"ddt_object_stats"
5759eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_STATS		"ddt_stats"
5761195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT		"splitcfg"
5771195e687SMark J Musante #define	ZPOOL_CONFIG_ORIG_GUID		"orig_guid"
5781195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_GUID		"split_guid"
5791195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_LIST		"guid_list"
5803f9d6ad7SLin Ling #define	ZPOOL_CONFIG_REMOVING		"removing"
581b4952e17SGeorge Wilson #define	ZPOOL_CONFIG_RESILVER_TXG	"resilver_txg"
5828704186eSDan McDonald #define	ZPOOL_CONFIG_COMMENT		"comment"
583e14bb325SJeff Bonwick #define	ZPOOL_CONFIG_SUSPENDED		"suspended"	/* not stored on disk */
584*e0f1c0afSOlaf Faaland #define	ZPOOL_CONFIG_SUSPENDED_REASON	"suspended_reason"	/* not stored */
585e7cbe64fSgw #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp"	/* not stored on disk */
586e7cbe64fSgw #define	ZPOOL_CONFIG_BOOTFS		"bootfs"	/* not stored on disk */
5874b964adaSGeorge Wilson #define	ZPOOL_CONFIG_MISSING_DEVICES	"missing_vdevs"	/* not stored on disk */
5884b964adaSGeorge Wilson #define	ZPOOL_CONFIG_LOAD_INFO		"load_info"	/* not stored on disk */
589ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_REWIND_INFO	"rewind_info"	/* not stored on disk */
590ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_UNSUP_FEAT		"unsup_feat"	/* not stored on disk */
59157221772SChristopher Siden #define	ZPOOL_CONFIG_ENABLED_FEAT	"enabled_feat"	/* not stored on disk */
592ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_CAN_RDONLY		"can_rdonly"	/* not stored on disk */
593ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_FEATURES_FOR_READ	"features_for_read"
594ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_FEATURE_STATS	"feature_stats"	/* not stored on disk */
595215198a6SJoe Stein #define	ZPOOL_CONFIG_VDEV_TOP_ZAP	"com.delphix:vdev_zap_top"
596215198a6SJoe Stein #define	ZPOOL_CONFIG_VDEV_LEAF_ZAP	"com.delphix:vdev_zap_leaf"
597215198a6SJoe Stein #define	ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS	"com.delphix:has_per_vdev_zaps"
5986f793812SPavel Zakharov #define	ZPOOL_CONFIG_CACHEFILE		"cachefile"	/* not stored on disk */
599*e0f1c0afSOlaf Faaland #define	ZPOOL_CONFIG_MMP_STATE		"mmp_state"	/* not stored on disk */
600*e0f1c0afSOlaf Faaland #define	ZPOOL_CONFIG_MMP_TXG		"mmp_txg"	/* not stored on disk */
601*e0f1c0afSOlaf Faaland #define	ZPOOL_CONFIG_MMP_HOSTNAME	"mmp_hostname"	/* not stored on disk */
602*e0f1c0afSOlaf Faaland #define	ZPOOL_CONFIG_MMP_HOSTID		"mmp_hostid"	/* not stored on disk */
6033d7072f8Seschrock /*
6043d7072f8Seschrock  * The persistent vdev state is stored as separate values rather than a single
6053d7072f8Seschrock  * 'vdev_state' entry.  This is because a device can be in multiple states, such
6063d7072f8Seschrock  * as offline and degraded.
6073d7072f8Seschrock  */
6083d7072f8Seschrock #define	ZPOOL_CONFIG_OFFLINE		"offline"
6093d7072f8Seschrock #define	ZPOOL_CONFIG_FAULTED		"faulted"
6103d7072f8Seschrock #define	ZPOOL_CONFIG_DEGRADED		"degraded"
6113d7072f8Seschrock #define	ZPOOL_CONFIG_REMOVED		"removed"
6126809eb4eSEric Schrock #define	ZPOOL_CONFIG_FRU		"fru"
613069f55e2SEric Schrock #define	ZPOOL_CONFIG_AUX_STATE		"aux_state"
614fa9e4066Sahrens 
6155dafeea3SPavel Zakharov /* Pool load policy parameters */
6165dafeea3SPavel Zakharov #define	ZPOOL_LOAD_POLICY		"load-policy"
6175dafeea3SPavel Zakharov #define	ZPOOL_LOAD_REWIND_POLICY	"load-rewind-policy"
6185dafeea3SPavel Zakharov #define	ZPOOL_LOAD_REQUEST_TXG		"load-request-txg"
6195dafeea3SPavel Zakharov #define	ZPOOL_LOAD_META_THRESH		"load-meta-thresh"
6205dafeea3SPavel Zakharov #define	ZPOOL_LOAD_DATA_THRESH		"load-data-thresh"
621468c413aSTim Haley 
622468c413aSTim Haley /* Rewind data discovered */
623468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_TIME		"rewind_txg_ts"
624468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_DATA_ERRORS	"verify_data_errors"
625468c413aSTim Haley #define	ZPOOL_CONFIG_REWIND_TIME	"seconds_of_rewind"
626468c413aSTim Haley 
627fa9e4066Sahrens #define	VDEV_TYPE_ROOT			"root"
628fa9e4066Sahrens #define	VDEV_TYPE_MIRROR		"mirror"
629fa9e4066Sahrens #define	VDEV_TYPE_REPLACING		"replacing"
630fa9e4066Sahrens #define	VDEV_TYPE_RAIDZ			"raidz"
631fa9e4066Sahrens #define	VDEV_TYPE_DISK			"disk"
632fa9e4066Sahrens #define	VDEV_TYPE_FILE			"file"
633fa9e4066Sahrens #define	VDEV_TYPE_MISSING		"missing"
63488ecc943SGeorge Wilson #define	VDEV_TYPE_HOLE			"hole"
63599653d4eSeschrock #define	VDEV_TYPE_SPARE			"spare"
6368654d025Sperrin #define	VDEV_TYPE_LOG			"log"
637fa94a07fSbrendan #define	VDEV_TYPE_L2CACHE		"l2cache"
6385cabbc6bSPrashanth Sreenivasa #define	VDEV_TYPE_INDIRECT		"indirect"
6395cabbc6bSPrashanth Sreenivasa 
6405cabbc6bSPrashanth Sreenivasa /* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */
6415cabbc6bSPrashanth Sreenivasa #define	VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \
6425cabbc6bSPrashanth Sreenivasa 	"com.delphix:indirect_obsolete_sm"
6435cabbc6bSPrashanth Sreenivasa #define	VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \
6445cabbc6bSPrashanth Sreenivasa 	"com.delphix:obsolete_counts_are_precise"
64586714001SSerapheim Dimitropoulos #define	VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \
64686714001SSerapheim Dimitropoulos 	"com.delphix:pool_checkpoint_sm"
647fa9e4066Sahrens 
648094e47e9SGeorge Wilson #define	VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET	\
649094e47e9SGeorge Wilson 	"com.delphix:next_offset_to_initialize"
650094e47e9SGeorge Wilson #define	VDEV_LEAF_ZAP_INITIALIZE_STATE	\
651094e47e9SGeorge Wilson 	"com.delphix:vdev_initialize_state"
652094e47e9SGeorge Wilson #define	VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME	\
653094e47e9SGeorge Wilson 	"com.delphix:vdev_initialize_action_time"
654094e47e9SGeorge Wilson 
655fa9e4066Sahrens /*
656fa9e4066Sahrens  * This is needed in userland to report the minimum necessary device size.
6574b5c8e93SMatthew Ahrens  *
6584b5c8e93SMatthew Ahrens  * Note that the zfs test suite uses 64MB vdevs.
659fa9e4066Sahrens  */
660fa9e4066Sahrens #define	SPA_MINDEVSIZE		(64ULL << 20)
661fa9e4066Sahrens 
6622e4c9986SGeorge Wilson /*
6632e4c9986SGeorge Wilson  * Set if the fragmentation has not yet been calculated. This can happen
6642e4c9986SGeorge Wilson  * because the space maps have not been upgraded or the histogram feature
6652e4c9986SGeorge Wilson  * is not enabled.
6662e4c9986SGeorge Wilson  */
6672e4c9986SGeorge Wilson #define	ZFS_FRAG_INVALID	UINT64_MAX
6682e4c9986SGeorge Wilson 
669fa9e4066Sahrens /*
670fa9e4066Sahrens  * The location of the pool configuration repository, shared between kernel and
671fa9e4066Sahrens  * userland.
672fa9e4066Sahrens  */
673c5904d13Seschrock #define	ZPOOL_CACHE		"/etc/zfs/zpool.cache"
674fa9e4066Sahrens 
675fa9e4066Sahrens /*
676fa9e4066Sahrens  * vdev states are ordered from least to most healthy.
677fa9e4066Sahrens  * A vdev that's CANT_OPEN or below is considered unusable.
678fa9e4066Sahrens  */
679fa9e4066Sahrens typedef enum vdev_state {
680fa9e4066Sahrens 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
681fa9e4066Sahrens 	VDEV_STATE_CLOSED,	/* Not currently open			*/
682fa9e4066Sahrens 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
6833d7072f8Seschrock 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
684fa9e4066Sahrens 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
6853d7072f8Seschrock 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
686fa9e4066Sahrens 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
687fa9e4066Sahrens 	VDEV_STATE_HEALTHY	/* Presumed good			*/
688fa9e4066Sahrens } vdev_state_t;
689fa9e4066Sahrens 
6903d7072f8Seschrock #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
6913d7072f8Seschrock 
692fa9e4066Sahrens /*
693fa9e4066Sahrens  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
694fa9e4066Sahrens  * of the vdev stats structure uses these constants to distinguish why.
695fa9e4066Sahrens  */
696fa9e4066Sahrens typedef enum vdev_aux {
697fa9e4066Sahrens 	VDEV_AUX_NONE,		/* no error				*/
698fa9e4066Sahrens 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
699fa9e4066Sahrens 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
700fa9e4066Sahrens 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
701fa9e4066Sahrens 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
702fa9e4066Sahrens 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
703eaca9bbdSeschrock 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
704eaca9bbdSeschrock 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
70599653d4eSeschrock 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
706ad135b5dSChristopher Siden 	VDEV_AUX_UNSUP_FEAT,	/* unsupported features			*/
7073d7072f8Seschrock 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
70832b87932Sek 	VDEV_AUX_ERR_EXCEEDED,	/* too many errors			*/
709b87f3af3Sperrin 	VDEV_AUX_IO_FAILURE,	/* experienced I/O failure		*/
710069f55e2SEric Schrock 	VDEV_AUX_BAD_LOG,	/* cannot read log chain(s)		*/
7111195e687SMark J Musante 	VDEV_AUX_EXTERNAL,	/* external diagnosis			*/
7126f793812SPavel Zakharov 	VDEV_AUX_SPLIT_POOL,	/* vdev was split off into another pool	*/
713*e0f1c0afSOlaf Faaland 	VDEV_AUX_ACTIVE,	/* vdev active on a different host	*/
7146f793812SPavel Zakharov 	VDEV_AUX_CHILDREN_OFFLINE /* all children are offline		*/
715fa9e4066Sahrens } vdev_aux_t;
716fa9e4066Sahrens 
717fa9e4066Sahrens /*
71846a2abf2Seschrock  * pool state.  The following states are written to disk as part of the normal
719fa94a07fSbrendan  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
720fa94a07fSbrendan  * states are software abstractions used at various levels to communicate
721fa94a07fSbrendan  * pool state.
722fa9e4066Sahrens  */
723fa9e4066Sahrens typedef enum pool_state {
724fa9e4066Sahrens 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
725fa9e4066Sahrens 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
726fa9e4066Sahrens 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
72799653d4eSeschrock 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
728fa94a07fSbrendan 	POOL_STATE_L2CACHE,		/* Level 2 ARC device		*/
729fa9e4066Sahrens 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
73046a2abf2Seschrock 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
73146a2abf2Seschrock 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
732fa9e4066Sahrens } pool_state_t;
733fa9e4066Sahrens 
734*e0f1c0afSOlaf Faaland /*
735*e0f1c0afSOlaf Faaland  * mmp state. The following states provide additional detail describing
736*e0f1c0afSOlaf Faaland  * why a pool couldn't be safely imported.
737*e0f1c0afSOlaf Faaland  */
738*e0f1c0afSOlaf Faaland typedef enum mmp_state {
739*e0f1c0afSOlaf Faaland 	MMP_STATE_ACTIVE = 0,		/* In active use		*/
740*e0f1c0afSOlaf Faaland 	MMP_STATE_INACTIVE,		/* Inactive and safe to import	*/
741*e0f1c0afSOlaf Faaland 	MMP_STATE_NO_HOSTID		/* System hostid is not set	*/
742*e0f1c0afSOlaf Faaland } mmp_state_t;
743*e0f1c0afSOlaf Faaland 
744fa9e4066Sahrens /*
7453f9d6ad7SLin Ling  * Scan Functions.
746fa9e4066Sahrens  */
7473f9d6ad7SLin Ling typedef enum pool_scan_func {
7483f9d6ad7SLin Ling 	POOL_SCAN_NONE,
7493f9d6ad7SLin Ling 	POOL_SCAN_SCRUB,
7503f9d6ad7SLin Ling 	POOL_SCAN_RESILVER,
7513f9d6ad7SLin Ling 	POOL_SCAN_FUNCS
7523f9d6ad7SLin Ling } pool_scan_func_t;
753fa9e4066Sahrens 
7541702cce7SAlek Pinchuk /*
7551702cce7SAlek Pinchuk  * Used to control scrub pause and resume.
7561702cce7SAlek Pinchuk  */
7571702cce7SAlek Pinchuk typedef enum pool_scrub_cmd {
7581702cce7SAlek Pinchuk 	POOL_SCRUB_NORMAL = 0,
7591702cce7SAlek Pinchuk 	POOL_SCRUB_PAUSE,
7601702cce7SAlek Pinchuk 	POOL_SCRUB_FLAGS_END
7611702cce7SAlek Pinchuk } pool_scrub_cmd_t;
7621702cce7SAlek Pinchuk 
763094e47e9SGeorge Wilson /*
764094e47e9SGeorge Wilson  * Initialize functions.
765094e47e9SGeorge Wilson  */
766094e47e9SGeorge Wilson typedef enum pool_initialize_func {
767094e47e9SGeorge Wilson 	POOL_INITIALIZE_DO,
768094e47e9SGeorge Wilson 	POOL_INITIALIZE_CANCEL,
769094e47e9SGeorge Wilson 	POOL_INITIALIZE_SUSPEND,
770094e47e9SGeorge Wilson 	POOL_INITIALIZE_FUNCS
771094e47e9SGeorge Wilson } pool_initialize_func_t;
7721702cce7SAlek Pinchuk 
773fa9e4066Sahrens /*
774fa9e4066Sahrens  * ZIO types.  Needed to interpret vdev statistics below.
775fa9e4066Sahrens  */
776fa9e4066Sahrens typedef enum zio_type {
777fa9e4066Sahrens 	ZIO_TYPE_NULL = 0,
778fa9e4066Sahrens 	ZIO_TYPE_READ,
779fa9e4066Sahrens 	ZIO_TYPE_WRITE,
780fa9e4066Sahrens 	ZIO_TYPE_FREE,
781fa9e4066Sahrens 	ZIO_TYPE_CLAIM,
782fa9e4066Sahrens 	ZIO_TYPE_IOCTL,
783fa9e4066Sahrens 	ZIO_TYPES
784fa9e4066Sahrens } zio_type_t;
785fa9e4066Sahrens 
7863f9d6ad7SLin Ling /*
7873f9d6ad7SLin Ling  * Pool statistics.  Note: all fields should be 64-bit because this
7883f9d6ad7SLin Ling  * is passed between kernel and userland as an nvlist uint64 array.
7893f9d6ad7SLin Ling  */
7903f9d6ad7SLin Ling typedef struct pool_scan_stat {
7913f9d6ad7SLin Ling 	/* values stored on disk */
7923f9d6ad7SLin Ling 	uint64_t	pss_func;	/* pool_scan_func_t */
7933f9d6ad7SLin Ling 	uint64_t	pss_state;	/* dsl_scan_state_t */
7943f9d6ad7SLin Ling 	uint64_t	pss_start_time;	/* scan start time */
7953f9d6ad7SLin Ling 	uint64_t	pss_end_time;	/* scan end time */
7963f9d6ad7SLin Ling 	uint64_t	pss_to_examine;	/* total bytes to scan */
7973f9d6ad7SLin Ling 	uint64_t	pss_examined;	/* total examined bytes	*/
7983f9d6ad7SLin Ling 	uint64_t	pss_to_process; /* total bytes to process */
7993f9d6ad7SLin Ling 	uint64_t	pss_processed;	/* total processed bytes */
8003f9d6ad7SLin Ling 	uint64_t	pss_errors;	/* scan errors	*/
8013f9d6ad7SLin Ling 
8023f9d6ad7SLin Ling 	/* values not stored on disk */
8033f9d6ad7SLin Ling 	uint64_t	pss_pass_exam;	/* examined bytes per scan pass */
8043f9d6ad7SLin Ling 	uint64_t	pss_pass_start;	/* start time of a scan pass */
8051702cce7SAlek Pinchuk 	uint64_t	pss_pass_scrub_pause; /* pause time of a scurb pass */
8061702cce7SAlek Pinchuk 	/* cumulative time scrub spent paused, needed for rate calculation */
8071702cce7SAlek Pinchuk 	uint64_t	pss_pass_scrub_spent_paused;
8083f9d6ad7SLin Ling } pool_scan_stat_t;
8093f9d6ad7SLin Ling 
8105cabbc6bSPrashanth Sreenivasa typedef struct pool_removal_stat {
8115cabbc6bSPrashanth Sreenivasa 	uint64_t prs_state; /* dsl_scan_state_t */
8125cabbc6bSPrashanth Sreenivasa 	uint64_t prs_removing_vdev;
8135cabbc6bSPrashanth Sreenivasa 	uint64_t prs_start_time;
8145cabbc6bSPrashanth Sreenivasa 	uint64_t prs_end_time;
8155cabbc6bSPrashanth Sreenivasa 	uint64_t prs_to_copy; /* bytes that need to be copied */
8165cabbc6bSPrashanth Sreenivasa 	uint64_t prs_copied; /* bytes copied so far */
8175cabbc6bSPrashanth Sreenivasa 	/*
8185cabbc6bSPrashanth Sreenivasa 	 * bytes of memory used for indirect mappings.
8195cabbc6bSPrashanth Sreenivasa 	 * This includes all removed vdevs.
8205cabbc6bSPrashanth Sreenivasa 	 */
8215cabbc6bSPrashanth Sreenivasa 	uint64_t prs_mapping_memory;
8225cabbc6bSPrashanth Sreenivasa } pool_removal_stat_t;
8235cabbc6bSPrashanth Sreenivasa 
8243f9d6ad7SLin Ling typedef enum dsl_scan_state {
8253f9d6ad7SLin Ling 	DSS_NONE,
8263f9d6ad7SLin Ling 	DSS_SCANNING,
8273f9d6ad7SLin Ling 	DSS_FINISHED,
8283f9d6ad7SLin Ling 	DSS_CANCELED,
8293f9d6ad7SLin Ling 	DSS_NUM_STATES
8303f9d6ad7SLin Ling } dsl_scan_state_t;
8313f9d6ad7SLin Ling 
83286714001SSerapheim Dimitropoulos typedef enum {
83386714001SSerapheim Dimitropoulos 	CS_NONE,
83486714001SSerapheim Dimitropoulos 	CS_CHECKPOINT_EXISTS,
83586714001SSerapheim Dimitropoulos 	CS_CHECKPOINT_DISCARDING,
83686714001SSerapheim Dimitropoulos 	CS_NUM_STATES
83786714001SSerapheim Dimitropoulos } checkpoint_state_t;
83886714001SSerapheim Dimitropoulos 
83986714001SSerapheim Dimitropoulos typedef struct pool_checkpoint_stat {
84086714001SSerapheim Dimitropoulos 	uint64_t pcs_state;		/* checkpoint_state_t */
84186714001SSerapheim Dimitropoulos 	uint64_t pcs_start_time;	/* time checkpoint/discard started */
84286714001SSerapheim Dimitropoulos 	uint64_t pcs_space;		/* checkpointed space */
84386714001SSerapheim Dimitropoulos } pool_checkpoint_stat_t;
8443f9d6ad7SLin Ling 
845094e47e9SGeorge Wilson typedef enum {
846094e47e9SGeorge Wilson 	VDEV_INITIALIZE_NONE,
847094e47e9SGeorge Wilson 	VDEV_INITIALIZE_ACTIVE,
848094e47e9SGeorge Wilson 	VDEV_INITIALIZE_CANCELED,
849094e47e9SGeorge Wilson 	VDEV_INITIALIZE_SUSPENDED,
850094e47e9SGeorge Wilson 	VDEV_INITIALIZE_COMPLETE
851094e47e9SGeorge Wilson } vdev_initializing_state_t;
852094e47e9SGeorge Wilson 
853fa9e4066Sahrens /*
854fa9e4066Sahrens  * Vdev statistics.  Note: all fields should be 64-bit because this
855fa9e4066Sahrens  * is passed between kernel and userland as an nvlist uint64 array.
856fa9e4066Sahrens  */
857fa9e4066Sahrens typedef struct vdev_stat {
858fa9e4066Sahrens 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
859fa9e4066Sahrens 	uint64_t	vs_state;		/* vdev state		*/
860fa9e4066Sahrens 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
861fa9e4066Sahrens 	uint64_t	vs_alloc;		/* space allocated	*/
862fa9e4066Sahrens 	uint64_t	vs_space;		/* total capacity	*/
86399653d4eSeschrock 	uint64_t	vs_dspace;		/* deflated capacity	*/
8642a79c5feSlling 	uint64_t	vs_rsize;		/* replaceable dev size */
8654263d13fSGeorge Wilson 	uint64_t	vs_esize;		/* expandable dev size */
866fa9e4066Sahrens 	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
867fa9e4066Sahrens 	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
868fa9e4066Sahrens 	uint64_t	vs_read_errors;		/* read errors		*/
869fa9e4066Sahrens 	uint64_t	vs_write_errors;	/* write errors		*/
870fa9e4066Sahrens 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
871094e47e9SGeorge Wilson 	uint64_t	vs_initialize_errors;	/* initializing errors	*/
872fa9e4066Sahrens 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
8733f9d6ad7SLin Ling 	uint64_t	vs_scan_removing;	/* removing?	*/
8743f9d6ad7SLin Ling 	uint64_t	vs_scan_processed;	/* scan processed bytes	*/
8752e4c9986SGeorge Wilson 	uint64_t	vs_fragmentation;	/* device fragmentation */
876094e47e9SGeorge Wilson 	uint64_t	vs_initialize_bytes_done; /* bytes initialized */
877094e47e9SGeorge Wilson 	uint64_t	vs_initialize_bytes_est; /* total bytes to initialize */
878094e47e9SGeorge Wilson 	uint64_t	vs_initialize_state;	/* vdev_initialzing_state_t */
879094e47e9SGeorge Wilson 	uint64_t	vs_initialize_action_time; /* time_t */
88086714001SSerapheim Dimitropoulos 	uint64_t	vs_checkpoint_space;    /* checkpoint-consumed space */
881fa9e4066Sahrens } vdev_stat_t;
882fa9e4066Sahrens 
8839eb19f4dSGeorge Wilson /*
8849eb19f4dSGeorge Wilson  * DDT statistics.  Note: all fields should be 64-bit because this
8859eb19f4dSGeorge Wilson  * is passed between kernel and userland as an nvlist uint64 array.
8869eb19f4dSGeorge Wilson  */
8879eb19f4dSGeorge Wilson typedef struct ddt_object {
88804e56356SAndriy Gapon 	uint64_t	ddo_count;	/* number of elments in ddt	*/
8899eb19f4dSGeorge Wilson 	uint64_t	ddo_dspace;	/* size of ddt on disk		*/
8909eb19f4dSGeorge Wilson 	uint64_t	ddo_mspace;	/* size of ddt in-core		*/
8919eb19f4dSGeorge Wilson } ddt_object_t;
8929eb19f4dSGeorge Wilson 
8939eb19f4dSGeorge Wilson typedef struct ddt_stat {
8949eb19f4dSGeorge Wilson 	uint64_t	dds_blocks;	/* blocks			*/
8959eb19f4dSGeorge Wilson 	uint64_t	dds_lsize;	/* logical size			*/
8969eb19f4dSGeorge Wilson 	uint64_t	dds_psize;	/* physical size		*/
8979eb19f4dSGeorge Wilson 	uint64_t	dds_dsize;	/* deflated allocated size	*/
8989eb19f4dSGeorge Wilson 	uint64_t	dds_ref_blocks;	/* referenced blocks		*/
8999eb19f4dSGeorge Wilson 	uint64_t	dds_ref_lsize;	/* referenced lsize * refcnt	*/
9009eb19f4dSGeorge Wilson 	uint64_t	dds_ref_psize;	/* referenced psize * refcnt	*/
9019eb19f4dSGeorge Wilson 	uint64_t	dds_ref_dsize;	/* referenced dsize * refcnt	*/
9029eb19f4dSGeorge Wilson } ddt_stat_t;
9039eb19f4dSGeorge Wilson 
9049eb19f4dSGeorge Wilson typedef struct ddt_histogram {
9059eb19f4dSGeorge Wilson 	ddt_stat_t	ddh_stat[64];	/* power-of-two histogram buckets */
9069eb19f4dSGeorge Wilson } ddt_histogram_t;
9079eb19f4dSGeorge Wilson 
908e7cbe64fSgw #define	ZVOL_DRIVER	"zvol"
909fa9e4066Sahrens #define	ZFS_DRIVER	"zfs"
910fa9e4066Sahrens #define	ZFS_DEV		"/dev/zfs"
9116401734dSWill Andrews #define	ZFS_DISK_ROOT	"/dev/dsk"
9126401734dSWill Andrews #define	ZFS_DISK_ROOTD	ZFS_DISK_ROOT "/"
9136401734dSWill Andrews #define	ZFS_RDISK_ROOT	"/dev/rdsk"
9146401734dSWill Andrews #define	ZFS_RDISK_ROOTD	ZFS_RDISK_ROOT "/"
915fa9e4066Sahrens 
916681d9761SEric Taylor /* general zvol path */
917681d9761SEric Taylor #define	ZVOL_DIR		"/dev/zvol"
918681d9761SEric Taylor /* expansion */
919573ca77eSGeorge Wilson #define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zfs@0:"
920681d9761SEric Taylor /* for dump and swap */
921681d9761SEric Taylor #define	ZVOL_FULL_DEV_DIR	ZVOL_DIR "/dsk/"
922681d9761SEric Taylor #define	ZVOL_FULL_RDEV_DIR	ZVOL_DIR "/rdsk/"
923fa9e4066Sahrens 
924fa9e4066Sahrens #define	ZVOL_PROP_NAME		"name"
925c1449561SEric Taylor #define	ZVOL_DEFAULT_BLOCKSIZE	8192
926fa9e4066Sahrens 
927fa9e4066Sahrens /*
928fa9e4066Sahrens  * /dev/zfs ioctl numbers.
929fa9e4066Sahrens  */
930fa9e4066Sahrens typedef enum zfs_ioc {
9314445fffbSMatthew Ahrens 	ZFS_IOC_FIRST =	('Z' << 8),
9324445fffbSMatthew Ahrens 	ZFS_IOC = ZFS_IOC_FIRST,
9334445fffbSMatthew Ahrens 	ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,
934fa9e4066Sahrens 	ZFS_IOC_POOL_DESTROY,
935fa9e4066Sahrens 	ZFS_IOC_POOL_IMPORT,
936fa9e4066Sahrens 	ZFS_IOC_POOL_EXPORT,
937fa9e4066Sahrens 	ZFS_IOC_POOL_CONFIGS,
938fa9e4066Sahrens 	ZFS_IOC_POOL_STATS,
939fa9e4066Sahrens 	ZFS_IOC_POOL_TRYIMPORT,
9403f9d6ad7SLin Ling 	ZFS_IOC_POOL_SCAN,
941fa9e4066Sahrens 	ZFS_IOC_POOL_FREEZE,
942eaca9bbdSeschrock 	ZFS_IOC_POOL_UPGRADE,
94306eeb2adSek 	ZFS_IOC_POOL_GET_HISTORY,
944fa9e4066Sahrens 	ZFS_IOC_VDEV_ADD,
945fa9e4066Sahrens 	ZFS_IOC_VDEV_REMOVE,
9463d7072f8Seschrock 	ZFS_IOC_VDEV_SET_STATE,
947fa9e4066Sahrens 	ZFS_IOC_VDEV_ATTACH,
948fa9e4066Sahrens 	ZFS_IOC_VDEV_DETACH,
949c67d9675Seschrock 	ZFS_IOC_VDEV_SETPATH,
9506809eb4eSEric Schrock 	ZFS_IOC_VDEV_SETFRU,
951fa9e4066Sahrens 	ZFS_IOC_OBJSET_STATS,
952de8267e0Stimh 	ZFS_IOC_OBJSET_ZPLPROPS,
953fa9e4066Sahrens 	ZFS_IOC_DATASET_LIST_NEXT,
954fa9e4066Sahrens 	ZFS_IOC_SNAPSHOT_LIST_NEXT,
955fa9e4066Sahrens 	ZFS_IOC_SET_PROP,
956fa9e4066Sahrens 	ZFS_IOC_CREATE,
957fa9e4066Sahrens 	ZFS_IOC_DESTROY,
958fa9e4066Sahrens 	ZFS_IOC_ROLLBACK,
959fa9e4066Sahrens 	ZFS_IOC_RENAME,
9603cb34c60Sahrens 	ZFS_IOC_RECV,
9613cb34c60Sahrens 	ZFS_IOC_SEND,
962ea8dc4b6Seschrock 	ZFS_IOC_INJECT_FAULT,
963ea8dc4b6Seschrock 	ZFS_IOC_CLEAR_FAULT,
964ea8dc4b6Seschrock 	ZFS_IOC_INJECT_LIST_NEXT,
965ea8dc4b6Seschrock 	ZFS_IOC_ERROR_LOG,
966ea8dc4b6Seschrock 	ZFS_IOC_CLEAR,
9671d452cf5Sahrens 	ZFS_IOC_PROMOTE,
96855434c77Sek 	ZFS_IOC_SNAPSHOT,
96955434c77Sek 	ZFS_IOC_DSOBJ_TO_DSNAME,
970b1b8ab34Slling 	ZFS_IOC_OBJ_TO_PATH,
971b1b8ab34Slling 	ZFS_IOC_POOL_SET_PROPS,
972ecd6cf80Smarks 	ZFS_IOC_POOL_GET_PROPS,
973ecd6cf80Smarks 	ZFS_IOC_SET_FSACL,
974ecd6cf80Smarks 	ZFS_IOC_GET_FSACL,
975e45ce728Sahrens 	ZFS_IOC_SHARE,
976743a77edSAlan Wright 	ZFS_IOC_INHERIT_PROP,
97714843421SMatthew Ahrens 	ZFS_IOC_SMB_ACL,
97814843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_ONE,
97914843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_MANY,
980842727c2SChris Kirby 	ZFS_IOC_USERSPACE_UPGRADE,
981842727c2SChris Kirby 	ZFS_IOC_HOLD,
982842727c2SChris Kirby 	ZFS_IOC_RELEASE,
98392241e0bSTom Erickson 	ZFS_IOC_GET_HOLDS,
9841195e687SMark J Musante 	ZFS_IOC_OBJSET_RECVD_PROPS,
98599d5e173STim Haley 	ZFS_IOC_VDEV_SPLIT,
98699d5e173STim Haley 	ZFS_IOC_NEXT_OBJ,
98799d5e173STim Haley 	ZFS_IOC_DIFF,
98899d5e173STim Haley 	ZFS_IOC_TMP_SNAPSHOT,
989e9103aaeSGarrett D'Amore 	ZFS_IOC_OBJ_TO_STATS,
99019b94df9SMatthew Ahrens 	ZFS_IOC_SPACE_WRITTEN,
99119b94df9SMatthew Ahrens 	ZFS_IOC_SPACE_SNAPS,
9924445fffbSMatthew Ahrens 	ZFS_IOC_DESTROY_SNAPS,
9934263d13fSGeorge Wilson 	ZFS_IOC_POOL_REGUID,
9944e3c9f44SBill Pijewski 	ZFS_IOC_POOL_REOPEN,
9954445fffbSMatthew Ahrens 	ZFS_IOC_SEND_PROGRESS,
9964445fffbSMatthew Ahrens 	ZFS_IOC_LOG_HISTORY,
9974445fffbSMatthew Ahrens 	ZFS_IOC_SEND_NEW,
9984445fffbSMatthew Ahrens 	ZFS_IOC_SEND_SPACE,
9994445fffbSMatthew Ahrens 	ZFS_IOC_CLONE,
100078f17100SMatthew Ahrens 	ZFS_IOC_BOOKMARK,
100178f17100SMatthew Ahrens 	ZFS_IOC_GET_BOOKMARKS,
100278f17100SMatthew Ahrens 	ZFS_IOC_DESTROY_BOOKMARKS,
1003dfc11533SChris Williamson 	ZFS_IOC_CHANNEL_PROGRAM,
10045cabbc6bSPrashanth Sreenivasa 	ZFS_IOC_REMAP,
100586714001SSerapheim Dimitropoulos 	ZFS_IOC_POOL_CHECKPOINT,
100686714001SSerapheim Dimitropoulos 	ZFS_IOC_POOL_DISCARD_CHECKPOINT,
1007094e47e9SGeorge Wilson 	ZFS_IOC_POOL_INITIALIZE,
10089c2acf00SAlek Pinchuk 	ZFS_IOC_POOL_SYNC,
10094445fffbSMatthew Ahrens 	ZFS_IOC_LAST
1010fa9e4066Sahrens } zfs_ioc_t;
1011fa9e4066Sahrens 
101286714001SSerapheim Dimitropoulos /*
101386714001SSerapheim Dimitropoulos  * ZFS-specific error codes used for returning descriptive errors
101486714001SSerapheim Dimitropoulos  * to the userland through zfs ioctls.
101586714001SSerapheim Dimitropoulos  *
101686714001SSerapheim Dimitropoulos  * The enum implicitly includes all the error codes from errno.h.
101786714001SSerapheim Dimitropoulos  * New code should use and extend this enum for errors that are
101886714001SSerapheim Dimitropoulos  * not described precisely by generic errno codes.
101986714001SSerapheim Dimitropoulos  */
102086714001SSerapheim Dimitropoulos typedef enum {
102186714001SSerapheim Dimitropoulos 	ZFS_ERR_CHECKPOINT_EXISTS = 1024,
102286714001SSerapheim Dimitropoulos 	ZFS_ERR_DISCARDING_CHECKPOINT,
102386714001SSerapheim Dimitropoulos 	ZFS_ERR_NO_CHECKPOINT,
102486714001SSerapheim Dimitropoulos 	ZFS_ERR_DEVRM_IN_PROGRESS,
102586714001SSerapheim Dimitropoulos 	ZFS_ERR_VDEV_TOO_BIG
102686714001SSerapheim Dimitropoulos } zfs_errno_t;
102786714001SSerapheim Dimitropoulos 
1028ea8dc4b6Seschrock /*
1029ea8dc4b6Seschrock  * Internal SPA load state.  Used by FMA diagnosis engine.
1030ea8dc4b6Seschrock  */
1031ea8dc4b6Seschrock typedef enum {
10329eb19f4dSGeorge Wilson 	SPA_LOAD_NONE,		/* no load in progress	*/
10339eb19f4dSGeorge Wilson 	SPA_LOAD_OPEN,		/* normal open		*/
10349eb19f4dSGeorge Wilson 	SPA_LOAD_IMPORT,	/* import in progress	*/
1035468c413aSTim Haley 	SPA_LOAD_TRYIMPORT,	/* tryimport in progress */
10369eb19f4dSGeorge Wilson 	SPA_LOAD_RECOVER,	/* recovery requested	*/
10370f7643c7SGeorge Wilson 	SPA_LOAD_ERROR,		/* load failed		*/
10380f7643c7SGeorge Wilson 	SPA_LOAD_CREATE		/* creation in progress */
1039ea8dc4b6Seschrock } spa_load_state_t;
1040ea8dc4b6Seschrock 
1041e9dbad6fSeschrock /*
1042e9dbad6fSeschrock  * Bookmark name values.
1043e9dbad6fSeschrock  */
104455434c77Sek #define	ZPOOL_ERR_LIST		"error list"
1045e9dbad6fSeschrock #define	ZPOOL_ERR_DATASET	"dataset"
1046e9dbad6fSeschrock #define	ZPOOL_ERR_OBJECT	"object"
1047e9dbad6fSeschrock 
104806eeb2adSek #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
104906eeb2adSek 
105006eeb2adSek /*
105106eeb2adSek  * The following are names used in the nvlist describing
105206eeb2adSek  * the pool's history log.
105306eeb2adSek  */
105406eeb2adSek #define	ZPOOL_HIST_RECORD	"history record"
105506eeb2adSek #define	ZPOOL_HIST_TIME		"history time"
105606eeb2adSek #define	ZPOOL_HIST_CMD		"history command"
1057ecd6cf80Smarks #define	ZPOOL_HIST_WHO		"history who"
1058ecd6cf80Smarks #define	ZPOOL_HIST_ZONE		"history zone"
1059ecd6cf80Smarks #define	ZPOOL_HIST_HOST		"history hostname"
1060ecd6cf80Smarks #define	ZPOOL_HIST_TXG		"history txg"
1061ecd6cf80Smarks #define	ZPOOL_HIST_INT_EVENT	"history internal event"
1062ecd6cf80Smarks #define	ZPOOL_HIST_INT_STR	"history internal str"
10634445fffbSMatthew Ahrens #define	ZPOOL_HIST_INT_NAME	"internal_name"
10644445fffbSMatthew Ahrens #define	ZPOOL_HIST_IOCTL	"ioctl"
10654445fffbSMatthew Ahrens #define	ZPOOL_HIST_INPUT_NVL	"in_nvl"
10664445fffbSMatthew Ahrens #define	ZPOOL_HIST_OUTPUT_NVL	"out_nvl"
10674445fffbSMatthew Ahrens #define	ZPOOL_HIST_DSNAME	"dsname"
10684445fffbSMatthew Ahrens #define	ZPOOL_HIST_DSID		"dsid"
1069dfc11533SChris Williamson #define	ZPOOL_HIST_ERRNO	"errno"
107006eeb2adSek 
1071094e47e9SGeorge Wilson /*
1072094e47e9SGeorge Wilson  * The following are names used when invoking ZFS_IOC_POOL_INITIALIZE.
1073094e47e9SGeorge Wilson  */
1074094e47e9SGeorge Wilson #define	ZPOOL_INITIALIZE_COMMAND	"initialize_command"
1075094e47e9SGeorge Wilson #define	ZPOOL_INITIALIZE_VDEVS		"initialize_vdevs"
1076094e47e9SGeorge Wilson 
10773d7072f8Seschrock /*
10783d7072f8Seschrock  * Flags for ZFS_IOC_VDEV_SET_STATE
10793d7072f8Seschrock  */
10803d7072f8Seschrock #define	ZFS_ONLINE_CHECKREMOVE	0x1
10813d7072f8Seschrock #define	ZFS_ONLINE_UNSPARE	0x2
10823d7072f8Seschrock #define	ZFS_ONLINE_FORCEFAULT	0x4
1083573ca77eSGeorge Wilson #define	ZFS_ONLINE_EXPAND	0x8
10843d7072f8Seschrock #define	ZFS_OFFLINE_TEMPORARY	0x1
10853d7072f8Seschrock 
10864b964adaSGeorge Wilson /*
10874b964adaSGeorge Wilson  * Flags for ZFS_IOC_POOL_IMPORT
10884b964adaSGeorge Wilson  */
10894b964adaSGeorge Wilson #define	ZFS_IMPORT_NORMAL	0x0
10904b964adaSGeorge Wilson #define	ZFS_IMPORT_VERBATIM	0x1
10914b964adaSGeorge Wilson #define	ZFS_IMPORT_ANY_HOST	0x2
10924b964adaSGeorge Wilson #define	ZFS_IMPORT_MISSING_LOG	0x4
1093f9af39baSGeorge Wilson #define	ZFS_IMPORT_ONLY		0x8
109486714001SSerapheim Dimitropoulos #define	ZFS_IMPORT_CHECKPOINT	0x10
109504e56356SAndriy Gapon #define	ZFS_IMPORT_TEMP_NAME	0x20
1096*e0f1c0afSOlaf Faaland #define	ZFS_IMPORT_SKIP_MMP	0x40
10974b964adaSGeorge Wilson 
1098dfc11533SChris Williamson /*
1099dfc11533SChris Williamson  * Channel program argument/return nvlist keys and defaults.
1100dfc11533SChris Williamson  */
1101dfc11533SChris Williamson #define	ZCP_ARG_PROGRAM		"program"
1102dfc11533SChris Williamson #define	ZCP_ARG_ARGLIST		"arg"
1103a3b28680SSerapheim Dimitropoulos #define	ZCP_ARG_SYNC		"sync"
1104dfc11533SChris Williamson #define	ZCP_ARG_INSTRLIMIT	"instrlimit"
1105dfc11533SChris Williamson #define	ZCP_ARG_MEMLIMIT	"memlimit"
1106dfc11533SChris Williamson 
1107dfc11533SChris Williamson #define	ZCP_ARG_CLIARGV		"argv"
1108dfc11533SChris Williamson 
1109dfc11533SChris Williamson #define	ZCP_RET_ERROR		"error"
1110dfc11533SChris Williamson #define	ZCP_RET_RETURN		"return"
1111dfc11533SChris Williamson 
1112dfc11533SChris Williamson #define	ZCP_DEFAULT_INSTRLIMIT	(10 * 1000 * 1000)
1113dfc11533SChris Williamson #define	ZCP_MAX_INSTRLIMIT	(10 * ZCP_DEFAULT_INSTRLIMIT)
1114dfc11533SChris Williamson #define	ZCP_DEFAULT_MEMLIMIT	(10 * 1024 * 1024)
1115dfc11533SChris Williamson #define	ZCP_MAX_MEMLIMIT	(10 * ZCP_DEFAULT_MEMLIMIT)
1116dfc11533SChris Williamson 
11173d7072f8Seschrock /*
11183d7072f8Seschrock  * Sysevent payload members.  ZFS will generate the following sysevents with the
11193d7072f8Seschrock  * given payloads:
11203d7072f8Seschrock  *
11213d7072f8Seschrock  *	ESC_ZFS_RESILVER_START
11223d7072f8Seschrock  *	ESC_ZFS_RESILVER_END
11233d7072f8Seschrock  *	ESC_ZFS_POOL_DESTROY
1124e9103aaeSGarrett D'Amore  *	ESC_ZFS_POOL_REGUID
11253d7072f8Seschrock  *
11263d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
11273d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
11283d7072f8Seschrock  *
11293d7072f8Seschrock  *	ESC_ZFS_VDEV_REMOVE
11303d7072f8Seschrock  *	ESC_ZFS_VDEV_CLEAR
11313d7072f8Seschrock  *	ESC_ZFS_VDEV_CHECK
11323d7072f8Seschrock  *
11333d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
11343d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
11353d7072f8Seschrock  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
11363d7072f8Seschrock  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
1137ce1577b0SDave Eddy  *
1138ce1577b0SDave Eddy  *	ESC_ZFS_HISTORY_EVENT
1139ce1577b0SDave Eddy  *
1140ce1577b0SDave Eddy  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
1141ce1577b0SDave Eddy  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
1142ce1577b0SDave Eddy  *		ZFS_EV_HIST_TIME	DATA_TYPE_UINT64	(optional)
1143ce1577b0SDave Eddy  *		ZFS_EV_HIST_CMD		DATA_TYPE_STRING	(optional)
1144ce1577b0SDave Eddy  *		ZFS_EV_HIST_WHO		DATA_TYPE_UINT64	(optional)
1145ce1577b0SDave Eddy  *		ZFS_EV_HIST_ZONE	DATA_TYPE_STRING	(optional)
1146ce1577b0SDave Eddy  *		ZFS_EV_HIST_HOST	DATA_TYPE_STRING	(optional)
1147ce1577b0SDave Eddy  *		ZFS_EV_HIST_TXG		DATA_TYPE_UINT64	(optional)
1148ce1577b0SDave Eddy  *		ZFS_EV_HIST_INT_EVENT	DATA_TYPE_UINT64	(optional)
1149ce1577b0SDave Eddy  *		ZFS_EV_HIST_INT_STR	DATA_TYPE_STRING	(optional)
1150ce1577b0SDave Eddy  *		ZFS_EV_HIST_INT_NAME	DATA_TYPE_STRING	(optional)
1151ce1577b0SDave Eddy  *		ZFS_EV_HIST_IOCTL	DATA_TYPE_STRING	(optional)
1152ce1577b0SDave Eddy  *		ZFS_EV_HIST_DSNAME	DATA_TYPE_STRING	(optional)
1153ce1577b0SDave Eddy  *		ZFS_EV_HIST_DSID	DATA_TYPE_UINT64	(optional)
1154ce1577b0SDave Eddy  *
1155ce1577b0SDave Eddy  * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the
1156ce1577b0SDave Eddy  * history log nvlist.  The keynames will be free of any spaces or other
1157ce1577b0SDave Eddy  * characters that could be potentially unexpected to consumers of the
1158ce1577b0SDave Eddy  * sysevents.
11593d7072f8Seschrock  */
11603d7072f8Seschrock #define	ZFS_EV_POOL_NAME	"pool_name"
11613d7072f8Seschrock #define	ZFS_EV_POOL_GUID	"pool_guid"
11623d7072f8Seschrock #define	ZFS_EV_VDEV_PATH	"vdev_path"
11633d7072f8Seschrock #define	ZFS_EV_VDEV_GUID	"vdev_guid"
1164ce1577b0SDave Eddy #define	ZFS_EV_HIST_TIME	"history_time"
1165ce1577b0SDave Eddy #define	ZFS_EV_HIST_CMD		"history_command"
1166ce1577b0SDave Eddy #define	ZFS_EV_HIST_WHO		"history_who"
1167ce1577b0SDave Eddy #define	ZFS_EV_HIST_ZONE	"history_zone"
1168ce1577b0SDave Eddy #define	ZFS_EV_HIST_HOST	"history_hostname"
1169ce1577b0SDave Eddy #define	ZFS_EV_HIST_TXG		"history_txg"
1170ce1577b0SDave Eddy #define	ZFS_EV_HIST_INT_EVENT	"history_internal_event"
1171ce1577b0SDave Eddy #define	ZFS_EV_HIST_INT_STR	"history_internal_str"
1172ce1577b0SDave Eddy #define	ZFS_EV_HIST_INT_NAME	"history_internal_name"
1173ce1577b0SDave Eddy #define	ZFS_EV_HIST_IOCTL	"history_ioctl"
1174ce1577b0SDave Eddy #define	ZFS_EV_HIST_DSNAME	"history_dsname"
1175ce1577b0SDave Eddy #define	ZFS_EV_HIST_DSID	"history_dsid"
11763d7072f8Seschrock 
1177fa9e4066Sahrens #ifdef	__cplusplus
1178fa9e4066Sahrens }
1179fa9e4066Sahrens #endif
1180fa9e4066Sahrens 
1181fa9e4066Sahrens #endif	/* _SYS_FS_ZFS_H */
1182