xref: /illumos-gate/usr/src/uts/common/sys/fs/zfs.h (revision 04e56356520b98d5a93c496b10f02530bb6647e0)
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,
151187d6ac0SMatt Ahrens 	ZFS_PROP_REFRATIO,
15219b94df9SMatthew Ahrens 	ZFS_PROP_WRITTEN,
15319b94df9SMatthew Ahrens 	ZFS_PROP_CLONES,
15477372cb0SMatthew Ahrens 	ZFS_PROP_LOGICALUSED,
15577372cb0SMatthew Ahrens 	ZFS_PROP_LOGICALREFERENCED,
156ca48f36fSKeith M Wesolowski 	ZFS_PROP_INCONSISTENT,		/* not exposed to the user */
157a2afb611SJerry Jelinek 	ZFS_PROP_FILESYSTEM_LIMIT,
158a2afb611SJerry Jelinek 	ZFS_PROP_SNAPSHOT_LIMIT,
159a2afb611SJerry Jelinek 	ZFS_PROP_FILESYSTEM_COUNT,
160a2afb611SJerry Jelinek 	ZFS_PROP_SNAPSHOT_COUNT,
161edf345e6SMatthew Ahrens 	ZFS_PROP_REDUNDANT_METADATA,
162b461c746SMatthew Ahrens 	ZFS_PROP_PREV_SNAP,
1639c3fd121SMatthew Ahrens 	ZFS_PROP_RECEIVE_RESUME_TOKEN,
1645cabbc6bSPrashanth Sreenivasa 	ZFS_PROP_REMAPTXG,		/* not exposed to the user */
16591ebeef5Sahrens 	ZFS_NUM_PROPS
166fa9e4066Sahrens } zfs_prop_t;
167fa9e4066Sahrens 
16814843421SMatthew Ahrens typedef enum {
16914843421SMatthew Ahrens 	ZFS_PROP_USERUSED,
17014843421SMatthew Ahrens 	ZFS_PROP_USERQUOTA,
17114843421SMatthew Ahrens 	ZFS_PROP_GROUPUSED,
17214843421SMatthew Ahrens 	ZFS_PROP_GROUPQUOTA,
17314843421SMatthew Ahrens 	ZFS_NUM_USERQUOTA_PROPS
17414843421SMatthew Ahrens } zfs_userquota_prop_t;
17514843421SMatthew Ahrens 
17614843421SMatthew Ahrens extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
17714843421SMatthew Ahrens 
178990b4856Slling /*
179990b4856Slling  * Pool properties are identified by these constants and must be added to the
180b87f3af3Sperrin  * end of this list to ensure that external consumers are not affected
181990b4856Slling  * by the change. If you make any changes to this list, be sure to update
182990b4856Slling  * the property table in usr/src/common/zfs/zpool_prop.c.
183990b4856Slling  */
184990b4856Slling typedef enum {
1854ae5f5f0SAlan Somers 	ZPOOL_PROP_INVAL = -1,
186990b4856Slling 	ZPOOL_PROP_NAME,
187990b4856Slling 	ZPOOL_PROP_SIZE,
188990b4856Slling 	ZPOOL_PROP_CAPACITY,
189990b4856Slling 	ZPOOL_PROP_ALTROOT,
190990b4856Slling 	ZPOOL_PROP_HEALTH,
191990b4856Slling 	ZPOOL_PROP_GUID,
192990b4856Slling 	ZPOOL_PROP_VERSION,
193990b4856Slling 	ZPOOL_PROP_BOOTFS,
194990b4856Slling 	ZPOOL_PROP_DELEGATION,
195990b4856Slling 	ZPOOL_PROP_AUTOREPLACE,
1962f8aaab3Seschrock 	ZPOOL_PROP_CACHEFILE,
1970a4e9518Sgw 	ZPOOL_PROP_FAILUREMODE,
198d5b5bb25SRich Morris 	ZPOOL_PROP_LISTSNAPS,
199573ca77eSGeorge Wilson 	ZPOOL_PROP_AUTOEXPAND,
200b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPDITTO,
201b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPRATIO,
202485bbbf5SGeorge Wilson 	ZPOOL_PROP_FREE,
203485bbbf5SGeorge Wilson 	ZPOOL_PROP_ALLOCATED,
204f9af39baSGeorge Wilson 	ZPOOL_PROP_READONLY,
2058704186eSDan McDonald 	ZPOOL_PROP_COMMENT,
2064263d13fSGeorge Wilson 	ZPOOL_PROP_EXPANDSZ,
207ad135b5dSChristopher Siden 	ZPOOL_PROP_FREEING,
2082e4c9986SGeorge Wilson 	ZPOOL_PROP_FRAGMENTATION,
2097fd05ac4SMatthew Ahrens 	ZPOOL_PROP_LEAKED,
210b5152584SMatthew Ahrens 	ZPOOL_PROP_MAXBLOCKSIZE,
2117855d95bSToomas Soome 	ZPOOL_PROP_BOOTSIZE,
21286714001SSerapheim Dimitropoulos 	ZPOOL_PROP_CHECKPOINT,
213*04e56356SAndriy Gapon 	ZPOOL_PROP_TNAME,
214990b4856Slling 	ZPOOL_NUM_PROPS
215990b4856Slling } zpool_prop_t;
216b1b8ab34Slling 
2178704186eSDan McDonald /* Small enough to not hog a whole line of printout in zpool(1M). */
2188704186eSDan McDonald #define	ZPROP_MAX_COMMENT	32
2198704186eSDan McDonald 
220990b4856Slling #define	ZPROP_VALUE		"value"
221990b4856Slling #define	ZPROP_SOURCE		"source"
2227f7322feSeschrock 
223b1b8ab34Slling typedef enum {
224990b4856Slling 	ZPROP_SRC_NONE = 0x1,
225990b4856Slling 	ZPROP_SRC_DEFAULT = 0x2,
226990b4856Slling 	ZPROP_SRC_TEMPORARY = 0x4,
227990b4856Slling 	ZPROP_SRC_LOCAL = 0x8,
22892241e0bSTom Erickson 	ZPROP_SRC_INHERITED = 0x10,
22992241e0bSTom Erickson 	ZPROP_SRC_RECEIVED = 0x20
230990b4856Slling } zprop_source_t;
231990b4856Slling 
23292241e0bSTom Erickson #define	ZPROP_SRC_ALL	0x3f
23392241e0bSTom Erickson 
23492241e0bSTom Erickson #define	ZPROP_SOURCE_VAL_RECVD	"$recvd"
23592241e0bSTom Erickson #define	ZPROP_N_MORE_ERRORS	"N_MORE_ERRORS"
23692241e0bSTom Erickson /*
23792241e0bSTom Erickson  * Dataset flag implemented as a special entry in the props zap object
23892241e0bSTom Erickson  * indicating that the dataset has received properties on or after
23992241e0bSTom Erickson  * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
24092241e0bSTom Erickson  * just as it did in earlier versions, and thereafter, local properties are
24192241e0bSTom Erickson  * preserved.
24292241e0bSTom Erickson  */
24392241e0bSTom Erickson #define	ZPROP_HAS_RECVD		"$hasrecvd"
24492241e0bSTom Erickson 
24592241e0bSTom Erickson typedef enum {
24692241e0bSTom Erickson 	ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
24792241e0bSTom Erickson 	ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
24892241e0bSTom Erickson } zprop_errflags_t;
249990b4856Slling 
250990b4856Slling typedef int (*zprop_func)(int, void *);
251990b4856Slling 
2520a48a24eStimh /*
2530a48a24eStimh  * Properties to be set on the root file system of a new pool
2540a48a24eStimh  * are stuffed into their own nvlist, which is then included in
2550a48a24eStimh  * the properties nvlist with the pool properties.
2560a48a24eStimh  */
2570a48a24eStimh #define	ZPOOL_ROOTFS_PROPS	"root-props-nvl"
2580a48a24eStimh 
259dfc11533SChris Williamson /*
260dfc11533SChris Williamson  * Length of 'written@' and 'written#'
261dfc11533SChris Williamson  */
262dfc11533SChris Williamson #define	ZFS_WRITTEN_PROP_PREFIX_LEN	8
263dfc11533SChris Williamson 
264990b4856Slling /*
265990b4856Slling  * Dataset property functions shared between libzfs and kernel.
266990b4856Slling  */
267990b4856Slling const char *zfs_prop_default_string(zfs_prop_t);
268990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t);
269990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t);
270dfc11533SChris Williamson boolean_t zfs_prop_visible(zfs_prop_t prop);
271990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t);
272da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t);
273990b4856Slling const char *zfs_prop_to_name(zfs_prop_t);
274990b4856Slling zfs_prop_t zfs_name_to_prop(const char *);
275990b4856Slling boolean_t zfs_prop_user(const char *);
27692241e0bSTom Erickson boolean_t zfs_prop_userquota(const char *);
27719b94df9SMatthew Ahrens boolean_t zfs_prop_written(const char *);
278990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
279990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
280b24ab676SJeff Bonwick uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
2814853e976Sgw boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
282b1b8ab34Slling 
283990b4856Slling /*
284990b4856Slling  * Pool property functions shared between libzfs and kernel.
285990b4856Slling  */
286990b4856Slling zpool_prop_t zpool_name_to_prop(const char *);
287990b4856Slling const char *zpool_prop_to_name(zpool_prop_t);
288990b4856Slling const char *zpool_prop_default_string(zpool_prop_t);
289990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t);
290990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t);
291ad135b5dSChristopher Siden boolean_t zpool_prop_feature(const char *);
292ad135b5dSChristopher Siden boolean_t zpool_prop_unsupported(const char *name);
293990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
294990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
295b24ab676SJeff Bonwick uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
296b1b8ab34Slling 
297990b4856Slling /*
298990b4856Slling  * Definitions for the Delegation.
299990b4856Slling  */
300ecd6cf80Smarks typedef enum {
301ecd6cf80Smarks 	ZFS_DELEG_WHO_UNKNOWN = 0,
302ecd6cf80Smarks 	ZFS_DELEG_USER = 'u',
303ecd6cf80Smarks 	ZFS_DELEG_USER_SETS = 'U',
304ecd6cf80Smarks 	ZFS_DELEG_GROUP = 'g',
305ecd6cf80Smarks 	ZFS_DELEG_GROUP_SETS = 'G',
306ecd6cf80Smarks 	ZFS_DELEG_EVERYONE = 'e',
307ecd6cf80Smarks 	ZFS_DELEG_EVERYONE_SETS = 'E',
308ecd6cf80Smarks 	ZFS_DELEG_CREATE = 'c',
309ecd6cf80Smarks 	ZFS_DELEG_CREATE_SETS = 'C',
310ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET = 's',
311ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET_SETS = 'S'
312ecd6cf80Smarks } zfs_deleg_who_type_t;
313ecd6cf80Smarks 
314ecd6cf80Smarks typedef enum {
315ecd6cf80Smarks 	ZFS_DELEG_NONE = 0,
316ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCAL = 1,
317ecd6cf80Smarks 	ZFS_DELEG_PERM_DESCENDENT = 2,
318ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
319ecd6cf80Smarks 	ZFS_DELEG_PERM_CREATE = 4
320ecd6cf80Smarks } zfs_deleg_inherit_t;
321ecd6cf80Smarks 
322ecd6cf80Smarks #define	ZFS_DELEG_PERM_UID	"uid"
323ecd6cf80Smarks #define	ZFS_DELEG_PERM_GID	"gid"
324ecd6cf80Smarks #define	ZFS_DELEG_PERM_GROUPS	"groups"
325ecd6cf80Smarks 
3264201a95eSRic Aleshire #define	ZFS_MLSLABEL_DEFAULT	"none"
3274201a95eSRic Aleshire 
328743a77edSAlan Wright #define	ZFS_SMB_ACL_SRC		"src"
329743a77edSAlan Wright #define	ZFS_SMB_ACL_TARGET	"target"
330743a77edSAlan Wright 
331a227b7f4Shs typedef enum {
332a227b7f4Shs 	ZFS_CANMOUNT_OFF = 0,
333a227b7f4Shs 	ZFS_CANMOUNT_ON = 1,
334a227b7f4Shs 	ZFS_CANMOUNT_NOAUTO = 2
335a227b7f4Shs } zfs_canmount_type_t;
336a227b7f4Shs 
337e09fa4daSNeil Perrin typedef enum {
338e09fa4daSNeil Perrin 	ZFS_LOGBIAS_LATENCY = 0,
339e09fa4daSNeil Perrin 	ZFS_LOGBIAS_THROUGHPUT = 1
340e09fa4daSNeil Perrin } zfs_logbias_op_t;
341e09fa4daSNeil Perrin 
342da6c28aaSamw typedef enum zfs_share_op {
343da6c28aaSamw 	ZFS_SHARE_NFS = 0,
344da6c28aaSamw 	ZFS_UNSHARE_NFS = 1,
345da6c28aaSamw 	ZFS_SHARE_SMB = 2,
346da6c28aaSamw 	ZFS_UNSHARE_SMB = 3
347da6c28aaSamw } zfs_share_op_t;
348da6c28aaSamw 
349743a77edSAlan Wright typedef enum zfs_smb_acl_op {
350743a77edSAlan Wright 	ZFS_SMB_ACL_ADD,
351743a77edSAlan Wright 	ZFS_SMB_ACL_REMOVE,
352743a77edSAlan Wright 	ZFS_SMB_ACL_RENAME,
353743a77edSAlan Wright 	ZFS_SMB_ACL_PURGE
354743a77edSAlan Wright } zfs_smb_acl_op_t;
355743a77edSAlan Wright 
3563baa08fcSek typedef enum zfs_cache_type {
3573baa08fcSek 	ZFS_CACHE_NONE = 0,
3583baa08fcSek 	ZFS_CACHE_METADATA = 1,
3593baa08fcSek 	ZFS_CACHE_ALL = 2
3603baa08fcSek } zfs_cache_type_t;
3613baa08fcSek 
36255da60b9SMark J Musante typedef enum {
36355da60b9SMark J Musante 	ZFS_SYNC_STANDARD = 0,
36455da60b9SMark J Musante 	ZFS_SYNC_ALWAYS = 1,
36555da60b9SMark J Musante 	ZFS_SYNC_DISABLED = 2
36655da60b9SMark J Musante } zfs_sync_type_t;
36755da60b9SMark J Musante 
368edf345e6SMatthew Ahrens typedef enum {
369edf345e6SMatthew Ahrens 	ZFS_REDUNDANT_METADATA_ALL,
370edf345e6SMatthew Ahrens 	ZFS_REDUNDANT_METADATA_MOST
371edf345e6SMatthew Ahrens } zfs_redundant_metadata_type_t;
3723baa08fcSek 
373eaca9bbdSeschrock /*
37499653d4eSeschrock  * On-disk version number.
375eaca9bbdSeschrock  */
376e7437265Sahrens #define	SPA_VERSION_1			1ULL
377e7437265Sahrens #define	SPA_VERSION_2			2ULL
378e7437265Sahrens #define	SPA_VERSION_3			3ULL
379e7437265Sahrens #define	SPA_VERSION_4			4ULL
380e7437265Sahrens #define	SPA_VERSION_5			5ULL
381e7437265Sahrens #define	SPA_VERSION_6			6ULL
382e7437265Sahrens #define	SPA_VERSION_7			7ULL
383e7437265Sahrens #define	SPA_VERSION_8			8ULL
384da6c28aaSamw #define	SPA_VERSION_9			9ULL
385fa94a07fSbrendan #define	SPA_VERSION_10			10ULL
386088f3894Sahrens #define	SPA_VERSION_11			11ULL
387bb0ade09Sahrens #define	SPA_VERSION_12			12ULL
38874e7dc98SMatthew Ahrens #define	SPA_VERSION_13			13ULL
389d0f3f37eSMark Shellenbaum #define	SPA_VERSION_14			14ULL
39014843421SMatthew Ahrens #define	SPA_VERSION_15			15ULL
391478ed9adSEric Taylor #define	SPA_VERSION_16			16ULL
392f94275ceSAdam Leventhal #define	SPA_VERSION_17			17ULL
393842727c2SChris Kirby #define	SPA_VERSION_18			18ULL
39488ecc943SGeorge Wilson #define	SPA_VERSION_19			19ULL
395b24ab676SJeff Bonwick #define	SPA_VERSION_20			20ULL
396b24ab676SJeff Bonwick #define	SPA_VERSION_21			21ULL
39792241e0bSTom Erickson #define	SPA_VERSION_22			22ULL
3986e1f5caaSNeil Perrin #define	SPA_VERSION_23			23ULL
3990a586ceaSMark Shellenbaum #define	SPA_VERSION_24			24ULL
4003f9d6ad7SLin Ling #define	SPA_VERSION_25			25ULL
401cde58dbcSMatthew Ahrens #define	SPA_VERSION_26			26ULL
4026e0cbcaaSMatthew Ahrens #define	SPA_VERSION_27			27ULL
403cb04b873SMark J Musante #define	SPA_VERSION_28			28ULL
404ad135b5dSChristopher Siden #define	SPA_VERSION_5000		5000ULL
405cb04b873SMark J Musante 
406b1b8ab34Slling /*
407e7cbe64fSgw  * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
408478ed9adSEric Taylor  * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
40914843421SMatthew Ahrens  * and do the appropriate changes.  Also bump the version number in
41014843421SMatthew Ahrens  * usr/src/grub/capability.
411b1b8ab34Slling  */
412ad135b5dSChristopher Siden #define	SPA_VERSION			SPA_VERSION_5000
413ad135b5dSChristopher Siden #define	SPA_VERSION_STRING		"5000"
41444cd46caSbillm 
41544cd46caSbillm /*
416e7437265Sahrens  * Symbolic names for the changes that caused a SPA_VERSION switch.
41744cd46caSbillm  * Used in the code when checking for presence or absence of a feature.
41844cd46caSbillm  * Feel free to define multiple symbolic names for each version if there
41944cd46caSbillm  * were multiple changes to on-disk structures during that version.
42044cd46caSbillm  *
421e7437265Sahrens  * NOTE: When checking the current SPA_VERSION in your code, be sure
42244cd46caSbillm  *       to use spa_version() since it reports the version of the
42344cd46caSbillm  *       last synced uberblock.  Checking the in-flight version can
42444cd46caSbillm  *       be dangerous in some cases.
42544cd46caSbillm  */
426e7437265Sahrens #define	SPA_VERSION_INITIAL		SPA_VERSION_1
427e7437265Sahrens #define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
428e7437265Sahrens #define	SPA_VERSION_SPARES		SPA_VERSION_3
429f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ2		SPA_VERSION_3
430cde58dbcSMatthew Ahrens #define	SPA_VERSION_BPOBJ_ACCOUNT	SPA_VERSION_3
431e7437265Sahrens #define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
432e7437265Sahrens #define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
433e7437265Sahrens #define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
434e7437265Sahrens #define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
435e7437265Sahrens #define	SPA_VERSION_BOOTFS		SPA_VERSION_6
436990b4856Slling #define	SPA_VERSION_SLOGS		SPA_VERSION_7
437990b4856Slling #define	SPA_VERSION_DELEGATED_PERMS	SPA_VERSION_8
438da6c28aaSamw #define	SPA_VERSION_FUID		SPA_VERSION_9
439a9799022Sck #define	SPA_VERSION_REFRESERVATION	SPA_VERSION_9
440a9799022Sck #define	SPA_VERSION_REFQUOTA		SPA_VERSION_9
441a9799022Sck #define	SPA_VERSION_UNIQUE_ACCURATE	SPA_VERSION_9
442fa94a07fSbrendan #define	SPA_VERSION_L2CACHE		SPA_VERSION_10
443088f3894Sahrens #define	SPA_VERSION_NEXT_CLONES		SPA_VERSION_11
444088f3894Sahrens #define	SPA_VERSION_ORIGIN		SPA_VERSION_11
445088f3894Sahrens #define	SPA_VERSION_DSL_SCRUB		SPA_VERSION_11
446bb0ade09Sahrens #define	SPA_VERSION_SNAP_PROPS		SPA_VERSION_12
44774e7dc98SMatthew Ahrens #define	SPA_VERSION_USED_BREAKDOWN	SPA_VERSION_13
448d0f3f37eSMark Shellenbaum #define	SPA_VERSION_PASSTHROUGH_X	SPA_VERSION_14
44914843421SMatthew Ahrens #define	SPA_VERSION_USERSPACE		SPA_VERSION_15
450478ed9adSEric Taylor #define	SPA_VERSION_STMF_PROP		SPA_VERSION_16
451f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ3		SPA_VERSION_17
452842727c2SChris Kirby #define	SPA_VERSION_USERREFS		SPA_VERSION_18
45388ecc943SGeorge Wilson #define	SPA_VERSION_HOLES		SPA_VERSION_19
454b24ab676SJeff Bonwick #define	SPA_VERSION_ZLE_COMPRESSION	SPA_VERSION_20
455b24ab676SJeff Bonwick #define	SPA_VERSION_DEDUP		SPA_VERSION_21
45692241e0bSTom Erickson #define	SPA_VERSION_RECVD_PROPS		SPA_VERSION_22
4576e1f5caaSNeil Perrin #define	SPA_VERSION_SLIM_ZIL		SPA_VERSION_23
4580a586ceaSMark Shellenbaum #define	SPA_VERSION_SA			SPA_VERSION_24
4593f9d6ad7SLin Ling #define	SPA_VERSION_SCAN		SPA_VERSION_25
460cde58dbcSMatthew Ahrens #define	SPA_VERSION_DIR_CLONES		SPA_VERSION_26
461cde58dbcSMatthew Ahrens #define	SPA_VERSION_DEADLISTS		SPA_VERSION_26
4626e0cbcaaSMatthew Ahrens #define	SPA_VERSION_FAST_SNAP		SPA_VERSION_27
463cb04b873SMark J Musante #define	SPA_VERSION_MULTI_REPLACE	SPA_VERSION_28
464ad135b5dSChristopher Siden #define	SPA_VERSION_BEFORE_FEATURES	SPA_VERSION_28
465ad135b5dSChristopher Siden #define	SPA_VERSION_FEATURES		SPA_VERSION_5000
466ad135b5dSChristopher Siden 
467ad135b5dSChristopher Siden #define	SPA_VERSION_IS_SUPPORTED(v) \
468ad135b5dSChristopher Siden 	(((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
469ad135b5dSChristopher Siden 	((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
470e7437265Sahrens 
471e7437265Sahrens /*
472e7437265Sahrens  * ZPL version - rev'd whenever an incompatible on-disk format change
473e7437265Sahrens  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
474e7437265Sahrens  * also update the version_table[] and help message in zfs_prop.c.
475e7437265Sahrens  *
476e7437265Sahrens  * When changing, be sure to teach GRUB how to read the new format!
477478ed9adSEric Taylor  * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
478e7437265Sahrens  */
479e7437265Sahrens #define	ZPL_VERSION_1			1ULL
480e7437265Sahrens #define	ZPL_VERSION_2			2ULL
481da6c28aaSamw #define	ZPL_VERSION_3			3ULL
48214843421SMatthew Ahrens #define	ZPL_VERSION_4			4ULL
4830a586ceaSMark Shellenbaum #define	ZPL_VERSION_5			5ULL
4840a586ceaSMark Shellenbaum #define	ZPL_VERSION			ZPL_VERSION_5
4850a586ceaSMark Shellenbaum #define	ZPL_VERSION_STRING		"5"
486e7437265Sahrens 
487e7437265Sahrens #define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
488e7437265Sahrens #define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
489da6c28aaSamw #define	ZPL_VERSION_FUID		ZPL_VERSION_3
490de8267e0Stimh #define	ZPL_VERSION_NORMALIZATION	ZPL_VERSION_3
491da6c28aaSamw #define	ZPL_VERSION_SYSATTR		ZPL_VERSION_3
49214843421SMatthew Ahrens #define	ZPL_VERSION_USERSPACE		ZPL_VERSION_4
4930a586ceaSMark Shellenbaum #define	ZPL_VERSION_SA			ZPL_VERSION_5
494eaca9bbdSeschrock 
4955dafeea3SPavel Zakharov /* Rewind policy information */
496c8ee1847SVictor Latushkin #define	ZPOOL_NO_REWIND		1  /* No policy - default behavior */
497c8ee1847SVictor Latushkin #define	ZPOOL_NEVER_REWIND	2  /* Do not search for best txg or rewind */
498c8ee1847SVictor Latushkin #define	ZPOOL_TRY_REWIND	4  /* Search for best txg, but do not rewind */
499c8ee1847SVictor Latushkin #define	ZPOOL_DO_REWIND		8  /* Rewind to best txg w/in deferred frees */
500c8ee1847SVictor Latushkin #define	ZPOOL_EXTREME_REWIND	16 /* Allow extreme measures to find best txg */
501c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_MASK	28 /* All the possible rewind bits */
502c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_POLICIES	31 /* All the possible policy bits */
503468c413aSTim Haley 
5045dafeea3SPavel Zakharov typedef struct zpool_load_policy {
5055dafeea3SPavel Zakharov 	uint32_t	zlp_rewind;	/* rewind policy requested */
5065dafeea3SPavel Zakharov 	uint64_t	zlp_maxmeta;	/* max acceptable meta-data errors */
5075dafeea3SPavel Zakharov 	uint64_t	zlp_maxdata;	/* max acceptable data errors */
5085dafeea3SPavel Zakharov 	uint64_t	zlp_txg;	/* specific txg to load */
5095dafeea3SPavel Zakharov } zpool_load_policy_t;
510468c413aSTim Haley 
511fa9e4066Sahrens /*
512fa9e4066Sahrens  * The following are configuration names used in the nvlist describing a pool's
5135cabbc6bSPrashanth Sreenivasa  * configuration.  New on-disk names should be prefixed with "<reverse-DNS>:"
5145cabbc6bSPrashanth Sreenivasa  * (e.g. "org.open-zfs:") to avoid conflicting names being developed
5155cabbc6bSPrashanth Sreenivasa  * independently.
516fa9e4066Sahrens  */
517fa9e4066Sahrens #define	ZPOOL_CONFIG_VERSION		"version"
518fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_NAME		"name"
519fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_STATE		"state"
520fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_TXG		"txg"
521fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
522fa9e4066Sahrens #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
523fa9e4066Sahrens #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
524fa9e4066Sahrens #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
525fa9e4066Sahrens #define	ZPOOL_CONFIG_TYPE		"type"
526fa9e4066Sahrens #define	ZPOOL_CONFIG_CHILDREN		"children"
527fa9e4066Sahrens #define	ZPOOL_CONFIG_ID			"id"
528fa9e4066Sahrens #define	ZPOOL_CONFIG_GUID		"guid"
5295cabbc6bSPrashanth Sreenivasa #define	ZPOOL_CONFIG_INDIRECT_OBJECT	"com.delphix:indirect_object"
5305cabbc6bSPrashanth Sreenivasa #define	ZPOOL_CONFIG_INDIRECT_BIRTHS	"com.delphix:indirect_births"
5315cabbc6bSPrashanth Sreenivasa #define	ZPOOL_CONFIG_PREV_INDIRECT_VDEV	"com.delphix:prev_indirect_vdev"
532fa9e4066Sahrens #define	ZPOOL_CONFIG_PATH		"path"
533fa9e4066Sahrens #define	ZPOOL_CONFIG_DEVID		"devid"
534fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
535fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
536fa9e4066Sahrens #define	ZPOOL_CONFIG_ASHIFT		"ashift"
537fa9e4066Sahrens #define	ZPOOL_CONFIG_ASIZE		"asize"
538fa9e4066Sahrens #define	ZPOOL_CONFIG_DTL		"DTL"
5393f9d6ad7SLin Ling #define	ZPOOL_CONFIG_SCAN_STATS		"scan_stats"	/* not stored on disk */
5405cabbc6bSPrashanth Sreenivasa #define	ZPOOL_CONFIG_REMOVAL_STATS	"removal_stats"	/* not stored on disk */
54186714001SSerapheim Dimitropoulos #define	ZPOOL_CONFIG_CHECKPOINT_STATS	"checkpoint_stats" /* not on disk */
5423f9d6ad7SLin Ling #define	ZPOOL_CONFIG_VDEV_STATS		"vdev_stats"	/* not stored on disk */
5435cabbc6bSPrashanth Sreenivasa #define	ZPOOL_CONFIG_INDIRECT_SIZE	"indirect_size"	/* not stored on disk */
544afefbcddSeschrock #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
545ea8dc4b6Seschrock #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
546ea8dc4b6Seschrock #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
54799653d4eSeschrock #define	ZPOOL_CONFIG_SPARES		"spares"
54899653d4eSeschrock #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
54999653d4eSeschrock #define	ZPOOL_CONFIG_NPARITY		"nparity"
55095173954Sek #define	ZPOOL_CONFIG_HOSTID		"hostid"
55195173954Sek #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
55211027bc7STim Haley #define	ZPOOL_CONFIG_LOADED_TIME	"initial_load_time"
5533d7072f8Seschrock #define	ZPOOL_CONFIG_UNSPARE		"unspare"
5543d7072f8Seschrock #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
5558654d025Sperrin #define	ZPOOL_CONFIG_IS_LOG		"is_log"
556fa94a07fSbrendan #define	ZPOOL_CONFIG_L2CACHE		"l2cache"
55788ecc943SGeorge Wilson #define	ZPOOL_CONFIG_HOLE_ARRAY		"hole_array"
55888ecc943SGeorge Wilson #define	ZPOOL_CONFIG_VDEV_CHILDREN	"vdev_children"
55988ecc943SGeorge Wilson #define	ZPOOL_CONFIG_IS_HOLE		"is_hole"
5609eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_HISTOGRAM	"ddt_histogram"
5619eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_OBJ_STATS	"ddt_object_stats"
5629eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_STATS		"ddt_stats"
5631195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT		"splitcfg"
5641195e687SMark J Musante #define	ZPOOL_CONFIG_ORIG_GUID		"orig_guid"
5651195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_GUID		"split_guid"
5661195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_LIST		"guid_list"
5673f9d6ad7SLin Ling #define	ZPOOL_CONFIG_REMOVING		"removing"
568b4952e17SGeorge Wilson #define	ZPOOL_CONFIG_RESILVER_TXG	"resilver_txg"
5698704186eSDan McDonald #define	ZPOOL_CONFIG_COMMENT		"comment"
570e14bb325SJeff Bonwick #define	ZPOOL_CONFIG_SUSPENDED		"suspended"	/* not stored on disk */
571e7cbe64fSgw #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp"	/* not stored on disk */
572e7cbe64fSgw #define	ZPOOL_CONFIG_BOOTFS		"bootfs"	/* not stored on disk */
5734b964adaSGeorge Wilson #define	ZPOOL_CONFIG_MISSING_DEVICES	"missing_vdevs"	/* not stored on disk */
5744b964adaSGeorge Wilson #define	ZPOOL_CONFIG_LOAD_INFO		"load_info"	/* not stored on disk */
575ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_REWIND_INFO	"rewind_info"	/* not stored on disk */
576ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_UNSUP_FEAT		"unsup_feat"	/* not stored on disk */
57757221772SChristopher Siden #define	ZPOOL_CONFIG_ENABLED_FEAT	"enabled_feat"	/* not stored on disk */
578ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_CAN_RDONLY		"can_rdonly"	/* not stored on disk */
579ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_FEATURES_FOR_READ	"features_for_read"
580ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_FEATURE_STATS	"feature_stats"	/* not stored on disk */
581215198a6SJoe Stein #define	ZPOOL_CONFIG_VDEV_TOP_ZAP	"com.delphix:vdev_zap_top"
582215198a6SJoe Stein #define	ZPOOL_CONFIG_VDEV_LEAF_ZAP	"com.delphix:vdev_zap_leaf"
583215198a6SJoe Stein #define	ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS	"com.delphix:has_per_vdev_zaps"
5846f793812SPavel Zakharov #define	ZPOOL_CONFIG_CACHEFILE		"cachefile"	/* not stored on disk */
5853d7072f8Seschrock /*
5863d7072f8Seschrock  * The persistent vdev state is stored as separate values rather than a single
5873d7072f8Seschrock  * 'vdev_state' entry.  This is because a device can be in multiple states, such
5883d7072f8Seschrock  * as offline and degraded.
5893d7072f8Seschrock  */
5903d7072f8Seschrock #define	ZPOOL_CONFIG_OFFLINE		"offline"
5913d7072f8Seschrock #define	ZPOOL_CONFIG_FAULTED		"faulted"
5923d7072f8Seschrock #define	ZPOOL_CONFIG_DEGRADED		"degraded"
5933d7072f8Seschrock #define	ZPOOL_CONFIG_REMOVED		"removed"
5946809eb4eSEric Schrock #define	ZPOOL_CONFIG_FRU		"fru"
595069f55e2SEric Schrock #define	ZPOOL_CONFIG_AUX_STATE		"aux_state"
596fa9e4066Sahrens 
5975dafeea3SPavel Zakharov /* Pool load policy parameters */
5985dafeea3SPavel Zakharov #define	ZPOOL_LOAD_POLICY		"load-policy"
5995dafeea3SPavel Zakharov #define	ZPOOL_LOAD_REWIND_POLICY	"load-rewind-policy"
6005dafeea3SPavel Zakharov #define	ZPOOL_LOAD_REQUEST_TXG		"load-request-txg"
6015dafeea3SPavel Zakharov #define	ZPOOL_LOAD_META_THRESH		"load-meta-thresh"
6025dafeea3SPavel Zakharov #define	ZPOOL_LOAD_DATA_THRESH		"load-data-thresh"
603468c413aSTim Haley 
604468c413aSTim Haley /* Rewind data discovered */
605468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_TIME		"rewind_txg_ts"
606468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_DATA_ERRORS	"verify_data_errors"
607468c413aSTim Haley #define	ZPOOL_CONFIG_REWIND_TIME	"seconds_of_rewind"
608468c413aSTim Haley 
609fa9e4066Sahrens #define	VDEV_TYPE_ROOT			"root"
610fa9e4066Sahrens #define	VDEV_TYPE_MIRROR		"mirror"
611fa9e4066Sahrens #define	VDEV_TYPE_REPLACING		"replacing"
612fa9e4066Sahrens #define	VDEV_TYPE_RAIDZ			"raidz"
613fa9e4066Sahrens #define	VDEV_TYPE_DISK			"disk"
614fa9e4066Sahrens #define	VDEV_TYPE_FILE			"file"
615fa9e4066Sahrens #define	VDEV_TYPE_MISSING		"missing"
61688ecc943SGeorge Wilson #define	VDEV_TYPE_HOLE			"hole"
61799653d4eSeschrock #define	VDEV_TYPE_SPARE			"spare"
6188654d025Sperrin #define	VDEV_TYPE_LOG			"log"
619fa94a07fSbrendan #define	VDEV_TYPE_L2CACHE		"l2cache"
6205cabbc6bSPrashanth Sreenivasa #define	VDEV_TYPE_INDIRECT		"indirect"
6215cabbc6bSPrashanth Sreenivasa 
6225cabbc6bSPrashanth Sreenivasa /* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */
6235cabbc6bSPrashanth Sreenivasa #define	VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \
6245cabbc6bSPrashanth Sreenivasa 	"com.delphix:indirect_obsolete_sm"
6255cabbc6bSPrashanth Sreenivasa #define	VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \
6265cabbc6bSPrashanth Sreenivasa 	"com.delphix:obsolete_counts_are_precise"
62786714001SSerapheim Dimitropoulos #define	VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \
62886714001SSerapheim Dimitropoulos 	"com.delphix:pool_checkpoint_sm"
629fa9e4066Sahrens 
630094e47e9SGeorge Wilson #define	VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET	\
631094e47e9SGeorge Wilson 	"com.delphix:next_offset_to_initialize"
632094e47e9SGeorge Wilson #define	VDEV_LEAF_ZAP_INITIALIZE_STATE	\
633094e47e9SGeorge Wilson 	"com.delphix:vdev_initialize_state"
634094e47e9SGeorge Wilson #define	VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME	\
635094e47e9SGeorge Wilson 	"com.delphix:vdev_initialize_action_time"
636094e47e9SGeorge Wilson 
637fa9e4066Sahrens /*
638fa9e4066Sahrens  * This is needed in userland to report the minimum necessary device size.
6394b5c8e93SMatthew Ahrens  *
6404b5c8e93SMatthew Ahrens  * Note that the zfs test suite uses 64MB vdevs.
641fa9e4066Sahrens  */
642fa9e4066Sahrens #define	SPA_MINDEVSIZE		(64ULL << 20)
643fa9e4066Sahrens 
6442e4c9986SGeorge Wilson /*
6452e4c9986SGeorge Wilson  * Set if the fragmentation has not yet been calculated. This can happen
6462e4c9986SGeorge Wilson  * because the space maps have not been upgraded or the histogram feature
6472e4c9986SGeorge Wilson  * is not enabled.
6482e4c9986SGeorge Wilson  */
6492e4c9986SGeorge Wilson #define	ZFS_FRAG_INVALID	UINT64_MAX
6502e4c9986SGeorge Wilson 
651fa9e4066Sahrens /*
652fa9e4066Sahrens  * The location of the pool configuration repository, shared between kernel and
653fa9e4066Sahrens  * userland.
654fa9e4066Sahrens  */
655c5904d13Seschrock #define	ZPOOL_CACHE		"/etc/zfs/zpool.cache"
656fa9e4066Sahrens 
657fa9e4066Sahrens /*
658fa9e4066Sahrens  * vdev states are ordered from least to most healthy.
659fa9e4066Sahrens  * A vdev that's CANT_OPEN or below is considered unusable.
660fa9e4066Sahrens  */
661fa9e4066Sahrens typedef enum vdev_state {
662fa9e4066Sahrens 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
663fa9e4066Sahrens 	VDEV_STATE_CLOSED,	/* Not currently open			*/
664fa9e4066Sahrens 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
6653d7072f8Seschrock 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
666fa9e4066Sahrens 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
6673d7072f8Seschrock 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
668fa9e4066Sahrens 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
669fa9e4066Sahrens 	VDEV_STATE_HEALTHY	/* Presumed good			*/
670fa9e4066Sahrens } vdev_state_t;
671fa9e4066Sahrens 
6723d7072f8Seschrock #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
6733d7072f8Seschrock 
674fa9e4066Sahrens /*
675fa9e4066Sahrens  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
676fa9e4066Sahrens  * of the vdev stats structure uses these constants to distinguish why.
677fa9e4066Sahrens  */
678fa9e4066Sahrens typedef enum vdev_aux {
679fa9e4066Sahrens 	VDEV_AUX_NONE,		/* no error				*/
680fa9e4066Sahrens 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
681fa9e4066Sahrens 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
682fa9e4066Sahrens 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
683fa9e4066Sahrens 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
684fa9e4066Sahrens 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
685eaca9bbdSeschrock 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
686eaca9bbdSeschrock 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
68799653d4eSeschrock 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
688ad135b5dSChristopher Siden 	VDEV_AUX_UNSUP_FEAT,	/* unsupported features			*/
6893d7072f8Seschrock 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
69032b87932Sek 	VDEV_AUX_ERR_EXCEEDED,	/* too many errors			*/
691b87f3af3Sperrin 	VDEV_AUX_IO_FAILURE,	/* experienced I/O failure		*/
692069f55e2SEric Schrock 	VDEV_AUX_BAD_LOG,	/* cannot read log chain(s)		*/
6931195e687SMark J Musante 	VDEV_AUX_EXTERNAL,	/* external diagnosis			*/
6946f793812SPavel Zakharov 	VDEV_AUX_SPLIT_POOL,	/* vdev was split off into another pool	*/
6956f793812SPavel Zakharov 	VDEV_AUX_CHILDREN_OFFLINE /* all children are offline		*/
696fa9e4066Sahrens } vdev_aux_t;
697fa9e4066Sahrens 
698fa9e4066Sahrens /*
69946a2abf2Seschrock  * pool state.  The following states are written to disk as part of the normal
700fa94a07fSbrendan  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
701fa94a07fSbrendan  * states are software abstractions used at various levels to communicate
702fa94a07fSbrendan  * pool state.
703fa9e4066Sahrens  */
704fa9e4066Sahrens typedef enum pool_state {
705fa9e4066Sahrens 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
706fa9e4066Sahrens 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
707fa9e4066Sahrens 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
70899653d4eSeschrock 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
709fa94a07fSbrendan 	POOL_STATE_L2CACHE,		/* Level 2 ARC device		*/
710fa9e4066Sahrens 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
71146a2abf2Seschrock 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
71246a2abf2Seschrock 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
713fa9e4066Sahrens } pool_state_t;
714fa9e4066Sahrens 
715fa9e4066Sahrens /*
7163f9d6ad7SLin Ling  * Scan Functions.
717fa9e4066Sahrens  */
7183f9d6ad7SLin Ling typedef enum pool_scan_func {
7193f9d6ad7SLin Ling 	POOL_SCAN_NONE,
7203f9d6ad7SLin Ling 	POOL_SCAN_SCRUB,
7213f9d6ad7SLin Ling 	POOL_SCAN_RESILVER,
7223f9d6ad7SLin Ling 	POOL_SCAN_FUNCS
7233f9d6ad7SLin Ling } pool_scan_func_t;
724fa9e4066Sahrens 
7251702cce7SAlek Pinchuk /*
7261702cce7SAlek Pinchuk  * Used to control scrub pause and resume.
7271702cce7SAlek Pinchuk  */
7281702cce7SAlek Pinchuk typedef enum pool_scrub_cmd {
7291702cce7SAlek Pinchuk 	POOL_SCRUB_NORMAL = 0,
7301702cce7SAlek Pinchuk 	POOL_SCRUB_PAUSE,
7311702cce7SAlek Pinchuk 	POOL_SCRUB_FLAGS_END
7321702cce7SAlek Pinchuk } pool_scrub_cmd_t;
7331702cce7SAlek Pinchuk 
734094e47e9SGeorge Wilson /*
735094e47e9SGeorge Wilson  * Initialize functions.
736094e47e9SGeorge Wilson  */
737094e47e9SGeorge Wilson typedef enum pool_initialize_func {
738094e47e9SGeorge Wilson 	POOL_INITIALIZE_DO,
739094e47e9SGeorge Wilson 	POOL_INITIALIZE_CANCEL,
740094e47e9SGeorge Wilson 	POOL_INITIALIZE_SUSPEND,
741094e47e9SGeorge Wilson 	POOL_INITIALIZE_FUNCS
742094e47e9SGeorge Wilson } pool_initialize_func_t;
7431702cce7SAlek Pinchuk 
744fa9e4066Sahrens /*
745fa9e4066Sahrens  * ZIO types.  Needed to interpret vdev statistics below.
746fa9e4066Sahrens  */
747fa9e4066Sahrens typedef enum zio_type {
748fa9e4066Sahrens 	ZIO_TYPE_NULL = 0,
749fa9e4066Sahrens 	ZIO_TYPE_READ,
750fa9e4066Sahrens 	ZIO_TYPE_WRITE,
751fa9e4066Sahrens 	ZIO_TYPE_FREE,
752fa9e4066Sahrens 	ZIO_TYPE_CLAIM,
753fa9e4066Sahrens 	ZIO_TYPE_IOCTL,
754fa9e4066Sahrens 	ZIO_TYPES
755fa9e4066Sahrens } zio_type_t;
756fa9e4066Sahrens 
7573f9d6ad7SLin Ling /*
7583f9d6ad7SLin Ling  * Pool statistics.  Note: all fields should be 64-bit because this
7593f9d6ad7SLin Ling  * is passed between kernel and userland as an nvlist uint64 array.
7603f9d6ad7SLin Ling  */
7613f9d6ad7SLin Ling typedef struct pool_scan_stat {
7623f9d6ad7SLin Ling 	/* values stored on disk */
7633f9d6ad7SLin Ling 	uint64_t	pss_func;	/* pool_scan_func_t */
7643f9d6ad7SLin Ling 	uint64_t	pss_state;	/* dsl_scan_state_t */
7653f9d6ad7SLin Ling 	uint64_t	pss_start_time;	/* scan start time */
7663f9d6ad7SLin Ling 	uint64_t	pss_end_time;	/* scan end time */
7673f9d6ad7SLin Ling 	uint64_t	pss_to_examine;	/* total bytes to scan */
7683f9d6ad7SLin Ling 	uint64_t	pss_examined;	/* total examined bytes	*/
7693f9d6ad7SLin Ling 	uint64_t	pss_to_process; /* total bytes to process */
7703f9d6ad7SLin Ling 	uint64_t	pss_processed;	/* total processed bytes */
7713f9d6ad7SLin Ling 	uint64_t	pss_errors;	/* scan errors	*/
7723f9d6ad7SLin Ling 
7733f9d6ad7SLin Ling 	/* values not stored on disk */
7743f9d6ad7SLin Ling 	uint64_t	pss_pass_exam;	/* examined bytes per scan pass */
7753f9d6ad7SLin Ling 	uint64_t	pss_pass_start;	/* start time of a scan pass */
7761702cce7SAlek Pinchuk 	uint64_t	pss_pass_scrub_pause; /* pause time of a scurb pass */
7771702cce7SAlek Pinchuk 	/* cumulative time scrub spent paused, needed for rate calculation */
7781702cce7SAlek Pinchuk 	uint64_t	pss_pass_scrub_spent_paused;
7793f9d6ad7SLin Ling } pool_scan_stat_t;
7803f9d6ad7SLin Ling 
7815cabbc6bSPrashanth Sreenivasa typedef struct pool_removal_stat {
7825cabbc6bSPrashanth Sreenivasa 	uint64_t prs_state; /* dsl_scan_state_t */
7835cabbc6bSPrashanth Sreenivasa 	uint64_t prs_removing_vdev;
7845cabbc6bSPrashanth Sreenivasa 	uint64_t prs_start_time;
7855cabbc6bSPrashanth Sreenivasa 	uint64_t prs_end_time;
7865cabbc6bSPrashanth Sreenivasa 	uint64_t prs_to_copy; /* bytes that need to be copied */
7875cabbc6bSPrashanth Sreenivasa 	uint64_t prs_copied; /* bytes copied so far */
7885cabbc6bSPrashanth Sreenivasa 	/*
7895cabbc6bSPrashanth Sreenivasa 	 * bytes of memory used for indirect mappings.
7905cabbc6bSPrashanth Sreenivasa 	 * This includes all removed vdevs.
7915cabbc6bSPrashanth Sreenivasa 	 */
7925cabbc6bSPrashanth Sreenivasa 	uint64_t prs_mapping_memory;
7935cabbc6bSPrashanth Sreenivasa } pool_removal_stat_t;
7945cabbc6bSPrashanth Sreenivasa 
7953f9d6ad7SLin Ling typedef enum dsl_scan_state {
7963f9d6ad7SLin Ling 	DSS_NONE,
7973f9d6ad7SLin Ling 	DSS_SCANNING,
7983f9d6ad7SLin Ling 	DSS_FINISHED,
7993f9d6ad7SLin Ling 	DSS_CANCELED,
8003f9d6ad7SLin Ling 	DSS_NUM_STATES
8013f9d6ad7SLin Ling } dsl_scan_state_t;
8023f9d6ad7SLin Ling 
80386714001SSerapheim Dimitropoulos typedef enum {
80486714001SSerapheim Dimitropoulos 	CS_NONE,
80586714001SSerapheim Dimitropoulos 	CS_CHECKPOINT_EXISTS,
80686714001SSerapheim Dimitropoulos 	CS_CHECKPOINT_DISCARDING,
80786714001SSerapheim Dimitropoulos 	CS_NUM_STATES
80886714001SSerapheim Dimitropoulos } checkpoint_state_t;
80986714001SSerapheim Dimitropoulos 
81086714001SSerapheim Dimitropoulos typedef struct pool_checkpoint_stat {
81186714001SSerapheim Dimitropoulos 	uint64_t pcs_state;		/* checkpoint_state_t */
81286714001SSerapheim Dimitropoulos 	uint64_t pcs_start_time;	/* time checkpoint/discard started */
81386714001SSerapheim Dimitropoulos 	uint64_t pcs_space;		/* checkpointed space */
81486714001SSerapheim Dimitropoulos } pool_checkpoint_stat_t;
8153f9d6ad7SLin Ling 
816094e47e9SGeorge Wilson typedef enum {
817094e47e9SGeorge Wilson 	VDEV_INITIALIZE_NONE,
818094e47e9SGeorge Wilson 	VDEV_INITIALIZE_ACTIVE,
819094e47e9SGeorge Wilson 	VDEV_INITIALIZE_CANCELED,
820094e47e9SGeorge Wilson 	VDEV_INITIALIZE_SUSPENDED,
821094e47e9SGeorge Wilson 	VDEV_INITIALIZE_COMPLETE
822094e47e9SGeorge Wilson } vdev_initializing_state_t;
823094e47e9SGeorge Wilson 
824fa9e4066Sahrens /*
825fa9e4066Sahrens  * Vdev statistics.  Note: all fields should be 64-bit because this
826fa9e4066Sahrens  * is passed between kernel and userland as an nvlist uint64 array.
827fa9e4066Sahrens  */
828fa9e4066Sahrens typedef struct vdev_stat {
829fa9e4066Sahrens 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
830fa9e4066Sahrens 	uint64_t	vs_state;		/* vdev state		*/
831fa9e4066Sahrens 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
832fa9e4066Sahrens 	uint64_t	vs_alloc;		/* space allocated	*/
833fa9e4066Sahrens 	uint64_t	vs_space;		/* total capacity	*/
83499653d4eSeschrock 	uint64_t	vs_dspace;		/* deflated capacity	*/
8352a79c5feSlling 	uint64_t	vs_rsize;		/* replaceable dev size */
8364263d13fSGeorge Wilson 	uint64_t	vs_esize;		/* expandable dev size */
837fa9e4066Sahrens 	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
838fa9e4066Sahrens 	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
839fa9e4066Sahrens 	uint64_t	vs_read_errors;		/* read errors		*/
840fa9e4066Sahrens 	uint64_t	vs_write_errors;	/* write errors		*/
841fa9e4066Sahrens 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
842094e47e9SGeorge Wilson 	uint64_t	vs_initialize_errors;	/* initializing errors	*/
843fa9e4066Sahrens 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
8443f9d6ad7SLin Ling 	uint64_t	vs_scan_removing;	/* removing?	*/
8453f9d6ad7SLin Ling 	uint64_t	vs_scan_processed;	/* scan processed bytes	*/
8462e4c9986SGeorge Wilson 	uint64_t	vs_fragmentation;	/* device fragmentation */
847094e47e9SGeorge Wilson 	uint64_t	vs_initialize_bytes_done; /* bytes initialized */
848094e47e9SGeorge Wilson 	uint64_t	vs_initialize_bytes_est; /* total bytes to initialize */
849094e47e9SGeorge Wilson 	uint64_t	vs_initialize_state;	/* vdev_initialzing_state_t */
850094e47e9SGeorge Wilson 	uint64_t	vs_initialize_action_time; /* time_t */
85186714001SSerapheim Dimitropoulos 	uint64_t	vs_checkpoint_space;    /* checkpoint-consumed space */
852fa9e4066Sahrens } vdev_stat_t;
853fa9e4066Sahrens 
8549eb19f4dSGeorge Wilson /*
8559eb19f4dSGeorge Wilson  * DDT statistics.  Note: all fields should be 64-bit because this
8569eb19f4dSGeorge Wilson  * is passed between kernel and userland as an nvlist uint64 array.
8579eb19f4dSGeorge Wilson  */
8589eb19f4dSGeorge Wilson typedef struct ddt_object {
859*04e56356SAndriy Gapon 	uint64_t	ddo_count;	/* number of elments in ddt	*/
8609eb19f4dSGeorge Wilson 	uint64_t	ddo_dspace;	/* size of ddt on disk		*/
8619eb19f4dSGeorge Wilson 	uint64_t	ddo_mspace;	/* size of ddt in-core		*/
8629eb19f4dSGeorge Wilson } ddt_object_t;
8639eb19f4dSGeorge Wilson 
8649eb19f4dSGeorge Wilson typedef struct ddt_stat {
8659eb19f4dSGeorge Wilson 	uint64_t	dds_blocks;	/* blocks			*/
8669eb19f4dSGeorge Wilson 	uint64_t	dds_lsize;	/* logical size			*/
8679eb19f4dSGeorge Wilson 	uint64_t	dds_psize;	/* physical size		*/
8689eb19f4dSGeorge Wilson 	uint64_t	dds_dsize;	/* deflated allocated size	*/
8699eb19f4dSGeorge Wilson 	uint64_t	dds_ref_blocks;	/* referenced blocks		*/
8709eb19f4dSGeorge Wilson 	uint64_t	dds_ref_lsize;	/* referenced lsize * refcnt	*/
8719eb19f4dSGeorge Wilson 	uint64_t	dds_ref_psize;	/* referenced psize * refcnt	*/
8729eb19f4dSGeorge Wilson 	uint64_t	dds_ref_dsize;	/* referenced dsize * refcnt	*/
8739eb19f4dSGeorge Wilson } ddt_stat_t;
8749eb19f4dSGeorge Wilson 
8759eb19f4dSGeorge Wilson typedef struct ddt_histogram {
8769eb19f4dSGeorge Wilson 	ddt_stat_t	ddh_stat[64];	/* power-of-two histogram buckets */
8779eb19f4dSGeorge Wilson } ddt_histogram_t;
8789eb19f4dSGeorge Wilson 
879e7cbe64fSgw #define	ZVOL_DRIVER	"zvol"
880fa9e4066Sahrens #define	ZFS_DRIVER	"zfs"
881fa9e4066Sahrens #define	ZFS_DEV		"/dev/zfs"
8826401734dSWill Andrews #define	ZFS_DISK_ROOT	"/dev/dsk"
8836401734dSWill Andrews #define	ZFS_DISK_ROOTD	ZFS_DISK_ROOT "/"
8846401734dSWill Andrews #define	ZFS_RDISK_ROOT	"/dev/rdsk"
8856401734dSWill Andrews #define	ZFS_RDISK_ROOTD	ZFS_RDISK_ROOT "/"
886fa9e4066Sahrens 
887681d9761SEric Taylor /* general zvol path */
888681d9761SEric Taylor #define	ZVOL_DIR		"/dev/zvol"
889681d9761SEric Taylor /* expansion */
890573ca77eSGeorge Wilson #define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zfs@0:"
891681d9761SEric Taylor /* for dump and swap */
892681d9761SEric Taylor #define	ZVOL_FULL_DEV_DIR	ZVOL_DIR "/dsk/"
893681d9761SEric Taylor #define	ZVOL_FULL_RDEV_DIR	ZVOL_DIR "/rdsk/"
894fa9e4066Sahrens 
895fa9e4066Sahrens #define	ZVOL_PROP_NAME		"name"
896c1449561SEric Taylor #define	ZVOL_DEFAULT_BLOCKSIZE	8192
897fa9e4066Sahrens 
898fa9e4066Sahrens /*
899fa9e4066Sahrens  * /dev/zfs ioctl numbers.
900fa9e4066Sahrens  */
901fa9e4066Sahrens typedef enum zfs_ioc {
9024445fffbSMatthew Ahrens 	ZFS_IOC_FIRST =	('Z' << 8),
9034445fffbSMatthew Ahrens 	ZFS_IOC = ZFS_IOC_FIRST,
9044445fffbSMatthew Ahrens 	ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,
905fa9e4066Sahrens 	ZFS_IOC_POOL_DESTROY,
906fa9e4066Sahrens 	ZFS_IOC_POOL_IMPORT,
907fa9e4066Sahrens 	ZFS_IOC_POOL_EXPORT,
908fa9e4066Sahrens 	ZFS_IOC_POOL_CONFIGS,
909fa9e4066Sahrens 	ZFS_IOC_POOL_STATS,
910fa9e4066Sahrens 	ZFS_IOC_POOL_TRYIMPORT,
9113f9d6ad7SLin Ling 	ZFS_IOC_POOL_SCAN,
912fa9e4066Sahrens 	ZFS_IOC_POOL_FREEZE,
913eaca9bbdSeschrock 	ZFS_IOC_POOL_UPGRADE,
91406eeb2adSek 	ZFS_IOC_POOL_GET_HISTORY,
915fa9e4066Sahrens 	ZFS_IOC_VDEV_ADD,
916fa9e4066Sahrens 	ZFS_IOC_VDEV_REMOVE,
9173d7072f8Seschrock 	ZFS_IOC_VDEV_SET_STATE,
918fa9e4066Sahrens 	ZFS_IOC_VDEV_ATTACH,
919fa9e4066Sahrens 	ZFS_IOC_VDEV_DETACH,
920c67d9675Seschrock 	ZFS_IOC_VDEV_SETPATH,
9216809eb4eSEric Schrock 	ZFS_IOC_VDEV_SETFRU,
922fa9e4066Sahrens 	ZFS_IOC_OBJSET_STATS,
923de8267e0Stimh 	ZFS_IOC_OBJSET_ZPLPROPS,
924fa9e4066Sahrens 	ZFS_IOC_DATASET_LIST_NEXT,
925fa9e4066Sahrens 	ZFS_IOC_SNAPSHOT_LIST_NEXT,
926fa9e4066Sahrens 	ZFS_IOC_SET_PROP,
927fa9e4066Sahrens 	ZFS_IOC_CREATE,
928fa9e4066Sahrens 	ZFS_IOC_DESTROY,
929fa9e4066Sahrens 	ZFS_IOC_ROLLBACK,
930fa9e4066Sahrens 	ZFS_IOC_RENAME,
9313cb34c60Sahrens 	ZFS_IOC_RECV,
9323cb34c60Sahrens 	ZFS_IOC_SEND,
933ea8dc4b6Seschrock 	ZFS_IOC_INJECT_FAULT,
934ea8dc4b6Seschrock 	ZFS_IOC_CLEAR_FAULT,
935ea8dc4b6Seschrock 	ZFS_IOC_INJECT_LIST_NEXT,
936ea8dc4b6Seschrock 	ZFS_IOC_ERROR_LOG,
937ea8dc4b6Seschrock 	ZFS_IOC_CLEAR,
9381d452cf5Sahrens 	ZFS_IOC_PROMOTE,
93955434c77Sek 	ZFS_IOC_SNAPSHOT,
94055434c77Sek 	ZFS_IOC_DSOBJ_TO_DSNAME,
941b1b8ab34Slling 	ZFS_IOC_OBJ_TO_PATH,
942b1b8ab34Slling 	ZFS_IOC_POOL_SET_PROPS,
943ecd6cf80Smarks 	ZFS_IOC_POOL_GET_PROPS,
944ecd6cf80Smarks 	ZFS_IOC_SET_FSACL,
945ecd6cf80Smarks 	ZFS_IOC_GET_FSACL,
946e45ce728Sahrens 	ZFS_IOC_SHARE,
947743a77edSAlan Wright 	ZFS_IOC_INHERIT_PROP,
94814843421SMatthew Ahrens 	ZFS_IOC_SMB_ACL,
94914843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_ONE,
95014843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_MANY,
951842727c2SChris Kirby 	ZFS_IOC_USERSPACE_UPGRADE,
952842727c2SChris Kirby 	ZFS_IOC_HOLD,
953842727c2SChris Kirby 	ZFS_IOC_RELEASE,
95492241e0bSTom Erickson 	ZFS_IOC_GET_HOLDS,
9551195e687SMark J Musante 	ZFS_IOC_OBJSET_RECVD_PROPS,
95699d5e173STim Haley 	ZFS_IOC_VDEV_SPLIT,
95799d5e173STim Haley 	ZFS_IOC_NEXT_OBJ,
95899d5e173STim Haley 	ZFS_IOC_DIFF,
95999d5e173STim Haley 	ZFS_IOC_TMP_SNAPSHOT,
960e9103aaeSGarrett D'Amore 	ZFS_IOC_OBJ_TO_STATS,
96119b94df9SMatthew Ahrens 	ZFS_IOC_SPACE_WRITTEN,
96219b94df9SMatthew Ahrens 	ZFS_IOC_SPACE_SNAPS,
9634445fffbSMatthew Ahrens 	ZFS_IOC_DESTROY_SNAPS,
9644263d13fSGeorge Wilson 	ZFS_IOC_POOL_REGUID,
9654e3c9f44SBill Pijewski 	ZFS_IOC_POOL_REOPEN,
9664445fffbSMatthew Ahrens 	ZFS_IOC_SEND_PROGRESS,
9674445fffbSMatthew Ahrens 	ZFS_IOC_LOG_HISTORY,
9684445fffbSMatthew Ahrens 	ZFS_IOC_SEND_NEW,
9694445fffbSMatthew Ahrens 	ZFS_IOC_SEND_SPACE,
9704445fffbSMatthew Ahrens 	ZFS_IOC_CLONE,
97178f17100SMatthew Ahrens 	ZFS_IOC_BOOKMARK,
97278f17100SMatthew Ahrens 	ZFS_IOC_GET_BOOKMARKS,
97378f17100SMatthew Ahrens 	ZFS_IOC_DESTROY_BOOKMARKS,
974dfc11533SChris Williamson 	ZFS_IOC_CHANNEL_PROGRAM,
9755cabbc6bSPrashanth Sreenivasa 	ZFS_IOC_REMAP,
97686714001SSerapheim Dimitropoulos 	ZFS_IOC_POOL_CHECKPOINT,
97786714001SSerapheim Dimitropoulos 	ZFS_IOC_POOL_DISCARD_CHECKPOINT,
978094e47e9SGeorge Wilson 	ZFS_IOC_POOL_INITIALIZE,
9794445fffbSMatthew Ahrens 	ZFS_IOC_LAST
980fa9e4066Sahrens } zfs_ioc_t;
981fa9e4066Sahrens 
98286714001SSerapheim Dimitropoulos /*
98386714001SSerapheim Dimitropoulos  * ZFS-specific error codes used for returning descriptive errors
98486714001SSerapheim Dimitropoulos  * to the userland through zfs ioctls.
98586714001SSerapheim Dimitropoulos  *
98686714001SSerapheim Dimitropoulos  * The enum implicitly includes all the error codes from errno.h.
98786714001SSerapheim Dimitropoulos  * New code should use and extend this enum for errors that are
98886714001SSerapheim Dimitropoulos  * not described precisely by generic errno codes.
98986714001SSerapheim Dimitropoulos  */
99086714001SSerapheim Dimitropoulos typedef enum {
99186714001SSerapheim Dimitropoulos 	ZFS_ERR_CHECKPOINT_EXISTS = 1024,
99286714001SSerapheim Dimitropoulos 	ZFS_ERR_DISCARDING_CHECKPOINT,
99386714001SSerapheim Dimitropoulos 	ZFS_ERR_NO_CHECKPOINT,
99486714001SSerapheim Dimitropoulos 	ZFS_ERR_DEVRM_IN_PROGRESS,
99586714001SSerapheim Dimitropoulos 	ZFS_ERR_VDEV_TOO_BIG
99686714001SSerapheim Dimitropoulos } zfs_errno_t;
99786714001SSerapheim Dimitropoulos 
998ea8dc4b6Seschrock /*
999ea8dc4b6Seschrock  * Internal SPA load state.  Used by FMA diagnosis engine.
1000ea8dc4b6Seschrock  */
1001ea8dc4b6Seschrock typedef enum {
10029eb19f4dSGeorge Wilson 	SPA_LOAD_NONE,		/* no load in progress	*/
10039eb19f4dSGeorge Wilson 	SPA_LOAD_OPEN,		/* normal open		*/
10049eb19f4dSGeorge Wilson 	SPA_LOAD_IMPORT,	/* import in progress	*/
1005468c413aSTim Haley 	SPA_LOAD_TRYIMPORT,	/* tryimport in progress */
10069eb19f4dSGeorge Wilson 	SPA_LOAD_RECOVER,	/* recovery requested	*/
10070f7643c7SGeorge Wilson 	SPA_LOAD_ERROR,		/* load failed		*/
10080f7643c7SGeorge Wilson 	SPA_LOAD_CREATE		/* creation in progress */
1009ea8dc4b6Seschrock } spa_load_state_t;
1010ea8dc4b6Seschrock 
1011e9dbad6fSeschrock /*
1012e9dbad6fSeschrock  * Bookmark name values.
1013e9dbad6fSeschrock  */
101455434c77Sek #define	ZPOOL_ERR_LIST		"error list"
1015e9dbad6fSeschrock #define	ZPOOL_ERR_DATASET	"dataset"
1016e9dbad6fSeschrock #define	ZPOOL_ERR_OBJECT	"object"
1017e9dbad6fSeschrock 
101806eeb2adSek #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
101906eeb2adSek 
102006eeb2adSek /*
102106eeb2adSek  * The following are names used in the nvlist describing
102206eeb2adSek  * the pool's history log.
102306eeb2adSek  */
102406eeb2adSek #define	ZPOOL_HIST_RECORD	"history record"
102506eeb2adSek #define	ZPOOL_HIST_TIME		"history time"
102606eeb2adSek #define	ZPOOL_HIST_CMD		"history command"
1027ecd6cf80Smarks #define	ZPOOL_HIST_WHO		"history who"
1028ecd6cf80Smarks #define	ZPOOL_HIST_ZONE		"history zone"
1029ecd6cf80Smarks #define	ZPOOL_HIST_HOST		"history hostname"
1030ecd6cf80Smarks #define	ZPOOL_HIST_TXG		"history txg"
1031ecd6cf80Smarks #define	ZPOOL_HIST_INT_EVENT	"history internal event"
1032ecd6cf80Smarks #define	ZPOOL_HIST_INT_STR	"history internal str"
10334445fffbSMatthew Ahrens #define	ZPOOL_HIST_INT_NAME	"internal_name"
10344445fffbSMatthew Ahrens #define	ZPOOL_HIST_IOCTL	"ioctl"
10354445fffbSMatthew Ahrens #define	ZPOOL_HIST_INPUT_NVL	"in_nvl"
10364445fffbSMatthew Ahrens #define	ZPOOL_HIST_OUTPUT_NVL	"out_nvl"
10374445fffbSMatthew Ahrens #define	ZPOOL_HIST_DSNAME	"dsname"
10384445fffbSMatthew Ahrens #define	ZPOOL_HIST_DSID		"dsid"
1039dfc11533SChris Williamson #define	ZPOOL_HIST_ERRNO	"errno"
104006eeb2adSek 
1041094e47e9SGeorge Wilson /*
1042094e47e9SGeorge Wilson  * The following are names used when invoking ZFS_IOC_POOL_INITIALIZE.
1043094e47e9SGeorge Wilson  */
1044094e47e9SGeorge Wilson #define	ZPOOL_INITIALIZE_COMMAND	"initialize_command"
1045094e47e9SGeorge Wilson #define	ZPOOL_INITIALIZE_VDEVS		"initialize_vdevs"
1046094e47e9SGeorge Wilson 
10473d7072f8Seschrock /*
10483d7072f8Seschrock  * Flags for ZFS_IOC_VDEV_SET_STATE
10493d7072f8Seschrock  */
10503d7072f8Seschrock #define	ZFS_ONLINE_CHECKREMOVE	0x1
10513d7072f8Seschrock #define	ZFS_ONLINE_UNSPARE	0x2
10523d7072f8Seschrock #define	ZFS_ONLINE_FORCEFAULT	0x4
1053573ca77eSGeorge Wilson #define	ZFS_ONLINE_EXPAND	0x8
10543d7072f8Seschrock #define	ZFS_OFFLINE_TEMPORARY	0x1
10553d7072f8Seschrock 
10564b964adaSGeorge Wilson /*
10574b964adaSGeorge Wilson  * Flags for ZFS_IOC_POOL_IMPORT
10584b964adaSGeorge Wilson  */
10594b964adaSGeorge Wilson #define	ZFS_IMPORT_NORMAL	0x0
10604b964adaSGeorge Wilson #define	ZFS_IMPORT_VERBATIM	0x1
10614b964adaSGeorge Wilson #define	ZFS_IMPORT_ANY_HOST	0x2
10624b964adaSGeorge Wilson #define	ZFS_IMPORT_MISSING_LOG	0x4
1063f9af39baSGeorge Wilson #define	ZFS_IMPORT_ONLY		0x8
106486714001SSerapheim Dimitropoulos #define	ZFS_IMPORT_CHECKPOINT	0x10
1065*04e56356SAndriy Gapon #define	ZFS_IMPORT_TEMP_NAME	0x20
10664b964adaSGeorge Wilson 
1067dfc11533SChris Williamson /*
1068dfc11533SChris Williamson  * Channel program argument/return nvlist keys and defaults.
1069dfc11533SChris Williamson  */
1070dfc11533SChris Williamson #define	ZCP_ARG_PROGRAM		"program"
1071dfc11533SChris Williamson #define	ZCP_ARG_ARGLIST		"arg"
1072a3b28680SSerapheim Dimitropoulos #define	ZCP_ARG_SYNC		"sync"
1073dfc11533SChris Williamson #define	ZCP_ARG_INSTRLIMIT	"instrlimit"
1074dfc11533SChris Williamson #define	ZCP_ARG_MEMLIMIT	"memlimit"
1075dfc11533SChris Williamson 
1076dfc11533SChris Williamson #define	ZCP_ARG_CLIARGV		"argv"
1077dfc11533SChris Williamson 
1078dfc11533SChris Williamson #define	ZCP_RET_ERROR		"error"
1079dfc11533SChris Williamson #define	ZCP_RET_RETURN		"return"
1080dfc11533SChris Williamson 
1081dfc11533SChris Williamson #define	ZCP_DEFAULT_INSTRLIMIT	(10 * 1000 * 1000)
1082dfc11533SChris Williamson #define	ZCP_MAX_INSTRLIMIT	(10 * ZCP_DEFAULT_INSTRLIMIT)
1083dfc11533SChris Williamson #define	ZCP_DEFAULT_MEMLIMIT	(10 * 1024 * 1024)
1084dfc11533SChris Williamson #define	ZCP_MAX_MEMLIMIT	(10 * ZCP_DEFAULT_MEMLIMIT)
1085dfc11533SChris Williamson 
10863d7072f8Seschrock /*
10873d7072f8Seschrock  * Sysevent payload members.  ZFS will generate the following sysevents with the
10883d7072f8Seschrock  * given payloads:
10893d7072f8Seschrock  *
10903d7072f8Seschrock  *	ESC_ZFS_RESILVER_START
10913d7072f8Seschrock  *	ESC_ZFS_RESILVER_END
10923d7072f8Seschrock  *	ESC_ZFS_POOL_DESTROY
1093e9103aaeSGarrett D'Amore  *	ESC_ZFS_POOL_REGUID
10943d7072f8Seschrock  *
10953d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
10963d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
10973d7072f8Seschrock  *
10983d7072f8Seschrock  *	ESC_ZFS_VDEV_REMOVE
10993d7072f8Seschrock  *	ESC_ZFS_VDEV_CLEAR
11003d7072f8Seschrock  *	ESC_ZFS_VDEV_CHECK
11013d7072f8Seschrock  *
11023d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
11033d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
11043d7072f8Seschrock  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
11053d7072f8Seschrock  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
1106ce1577b0SDave Eddy  *
1107ce1577b0SDave Eddy  *	ESC_ZFS_HISTORY_EVENT
1108ce1577b0SDave Eddy  *
1109ce1577b0SDave Eddy  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
1110ce1577b0SDave Eddy  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
1111ce1577b0SDave Eddy  *		ZFS_EV_HIST_TIME	DATA_TYPE_UINT64	(optional)
1112ce1577b0SDave Eddy  *		ZFS_EV_HIST_CMD		DATA_TYPE_STRING	(optional)
1113ce1577b0SDave Eddy  *		ZFS_EV_HIST_WHO		DATA_TYPE_UINT64	(optional)
1114ce1577b0SDave Eddy  *		ZFS_EV_HIST_ZONE	DATA_TYPE_STRING	(optional)
1115ce1577b0SDave Eddy  *		ZFS_EV_HIST_HOST	DATA_TYPE_STRING	(optional)
1116ce1577b0SDave Eddy  *		ZFS_EV_HIST_TXG		DATA_TYPE_UINT64	(optional)
1117ce1577b0SDave Eddy  *		ZFS_EV_HIST_INT_EVENT	DATA_TYPE_UINT64	(optional)
1118ce1577b0SDave Eddy  *		ZFS_EV_HIST_INT_STR	DATA_TYPE_STRING	(optional)
1119ce1577b0SDave Eddy  *		ZFS_EV_HIST_INT_NAME	DATA_TYPE_STRING	(optional)
1120ce1577b0SDave Eddy  *		ZFS_EV_HIST_IOCTL	DATA_TYPE_STRING	(optional)
1121ce1577b0SDave Eddy  *		ZFS_EV_HIST_DSNAME	DATA_TYPE_STRING	(optional)
1122ce1577b0SDave Eddy  *		ZFS_EV_HIST_DSID	DATA_TYPE_UINT64	(optional)
1123ce1577b0SDave Eddy  *
1124ce1577b0SDave Eddy  * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the
1125ce1577b0SDave Eddy  * history log nvlist.  The keynames will be free of any spaces or other
1126ce1577b0SDave Eddy  * characters that could be potentially unexpected to consumers of the
1127ce1577b0SDave Eddy  * sysevents.
11283d7072f8Seschrock  */
11293d7072f8Seschrock #define	ZFS_EV_POOL_NAME	"pool_name"
11303d7072f8Seschrock #define	ZFS_EV_POOL_GUID	"pool_guid"
11313d7072f8Seschrock #define	ZFS_EV_VDEV_PATH	"vdev_path"
11323d7072f8Seschrock #define	ZFS_EV_VDEV_GUID	"vdev_guid"
1133ce1577b0SDave Eddy #define	ZFS_EV_HIST_TIME	"history_time"
1134ce1577b0SDave Eddy #define	ZFS_EV_HIST_CMD		"history_command"
1135ce1577b0SDave Eddy #define	ZFS_EV_HIST_WHO		"history_who"
1136ce1577b0SDave Eddy #define	ZFS_EV_HIST_ZONE	"history_zone"
1137ce1577b0SDave Eddy #define	ZFS_EV_HIST_HOST	"history_hostname"
1138ce1577b0SDave Eddy #define	ZFS_EV_HIST_TXG		"history_txg"
1139ce1577b0SDave Eddy #define	ZFS_EV_HIST_INT_EVENT	"history_internal_event"
1140ce1577b0SDave Eddy #define	ZFS_EV_HIST_INT_STR	"history_internal_str"
1141ce1577b0SDave Eddy #define	ZFS_EV_HIST_INT_NAME	"history_internal_name"
1142ce1577b0SDave Eddy #define	ZFS_EV_HIST_IOCTL	"history_ioctl"
1143ce1577b0SDave Eddy #define	ZFS_EV_HIST_DSNAME	"history_dsname"
1144ce1577b0SDave Eddy #define	ZFS_EV_HIST_DSID	"history_dsid"
11453d7072f8Seschrock 
1146fa9e4066Sahrens #ifdef	__cplusplus
1147fa9e4066Sahrens }
1148fa9e4066Sahrens #endif
1149fa9e4066Sahrens 
1150fa9e4066Sahrens #endif	/* _SYS_FS_ZFS_H */
1151