xref: /illumos-gate/usr/src/uts/common/sys/fs/zfs.h (revision ce1577b04976f1d8bb5f235b6eaaab15b46a3068)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5441d80aaSlling  * Common Development and Distribution License (the "License").
6441d80aaSlling  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21f94275ceSAdam Leventhal 
22fa9e4066Sahrens /*
2327dd1e87SMark Shellenbaum  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24edf345e6SMatthew Ahrens  * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
25e9103aaeSGarrett D'Amore  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
26c3d26abcSMatthew Ahrens  * Copyright (c) 2014 Integros [integros.com]
27*ce1577b0SDave Eddy  * Copyright 2017 Joyent, Inc.
28fa9e4066Sahrens  */
29fa9e4066Sahrens 
3055da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */
3155da60b9SMark J Musante 
32fa9e4066Sahrens #ifndef	_SYS_FS_ZFS_H
33fa9e4066Sahrens #define	_SYS_FS_ZFS_H
34fa9e4066Sahrens 
35842727c2SChris Kirby #include <sys/time.h>
36842727c2SChris Kirby 
37fa9e4066Sahrens #ifdef	__cplusplus
38fa9e4066Sahrens extern "C" {
39fa9e4066Sahrens #endif
40fa9e4066Sahrens 
41fa9e4066Sahrens /*
42fa9e4066Sahrens  * Types and constants shared between userland and the kernel.
43fa9e4066Sahrens  */
44fa9e4066Sahrens 
45fa9e4066Sahrens /*
46fa9e4066Sahrens  * Each dataset can be one of the following types.  These constants can be
47fa9e4066Sahrens  * combined into masks that can be passed to various functions.
48fa9e4066Sahrens  */
49fa9e4066Sahrens typedef enum {
5078f17100SMatthew Ahrens 	ZFS_TYPE_FILESYSTEM	= (1 << 0),
5178f17100SMatthew Ahrens 	ZFS_TYPE_SNAPSHOT	= (1 << 1),
5278f17100SMatthew Ahrens 	ZFS_TYPE_VOLUME		= (1 << 2),
5378f17100SMatthew Ahrens 	ZFS_TYPE_POOL		= (1 << 3),
5478f17100SMatthew Ahrens 	ZFS_TYPE_BOOKMARK	= (1 << 4)
55fa9e4066Sahrens } zfs_type_t;
56fa9e4066Sahrens 
5726455f9eSAndriy Gapon /*
5826455f9eSAndriy Gapon  * NB: lzc_dataset_type should be updated whenever a new objset type is added,
5926455f9eSAndriy Gapon  * if it represents a real type of a dataset that can be created from userland.
6026455f9eSAndriy Gapon  */
614445fffbSMatthew Ahrens typedef enum dmu_objset_type {
624445fffbSMatthew Ahrens 	DMU_OST_NONE,
634445fffbSMatthew Ahrens 	DMU_OST_META,
644445fffbSMatthew Ahrens 	DMU_OST_ZFS,
654445fffbSMatthew Ahrens 	DMU_OST_ZVOL,
664445fffbSMatthew Ahrens 	DMU_OST_OTHER,			/* For testing only! */
674445fffbSMatthew Ahrens 	DMU_OST_ANY,			/* Be careful! */
684445fffbSMatthew Ahrens 	DMU_OST_NUMTYPES
694445fffbSMatthew Ahrens } dmu_objset_type_t;
704445fffbSMatthew Ahrens 
71990b4856Slling #define	ZFS_TYPE_DATASET	\
72fa9e4066Sahrens 	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
73fa9e4066Sahrens 
749adfa60dSMatthew Ahrens /*
759adfa60dSMatthew Ahrens  * All of these include the terminating NUL byte.
769adfa60dSMatthew Ahrens  */
77478ed9adSEric Taylor #define	ZAP_MAXNAMELEN 256
78478ed9adSEric Taylor #define	ZAP_MAXVALUELEN (1024 * 8)
79478ed9adSEric Taylor #define	ZAP_OLDMAXVALUELEN 1024
809adfa60dSMatthew Ahrens #define	ZFS_MAX_DATASET_NAME_LEN 256
81478ed9adSEric Taylor 
82fa9e4066Sahrens /*
83990b4856Slling  * Dataset properties are identified by these constants and must be added to
84990b4856Slling  * the end of this list to ensure that external consumers are not affected
85990b4856Slling  * by the change. If you make any changes to this list, be sure to update
8666e2aaccSgw  * the property table in usr/src/common/zfs/zfs_prop.c.
87fa9e4066Sahrens  */
88fa9e4066Sahrens typedef enum {
89c16bcc45SIgor Kozhukhov 	ZFS_PROP_BAD = -1,
90c16bcc45SIgor Kozhukhov 	ZFS_PROP_TYPE = 0,
91fa9e4066Sahrens 	ZFS_PROP_CREATION,
92fa9e4066Sahrens 	ZFS_PROP_USED,
93fa9e4066Sahrens 	ZFS_PROP_AVAILABLE,
94fa9e4066Sahrens 	ZFS_PROP_REFERENCED,
95fa9e4066Sahrens 	ZFS_PROP_COMPRESSRATIO,
96fa9e4066Sahrens 	ZFS_PROP_MOUNTED,
97fa9e4066Sahrens 	ZFS_PROP_ORIGIN,
98fa9e4066Sahrens 	ZFS_PROP_QUOTA,
99fa9e4066Sahrens 	ZFS_PROP_RESERVATION,
100fa9e4066Sahrens 	ZFS_PROP_VOLSIZE,
101fa9e4066Sahrens 	ZFS_PROP_VOLBLOCKSIZE,
102fa9e4066Sahrens 	ZFS_PROP_RECORDSIZE,
103fa9e4066Sahrens 	ZFS_PROP_MOUNTPOINT,
104fa9e4066Sahrens 	ZFS_PROP_SHARENFS,
105fa9e4066Sahrens 	ZFS_PROP_CHECKSUM,
106fa9e4066Sahrens 	ZFS_PROP_COMPRESSION,
107fa9e4066Sahrens 	ZFS_PROP_ATIME,
108fa9e4066Sahrens 	ZFS_PROP_DEVICES,
109fa9e4066Sahrens 	ZFS_PROP_EXEC,
110fa9e4066Sahrens 	ZFS_PROP_SETUID,
111fa9e4066Sahrens 	ZFS_PROP_READONLY,
112fa9e4066Sahrens 	ZFS_PROP_ZONED,
113fa9e4066Sahrens 	ZFS_PROP_SNAPDIR,
114a3c49ce1SAlbert Lee 	ZFS_PROP_ACLMODE,
115fa9e4066Sahrens 	ZFS_PROP_ACLINHERIT,
11666e2aaccSgw 	ZFS_PROP_CREATETXG,		/* not exposed to the user */
11766e2aaccSgw 	ZFS_PROP_NAME,			/* not exposed to the user */
118e9dbad6fSeschrock 	ZFS_PROP_CANMOUNT,
11966e2aaccSgw 	ZFS_PROP_ISCSIOPTIONS,		/* not exposed to the user */
1207b55fa8eSck 	ZFS_PROP_XATTR,
121d0ad202dSahrens 	ZFS_PROP_NUMCLONES,		/* not exposed to the user */
122b1b8ab34Slling 	ZFS_PROP_COPIES,
123e7437265Sahrens 	ZFS_PROP_VERSION,
124da6c28aaSamw 	ZFS_PROP_UTF8ONLY,
125da6c28aaSamw 	ZFS_PROP_NORMALIZE,
126da6c28aaSamw 	ZFS_PROP_CASE,
127da6c28aaSamw 	ZFS_PROP_VSCAN,
128da6c28aaSamw 	ZFS_PROP_NBMAND,
129da6c28aaSamw 	ZFS_PROP_SHARESMB,
130a9799022Sck 	ZFS_PROP_REFQUOTA,
131a9799022Sck 	ZFS_PROP_REFRESERVATION,
132c5904d13Seschrock 	ZFS_PROP_GUID,
1333baa08fcSek 	ZFS_PROP_PRIMARYCACHE,
1343baa08fcSek 	ZFS_PROP_SECONDARYCACHE,
13574e7dc98SMatthew Ahrens 	ZFS_PROP_USEDSNAP,
13674e7dc98SMatthew Ahrens 	ZFS_PROP_USEDDS,
13774e7dc98SMatthew Ahrens 	ZFS_PROP_USEDCHILD,
13874e7dc98SMatthew Ahrens 	ZFS_PROP_USEDREFRESERV,
13914843421SMatthew Ahrens 	ZFS_PROP_USERACCOUNTING,	/* not exposed to the user */
140478ed9adSEric Taylor 	ZFS_PROP_STMF_SHAREINFO,	/* not exposed to the user */
141842727c2SChris Kirby 	ZFS_PROP_DEFER_DESTROY,
142842727c2SChris Kirby 	ZFS_PROP_USERREFS,
143e09fa4daSNeil Perrin 	ZFS_PROP_LOGBIAS,
1441d713200SEric Schrock 	ZFS_PROP_UNIQUE,		/* not exposed to the user */
1451d713200SEric Schrock 	ZFS_PROP_OBJSETID,		/* not exposed to the user */
146b24ab676SJeff Bonwick 	ZFS_PROP_DEDUP,
1474201a95eSRic Aleshire 	ZFS_PROP_MLSLABEL,
14855da60b9SMark J Musante 	ZFS_PROP_SYNC,
149187d6ac0SMatt Ahrens 	ZFS_PROP_REFRATIO,
15019b94df9SMatthew Ahrens 	ZFS_PROP_WRITTEN,
15119b94df9SMatthew Ahrens 	ZFS_PROP_CLONES,
15277372cb0SMatthew Ahrens 	ZFS_PROP_LOGICALUSED,
15377372cb0SMatthew Ahrens 	ZFS_PROP_LOGICALREFERENCED,
154ca48f36fSKeith M Wesolowski 	ZFS_PROP_INCONSISTENT,		/* not exposed to the user */
155a2afb611SJerry Jelinek 	ZFS_PROP_FILESYSTEM_LIMIT,
156a2afb611SJerry Jelinek 	ZFS_PROP_SNAPSHOT_LIMIT,
157a2afb611SJerry Jelinek 	ZFS_PROP_FILESYSTEM_COUNT,
158a2afb611SJerry Jelinek 	ZFS_PROP_SNAPSHOT_COUNT,
159edf345e6SMatthew Ahrens 	ZFS_PROP_REDUNDANT_METADATA,
160b461c746SMatthew Ahrens 	ZFS_PROP_PREV_SNAP,
1619c3fd121SMatthew Ahrens 	ZFS_PROP_RECEIVE_RESUME_TOKEN,
16291ebeef5Sahrens 	ZFS_NUM_PROPS
163fa9e4066Sahrens } zfs_prop_t;
164fa9e4066Sahrens 
16514843421SMatthew Ahrens typedef enum {
16614843421SMatthew Ahrens 	ZFS_PROP_USERUSED,
16714843421SMatthew Ahrens 	ZFS_PROP_USERQUOTA,
16814843421SMatthew Ahrens 	ZFS_PROP_GROUPUSED,
16914843421SMatthew Ahrens 	ZFS_PROP_GROUPQUOTA,
17014843421SMatthew Ahrens 	ZFS_NUM_USERQUOTA_PROPS
17114843421SMatthew Ahrens } zfs_userquota_prop_t;
17214843421SMatthew Ahrens 
17314843421SMatthew Ahrens extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
17414843421SMatthew Ahrens 
175990b4856Slling /*
176990b4856Slling  * Pool properties are identified by these constants and must be added to the
177b87f3af3Sperrin  * end of this list to ensure that external consumers are not affected
178990b4856Slling  * by the change. If you make any changes to this list, be sure to update
179990b4856Slling  * the property table in usr/src/common/zfs/zpool_prop.c.
180990b4856Slling  */
181990b4856Slling typedef enum {
182990b4856Slling 	ZPOOL_PROP_NAME,
183990b4856Slling 	ZPOOL_PROP_SIZE,
184990b4856Slling 	ZPOOL_PROP_CAPACITY,
185990b4856Slling 	ZPOOL_PROP_ALTROOT,
186990b4856Slling 	ZPOOL_PROP_HEALTH,
187990b4856Slling 	ZPOOL_PROP_GUID,
188990b4856Slling 	ZPOOL_PROP_VERSION,
189990b4856Slling 	ZPOOL_PROP_BOOTFS,
190990b4856Slling 	ZPOOL_PROP_DELEGATION,
191990b4856Slling 	ZPOOL_PROP_AUTOREPLACE,
1922f8aaab3Seschrock 	ZPOOL_PROP_CACHEFILE,
1930a4e9518Sgw 	ZPOOL_PROP_FAILUREMODE,
194d5b5bb25SRich Morris 	ZPOOL_PROP_LISTSNAPS,
195573ca77eSGeorge Wilson 	ZPOOL_PROP_AUTOEXPAND,
196b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPDITTO,
197b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPRATIO,
198485bbbf5SGeorge Wilson 	ZPOOL_PROP_FREE,
199485bbbf5SGeorge Wilson 	ZPOOL_PROP_ALLOCATED,
200f9af39baSGeorge Wilson 	ZPOOL_PROP_READONLY,
2018704186eSDan McDonald 	ZPOOL_PROP_COMMENT,
2024263d13fSGeorge Wilson 	ZPOOL_PROP_EXPANDSZ,
203ad135b5dSChristopher Siden 	ZPOOL_PROP_FREEING,
2042e4c9986SGeorge Wilson 	ZPOOL_PROP_FRAGMENTATION,
2057fd05ac4SMatthew Ahrens 	ZPOOL_PROP_LEAKED,
206b5152584SMatthew Ahrens 	ZPOOL_PROP_MAXBLOCKSIZE,
2077855d95bSToomas Soome 	ZPOOL_PROP_BOOTSIZE,
208990b4856Slling 	ZPOOL_NUM_PROPS
209990b4856Slling } zpool_prop_t;
210b1b8ab34Slling 
2118704186eSDan McDonald /* Small enough to not hog a whole line of printout in zpool(1M). */
2128704186eSDan McDonald #define	ZPROP_MAX_COMMENT	32
2138704186eSDan McDonald 
214990b4856Slling #define	ZPROP_CONT		-2
215990b4856Slling #define	ZPROP_INVAL		-1
2163d7072f8Seschrock 
217990b4856Slling #define	ZPROP_VALUE		"value"
218990b4856Slling #define	ZPROP_SOURCE		"source"
2197f7322feSeschrock 
220b1b8ab34Slling typedef enum {
221990b4856Slling 	ZPROP_SRC_NONE = 0x1,
222990b4856Slling 	ZPROP_SRC_DEFAULT = 0x2,
223990b4856Slling 	ZPROP_SRC_TEMPORARY = 0x4,
224990b4856Slling 	ZPROP_SRC_LOCAL = 0x8,
22592241e0bSTom Erickson 	ZPROP_SRC_INHERITED = 0x10,
22692241e0bSTom Erickson 	ZPROP_SRC_RECEIVED = 0x20
227990b4856Slling } zprop_source_t;
228990b4856Slling 
22992241e0bSTom Erickson #define	ZPROP_SRC_ALL	0x3f
23092241e0bSTom Erickson 
23192241e0bSTom Erickson #define	ZPROP_SOURCE_VAL_RECVD	"$recvd"
23292241e0bSTom Erickson #define	ZPROP_N_MORE_ERRORS	"N_MORE_ERRORS"
23392241e0bSTom Erickson /*
23492241e0bSTom Erickson  * Dataset flag implemented as a special entry in the props zap object
23592241e0bSTom Erickson  * indicating that the dataset has received properties on or after
23692241e0bSTom Erickson  * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
23792241e0bSTom Erickson  * just as it did in earlier versions, and thereafter, local properties are
23892241e0bSTom Erickson  * preserved.
23992241e0bSTom Erickson  */
24092241e0bSTom Erickson #define	ZPROP_HAS_RECVD		"$hasrecvd"
24192241e0bSTom Erickson 
24292241e0bSTom Erickson typedef enum {
24392241e0bSTom Erickson 	ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
24492241e0bSTom Erickson 	ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
24592241e0bSTom Erickson } zprop_errflags_t;
246990b4856Slling 
247990b4856Slling typedef int (*zprop_func)(int, void *);
248990b4856Slling 
2490a48a24eStimh /*
2500a48a24eStimh  * Properties to be set on the root file system of a new pool
2510a48a24eStimh  * are stuffed into their own nvlist, which is then included in
2520a48a24eStimh  * the properties nvlist with the pool properties.
2530a48a24eStimh  */
2540a48a24eStimh #define	ZPOOL_ROOTFS_PROPS	"root-props-nvl"
2550a48a24eStimh 
256990b4856Slling /*
257990b4856Slling  * Dataset property functions shared between libzfs and kernel.
258990b4856Slling  */
259990b4856Slling const char *zfs_prop_default_string(zfs_prop_t);
260990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t);
261990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t);
262990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t);
263da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t);
264990b4856Slling const char *zfs_prop_to_name(zfs_prop_t);
265990b4856Slling zfs_prop_t zfs_name_to_prop(const char *);
266990b4856Slling boolean_t zfs_prop_user(const char *);
26792241e0bSTom Erickson boolean_t zfs_prop_userquota(const char *);
26819b94df9SMatthew Ahrens boolean_t zfs_prop_written(const char *);
269990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
270990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
271b24ab676SJeff Bonwick uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
2724853e976Sgw boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
273b1b8ab34Slling 
274990b4856Slling /*
275990b4856Slling  * Pool property functions shared between libzfs and kernel.
276990b4856Slling  */
277990b4856Slling zpool_prop_t zpool_name_to_prop(const char *);
278990b4856Slling const char *zpool_prop_to_name(zpool_prop_t);
279990b4856Slling const char *zpool_prop_default_string(zpool_prop_t);
280990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t);
281990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t);
282ad135b5dSChristopher Siden boolean_t zpool_prop_feature(const char *);
283ad135b5dSChristopher Siden boolean_t zpool_prop_unsupported(const char *name);
284990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
285990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
286b24ab676SJeff Bonwick uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
287b1b8ab34Slling 
288990b4856Slling /*
289990b4856Slling  * Definitions for the Delegation.
290990b4856Slling  */
291ecd6cf80Smarks typedef enum {
292ecd6cf80Smarks 	ZFS_DELEG_WHO_UNKNOWN = 0,
293ecd6cf80Smarks 	ZFS_DELEG_USER = 'u',
294ecd6cf80Smarks 	ZFS_DELEG_USER_SETS = 'U',
295ecd6cf80Smarks 	ZFS_DELEG_GROUP = 'g',
296ecd6cf80Smarks 	ZFS_DELEG_GROUP_SETS = 'G',
297ecd6cf80Smarks 	ZFS_DELEG_EVERYONE = 'e',
298ecd6cf80Smarks 	ZFS_DELEG_EVERYONE_SETS = 'E',
299ecd6cf80Smarks 	ZFS_DELEG_CREATE = 'c',
300ecd6cf80Smarks 	ZFS_DELEG_CREATE_SETS = 'C',
301ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET = 's',
302ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET_SETS = 'S'
303ecd6cf80Smarks } zfs_deleg_who_type_t;
304ecd6cf80Smarks 
305ecd6cf80Smarks typedef enum {
306ecd6cf80Smarks 	ZFS_DELEG_NONE = 0,
307ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCAL = 1,
308ecd6cf80Smarks 	ZFS_DELEG_PERM_DESCENDENT = 2,
309ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
310ecd6cf80Smarks 	ZFS_DELEG_PERM_CREATE = 4
311ecd6cf80Smarks } zfs_deleg_inherit_t;
312ecd6cf80Smarks 
313ecd6cf80Smarks #define	ZFS_DELEG_PERM_UID	"uid"
314ecd6cf80Smarks #define	ZFS_DELEG_PERM_GID	"gid"
315ecd6cf80Smarks #define	ZFS_DELEG_PERM_GROUPS	"groups"
316ecd6cf80Smarks 
3174201a95eSRic Aleshire #define	ZFS_MLSLABEL_DEFAULT	"none"
3184201a95eSRic Aleshire 
319743a77edSAlan Wright #define	ZFS_SMB_ACL_SRC		"src"
320743a77edSAlan Wright #define	ZFS_SMB_ACL_TARGET	"target"
321743a77edSAlan Wright 
322a227b7f4Shs typedef enum {
323a227b7f4Shs 	ZFS_CANMOUNT_OFF = 0,
324a227b7f4Shs 	ZFS_CANMOUNT_ON = 1,
325a227b7f4Shs 	ZFS_CANMOUNT_NOAUTO = 2
326a227b7f4Shs } zfs_canmount_type_t;
327a227b7f4Shs 
328e09fa4daSNeil Perrin typedef enum {
329e09fa4daSNeil Perrin 	ZFS_LOGBIAS_LATENCY = 0,
330e09fa4daSNeil Perrin 	ZFS_LOGBIAS_THROUGHPUT = 1
331e09fa4daSNeil Perrin } zfs_logbias_op_t;
332e09fa4daSNeil Perrin 
333da6c28aaSamw typedef enum zfs_share_op {
334da6c28aaSamw 	ZFS_SHARE_NFS = 0,
335da6c28aaSamw 	ZFS_UNSHARE_NFS = 1,
336da6c28aaSamw 	ZFS_SHARE_SMB = 2,
337da6c28aaSamw 	ZFS_UNSHARE_SMB = 3
338da6c28aaSamw } zfs_share_op_t;
339da6c28aaSamw 
340743a77edSAlan Wright typedef enum zfs_smb_acl_op {
341743a77edSAlan Wright 	ZFS_SMB_ACL_ADD,
342743a77edSAlan Wright 	ZFS_SMB_ACL_REMOVE,
343743a77edSAlan Wright 	ZFS_SMB_ACL_RENAME,
344743a77edSAlan Wright 	ZFS_SMB_ACL_PURGE
345743a77edSAlan Wright } zfs_smb_acl_op_t;
346743a77edSAlan Wright 
3473baa08fcSek typedef enum zfs_cache_type {
3483baa08fcSek 	ZFS_CACHE_NONE = 0,
3493baa08fcSek 	ZFS_CACHE_METADATA = 1,
3503baa08fcSek 	ZFS_CACHE_ALL = 2
3513baa08fcSek } zfs_cache_type_t;
3523baa08fcSek 
35355da60b9SMark J Musante typedef enum {
35455da60b9SMark J Musante 	ZFS_SYNC_STANDARD = 0,
35555da60b9SMark J Musante 	ZFS_SYNC_ALWAYS = 1,
35655da60b9SMark J Musante 	ZFS_SYNC_DISABLED = 2
35755da60b9SMark J Musante } zfs_sync_type_t;
35855da60b9SMark J Musante 
359edf345e6SMatthew Ahrens typedef enum {
360edf345e6SMatthew Ahrens 	ZFS_REDUNDANT_METADATA_ALL,
361edf345e6SMatthew Ahrens 	ZFS_REDUNDANT_METADATA_MOST
362edf345e6SMatthew Ahrens } zfs_redundant_metadata_type_t;
3633baa08fcSek 
364eaca9bbdSeschrock /*
36599653d4eSeschrock  * On-disk version number.
366eaca9bbdSeschrock  */
367e7437265Sahrens #define	SPA_VERSION_1			1ULL
368e7437265Sahrens #define	SPA_VERSION_2			2ULL
369e7437265Sahrens #define	SPA_VERSION_3			3ULL
370e7437265Sahrens #define	SPA_VERSION_4			4ULL
371e7437265Sahrens #define	SPA_VERSION_5			5ULL
372e7437265Sahrens #define	SPA_VERSION_6			6ULL
373e7437265Sahrens #define	SPA_VERSION_7			7ULL
374e7437265Sahrens #define	SPA_VERSION_8			8ULL
375da6c28aaSamw #define	SPA_VERSION_9			9ULL
376fa94a07fSbrendan #define	SPA_VERSION_10			10ULL
377088f3894Sahrens #define	SPA_VERSION_11			11ULL
378bb0ade09Sahrens #define	SPA_VERSION_12			12ULL
37974e7dc98SMatthew Ahrens #define	SPA_VERSION_13			13ULL
380d0f3f37eSMark Shellenbaum #define	SPA_VERSION_14			14ULL
38114843421SMatthew Ahrens #define	SPA_VERSION_15			15ULL
382478ed9adSEric Taylor #define	SPA_VERSION_16			16ULL
383f94275ceSAdam Leventhal #define	SPA_VERSION_17			17ULL
384842727c2SChris Kirby #define	SPA_VERSION_18			18ULL
38588ecc943SGeorge Wilson #define	SPA_VERSION_19			19ULL
386b24ab676SJeff Bonwick #define	SPA_VERSION_20			20ULL
387b24ab676SJeff Bonwick #define	SPA_VERSION_21			21ULL
38892241e0bSTom Erickson #define	SPA_VERSION_22			22ULL
3896e1f5caaSNeil Perrin #define	SPA_VERSION_23			23ULL
3900a586ceaSMark Shellenbaum #define	SPA_VERSION_24			24ULL
3913f9d6ad7SLin Ling #define	SPA_VERSION_25			25ULL
392cde58dbcSMatthew Ahrens #define	SPA_VERSION_26			26ULL
3936e0cbcaaSMatthew Ahrens #define	SPA_VERSION_27			27ULL
394cb04b873SMark J Musante #define	SPA_VERSION_28			28ULL
395ad135b5dSChristopher Siden #define	SPA_VERSION_5000		5000ULL
396cb04b873SMark J Musante 
397b1b8ab34Slling /*
398e7cbe64fSgw  * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
399478ed9adSEric Taylor  * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
40014843421SMatthew Ahrens  * and do the appropriate changes.  Also bump the version number in
40114843421SMatthew Ahrens  * usr/src/grub/capability.
402b1b8ab34Slling  */
403ad135b5dSChristopher Siden #define	SPA_VERSION			SPA_VERSION_5000
404ad135b5dSChristopher Siden #define	SPA_VERSION_STRING		"5000"
40544cd46caSbillm 
40644cd46caSbillm /*
407e7437265Sahrens  * Symbolic names for the changes that caused a SPA_VERSION switch.
40844cd46caSbillm  * Used in the code when checking for presence or absence of a feature.
40944cd46caSbillm  * Feel free to define multiple symbolic names for each version if there
41044cd46caSbillm  * were multiple changes to on-disk structures during that version.
41144cd46caSbillm  *
412e7437265Sahrens  * NOTE: When checking the current SPA_VERSION in your code, be sure
41344cd46caSbillm  *       to use spa_version() since it reports the version of the
41444cd46caSbillm  *       last synced uberblock.  Checking the in-flight version can
41544cd46caSbillm  *       be dangerous in some cases.
41644cd46caSbillm  */
417e7437265Sahrens #define	SPA_VERSION_INITIAL		SPA_VERSION_1
418e7437265Sahrens #define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
419e7437265Sahrens #define	SPA_VERSION_SPARES		SPA_VERSION_3
420f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ2		SPA_VERSION_3
421cde58dbcSMatthew Ahrens #define	SPA_VERSION_BPOBJ_ACCOUNT	SPA_VERSION_3
422e7437265Sahrens #define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
423e7437265Sahrens #define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
424e7437265Sahrens #define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
425e7437265Sahrens #define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
426e7437265Sahrens #define	SPA_VERSION_BOOTFS		SPA_VERSION_6
427990b4856Slling #define	SPA_VERSION_SLOGS		SPA_VERSION_7
428990b4856Slling #define	SPA_VERSION_DELEGATED_PERMS	SPA_VERSION_8
429da6c28aaSamw #define	SPA_VERSION_FUID		SPA_VERSION_9
430a9799022Sck #define	SPA_VERSION_REFRESERVATION	SPA_VERSION_9
431a9799022Sck #define	SPA_VERSION_REFQUOTA		SPA_VERSION_9
432a9799022Sck #define	SPA_VERSION_UNIQUE_ACCURATE	SPA_VERSION_9
433fa94a07fSbrendan #define	SPA_VERSION_L2CACHE		SPA_VERSION_10
434088f3894Sahrens #define	SPA_VERSION_NEXT_CLONES		SPA_VERSION_11
435088f3894Sahrens #define	SPA_VERSION_ORIGIN		SPA_VERSION_11
436088f3894Sahrens #define	SPA_VERSION_DSL_SCRUB		SPA_VERSION_11
437bb0ade09Sahrens #define	SPA_VERSION_SNAP_PROPS		SPA_VERSION_12
43874e7dc98SMatthew Ahrens #define	SPA_VERSION_USED_BREAKDOWN	SPA_VERSION_13
439d0f3f37eSMark Shellenbaum #define	SPA_VERSION_PASSTHROUGH_X	SPA_VERSION_14
44014843421SMatthew Ahrens #define	SPA_VERSION_USERSPACE		SPA_VERSION_15
441478ed9adSEric Taylor #define	SPA_VERSION_STMF_PROP		SPA_VERSION_16
442f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ3		SPA_VERSION_17
443842727c2SChris Kirby #define	SPA_VERSION_USERREFS		SPA_VERSION_18
44488ecc943SGeorge Wilson #define	SPA_VERSION_HOLES		SPA_VERSION_19
445b24ab676SJeff Bonwick #define	SPA_VERSION_ZLE_COMPRESSION	SPA_VERSION_20
446b24ab676SJeff Bonwick #define	SPA_VERSION_DEDUP		SPA_VERSION_21
44792241e0bSTom Erickson #define	SPA_VERSION_RECVD_PROPS		SPA_VERSION_22
4486e1f5caaSNeil Perrin #define	SPA_VERSION_SLIM_ZIL		SPA_VERSION_23
4490a586ceaSMark Shellenbaum #define	SPA_VERSION_SA			SPA_VERSION_24
4503f9d6ad7SLin Ling #define	SPA_VERSION_SCAN		SPA_VERSION_25
451cde58dbcSMatthew Ahrens #define	SPA_VERSION_DIR_CLONES		SPA_VERSION_26
452cde58dbcSMatthew Ahrens #define	SPA_VERSION_DEADLISTS		SPA_VERSION_26
4536e0cbcaaSMatthew Ahrens #define	SPA_VERSION_FAST_SNAP		SPA_VERSION_27
454cb04b873SMark J Musante #define	SPA_VERSION_MULTI_REPLACE	SPA_VERSION_28
455ad135b5dSChristopher Siden #define	SPA_VERSION_BEFORE_FEATURES	SPA_VERSION_28
456ad135b5dSChristopher Siden #define	SPA_VERSION_FEATURES		SPA_VERSION_5000
457ad135b5dSChristopher Siden 
458ad135b5dSChristopher Siden #define	SPA_VERSION_IS_SUPPORTED(v) \
459ad135b5dSChristopher Siden 	(((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
460ad135b5dSChristopher Siden 	((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
461e7437265Sahrens 
462e7437265Sahrens /*
463e7437265Sahrens  * ZPL version - rev'd whenever an incompatible on-disk format change
464e7437265Sahrens  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
465e7437265Sahrens  * also update the version_table[] and help message in zfs_prop.c.
466e7437265Sahrens  *
467e7437265Sahrens  * When changing, be sure to teach GRUB how to read the new format!
468478ed9adSEric Taylor  * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
469e7437265Sahrens  */
470e7437265Sahrens #define	ZPL_VERSION_1			1ULL
471e7437265Sahrens #define	ZPL_VERSION_2			2ULL
472da6c28aaSamw #define	ZPL_VERSION_3			3ULL
47314843421SMatthew Ahrens #define	ZPL_VERSION_4			4ULL
4740a586ceaSMark Shellenbaum #define	ZPL_VERSION_5			5ULL
4750a586ceaSMark Shellenbaum #define	ZPL_VERSION			ZPL_VERSION_5
4760a586ceaSMark Shellenbaum #define	ZPL_VERSION_STRING		"5"
477e7437265Sahrens 
478e7437265Sahrens #define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
479e7437265Sahrens #define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
480da6c28aaSamw #define	ZPL_VERSION_FUID		ZPL_VERSION_3
481de8267e0Stimh #define	ZPL_VERSION_NORMALIZATION	ZPL_VERSION_3
482da6c28aaSamw #define	ZPL_VERSION_SYSATTR		ZPL_VERSION_3
48314843421SMatthew Ahrens #define	ZPL_VERSION_USERSPACE		ZPL_VERSION_4
4840a586ceaSMark Shellenbaum #define	ZPL_VERSION_SA			ZPL_VERSION_5
485eaca9bbdSeschrock 
486468c413aSTim Haley /* Rewind request information */
487c8ee1847SVictor Latushkin #define	ZPOOL_NO_REWIND		1  /* No policy - default behavior */
488c8ee1847SVictor Latushkin #define	ZPOOL_NEVER_REWIND	2  /* Do not search for best txg or rewind */
489c8ee1847SVictor Latushkin #define	ZPOOL_TRY_REWIND	4  /* Search for best txg, but do not rewind */
490c8ee1847SVictor Latushkin #define	ZPOOL_DO_REWIND		8  /* Rewind to best txg w/in deferred frees */
491c8ee1847SVictor Latushkin #define	ZPOOL_EXTREME_REWIND	16 /* Allow extreme measures to find best txg */
492c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_MASK	28 /* All the possible rewind bits */
493c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_POLICIES	31 /* All the possible policy bits */
494468c413aSTim Haley 
495468c413aSTim Haley typedef struct zpool_rewind_policy {
496468c413aSTim Haley 	uint32_t	zrp_request;	/* rewind behavior requested */
497c8ee1847SVictor Latushkin 	uint64_t	zrp_maxmeta;	/* max acceptable meta-data errors */
498c8ee1847SVictor Latushkin 	uint64_t	zrp_maxdata;	/* max acceptable data errors */
499468c413aSTim Haley 	uint64_t	zrp_txg;	/* specific txg to load */
500468c413aSTim Haley } zpool_rewind_policy_t;
501468c413aSTim Haley 
502fa9e4066Sahrens /*
503fa9e4066Sahrens  * The following are configuration names used in the nvlist describing a pool's
504fa9e4066Sahrens  * configuration.
505fa9e4066Sahrens  */
506fa9e4066Sahrens #define	ZPOOL_CONFIG_VERSION		"version"
507fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_NAME		"name"
508fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_STATE		"state"
509fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_TXG		"txg"
510fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
511fa9e4066Sahrens #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
512fa9e4066Sahrens #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
513fa9e4066Sahrens #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
514fa9e4066Sahrens #define	ZPOOL_CONFIG_TYPE		"type"
515fa9e4066Sahrens #define	ZPOOL_CONFIG_CHILDREN		"children"
516fa9e4066Sahrens #define	ZPOOL_CONFIG_ID			"id"
517fa9e4066Sahrens #define	ZPOOL_CONFIG_GUID		"guid"
518fa9e4066Sahrens #define	ZPOOL_CONFIG_PATH		"path"
519fa9e4066Sahrens #define	ZPOOL_CONFIG_DEVID		"devid"
520fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
521fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
522fa9e4066Sahrens #define	ZPOOL_CONFIG_ASHIFT		"ashift"
523fa9e4066Sahrens #define	ZPOOL_CONFIG_ASIZE		"asize"
524fa9e4066Sahrens #define	ZPOOL_CONFIG_DTL		"DTL"
5253f9d6ad7SLin Ling #define	ZPOOL_CONFIG_SCAN_STATS		"scan_stats"	/* not stored on disk */
5263f9d6ad7SLin Ling #define	ZPOOL_CONFIG_VDEV_STATS		"vdev_stats"	/* not stored on disk */
527afefbcddSeschrock #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
528ea8dc4b6Seschrock #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
529ea8dc4b6Seschrock #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
53099653d4eSeschrock #define	ZPOOL_CONFIG_SPARES		"spares"
53199653d4eSeschrock #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
53299653d4eSeschrock #define	ZPOOL_CONFIG_NPARITY		"nparity"
53395173954Sek #define	ZPOOL_CONFIG_HOSTID		"hostid"
53495173954Sek #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
53511027bc7STim Haley #define	ZPOOL_CONFIG_LOADED_TIME	"initial_load_time"
5363d7072f8Seschrock #define	ZPOOL_CONFIG_UNSPARE		"unspare"
5373d7072f8Seschrock #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
5388654d025Sperrin #define	ZPOOL_CONFIG_IS_LOG		"is_log"
539fa94a07fSbrendan #define	ZPOOL_CONFIG_L2CACHE		"l2cache"
54088ecc943SGeorge Wilson #define	ZPOOL_CONFIG_HOLE_ARRAY		"hole_array"
54188ecc943SGeorge Wilson #define	ZPOOL_CONFIG_VDEV_CHILDREN	"vdev_children"
54288ecc943SGeorge Wilson #define	ZPOOL_CONFIG_IS_HOLE		"is_hole"
5439eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_HISTOGRAM	"ddt_histogram"
5449eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_OBJ_STATS	"ddt_object_stats"
5459eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_STATS		"ddt_stats"
5461195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT		"splitcfg"
5471195e687SMark J Musante #define	ZPOOL_CONFIG_ORIG_GUID		"orig_guid"
5481195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_GUID		"split_guid"
5491195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_LIST		"guid_list"
5503f9d6ad7SLin Ling #define	ZPOOL_CONFIG_REMOVING		"removing"
551b4952e17SGeorge Wilson #define	ZPOOL_CONFIG_RESILVER_TXG	"resilver_txg"
5528704186eSDan McDonald #define	ZPOOL_CONFIG_COMMENT		"comment"
553e14bb325SJeff Bonwick #define	ZPOOL_CONFIG_SUSPENDED		"suspended"	/* not stored on disk */
554e7cbe64fSgw #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp"	/* not stored on disk */
555e7cbe64fSgw #define	ZPOOL_CONFIG_BOOTFS		"bootfs"	/* not stored on disk */
5564b964adaSGeorge Wilson #define	ZPOOL_CONFIG_MISSING_DEVICES	"missing_vdevs"	/* not stored on disk */
5574b964adaSGeorge Wilson #define	ZPOOL_CONFIG_LOAD_INFO		"load_info"	/* not stored on disk */
558ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_REWIND_INFO	"rewind_info"	/* not stored on disk */
559ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_UNSUP_FEAT		"unsup_feat"	/* not stored on disk */
56057221772SChristopher Siden #define	ZPOOL_CONFIG_ENABLED_FEAT	"enabled_feat"	/* not stored on disk */
561ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_CAN_RDONLY		"can_rdonly"	/* not stored on disk */
562ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_FEATURES_FOR_READ	"features_for_read"
563ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_FEATURE_STATS	"feature_stats"	/* not stored on disk */
564215198a6SJoe Stein #define	ZPOOL_CONFIG_VDEV_TOP_ZAP	"com.delphix:vdev_zap_top"
565215198a6SJoe Stein #define	ZPOOL_CONFIG_VDEV_LEAF_ZAP	"com.delphix:vdev_zap_leaf"
566215198a6SJoe Stein #define	ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS	"com.delphix:has_per_vdev_zaps"
5673d7072f8Seschrock /*
5683d7072f8Seschrock  * The persistent vdev state is stored as separate values rather than a single
5693d7072f8Seschrock  * 'vdev_state' entry.  This is because a device can be in multiple states, such
5703d7072f8Seschrock  * as offline and degraded.
5713d7072f8Seschrock  */
5723d7072f8Seschrock #define	ZPOOL_CONFIG_OFFLINE		"offline"
5733d7072f8Seschrock #define	ZPOOL_CONFIG_FAULTED		"faulted"
5743d7072f8Seschrock #define	ZPOOL_CONFIG_DEGRADED		"degraded"
5753d7072f8Seschrock #define	ZPOOL_CONFIG_REMOVED		"removed"
5766809eb4eSEric Schrock #define	ZPOOL_CONFIG_FRU		"fru"
577069f55e2SEric Schrock #define	ZPOOL_CONFIG_AUX_STATE		"aux_state"
578fa9e4066Sahrens 
579468c413aSTim Haley /* Rewind policy parameters */
580468c413aSTim Haley #define	ZPOOL_REWIND_POLICY		"rewind-policy"
581468c413aSTim Haley #define	ZPOOL_REWIND_REQUEST		"rewind-request"
582468c413aSTim Haley #define	ZPOOL_REWIND_REQUEST_TXG	"rewind-request-txg"
583468c413aSTim Haley #define	ZPOOL_REWIND_META_THRESH	"rewind-meta-thresh"
584468c413aSTim Haley #define	ZPOOL_REWIND_DATA_THRESH	"rewind-data-thresh"
585468c413aSTim Haley 
586468c413aSTim Haley /* Rewind data discovered */
587468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_TIME		"rewind_txg_ts"
588468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_DATA_ERRORS	"verify_data_errors"
589468c413aSTim Haley #define	ZPOOL_CONFIG_REWIND_TIME	"seconds_of_rewind"
590468c413aSTim Haley 
591fa9e4066Sahrens #define	VDEV_TYPE_ROOT			"root"
592fa9e4066Sahrens #define	VDEV_TYPE_MIRROR		"mirror"
593fa9e4066Sahrens #define	VDEV_TYPE_REPLACING		"replacing"
594fa9e4066Sahrens #define	VDEV_TYPE_RAIDZ			"raidz"
595fa9e4066Sahrens #define	VDEV_TYPE_DISK			"disk"
596fa9e4066Sahrens #define	VDEV_TYPE_FILE			"file"
597fa9e4066Sahrens #define	VDEV_TYPE_MISSING		"missing"
59888ecc943SGeorge Wilson #define	VDEV_TYPE_HOLE			"hole"
59999653d4eSeschrock #define	VDEV_TYPE_SPARE			"spare"
6008654d025Sperrin #define	VDEV_TYPE_LOG			"log"
601fa94a07fSbrendan #define	VDEV_TYPE_L2CACHE		"l2cache"
602fa9e4066Sahrens 
603fa9e4066Sahrens /*
604fa9e4066Sahrens  * This is needed in userland to report the minimum necessary device size.
6054b5c8e93SMatthew Ahrens  *
6064b5c8e93SMatthew Ahrens  * Note that the zfs test suite uses 64MB vdevs.
607fa9e4066Sahrens  */
608fa9e4066Sahrens #define	SPA_MINDEVSIZE		(64ULL << 20)
609fa9e4066Sahrens 
6102e4c9986SGeorge Wilson /*
6112e4c9986SGeorge Wilson  * Set if the fragmentation has not yet been calculated. This can happen
6122e4c9986SGeorge Wilson  * because the space maps have not been upgraded or the histogram feature
6132e4c9986SGeorge Wilson  * is not enabled.
6142e4c9986SGeorge Wilson  */
6152e4c9986SGeorge Wilson #define	ZFS_FRAG_INVALID	UINT64_MAX
6162e4c9986SGeorge Wilson 
617fa9e4066Sahrens /*
618fa9e4066Sahrens  * The location of the pool configuration repository, shared between kernel and
619fa9e4066Sahrens  * userland.
620fa9e4066Sahrens  */
621c5904d13Seschrock #define	ZPOOL_CACHE		"/etc/zfs/zpool.cache"
622fa9e4066Sahrens 
623fa9e4066Sahrens /*
624fa9e4066Sahrens  * vdev states are ordered from least to most healthy.
625fa9e4066Sahrens  * A vdev that's CANT_OPEN or below is considered unusable.
626fa9e4066Sahrens  */
627fa9e4066Sahrens typedef enum vdev_state {
628fa9e4066Sahrens 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
629fa9e4066Sahrens 	VDEV_STATE_CLOSED,	/* Not currently open			*/
630fa9e4066Sahrens 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
6313d7072f8Seschrock 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
632fa9e4066Sahrens 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
6333d7072f8Seschrock 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
634fa9e4066Sahrens 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
635fa9e4066Sahrens 	VDEV_STATE_HEALTHY	/* Presumed good			*/
636fa9e4066Sahrens } vdev_state_t;
637fa9e4066Sahrens 
6383d7072f8Seschrock #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
6393d7072f8Seschrock 
640fa9e4066Sahrens /*
641fa9e4066Sahrens  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
642fa9e4066Sahrens  * of the vdev stats structure uses these constants to distinguish why.
643fa9e4066Sahrens  */
644fa9e4066Sahrens typedef enum vdev_aux {
645fa9e4066Sahrens 	VDEV_AUX_NONE,		/* no error				*/
646fa9e4066Sahrens 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
647fa9e4066Sahrens 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
648fa9e4066Sahrens 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
649fa9e4066Sahrens 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
650fa9e4066Sahrens 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
651eaca9bbdSeschrock 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
652eaca9bbdSeschrock 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
65399653d4eSeschrock 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
654ad135b5dSChristopher Siden 	VDEV_AUX_UNSUP_FEAT,	/* unsupported features			*/
6553d7072f8Seschrock 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
65632b87932Sek 	VDEV_AUX_ERR_EXCEEDED,	/* too many errors			*/
657b87f3af3Sperrin 	VDEV_AUX_IO_FAILURE,	/* experienced I/O failure		*/
658069f55e2SEric Schrock 	VDEV_AUX_BAD_LOG,	/* cannot read log chain(s)		*/
6591195e687SMark J Musante 	VDEV_AUX_EXTERNAL,	/* external diagnosis			*/
6601195e687SMark J Musante 	VDEV_AUX_SPLIT_POOL	/* vdev was split off into another pool	*/
661fa9e4066Sahrens } vdev_aux_t;
662fa9e4066Sahrens 
663fa9e4066Sahrens /*
66446a2abf2Seschrock  * pool state.  The following states are written to disk as part of the normal
665fa94a07fSbrendan  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
666fa94a07fSbrendan  * states are software abstractions used at various levels to communicate
667fa94a07fSbrendan  * pool state.
668fa9e4066Sahrens  */
669fa9e4066Sahrens typedef enum pool_state {
670fa9e4066Sahrens 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
671fa9e4066Sahrens 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
672fa9e4066Sahrens 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
67399653d4eSeschrock 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
674fa94a07fSbrendan 	POOL_STATE_L2CACHE,		/* Level 2 ARC device		*/
675fa9e4066Sahrens 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
67646a2abf2Seschrock 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
67746a2abf2Seschrock 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
678fa9e4066Sahrens } pool_state_t;
679fa9e4066Sahrens 
680fa9e4066Sahrens /*
6813f9d6ad7SLin Ling  * Scan Functions.
682fa9e4066Sahrens  */
6833f9d6ad7SLin Ling typedef enum pool_scan_func {
6843f9d6ad7SLin Ling 	POOL_SCAN_NONE,
6853f9d6ad7SLin Ling 	POOL_SCAN_SCRUB,
6863f9d6ad7SLin Ling 	POOL_SCAN_RESILVER,
6873f9d6ad7SLin Ling 	POOL_SCAN_FUNCS
6883f9d6ad7SLin Ling } pool_scan_func_t;
689fa9e4066Sahrens 
690fa9e4066Sahrens /*
691fa9e4066Sahrens  * ZIO types.  Needed to interpret vdev statistics below.
692fa9e4066Sahrens  */
693fa9e4066Sahrens typedef enum zio_type {
694fa9e4066Sahrens 	ZIO_TYPE_NULL = 0,
695fa9e4066Sahrens 	ZIO_TYPE_READ,
696fa9e4066Sahrens 	ZIO_TYPE_WRITE,
697fa9e4066Sahrens 	ZIO_TYPE_FREE,
698fa9e4066Sahrens 	ZIO_TYPE_CLAIM,
699fa9e4066Sahrens 	ZIO_TYPE_IOCTL,
700fa9e4066Sahrens 	ZIO_TYPES
701fa9e4066Sahrens } zio_type_t;
702fa9e4066Sahrens 
7033f9d6ad7SLin Ling /*
7043f9d6ad7SLin Ling  * Pool statistics.  Note: all fields should be 64-bit because this
7053f9d6ad7SLin Ling  * is passed between kernel and userland as an nvlist uint64 array.
7063f9d6ad7SLin Ling  */
7073f9d6ad7SLin Ling typedef struct pool_scan_stat {
7083f9d6ad7SLin Ling 	/* values stored on disk */
7093f9d6ad7SLin Ling 	uint64_t	pss_func;	/* pool_scan_func_t */
7103f9d6ad7SLin Ling 	uint64_t	pss_state;	/* dsl_scan_state_t */
7113f9d6ad7SLin Ling 	uint64_t	pss_start_time;	/* scan start time */
7123f9d6ad7SLin Ling 	uint64_t	pss_end_time;	/* scan end time */
7133f9d6ad7SLin Ling 	uint64_t	pss_to_examine;	/* total bytes to scan */
7143f9d6ad7SLin Ling 	uint64_t	pss_examined;	/* total examined bytes	*/
7153f9d6ad7SLin Ling 	uint64_t	pss_to_process; /* total bytes to process */
7163f9d6ad7SLin Ling 	uint64_t	pss_processed;	/* total processed bytes */
7173f9d6ad7SLin Ling 	uint64_t	pss_errors;	/* scan errors	*/
7183f9d6ad7SLin Ling 
7193f9d6ad7SLin Ling 	/* values not stored on disk */
7203f9d6ad7SLin Ling 	uint64_t	pss_pass_exam;	/* examined bytes per scan pass */
7213f9d6ad7SLin Ling 	uint64_t	pss_pass_start;	/* start time of a scan pass */
7223f9d6ad7SLin Ling } pool_scan_stat_t;
7233f9d6ad7SLin Ling 
7243f9d6ad7SLin Ling typedef enum dsl_scan_state {
7253f9d6ad7SLin Ling 	DSS_NONE,
7263f9d6ad7SLin Ling 	DSS_SCANNING,
7273f9d6ad7SLin Ling 	DSS_FINISHED,
7283f9d6ad7SLin Ling 	DSS_CANCELED,
7293f9d6ad7SLin Ling 	DSS_NUM_STATES
7303f9d6ad7SLin Ling } dsl_scan_state_t;
7313f9d6ad7SLin Ling 
7323f9d6ad7SLin Ling 
733fa9e4066Sahrens /*
734fa9e4066Sahrens  * Vdev statistics.  Note: all fields should be 64-bit because this
735fa9e4066Sahrens  * is passed between kernel and userland as an nvlist uint64 array.
736fa9e4066Sahrens  */
737fa9e4066Sahrens typedef struct vdev_stat {
738fa9e4066Sahrens 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
739fa9e4066Sahrens 	uint64_t	vs_state;		/* vdev state		*/
740fa9e4066Sahrens 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
741fa9e4066Sahrens 	uint64_t	vs_alloc;		/* space allocated	*/
742fa9e4066Sahrens 	uint64_t	vs_space;		/* total capacity	*/
74399653d4eSeschrock 	uint64_t	vs_dspace;		/* deflated capacity	*/
7442a79c5feSlling 	uint64_t	vs_rsize;		/* replaceable dev size */
7454263d13fSGeorge Wilson 	uint64_t	vs_esize;		/* expandable dev size */
746fa9e4066Sahrens 	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
747fa9e4066Sahrens 	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
748fa9e4066Sahrens 	uint64_t	vs_read_errors;		/* read errors		*/
749fa9e4066Sahrens 	uint64_t	vs_write_errors;	/* write errors		*/
750fa9e4066Sahrens 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
751fa9e4066Sahrens 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
7523f9d6ad7SLin Ling 	uint64_t	vs_scan_removing;	/* removing?	*/
7533f9d6ad7SLin Ling 	uint64_t	vs_scan_processed;	/* scan processed bytes	*/
7542e4c9986SGeorge Wilson 	uint64_t	vs_fragmentation;	/* device fragmentation */
755fa9e4066Sahrens } vdev_stat_t;
756fa9e4066Sahrens 
7579eb19f4dSGeorge Wilson /*
7589eb19f4dSGeorge Wilson  * DDT statistics.  Note: all fields should be 64-bit because this
7599eb19f4dSGeorge Wilson  * is passed between kernel and userland as an nvlist uint64 array.
7609eb19f4dSGeorge Wilson  */
7619eb19f4dSGeorge Wilson typedef struct ddt_object {
7629eb19f4dSGeorge Wilson 	uint64_t	ddo_count;	/* number of elments in ddt 	*/
7639eb19f4dSGeorge Wilson 	uint64_t	ddo_dspace;	/* size of ddt on disk		*/
7649eb19f4dSGeorge Wilson 	uint64_t	ddo_mspace;	/* size of ddt in-core		*/
7659eb19f4dSGeorge Wilson } ddt_object_t;
7669eb19f4dSGeorge Wilson 
7679eb19f4dSGeorge Wilson typedef struct ddt_stat {
7689eb19f4dSGeorge Wilson 	uint64_t	dds_blocks;	/* blocks			*/
7699eb19f4dSGeorge Wilson 	uint64_t	dds_lsize;	/* logical size			*/
7709eb19f4dSGeorge Wilson 	uint64_t	dds_psize;	/* physical size		*/
7719eb19f4dSGeorge Wilson 	uint64_t	dds_dsize;	/* deflated allocated size	*/
7729eb19f4dSGeorge Wilson 	uint64_t	dds_ref_blocks;	/* referenced blocks		*/
7739eb19f4dSGeorge Wilson 	uint64_t	dds_ref_lsize;	/* referenced lsize * refcnt	*/
7749eb19f4dSGeorge Wilson 	uint64_t	dds_ref_psize;	/* referenced psize * refcnt	*/
7759eb19f4dSGeorge Wilson 	uint64_t	dds_ref_dsize;	/* referenced dsize * refcnt	*/
7769eb19f4dSGeorge Wilson } ddt_stat_t;
7779eb19f4dSGeorge Wilson 
7789eb19f4dSGeorge Wilson typedef struct ddt_histogram {
7799eb19f4dSGeorge Wilson 	ddt_stat_t	ddh_stat[64];	/* power-of-two histogram buckets */
7809eb19f4dSGeorge Wilson } ddt_histogram_t;
7819eb19f4dSGeorge Wilson 
782e7cbe64fSgw #define	ZVOL_DRIVER	"zvol"
783fa9e4066Sahrens #define	ZFS_DRIVER	"zfs"
784fa9e4066Sahrens #define	ZFS_DEV		"/dev/zfs"
7856401734dSWill Andrews #define	ZFS_DISK_ROOT	"/dev/dsk"
7866401734dSWill Andrews #define	ZFS_DISK_ROOTD	ZFS_DISK_ROOT "/"
7876401734dSWill Andrews #define	ZFS_RDISK_ROOT	"/dev/rdsk"
7886401734dSWill Andrews #define	ZFS_RDISK_ROOTD	ZFS_RDISK_ROOT "/"
789fa9e4066Sahrens 
790681d9761SEric Taylor /* general zvol path */
791681d9761SEric Taylor #define	ZVOL_DIR		"/dev/zvol"
792681d9761SEric Taylor /* expansion */
793573ca77eSGeorge Wilson #define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zfs@0:"
794681d9761SEric Taylor /* for dump and swap */
795681d9761SEric Taylor #define	ZVOL_FULL_DEV_DIR	ZVOL_DIR "/dsk/"
796681d9761SEric Taylor #define	ZVOL_FULL_RDEV_DIR	ZVOL_DIR "/rdsk/"
797fa9e4066Sahrens 
798fa9e4066Sahrens #define	ZVOL_PROP_NAME		"name"
799c1449561SEric Taylor #define	ZVOL_DEFAULT_BLOCKSIZE	8192
800fa9e4066Sahrens 
801fa9e4066Sahrens /*
802fa9e4066Sahrens  * /dev/zfs ioctl numbers.
803fa9e4066Sahrens  */
804fa9e4066Sahrens typedef enum zfs_ioc {
8054445fffbSMatthew Ahrens 	ZFS_IOC_FIRST =	('Z' << 8),
8064445fffbSMatthew Ahrens 	ZFS_IOC = ZFS_IOC_FIRST,
8074445fffbSMatthew Ahrens 	ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,
808fa9e4066Sahrens 	ZFS_IOC_POOL_DESTROY,
809fa9e4066Sahrens 	ZFS_IOC_POOL_IMPORT,
810fa9e4066Sahrens 	ZFS_IOC_POOL_EXPORT,
811fa9e4066Sahrens 	ZFS_IOC_POOL_CONFIGS,
812fa9e4066Sahrens 	ZFS_IOC_POOL_STATS,
813fa9e4066Sahrens 	ZFS_IOC_POOL_TRYIMPORT,
8143f9d6ad7SLin Ling 	ZFS_IOC_POOL_SCAN,
815fa9e4066Sahrens 	ZFS_IOC_POOL_FREEZE,
816eaca9bbdSeschrock 	ZFS_IOC_POOL_UPGRADE,
81706eeb2adSek 	ZFS_IOC_POOL_GET_HISTORY,
818fa9e4066Sahrens 	ZFS_IOC_VDEV_ADD,
819fa9e4066Sahrens 	ZFS_IOC_VDEV_REMOVE,
8203d7072f8Seschrock 	ZFS_IOC_VDEV_SET_STATE,
821fa9e4066Sahrens 	ZFS_IOC_VDEV_ATTACH,
822fa9e4066Sahrens 	ZFS_IOC_VDEV_DETACH,
823c67d9675Seschrock 	ZFS_IOC_VDEV_SETPATH,
8246809eb4eSEric Schrock 	ZFS_IOC_VDEV_SETFRU,
825fa9e4066Sahrens 	ZFS_IOC_OBJSET_STATS,
826de8267e0Stimh 	ZFS_IOC_OBJSET_ZPLPROPS,
827fa9e4066Sahrens 	ZFS_IOC_DATASET_LIST_NEXT,
828fa9e4066Sahrens 	ZFS_IOC_SNAPSHOT_LIST_NEXT,
829fa9e4066Sahrens 	ZFS_IOC_SET_PROP,
830fa9e4066Sahrens 	ZFS_IOC_CREATE,
831fa9e4066Sahrens 	ZFS_IOC_DESTROY,
832fa9e4066Sahrens 	ZFS_IOC_ROLLBACK,
833fa9e4066Sahrens 	ZFS_IOC_RENAME,
8343cb34c60Sahrens 	ZFS_IOC_RECV,
8353cb34c60Sahrens 	ZFS_IOC_SEND,
836ea8dc4b6Seschrock 	ZFS_IOC_INJECT_FAULT,
837ea8dc4b6Seschrock 	ZFS_IOC_CLEAR_FAULT,
838ea8dc4b6Seschrock 	ZFS_IOC_INJECT_LIST_NEXT,
839ea8dc4b6Seschrock 	ZFS_IOC_ERROR_LOG,
840ea8dc4b6Seschrock 	ZFS_IOC_CLEAR,
8411d452cf5Sahrens 	ZFS_IOC_PROMOTE,
84255434c77Sek 	ZFS_IOC_SNAPSHOT,
84355434c77Sek 	ZFS_IOC_DSOBJ_TO_DSNAME,
844b1b8ab34Slling 	ZFS_IOC_OBJ_TO_PATH,
845b1b8ab34Slling 	ZFS_IOC_POOL_SET_PROPS,
846ecd6cf80Smarks 	ZFS_IOC_POOL_GET_PROPS,
847ecd6cf80Smarks 	ZFS_IOC_SET_FSACL,
848ecd6cf80Smarks 	ZFS_IOC_GET_FSACL,
849e45ce728Sahrens 	ZFS_IOC_SHARE,
850743a77edSAlan Wright 	ZFS_IOC_INHERIT_PROP,
85114843421SMatthew Ahrens 	ZFS_IOC_SMB_ACL,
85214843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_ONE,
85314843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_MANY,
854842727c2SChris Kirby 	ZFS_IOC_USERSPACE_UPGRADE,
855842727c2SChris Kirby 	ZFS_IOC_HOLD,
856842727c2SChris Kirby 	ZFS_IOC_RELEASE,
85792241e0bSTom Erickson 	ZFS_IOC_GET_HOLDS,
8581195e687SMark J Musante 	ZFS_IOC_OBJSET_RECVD_PROPS,
85999d5e173STim Haley 	ZFS_IOC_VDEV_SPLIT,
86099d5e173STim Haley 	ZFS_IOC_NEXT_OBJ,
86199d5e173STim Haley 	ZFS_IOC_DIFF,
86299d5e173STim Haley 	ZFS_IOC_TMP_SNAPSHOT,
863e9103aaeSGarrett D'Amore 	ZFS_IOC_OBJ_TO_STATS,
86419b94df9SMatthew Ahrens 	ZFS_IOC_SPACE_WRITTEN,
86519b94df9SMatthew Ahrens 	ZFS_IOC_SPACE_SNAPS,
8664445fffbSMatthew Ahrens 	ZFS_IOC_DESTROY_SNAPS,
8674263d13fSGeorge Wilson 	ZFS_IOC_POOL_REGUID,
8684e3c9f44SBill Pijewski 	ZFS_IOC_POOL_REOPEN,
8694445fffbSMatthew Ahrens 	ZFS_IOC_SEND_PROGRESS,
8704445fffbSMatthew Ahrens 	ZFS_IOC_LOG_HISTORY,
8714445fffbSMatthew Ahrens 	ZFS_IOC_SEND_NEW,
8724445fffbSMatthew Ahrens 	ZFS_IOC_SEND_SPACE,
8734445fffbSMatthew Ahrens 	ZFS_IOC_CLONE,
87478f17100SMatthew Ahrens 	ZFS_IOC_BOOKMARK,
87578f17100SMatthew Ahrens 	ZFS_IOC_GET_BOOKMARKS,
87678f17100SMatthew Ahrens 	ZFS_IOC_DESTROY_BOOKMARKS,
8774445fffbSMatthew Ahrens 	ZFS_IOC_LAST
878fa9e4066Sahrens } zfs_ioc_t;
879fa9e4066Sahrens 
880ea8dc4b6Seschrock /*
881ea8dc4b6Seschrock  * Internal SPA load state.  Used by FMA diagnosis engine.
882ea8dc4b6Seschrock  */
883ea8dc4b6Seschrock typedef enum {
8849eb19f4dSGeorge Wilson 	SPA_LOAD_NONE,		/* no load in progress	*/
8859eb19f4dSGeorge Wilson 	SPA_LOAD_OPEN,		/* normal open		*/
8869eb19f4dSGeorge Wilson 	SPA_LOAD_IMPORT,	/* import in progress	*/
887468c413aSTim Haley 	SPA_LOAD_TRYIMPORT,	/* tryimport in progress */
8889eb19f4dSGeorge Wilson 	SPA_LOAD_RECOVER,	/* recovery requested	*/
8890f7643c7SGeorge Wilson 	SPA_LOAD_ERROR,		/* load failed		*/
8900f7643c7SGeorge Wilson 	SPA_LOAD_CREATE		/* creation in progress */
891ea8dc4b6Seschrock } spa_load_state_t;
892ea8dc4b6Seschrock 
893e9dbad6fSeschrock /*
894e9dbad6fSeschrock  * Bookmark name values.
895e9dbad6fSeschrock  */
89655434c77Sek #define	ZPOOL_ERR_LIST		"error list"
897e9dbad6fSeschrock #define	ZPOOL_ERR_DATASET	"dataset"
898e9dbad6fSeschrock #define	ZPOOL_ERR_OBJECT	"object"
899e9dbad6fSeschrock 
90006eeb2adSek #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
90106eeb2adSek 
90206eeb2adSek /*
90306eeb2adSek  * The following are names used in the nvlist describing
90406eeb2adSek  * the pool's history log.
90506eeb2adSek  */
90606eeb2adSek #define	ZPOOL_HIST_RECORD	"history record"
90706eeb2adSek #define	ZPOOL_HIST_TIME		"history time"
90806eeb2adSek #define	ZPOOL_HIST_CMD		"history command"
909ecd6cf80Smarks #define	ZPOOL_HIST_WHO		"history who"
910ecd6cf80Smarks #define	ZPOOL_HIST_ZONE		"history zone"
911ecd6cf80Smarks #define	ZPOOL_HIST_HOST		"history hostname"
912ecd6cf80Smarks #define	ZPOOL_HIST_TXG		"history txg"
913ecd6cf80Smarks #define	ZPOOL_HIST_INT_EVENT	"history internal event"
914ecd6cf80Smarks #define	ZPOOL_HIST_INT_STR	"history internal str"
9154445fffbSMatthew Ahrens #define	ZPOOL_HIST_INT_NAME	"internal_name"
9164445fffbSMatthew Ahrens #define	ZPOOL_HIST_IOCTL	"ioctl"
9174445fffbSMatthew Ahrens #define	ZPOOL_HIST_INPUT_NVL	"in_nvl"
9184445fffbSMatthew Ahrens #define	ZPOOL_HIST_OUTPUT_NVL	"out_nvl"
9194445fffbSMatthew Ahrens #define	ZPOOL_HIST_DSNAME	"dsname"
9204445fffbSMatthew Ahrens #define	ZPOOL_HIST_DSID		"dsid"
92106eeb2adSek 
9223d7072f8Seschrock /*
9233d7072f8Seschrock  * Flags for ZFS_IOC_VDEV_SET_STATE
9243d7072f8Seschrock  */
9253d7072f8Seschrock #define	ZFS_ONLINE_CHECKREMOVE	0x1
9263d7072f8Seschrock #define	ZFS_ONLINE_UNSPARE	0x2
9273d7072f8Seschrock #define	ZFS_ONLINE_FORCEFAULT	0x4
928573ca77eSGeorge Wilson #define	ZFS_ONLINE_EXPAND	0x8
9293d7072f8Seschrock #define	ZFS_OFFLINE_TEMPORARY	0x1
9303d7072f8Seschrock 
9314b964adaSGeorge Wilson /*
9324b964adaSGeorge Wilson  * Flags for ZFS_IOC_POOL_IMPORT
9334b964adaSGeorge Wilson  */
9344b964adaSGeorge Wilson #define	ZFS_IMPORT_NORMAL	0x0
9354b964adaSGeorge Wilson #define	ZFS_IMPORT_VERBATIM	0x1
9364b964adaSGeorge Wilson #define	ZFS_IMPORT_ANY_HOST	0x2
9374b964adaSGeorge Wilson #define	ZFS_IMPORT_MISSING_LOG	0x4
938f9af39baSGeorge Wilson #define	ZFS_IMPORT_ONLY		0x8
9394b964adaSGeorge Wilson 
9403d7072f8Seschrock /*
9413d7072f8Seschrock  * Sysevent payload members.  ZFS will generate the following sysevents with the
9423d7072f8Seschrock  * given payloads:
9433d7072f8Seschrock  *
9443d7072f8Seschrock  *	ESC_ZFS_RESILVER_START
9453d7072f8Seschrock  *	ESC_ZFS_RESILVER_END
9463d7072f8Seschrock  *	ESC_ZFS_POOL_DESTROY
947e9103aaeSGarrett D'Amore  *	ESC_ZFS_POOL_REGUID
9483d7072f8Seschrock  *
9493d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
9503d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
9513d7072f8Seschrock  *
9523d7072f8Seschrock  *	ESC_ZFS_VDEV_REMOVE
9533d7072f8Seschrock  *	ESC_ZFS_VDEV_CLEAR
9543d7072f8Seschrock  *	ESC_ZFS_VDEV_CHECK
9553d7072f8Seschrock  *
9563d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
9573d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
9583d7072f8Seschrock  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
9593d7072f8Seschrock  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
960*ce1577b0SDave Eddy  *
961*ce1577b0SDave Eddy  *	ESC_ZFS_HISTORY_EVENT
962*ce1577b0SDave Eddy  *
963*ce1577b0SDave Eddy  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
964*ce1577b0SDave Eddy  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
965*ce1577b0SDave Eddy  *		ZFS_EV_HIST_TIME	DATA_TYPE_UINT64	(optional)
966*ce1577b0SDave Eddy  *		ZFS_EV_HIST_CMD		DATA_TYPE_STRING	(optional)
967*ce1577b0SDave Eddy  *		ZFS_EV_HIST_WHO		DATA_TYPE_UINT64	(optional)
968*ce1577b0SDave Eddy  *		ZFS_EV_HIST_ZONE	DATA_TYPE_STRING	(optional)
969*ce1577b0SDave Eddy  *		ZFS_EV_HIST_HOST	DATA_TYPE_STRING	(optional)
970*ce1577b0SDave Eddy  *		ZFS_EV_HIST_TXG		DATA_TYPE_UINT64	(optional)
971*ce1577b0SDave Eddy  *		ZFS_EV_HIST_INT_EVENT	DATA_TYPE_UINT64	(optional)
972*ce1577b0SDave Eddy  *		ZFS_EV_HIST_INT_STR	DATA_TYPE_STRING	(optional)
973*ce1577b0SDave Eddy  *		ZFS_EV_HIST_INT_NAME	DATA_TYPE_STRING	(optional)
974*ce1577b0SDave Eddy  *		ZFS_EV_HIST_IOCTL	DATA_TYPE_STRING	(optional)
975*ce1577b0SDave Eddy  *		ZFS_EV_HIST_DSNAME	DATA_TYPE_STRING	(optional)
976*ce1577b0SDave Eddy  *		ZFS_EV_HIST_DSID	DATA_TYPE_UINT64	(optional)
977*ce1577b0SDave Eddy  *
978*ce1577b0SDave Eddy  * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the
979*ce1577b0SDave Eddy  * history log nvlist.  The keynames will be free of any spaces or other
980*ce1577b0SDave Eddy  * characters that could be potentially unexpected to consumers of the
981*ce1577b0SDave Eddy  * sysevents.
9823d7072f8Seschrock  */
9833d7072f8Seschrock #define	ZFS_EV_POOL_NAME	"pool_name"
9843d7072f8Seschrock #define	ZFS_EV_POOL_GUID	"pool_guid"
9853d7072f8Seschrock #define	ZFS_EV_VDEV_PATH	"vdev_path"
9863d7072f8Seschrock #define	ZFS_EV_VDEV_GUID	"vdev_guid"
987*ce1577b0SDave Eddy #define	ZFS_EV_HIST_TIME	"history_time"
988*ce1577b0SDave Eddy #define	ZFS_EV_HIST_CMD		"history_command"
989*ce1577b0SDave Eddy #define	ZFS_EV_HIST_WHO		"history_who"
990*ce1577b0SDave Eddy #define	ZFS_EV_HIST_ZONE	"history_zone"
991*ce1577b0SDave Eddy #define	ZFS_EV_HIST_HOST	"history_hostname"
992*ce1577b0SDave Eddy #define	ZFS_EV_HIST_TXG		"history_txg"
993*ce1577b0SDave Eddy #define	ZFS_EV_HIST_INT_EVENT	"history_internal_event"
994*ce1577b0SDave Eddy #define	ZFS_EV_HIST_INT_STR	"history_internal_str"
995*ce1577b0SDave Eddy #define	ZFS_EV_HIST_INT_NAME	"history_internal_name"
996*ce1577b0SDave Eddy #define	ZFS_EV_HIST_IOCTL	"history_ioctl"
997*ce1577b0SDave Eddy #define	ZFS_EV_HIST_DSNAME	"history_dsname"
998*ce1577b0SDave Eddy #define	ZFS_EV_HIST_DSID	"history_dsid"
9993d7072f8Seschrock 
1000fa9e4066Sahrens #ifdef	__cplusplus
1001fa9e4066Sahrens }
1002fa9e4066Sahrens #endif
1003fa9e4066Sahrens 
1004fa9e4066Sahrens #endif	/* _SYS_FS_ZFS_H */
1005