xref: /illumos-gate/usr/src/uts/common/sys/fs/zfs.h (revision b4952e17e8858d3225793b28788278de9fe6038d)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5441d80aaSlling  * Common Development and Distribution License (the "License").
6441d80aaSlling  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21f94275ceSAdam Leventhal 
22fa9e4066Sahrens /*
2327dd1e87SMark Shellenbaum  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24*b4952e17SGeorge Wilson  * Copyright (c) 2013 by Delphix. All rights reserved.
25e9103aaeSGarrett D'Amore  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
264e3c9f44SBill Pijewski  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
27fa9e4066Sahrens  */
28fa9e4066Sahrens 
2955da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */
3055da60b9SMark J Musante 
31fa9e4066Sahrens #ifndef	_SYS_FS_ZFS_H
32fa9e4066Sahrens #define	_SYS_FS_ZFS_H
33fa9e4066Sahrens 
34842727c2SChris Kirby #include <sys/time.h>
35842727c2SChris Kirby 
36fa9e4066Sahrens #ifdef	__cplusplus
37fa9e4066Sahrens extern "C" {
38fa9e4066Sahrens #endif
39fa9e4066Sahrens 
40fa9e4066Sahrens /*
41fa9e4066Sahrens  * Types and constants shared between userland and the kernel.
42fa9e4066Sahrens  */
43fa9e4066Sahrens 
44fa9e4066Sahrens /*
45fa9e4066Sahrens  * Each dataset can be one of the following types.  These constants can be
46fa9e4066Sahrens  * combined into masks that can be passed to various functions.
47fa9e4066Sahrens  */
48fa9e4066Sahrens typedef enum {
49fa9e4066Sahrens 	ZFS_TYPE_FILESYSTEM	= 0x1,
50fa9e4066Sahrens 	ZFS_TYPE_SNAPSHOT	= 0x2,
51b1b8ab34Slling 	ZFS_TYPE_VOLUME		= 0x4,
52b1b8ab34Slling 	ZFS_TYPE_POOL		= 0x8
53fa9e4066Sahrens } zfs_type_t;
54fa9e4066Sahrens 
554445fffbSMatthew Ahrens typedef enum dmu_objset_type {
564445fffbSMatthew Ahrens 	DMU_OST_NONE,
574445fffbSMatthew Ahrens 	DMU_OST_META,
584445fffbSMatthew Ahrens 	DMU_OST_ZFS,
594445fffbSMatthew Ahrens 	DMU_OST_ZVOL,
604445fffbSMatthew Ahrens 	DMU_OST_OTHER,			/* For testing only! */
614445fffbSMatthew Ahrens 	DMU_OST_ANY,			/* Be careful! */
624445fffbSMatthew Ahrens 	DMU_OST_NUMTYPES
634445fffbSMatthew Ahrens } dmu_objset_type_t;
644445fffbSMatthew Ahrens 
65990b4856Slling #define	ZFS_TYPE_DATASET	\
66fa9e4066Sahrens 	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
67fa9e4066Sahrens 
68478ed9adSEric Taylor #define	ZAP_MAXNAMELEN 256
69478ed9adSEric Taylor #define	ZAP_MAXVALUELEN (1024 * 8)
70478ed9adSEric Taylor #define	ZAP_OLDMAXVALUELEN 1024
71478ed9adSEric Taylor 
72fa9e4066Sahrens /*
73990b4856Slling  * Dataset properties are identified by these constants and must be added to
74990b4856Slling  * the end of this list to ensure that external consumers are not affected
75990b4856Slling  * by the change. If you make any changes to this list, be sure to update
7666e2aaccSgw  * the property table in usr/src/common/zfs/zfs_prop.c.
77fa9e4066Sahrens  */
78fa9e4066Sahrens typedef enum {
79fa9e4066Sahrens 	ZFS_PROP_TYPE,
80fa9e4066Sahrens 	ZFS_PROP_CREATION,
81fa9e4066Sahrens 	ZFS_PROP_USED,
82fa9e4066Sahrens 	ZFS_PROP_AVAILABLE,
83fa9e4066Sahrens 	ZFS_PROP_REFERENCED,
84fa9e4066Sahrens 	ZFS_PROP_COMPRESSRATIO,
85fa9e4066Sahrens 	ZFS_PROP_MOUNTED,
86fa9e4066Sahrens 	ZFS_PROP_ORIGIN,
87fa9e4066Sahrens 	ZFS_PROP_QUOTA,
88fa9e4066Sahrens 	ZFS_PROP_RESERVATION,
89fa9e4066Sahrens 	ZFS_PROP_VOLSIZE,
90fa9e4066Sahrens 	ZFS_PROP_VOLBLOCKSIZE,
91fa9e4066Sahrens 	ZFS_PROP_RECORDSIZE,
92fa9e4066Sahrens 	ZFS_PROP_MOUNTPOINT,
93fa9e4066Sahrens 	ZFS_PROP_SHARENFS,
94fa9e4066Sahrens 	ZFS_PROP_CHECKSUM,
95fa9e4066Sahrens 	ZFS_PROP_COMPRESSION,
96fa9e4066Sahrens 	ZFS_PROP_ATIME,
97fa9e4066Sahrens 	ZFS_PROP_DEVICES,
98fa9e4066Sahrens 	ZFS_PROP_EXEC,
99fa9e4066Sahrens 	ZFS_PROP_SETUID,
100fa9e4066Sahrens 	ZFS_PROP_READONLY,
101fa9e4066Sahrens 	ZFS_PROP_ZONED,
102fa9e4066Sahrens 	ZFS_PROP_SNAPDIR,
103a3c49ce1SAlbert Lee 	ZFS_PROP_ACLMODE,
104fa9e4066Sahrens 	ZFS_PROP_ACLINHERIT,
10566e2aaccSgw 	ZFS_PROP_CREATETXG,		/* not exposed to the user */
10666e2aaccSgw 	ZFS_PROP_NAME,			/* not exposed to the user */
107e9dbad6fSeschrock 	ZFS_PROP_CANMOUNT,
10866e2aaccSgw 	ZFS_PROP_ISCSIOPTIONS,		/* not exposed to the user */
1097b55fa8eSck 	ZFS_PROP_XATTR,
110d0ad202dSahrens 	ZFS_PROP_NUMCLONES,		/* not exposed to the user */
111b1b8ab34Slling 	ZFS_PROP_COPIES,
112e7437265Sahrens 	ZFS_PROP_VERSION,
113da6c28aaSamw 	ZFS_PROP_UTF8ONLY,
114da6c28aaSamw 	ZFS_PROP_NORMALIZE,
115da6c28aaSamw 	ZFS_PROP_CASE,
116da6c28aaSamw 	ZFS_PROP_VSCAN,
117da6c28aaSamw 	ZFS_PROP_NBMAND,
118da6c28aaSamw 	ZFS_PROP_SHARESMB,
119a9799022Sck 	ZFS_PROP_REFQUOTA,
120a9799022Sck 	ZFS_PROP_REFRESERVATION,
121c5904d13Seschrock 	ZFS_PROP_GUID,
1223baa08fcSek 	ZFS_PROP_PRIMARYCACHE,
1233baa08fcSek 	ZFS_PROP_SECONDARYCACHE,
12474e7dc98SMatthew Ahrens 	ZFS_PROP_USEDSNAP,
12574e7dc98SMatthew Ahrens 	ZFS_PROP_USEDDS,
12674e7dc98SMatthew Ahrens 	ZFS_PROP_USEDCHILD,
12774e7dc98SMatthew Ahrens 	ZFS_PROP_USEDREFRESERV,
12814843421SMatthew Ahrens 	ZFS_PROP_USERACCOUNTING,	/* not exposed to the user */
129478ed9adSEric Taylor 	ZFS_PROP_STMF_SHAREINFO,	/* not exposed to the user */
130842727c2SChris Kirby 	ZFS_PROP_DEFER_DESTROY,
131842727c2SChris Kirby 	ZFS_PROP_USERREFS,
132e09fa4daSNeil Perrin 	ZFS_PROP_LOGBIAS,
1331d713200SEric Schrock 	ZFS_PROP_UNIQUE,		/* not exposed to the user */
1341d713200SEric Schrock 	ZFS_PROP_OBJSETID,		/* not exposed to the user */
135b24ab676SJeff Bonwick 	ZFS_PROP_DEDUP,
1364201a95eSRic Aleshire 	ZFS_PROP_MLSLABEL,
13755da60b9SMark J Musante 	ZFS_PROP_SYNC,
138187d6ac0SMatt Ahrens 	ZFS_PROP_REFRATIO,
13919b94df9SMatthew Ahrens 	ZFS_PROP_WRITTEN,
14019b94df9SMatthew Ahrens 	ZFS_PROP_CLONES,
14177372cb0SMatthew Ahrens 	ZFS_PROP_LOGICALUSED,
14277372cb0SMatthew Ahrens 	ZFS_PROP_LOGICALREFERENCED,
143ca48f36fSKeith M Wesolowski 	ZFS_PROP_INCONSISTENT,		/* not exposed to the user */
14491ebeef5Sahrens 	ZFS_NUM_PROPS
145fa9e4066Sahrens } zfs_prop_t;
146fa9e4066Sahrens 
14714843421SMatthew Ahrens typedef enum {
14814843421SMatthew Ahrens 	ZFS_PROP_USERUSED,
14914843421SMatthew Ahrens 	ZFS_PROP_USERQUOTA,
15014843421SMatthew Ahrens 	ZFS_PROP_GROUPUSED,
15114843421SMatthew Ahrens 	ZFS_PROP_GROUPQUOTA,
15214843421SMatthew Ahrens 	ZFS_NUM_USERQUOTA_PROPS
15314843421SMatthew Ahrens } zfs_userquota_prop_t;
15414843421SMatthew Ahrens 
15514843421SMatthew Ahrens extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
15614843421SMatthew Ahrens 
157990b4856Slling /*
158990b4856Slling  * Pool properties are identified by these constants and must be added to the
159b87f3af3Sperrin  * end of this list to ensure that external consumers are not affected
160990b4856Slling  * by the change. If you make any changes to this list, be sure to update
161990b4856Slling  * the property table in usr/src/common/zfs/zpool_prop.c.
162990b4856Slling  */
163990b4856Slling typedef enum {
164990b4856Slling 	ZPOOL_PROP_NAME,
165990b4856Slling 	ZPOOL_PROP_SIZE,
166990b4856Slling 	ZPOOL_PROP_CAPACITY,
167990b4856Slling 	ZPOOL_PROP_ALTROOT,
168990b4856Slling 	ZPOOL_PROP_HEALTH,
169990b4856Slling 	ZPOOL_PROP_GUID,
170990b4856Slling 	ZPOOL_PROP_VERSION,
171990b4856Slling 	ZPOOL_PROP_BOOTFS,
172990b4856Slling 	ZPOOL_PROP_DELEGATION,
173990b4856Slling 	ZPOOL_PROP_AUTOREPLACE,
1742f8aaab3Seschrock 	ZPOOL_PROP_CACHEFILE,
1750a4e9518Sgw 	ZPOOL_PROP_FAILUREMODE,
176d5b5bb25SRich Morris 	ZPOOL_PROP_LISTSNAPS,
177573ca77eSGeorge Wilson 	ZPOOL_PROP_AUTOEXPAND,
178b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPDITTO,
179b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPRATIO,
180485bbbf5SGeorge Wilson 	ZPOOL_PROP_FREE,
181485bbbf5SGeorge Wilson 	ZPOOL_PROP_ALLOCATED,
182f9af39baSGeorge Wilson 	ZPOOL_PROP_READONLY,
1838704186eSDan McDonald 	ZPOOL_PROP_COMMENT,
1844263d13fSGeorge Wilson 	ZPOOL_PROP_EXPANDSZ,
185ad135b5dSChristopher Siden 	ZPOOL_PROP_FREEING,
186990b4856Slling 	ZPOOL_NUM_PROPS
187990b4856Slling } zpool_prop_t;
188b1b8ab34Slling 
1898704186eSDan McDonald /* Small enough to not hog a whole line of printout in zpool(1M). */
1908704186eSDan McDonald #define	ZPROP_MAX_COMMENT	32
1918704186eSDan McDonald 
192990b4856Slling #define	ZPROP_CONT		-2
193990b4856Slling #define	ZPROP_INVAL		-1
1943d7072f8Seschrock 
195990b4856Slling #define	ZPROP_VALUE		"value"
196990b4856Slling #define	ZPROP_SOURCE		"source"
1977f7322feSeschrock 
198b1b8ab34Slling typedef enum {
199990b4856Slling 	ZPROP_SRC_NONE = 0x1,
200990b4856Slling 	ZPROP_SRC_DEFAULT = 0x2,
201990b4856Slling 	ZPROP_SRC_TEMPORARY = 0x4,
202990b4856Slling 	ZPROP_SRC_LOCAL = 0x8,
20392241e0bSTom Erickson 	ZPROP_SRC_INHERITED = 0x10,
20492241e0bSTom Erickson 	ZPROP_SRC_RECEIVED = 0x20
205990b4856Slling } zprop_source_t;
206990b4856Slling 
20792241e0bSTom Erickson #define	ZPROP_SRC_ALL	0x3f
20892241e0bSTom Erickson 
20992241e0bSTom Erickson #define	ZPROP_SOURCE_VAL_RECVD	"$recvd"
21092241e0bSTom Erickson #define	ZPROP_N_MORE_ERRORS	"N_MORE_ERRORS"
21192241e0bSTom Erickson /*
21292241e0bSTom Erickson  * Dataset flag implemented as a special entry in the props zap object
21392241e0bSTom Erickson  * indicating that the dataset has received properties on or after
21492241e0bSTom Erickson  * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
21592241e0bSTom Erickson  * just as it did in earlier versions, and thereafter, local properties are
21692241e0bSTom Erickson  * preserved.
21792241e0bSTom Erickson  */
21892241e0bSTom Erickson #define	ZPROP_HAS_RECVD		"$hasrecvd"
21992241e0bSTom Erickson 
22092241e0bSTom Erickson typedef enum {
22192241e0bSTom Erickson 	ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
22292241e0bSTom Erickson 	ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
22392241e0bSTom Erickson } zprop_errflags_t;
224990b4856Slling 
225990b4856Slling typedef int (*zprop_func)(int, void *);
226990b4856Slling 
2270a48a24eStimh /*
2280a48a24eStimh  * Properties to be set on the root file system of a new pool
2290a48a24eStimh  * are stuffed into their own nvlist, which is then included in
2300a48a24eStimh  * the properties nvlist with the pool properties.
2310a48a24eStimh  */
2320a48a24eStimh #define	ZPOOL_ROOTFS_PROPS	"root-props-nvl"
2330a48a24eStimh 
234990b4856Slling /*
235990b4856Slling  * Dataset property functions shared between libzfs and kernel.
236990b4856Slling  */
237990b4856Slling const char *zfs_prop_default_string(zfs_prop_t);
238990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t);
239990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t);
240990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t);
241da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t);
242990b4856Slling const char *zfs_prop_to_name(zfs_prop_t);
243990b4856Slling zfs_prop_t zfs_name_to_prop(const char *);
244990b4856Slling boolean_t zfs_prop_user(const char *);
24592241e0bSTom Erickson boolean_t zfs_prop_userquota(const char *);
24619b94df9SMatthew Ahrens boolean_t zfs_prop_written(const char *);
247990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
248990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
249b24ab676SJeff Bonwick uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
2504853e976Sgw boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
251b1b8ab34Slling 
252990b4856Slling /*
253990b4856Slling  * Pool property functions shared between libzfs and kernel.
254990b4856Slling  */
255990b4856Slling zpool_prop_t zpool_name_to_prop(const char *);
256990b4856Slling const char *zpool_prop_to_name(zpool_prop_t);
257990b4856Slling const char *zpool_prop_default_string(zpool_prop_t);
258990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t);
259990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t);
260ad135b5dSChristopher Siden boolean_t zpool_prop_feature(const char *);
261ad135b5dSChristopher Siden boolean_t zpool_prop_unsupported(const char *name);
262990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
263990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
264b24ab676SJeff Bonwick uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
265b1b8ab34Slling 
266990b4856Slling /*
267990b4856Slling  * Definitions for the Delegation.
268990b4856Slling  */
269ecd6cf80Smarks typedef enum {
270ecd6cf80Smarks 	ZFS_DELEG_WHO_UNKNOWN = 0,
271ecd6cf80Smarks 	ZFS_DELEG_USER = 'u',
272ecd6cf80Smarks 	ZFS_DELEG_USER_SETS = 'U',
273ecd6cf80Smarks 	ZFS_DELEG_GROUP = 'g',
274ecd6cf80Smarks 	ZFS_DELEG_GROUP_SETS = 'G',
275ecd6cf80Smarks 	ZFS_DELEG_EVERYONE = 'e',
276ecd6cf80Smarks 	ZFS_DELEG_EVERYONE_SETS = 'E',
277ecd6cf80Smarks 	ZFS_DELEG_CREATE = 'c',
278ecd6cf80Smarks 	ZFS_DELEG_CREATE_SETS = 'C',
279ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET = 's',
280ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET_SETS = 'S'
281ecd6cf80Smarks } zfs_deleg_who_type_t;
282ecd6cf80Smarks 
283ecd6cf80Smarks typedef enum {
284ecd6cf80Smarks 	ZFS_DELEG_NONE = 0,
285ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCAL = 1,
286ecd6cf80Smarks 	ZFS_DELEG_PERM_DESCENDENT = 2,
287ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
288ecd6cf80Smarks 	ZFS_DELEG_PERM_CREATE = 4
289ecd6cf80Smarks } zfs_deleg_inherit_t;
290ecd6cf80Smarks 
291ecd6cf80Smarks #define	ZFS_DELEG_PERM_UID	"uid"
292ecd6cf80Smarks #define	ZFS_DELEG_PERM_GID	"gid"
293ecd6cf80Smarks #define	ZFS_DELEG_PERM_GROUPS	"groups"
294ecd6cf80Smarks 
2954201a95eSRic Aleshire #define	ZFS_MLSLABEL_DEFAULT	"none"
2964201a95eSRic Aleshire 
297743a77edSAlan Wright #define	ZFS_SMB_ACL_SRC		"src"
298743a77edSAlan Wright #define	ZFS_SMB_ACL_TARGET	"target"
299743a77edSAlan Wright 
300a227b7f4Shs typedef enum {
301a227b7f4Shs 	ZFS_CANMOUNT_OFF = 0,
302a227b7f4Shs 	ZFS_CANMOUNT_ON = 1,
303a227b7f4Shs 	ZFS_CANMOUNT_NOAUTO = 2
304a227b7f4Shs } zfs_canmount_type_t;
305a227b7f4Shs 
306e09fa4daSNeil Perrin typedef enum {
307e09fa4daSNeil Perrin 	ZFS_LOGBIAS_LATENCY = 0,
308e09fa4daSNeil Perrin 	ZFS_LOGBIAS_THROUGHPUT = 1
309e09fa4daSNeil Perrin } zfs_logbias_op_t;
310e09fa4daSNeil Perrin 
311da6c28aaSamw typedef enum zfs_share_op {
312da6c28aaSamw 	ZFS_SHARE_NFS = 0,
313da6c28aaSamw 	ZFS_UNSHARE_NFS = 1,
314da6c28aaSamw 	ZFS_SHARE_SMB = 2,
315da6c28aaSamw 	ZFS_UNSHARE_SMB = 3
316da6c28aaSamw } zfs_share_op_t;
317da6c28aaSamw 
318743a77edSAlan Wright typedef enum zfs_smb_acl_op {
319743a77edSAlan Wright 	ZFS_SMB_ACL_ADD,
320743a77edSAlan Wright 	ZFS_SMB_ACL_REMOVE,
321743a77edSAlan Wright 	ZFS_SMB_ACL_RENAME,
322743a77edSAlan Wright 	ZFS_SMB_ACL_PURGE
323743a77edSAlan Wright } zfs_smb_acl_op_t;
324743a77edSAlan Wright 
3253baa08fcSek typedef enum zfs_cache_type {
3263baa08fcSek 	ZFS_CACHE_NONE = 0,
3273baa08fcSek 	ZFS_CACHE_METADATA = 1,
3283baa08fcSek 	ZFS_CACHE_ALL = 2
3293baa08fcSek } zfs_cache_type_t;
3303baa08fcSek 
33155da60b9SMark J Musante typedef enum {
33255da60b9SMark J Musante 	ZFS_SYNC_STANDARD = 0,
33355da60b9SMark J Musante 	ZFS_SYNC_ALWAYS = 1,
33455da60b9SMark J Musante 	ZFS_SYNC_DISABLED = 2
33555da60b9SMark J Musante } zfs_sync_type_t;
33655da60b9SMark J Musante 
3373baa08fcSek 
338eaca9bbdSeschrock /*
33999653d4eSeschrock  * On-disk version number.
340eaca9bbdSeschrock  */
341e7437265Sahrens #define	SPA_VERSION_1			1ULL
342e7437265Sahrens #define	SPA_VERSION_2			2ULL
343e7437265Sahrens #define	SPA_VERSION_3			3ULL
344e7437265Sahrens #define	SPA_VERSION_4			4ULL
345e7437265Sahrens #define	SPA_VERSION_5			5ULL
346e7437265Sahrens #define	SPA_VERSION_6			6ULL
347e7437265Sahrens #define	SPA_VERSION_7			7ULL
348e7437265Sahrens #define	SPA_VERSION_8			8ULL
349da6c28aaSamw #define	SPA_VERSION_9			9ULL
350fa94a07fSbrendan #define	SPA_VERSION_10			10ULL
351088f3894Sahrens #define	SPA_VERSION_11			11ULL
352bb0ade09Sahrens #define	SPA_VERSION_12			12ULL
35374e7dc98SMatthew Ahrens #define	SPA_VERSION_13			13ULL
354d0f3f37eSMark Shellenbaum #define	SPA_VERSION_14			14ULL
35514843421SMatthew Ahrens #define	SPA_VERSION_15			15ULL
356478ed9adSEric Taylor #define	SPA_VERSION_16			16ULL
357f94275ceSAdam Leventhal #define	SPA_VERSION_17			17ULL
358842727c2SChris Kirby #define	SPA_VERSION_18			18ULL
35988ecc943SGeorge Wilson #define	SPA_VERSION_19			19ULL
360b24ab676SJeff Bonwick #define	SPA_VERSION_20			20ULL
361b24ab676SJeff Bonwick #define	SPA_VERSION_21			21ULL
36292241e0bSTom Erickson #define	SPA_VERSION_22			22ULL
3636e1f5caaSNeil Perrin #define	SPA_VERSION_23			23ULL
3640a586ceaSMark Shellenbaum #define	SPA_VERSION_24			24ULL
3653f9d6ad7SLin Ling #define	SPA_VERSION_25			25ULL
366cde58dbcSMatthew Ahrens #define	SPA_VERSION_26			26ULL
3676e0cbcaaSMatthew Ahrens #define	SPA_VERSION_27			27ULL
368cb04b873SMark J Musante #define	SPA_VERSION_28			28ULL
369ad135b5dSChristopher Siden #define	SPA_VERSION_5000		5000ULL
370cb04b873SMark J Musante 
371b1b8ab34Slling /*
372e7cbe64fSgw  * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
373478ed9adSEric Taylor  * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
37414843421SMatthew Ahrens  * and do the appropriate changes.  Also bump the version number in
37514843421SMatthew Ahrens  * usr/src/grub/capability.
376b1b8ab34Slling  */
377ad135b5dSChristopher Siden #define	SPA_VERSION			SPA_VERSION_5000
378ad135b5dSChristopher Siden #define	SPA_VERSION_STRING		"5000"
37944cd46caSbillm 
38044cd46caSbillm /*
381e7437265Sahrens  * Symbolic names for the changes that caused a SPA_VERSION switch.
38244cd46caSbillm  * Used in the code when checking for presence or absence of a feature.
38344cd46caSbillm  * Feel free to define multiple symbolic names for each version if there
38444cd46caSbillm  * were multiple changes to on-disk structures during that version.
38544cd46caSbillm  *
386e7437265Sahrens  * NOTE: When checking the current SPA_VERSION in your code, be sure
38744cd46caSbillm  *       to use spa_version() since it reports the version of the
38844cd46caSbillm  *       last synced uberblock.  Checking the in-flight version can
38944cd46caSbillm  *       be dangerous in some cases.
39044cd46caSbillm  */
391e7437265Sahrens #define	SPA_VERSION_INITIAL		SPA_VERSION_1
392e7437265Sahrens #define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
393e7437265Sahrens #define	SPA_VERSION_SPARES		SPA_VERSION_3
394f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ2		SPA_VERSION_3
395cde58dbcSMatthew Ahrens #define	SPA_VERSION_BPOBJ_ACCOUNT	SPA_VERSION_3
396e7437265Sahrens #define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
397e7437265Sahrens #define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
398e7437265Sahrens #define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
399e7437265Sahrens #define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
400e7437265Sahrens #define	SPA_VERSION_BOOTFS		SPA_VERSION_6
401990b4856Slling #define	SPA_VERSION_SLOGS		SPA_VERSION_7
402990b4856Slling #define	SPA_VERSION_DELEGATED_PERMS	SPA_VERSION_8
403da6c28aaSamw #define	SPA_VERSION_FUID		SPA_VERSION_9
404a9799022Sck #define	SPA_VERSION_REFRESERVATION	SPA_VERSION_9
405a9799022Sck #define	SPA_VERSION_REFQUOTA		SPA_VERSION_9
406a9799022Sck #define	SPA_VERSION_UNIQUE_ACCURATE	SPA_VERSION_9
407fa94a07fSbrendan #define	SPA_VERSION_L2CACHE		SPA_VERSION_10
408088f3894Sahrens #define	SPA_VERSION_NEXT_CLONES		SPA_VERSION_11
409088f3894Sahrens #define	SPA_VERSION_ORIGIN		SPA_VERSION_11
410088f3894Sahrens #define	SPA_VERSION_DSL_SCRUB		SPA_VERSION_11
411bb0ade09Sahrens #define	SPA_VERSION_SNAP_PROPS		SPA_VERSION_12
41274e7dc98SMatthew Ahrens #define	SPA_VERSION_USED_BREAKDOWN	SPA_VERSION_13
413d0f3f37eSMark Shellenbaum #define	SPA_VERSION_PASSTHROUGH_X	SPA_VERSION_14
41414843421SMatthew Ahrens #define	SPA_VERSION_USERSPACE		SPA_VERSION_15
415478ed9adSEric Taylor #define	SPA_VERSION_STMF_PROP		SPA_VERSION_16
416f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ3		SPA_VERSION_17
417842727c2SChris Kirby #define	SPA_VERSION_USERREFS		SPA_VERSION_18
41888ecc943SGeorge Wilson #define	SPA_VERSION_HOLES		SPA_VERSION_19
419b24ab676SJeff Bonwick #define	SPA_VERSION_ZLE_COMPRESSION	SPA_VERSION_20
420b24ab676SJeff Bonwick #define	SPA_VERSION_DEDUP		SPA_VERSION_21
42192241e0bSTom Erickson #define	SPA_VERSION_RECVD_PROPS		SPA_VERSION_22
4226e1f5caaSNeil Perrin #define	SPA_VERSION_SLIM_ZIL		SPA_VERSION_23
4230a586ceaSMark Shellenbaum #define	SPA_VERSION_SA			SPA_VERSION_24
4243f9d6ad7SLin Ling #define	SPA_VERSION_SCAN		SPA_VERSION_25
425cde58dbcSMatthew Ahrens #define	SPA_VERSION_DIR_CLONES		SPA_VERSION_26
426cde58dbcSMatthew Ahrens #define	SPA_VERSION_DEADLISTS		SPA_VERSION_26
4276e0cbcaaSMatthew Ahrens #define	SPA_VERSION_FAST_SNAP		SPA_VERSION_27
428cb04b873SMark J Musante #define	SPA_VERSION_MULTI_REPLACE	SPA_VERSION_28
429ad135b5dSChristopher Siden #define	SPA_VERSION_BEFORE_FEATURES	SPA_VERSION_28
430ad135b5dSChristopher Siden #define	SPA_VERSION_FEATURES		SPA_VERSION_5000
431ad135b5dSChristopher Siden 
432ad135b5dSChristopher Siden #define	SPA_VERSION_IS_SUPPORTED(v) \
433ad135b5dSChristopher Siden 	(((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
434ad135b5dSChristopher Siden 	((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
435e7437265Sahrens 
436e7437265Sahrens /*
437e7437265Sahrens  * ZPL version - rev'd whenever an incompatible on-disk format change
438e7437265Sahrens  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
439e7437265Sahrens  * also update the version_table[] and help message in zfs_prop.c.
440e7437265Sahrens  *
441e7437265Sahrens  * When changing, be sure to teach GRUB how to read the new format!
442478ed9adSEric Taylor  * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
443e7437265Sahrens  */
444e7437265Sahrens #define	ZPL_VERSION_1			1ULL
445e7437265Sahrens #define	ZPL_VERSION_2			2ULL
446da6c28aaSamw #define	ZPL_VERSION_3			3ULL
44714843421SMatthew Ahrens #define	ZPL_VERSION_4			4ULL
4480a586ceaSMark Shellenbaum #define	ZPL_VERSION_5			5ULL
4490a586ceaSMark Shellenbaum #define	ZPL_VERSION			ZPL_VERSION_5
4500a586ceaSMark Shellenbaum #define	ZPL_VERSION_STRING		"5"
451e7437265Sahrens 
452e7437265Sahrens #define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
453e7437265Sahrens #define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
454da6c28aaSamw #define	ZPL_VERSION_FUID		ZPL_VERSION_3
455de8267e0Stimh #define	ZPL_VERSION_NORMALIZATION	ZPL_VERSION_3
456da6c28aaSamw #define	ZPL_VERSION_SYSATTR		ZPL_VERSION_3
45714843421SMatthew Ahrens #define	ZPL_VERSION_USERSPACE		ZPL_VERSION_4
4580a586ceaSMark Shellenbaum #define	ZPL_VERSION_SA			ZPL_VERSION_5
459eaca9bbdSeschrock 
460468c413aSTim Haley /* Rewind request information */
461c8ee1847SVictor Latushkin #define	ZPOOL_NO_REWIND		1  /* No policy - default behavior */
462c8ee1847SVictor Latushkin #define	ZPOOL_NEVER_REWIND	2  /* Do not search for best txg or rewind */
463c8ee1847SVictor Latushkin #define	ZPOOL_TRY_REWIND	4  /* Search for best txg, but do not rewind */
464c8ee1847SVictor Latushkin #define	ZPOOL_DO_REWIND		8  /* Rewind to best txg w/in deferred frees */
465c8ee1847SVictor Latushkin #define	ZPOOL_EXTREME_REWIND	16 /* Allow extreme measures to find best txg */
466c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_MASK	28 /* All the possible rewind bits */
467c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_POLICIES	31 /* All the possible policy bits */
468468c413aSTim Haley 
469468c413aSTim Haley typedef struct zpool_rewind_policy {
470468c413aSTim Haley 	uint32_t	zrp_request;	/* rewind behavior requested */
471c8ee1847SVictor Latushkin 	uint64_t	zrp_maxmeta;	/* max acceptable meta-data errors */
472c8ee1847SVictor Latushkin 	uint64_t	zrp_maxdata;	/* max acceptable data errors */
473468c413aSTim Haley 	uint64_t	zrp_txg;	/* specific txg to load */
474468c413aSTim Haley } zpool_rewind_policy_t;
475468c413aSTim Haley 
476fa9e4066Sahrens /*
477fa9e4066Sahrens  * The following are configuration names used in the nvlist describing a pool's
478fa9e4066Sahrens  * configuration.
479fa9e4066Sahrens  */
480fa9e4066Sahrens #define	ZPOOL_CONFIG_VERSION		"version"
481fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_NAME		"name"
482fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_STATE		"state"
483fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_TXG		"txg"
484fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
485fa9e4066Sahrens #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
486fa9e4066Sahrens #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
487fa9e4066Sahrens #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
488fa9e4066Sahrens #define	ZPOOL_CONFIG_TYPE		"type"
489fa9e4066Sahrens #define	ZPOOL_CONFIG_CHILDREN		"children"
490fa9e4066Sahrens #define	ZPOOL_CONFIG_ID			"id"
491fa9e4066Sahrens #define	ZPOOL_CONFIG_GUID		"guid"
492fa9e4066Sahrens #define	ZPOOL_CONFIG_PATH		"path"
493fa9e4066Sahrens #define	ZPOOL_CONFIG_DEVID		"devid"
494fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
495fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
496fa9e4066Sahrens #define	ZPOOL_CONFIG_ASHIFT		"ashift"
497fa9e4066Sahrens #define	ZPOOL_CONFIG_ASIZE		"asize"
498fa9e4066Sahrens #define	ZPOOL_CONFIG_DTL		"DTL"
4993f9d6ad7SLin Ling #define	ZPOOL_CONFIG_SCAN_STATS		"scan_stats"	/* not stored on disk */
5003f9d6ad7SLin Ling #define	ZPOOL_CONFIG_VDEV_STATS		"vdev_stats"	/* not stored on disk */
501afefbcddSeschrock #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
502ea8dc4b6Seschrock #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
503ea8dc4b6Seschrock #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
50499653d4eSeschrock #define	ZPOOL_CONFIG_SPARES		"spares"
50599653d4eSeschrock #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
50699653d4eSeschrock #define	ZPOOL_CONFIG_NPARITY		"nparity"
50795173954Sek #define	ZPOOL_CONFIG_HOSTID		"hostid"
50895173954Sek #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
50911027bc7STim Haley #define	ZPOOL_CONFIG_LOADED_TIME	"initial_load_time"
5103d7072f8Seschrock #define	ZPOOL_CONFIG_UNSPARE		"unspare"
5113d7072f8Seschrock #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
5128654d025Sperrin #define	ZPOOL_CONFIG_IS_LOG		"is_log"
513fa94a07fSbrendan #define	ZPOOL_CONFIG_L2CACHE		"l2cache"
51488ecc943SGeorge Wilson #define	ZPOOL_CONFIG_HOLE_ARRAY		"hole_array"
51588ecc943SGeorge Wilson #define	ZPOOL_CONFIG_VDEV_CHILDREN	"vdev_children"
51688ecc943SGeorge Wilson #define	ZPOOL_CONFIG_IS_HOLE		"is_hole"
5179eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_HISTOGRAM	"ddt_histogram"
5189eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_OBJ_STATS	"ddt_object_stats"
5199eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_STATS		"ddt_stats"
5201195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT		"splitcfg"
5211195e687SMark J Musante #define	ZPOOL_CONFIG_ORIG_GUID		"orig_guid"
5221195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_GUID		"split_guid"
5231195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_LIST		"guid_list"
5243f9d6ad7SLin Ling #define	ZPOOL_CONFIG_REMOVING		"removing"
525*b4952e17SGeorge Wilson #define	ZPOOL_CONFIG_RESILVER_TXG	"resilver_txg"
5268704186eSDan McDonald #define	ZPOOL_CONFIG_COMMENT		"comment"
527e14bb325SJeff Bonwick #define	ZPOOL_CONFIG_SUSPENDED		"suspended"	/* not stored on disk */
528e7cbe64fSgw #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp"	/* not stored on disk */
529e7cbe64fSgw #define	ZPOOL_CONFIG_BOOTFS		"bootfs"	/* not stored on disk */
5304b964adaSGeorge Wilson #define	ZPOOL_CONFIG_MISSING_DEVICES	"missing_vdevs"	/* not stored on disk */
5314b964adaSGeorge Wilson #define	ZPOOL_CONFIG_LOAD_INFO		"load_info"	/* not stored on disk */
532ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_REWIND_INFO	"rewind_info"	/* not stored on disk */
533ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_UNSUP_FEAT		"unsup_feat"	/* not stored on disk */
53457221772SChristopher Siden #define	ZPOOL_CONFIG_ENABLED_FEAT	"enabled_feat"	/* not stored on disk */
535ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_CAN_RDONLY		"can_rdonly"	/* not stored on disk */
536ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_FEATURES_FOR_READ	"features_for_read"
537ad135b5dSChristopher Siden #define	ZPOOL_CONFIG_FEATURE_STATS	"feature_stats"	/* not stored on disk */
5383d7072f8Seschrock /*
5393d7072f8Seschrock  * The persistent vdev state is stored as separate values rather than a single
5403d7072f8Seschrock  * 'vdev_state' entry.  This is because a device can be in multiple states, such
5413d7072f8Seschrock  * as offline and degraded.
5423d7072f8Seschrock  */
5433d7072f8Seschrock #define	ZPOOL_CONFIG_OFFLINE		"offline"
5443d7072f8Seschrock #define	ZPOOL_CONFIG_FAULTED		"faulted"
5453d7072f8Seschrock #define	ZPOOL_CONFIG_DEGRADED		"degraded"
5463d7072f8Seschrock #define	ZPOOL_CONFIG_REMOVED		"removed"
5476809eb4eSEric Schrock #define	ZPOOL_CONFIG_FRU		"fru"
548069f55e2SEric Schrock #define	ZPOOL_CONFIG_AUX_STATE		"aux_state"
549fa9e4066Sahrens 
550468c413aSTim Haley /* Rewind policy parameters */
551468c413aSTim Haley #define	ZPOOL_REWIND_POLICY		"rewind-policy"
552468c413aSTim Haley #define	ZPOOL_REWIND_REQUEST		"rewind-request"
553468c413aSTim Haley #define	ZPOOL_REWIND_REQUEST_TXG	"rewind-request-txg"
554468c413aSTim Haley #define	ZPOOL_REWIND_META_THRESH	"rewind-meta-thresh"
555468c413aSTim Haley #define	ZPOOL_REWIND_DATA_THRESH	"rewind-data-thresh"
556468c413aSTim Haley 
557468c413aSTim Haley /* Rewind data discovered */
558468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_TIME		"rewind_txg_ts"
559468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_DATA_ERRORS	"verify_data_errors"
560468c413aSTim Haley #define	ZPOOL_CONFIG_REWIND_TIME	"seconds_of_rewind"
561468c413aSTim Haley 
562fa9e4066Sahrens #define	VDEV_TYPE_ROOT			"root"
563fa9e4066Sahrens #define	VDEV_TYPE_MIRROR		"mirror"
564fa9e4066Sahrens #define	VDEV_TYPE_REPLACING		"replacing"
565fa9e4066Sahrens #define	VDEV_TYPE_RAIDZ			"raidz"
566fa9e4066Sahrens #define	VDEV_TYPE_DISK			"disk"
567fa9e4066Sahrens #define	VDEV_TYPE_FILE			"file"
568fa9e4066Sahrens #define	VDEV_TYPE_MISSING		"missing"
56988ecc943SGeorge Wilson #define	VDEV_TYPE_HOLE			"hole"
57099653d4eSeschrock #define	VDEV_TYPE_SPARE			"spare"
5718654d025Sperrin #define	VDEV_TYPE_LOG			"log"
572fa94a07fSbrendan #define	VDEV_TYPE_L2CACHE		"l2cache"
573fa9e4066Sahrens 
574fa9e4066Sahrens /*
575fa9e4066Sahrens  * This is needed in userland to report the minimum necessary device size.
576fa9e4066Sahrens  */
577fa9e4066Sahrens #define	SPA_MINDEVSIZE		(64ULL << 20)
578fa9e4066Sahrens 
579fa9e4066Sahrens /*
580fa9e4066Sahrens  * The location of the pool configuration repository, shared between kernel and
581fa9e4066Sahrens  * userland.
582fa9e4066Sahrens  */
583c5904d13Seschrock #define	ZPOOL_CACHE		"/etc/zfs/zpool.cache"
584fa9e4066Sahrens 
585fa9e4066Sahrens /*
586fa9e4066Sahrens  * vdev states are ordered from least to most healthy.
587fa9e4066Sahrens  * A vdev that's CANT_OPEN or below is considered unusable.
588fa9e4066Sahrens  */
589fa9e4066Sahrens typedef enum vdev_state {
590fa9e4066Sahrens 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
591fa9e4066Sahrens 	VDEV_STATE_CLOSED,	/* Not currently open			*/
592fa9e4066Sahrens 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
5933d7072f8Seschrock 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
594fa9e4066Sahrens 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
5953d7072f8Seschrock 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
596fa9e4066Sahrens 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
597fa9e4066Sahrens 	VDEV_STATE_HEALTHY	/* Presumed good			*/
598fa9e4066Sahrens } vdev_state_t;
599fa9e4066Sahrens 
6003d7072f8Seschrock #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
6013d7072f8Seschrock 
602fa9e4066Sahrens /*
603fa9e4066Sahrens  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
604fa9e4066Sahrens  * of the vdev stats structure uses these constants to distinguish why.
605fa9e4066Sahrens  */
606fa9e4066Sahrens typedef enum vdev_aux {
607fa9e4066Sahrens 	VDEV_AUX_NONE,		/* no error				*/
608fa9e4066Sahrens 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
609fa9e4066Sahrens 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
610fa9e4066Sahrens 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
611fa9e4066Sahrens 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
612fa9e4066Sahrens 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
613eaca9bbdSeschrock 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
614eaca9bbdSeschrock 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
61599653d4eSeschrock 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
616ad135b5dSChristopher Siden 	VDEV_AUX_UNSUP_FEAT,	/* unsupported features			*/
6173d7072f8Seschrock 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
61832b87932Sek 	VDEV_AUX_ERR_EXCEEDED,	/* too many errors			*/
619b87f3af3Sperrin 	VDEV_AUX_IO_FAILURE,	/* experienced I/O failure		*/
620069f55e2SEric Schrock 	VDEV_AUX_BAD_LOG,	/* cannot read log chain(s)		*/
6211195e687SMark J Musante 	VDEV_AUX_EXTERNAL,	/* external diagnosis			*/
6221195e687SMark J Musante 	VDEV_AUX_SPLIT_POOL	/* vdev was split off into another pool	*/
623fa9e4066Sahrens } vdev_aux_t;
624fa9e4066Sahrens 
625fa9e4066Sahrens /*
62646a2abf2Seschrock  * pool state.  The following states are written to disk as part of the normal
627fa94a07fSbrendan  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
628fa94a07fSbrendan  * states are software abstractions used at various levels to communicate
629fa94a07fSbrendan  * pool state.
630fa9e4066Sahrens  */
631fa9e4066Sahrens typedef enum pool_state {
632fa9e4066Sahrens 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
633fa9e4066Sahrens 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
634fa9e4066Sahrens 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
63599653d4eSeschrock 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
636fa94a07fSbrendan 	POOL_STATE_L2CACHE,		/* Level 2 ARC device		*/
637fa9e4066Sahrens 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
63846a2abf2Seschrock 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
63946a2abf2Seschrock 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
640fa9e4066Sahrens } pool_state_t;
641fa9e4066Sahrens 
642fa9e4066Sahrens /*
6433f9d6ad7SLin Ling  * Scan Functions.
644fa9e4066Sahrens  */
6453f9d6ad7SLin Ling typedef enum pool_scan_func {
6463f9d6ad7SLin Ling 	POOL_SCAN_NONE,
6473f9d6ad7SLin Ling 	POOL_SCAN_SCRUB,
6483f9d6ad7SLin Ling 	POOL_SCAN_RESILVER,
6493f9d6ad7SLin Ling 	POOL_SCAN_FUNCS
6503f9d6ad7SLin Ling } pool_scan_func_t;
651fa9e4066Sahrens 
652fa9e4066Sahrens /*
653fa9e4066Sahrens  * ZIO types.  Needed to interpret vdev statistics below.
654fa9e4066Sahrens  */
655fa9e4066Sahrens typedef enum zio_type {
656fa9e4066Sahrens 	ZIO_TYPE_NULL = 0,
657fa9e4066Sahrens 	ZIO_TYPE_READ,
658fa9e4066Sahrens 	ZIO_TYPE_WRITE,
659fa9e4066Sahrens 	ZIO_TYPE_FREE,
660fa9e4066Sahrens 	ZIO_TYPE_CLAIM,
661fa9e4066Sahrens 	ZIO_TYPE_IOCTL,
662fa9e4066Sahrens 	ZIO_TYPES
663fa9e4066Sahrens } zio_type_t;
664fa9e4066Sahrens 
6653f9d6ad7SLin Ling /*
6663f9d6ad7SLin Ling  * Pool statistics.  Note: all fields should be 64-bit because this
6673f9d6ad7SLin Ling  * is passed between kernel and userland as an nvlist uint64 array.
6683f9d6ad7SLin Ling  */
6693f9d6ad7SLin Ling typedef struct pool_scan_stat {
6703f9d6ad7SLin Ling 	/* values stored on disk */
6713f9d6ad7SLin Ling 	uint64_t	pss_func;	/* pool_scan_func_t */
6723f9d6ad7SLin Ling 	uint64_t	pss_state;	/* dsl_scan_state_t */
6733f9d6ad7SLin Ling 	uint64_t	pss_start_time;	/* scan start time */
6743f9d6ad7SLin Ling 	uint64_t	pss_end_time;	/* scan end time */
6753f9d6ad7SLin Ling 	uint64_t	pss_to_examine;	/* total bytes to scan */
6763f9d6ad7SLin Ling 	uint64_t	pss_examined;	/* total examined bytes	*/
6773f9d6ad7SLin Ling 	uint64_t	pss_to_process; /* total bytes to process */
6783f9d6ad7SLin Ling 	uint64_t	pss_processed;	/* total processed bytes */
6793f9d6ad7SLin Ling 	uint64_t	pss_errors;	/* scan errors	*/
6803f9d6ad7SLin Ling 
6813f9d6ad7SLin Ling 	/* values not stored on disk */
6823f9d6ad7SLin Ling 	uint64_t	pss_pass_exam;	/* examined bytes per scan pass */
6833f9d6ad7SLin Ling 	uint64_t	pss_pass_start;	/* start time of a scan pass */
6843f9d6ad7SLin Ling } pool_scan_stat_t;
6853f9d6ad7SLin Ling 
6863f9d6ad7SLin Ling typedef enum dsl_scan_state {
6873f9d6ad7SLin Ling 	DSS_NONE,
6883f9d6ad7SLin Ling 	DSS_SCANNING,
6893f9d6ad7SLin Ling 	DSS_FINISHED,
6903f9d6ad7SLin Ling 	DSS_CANCELED,
6913f9d6ad7SLin Ling 	DSS_NUM_STATES
6923f9d6ad7SLin Ling } dsl_scan_state_t;
6933f9d6ad7SLin Ling 
6943f9d6ad7SLin Ling 
695fa9e4066Sahrens /*
696fa9e4066Sahrens  * Vdev statistics.  Note: all fields should be 64-bit because this
697fa9e4066Sahrens  * is passed between kernel and userland as an nvlist uint64 array.
698fa9e4066Sahrens  */
699fa9e4066Sahrens typedef struct vdev_stat {
700fa9e4066Sahrens 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
701fa9e4066Sahrens 	uint64_t	vs_state;		/* vdev state		*/
702fa9e4066Sahrens 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
703fa9e4066Sahrens 	uint64_t	vs_alloc;		/* space allocated	*/
704fa9e4066Sahrens 	uint64_t	vs_space;		/* total capacity	*/
70599653d4eSeschrock 	uint64_t	vs_dspace;		/* deflated capacity	*/
7062a79c5feSlling 	uint64_t	vs_rsize;		/* replaceable dev size */
7074263d13fSGeorge Wilson 	uint64_t	vs_esize;		/* expandable dev size */
708fa9e4066Sahrens 	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
709fa9e4066Sahrens 	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
710fa9e4066Sahrens 	uint64_t	vs_read_errors;		/* read errors		*/
711fa9e4066Sahrens 	uint64_t	vs_write_errors;	/* write errors		*/
712fa9e4066Sahrens 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
713fa9e4066Sahrens 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
7143f9d6ad7SLin Ling 	uint64_t	vs_scan_removing;	/* removing?	*/
7153f9d6ad7SLin Ling 	uint64_t	vs_scan_processed;	/* scan processed bytes	*/
716fa9e4066Sahrens } vdev_stat_t;
717fa9e4066Sahrens 
7189eb19f4dSGeorge Wilson /*
7199eb19f4dSGeorge Wilson  * DDT statistics.  Note: all fields should be 64-bit because this
7209eb19f4dSGeorge Wilson  * is passed between kernel and userland as an nvlist uint64 array.
7219eb19f4dSGeorge Wilson  */
7229eb19f4dSGeorge Wilson typedef struct ddt_object {
7239eb19f4dSGeorge Wilson 	uint64_t	ddo_count;	/* number of elments in ddt 	*/
7249eb19f4dSGeorge Wilson 	uint64_t	ddo_dspace;	/* size of ddt on disk		*/
7259eb19f4dSGeorge Wilson 	uint64_t	ddo_mspace;	/* size of ddt in-core		*/
7269eb19f4dSGeorge Wilson } ddt_object_t;
7279eb19f4dSGeorge Wilson 
7289eb19f4dSGeorge Wilson typedef struct ddt_stat {
7299eb19f4dSGeorge Wilson 	uint64_t	dds_blocks;	/* blocks			*/
7309eb19f4dSGeorge Wilson 	uint64_t	dds_lsize;	/* logical size			*/
7319eb19f4dSGeorge Wilson 	uint64_t	dds_psize;	/* physical size		*/
7329eb19f4dSGeorge Wilson 	uint64_t	dds_dsize;	/* deflated allocated size	*/
7339eb19f4dSGeorge Wilson 	uint64_t	dds_ref_blocks;	/* referenced blocks		*/
7349eb19f4dSGeorge Wilson 	uint64_t	dds_ref_lsize;	/* referenced lsize * refcnt	*/
7359eb19f4dSGeorge Wilson 	uint64_t	dds_ref_psize;	/* referenced psize * refcnt	*/
7369eb19f4dSGeorge Wilson 	uint64_t	dds_ref_dsize;	/* referenced dsize * refcnt	*/
7379eb19f4dSGeorge Wilson } ddt_stat_t;
7389eb19f4dSGeorge Wilson 
7399eb19f4dSGeorge Wilson typedef struct ddt_histogram {
7409eb19f4dSGeorge Wilson 	ddt_stat_t	ddh_stat[64];	/* power-of-two histogram buckets */
7419eb19f4dSGeorge Wilson } ddt_histogram_t;
7429eb19f4dSGeorge Wilson 
743e7cbe64fSgw #define	ZVOL_DRIVER	"zvol"
744fa9e4066Sahrens #define	ZFS_DRIVER	"zfs"
745fa9e4066Sahrens #define	ZFS_DEV		"/dev/zfs"
746fa9e4066Sahrens 
747681d9761SEric Taylor /* general zvol path */
748681d9761SEric Taylor #define	ZVOL_DIR		"/dev/zvol"
749681d9761SEric Taylor /* expansion */
750573ca77eSGeorge Wilson #define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zfs@0:"
751681d9761SEric Taylor /* for dump and swap */
752681d9761SEric Taylor #define	ZVOL_FULL_DEV_DIR	ZVOL_DIR "/dsk/"
753681d9761SEric Taylor #define	ZVOL_FULL_RDEV_DIR	ZVOL_DIR "/rdsk/"
754fa9e4066Sahrens 
755fa9e4066Sahrens #define	ZVOL_PROP_NAME		"name"
756c1449561SEric Taylor #define	ZVOL_DEFAULT_BLOCKSIZE	8192
757fa9e4066Sahrens 
758fa9e4066Sahrens /*
759fa9e4066Sahrens  * /dev/zfs ioctl numbers.
760fa9e4066Sahrens  */
761fa9e4066Sahrens typedef enum zfs_ioc {
7624445fffbSMatthew Ahrens 	ZFS_IOC_FIRST =	('Z' << 8),
7634445fffbSMatthew Ahrens 	ZFS_IOC = ZFS_IOC_FIRST,
7644445fffbSMatthew Ahrens 	ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,
765fa9e4066Sahrens 	ZFS_IOC_POOL_DESTROY,
766fa9e4066Sahrens 	ZFS_IOC_POOL_IMPORT,
767fa9e4066Sahrens 	ZFS_IOC_POOL_EXPORT,
768fa9e4066Sahrens 	ZFS_IOC_POOL_CONFIGS,
769fa9e4066Sahrens 	ZFS_IOC_POOL_STATS,
770fa9e4066Sahrens 	ZFS_IOC_POOL_TRYIMPORT,
7713f9d6ad7SLin Ling 	ZFS_IOC_POOL_SCAN,
772fa9e4066Sahrens 	ZFS_IOC_POOL_FREEZE,
773eaca9bbdSeschrock 	ZFS_IOC_POOL_UPGRADE,
77406eeb2adSek 	ZFS_IOC_POOL_GET_HISTORY,
775fa9e4066Sahrens 	ZFS_IOC_VDEV_ADD,
776fa9e4066Sahrens 	ZFS_IOC_VDEV_REMOVE,
7773d7072f8Seschrock 	ZFS_IOC_VDEV_SET_STATE,
778fa9e4066Sahrens 	ZFS_IOC_VDEV_ATTACH,
779fa9e4066Sahrens 	ZFS_IOC_VDEV_DETACH,
780c67d9675Seschrock 	ZFS_IOC_VDEV_SETPATH,
7816809eb4eSEric Schrock 	ZFS_IOC_VDEV_SETFRU,
782fa9e4066Sahrens 	ZFS_IOC_OBJSET_STATS,
783de8267e0Stimh 	ZFS_IOC_OBJSET_ZPLPROPS,
784fa9e4066Sahrens 	ZFS_IOC_DATASET_LIST_NEXT,
785fa9e4066Sahrens 	ZFS_IOC_SNAPSHOT_LIST_NEXT,
786fa9e4066Sahrens 	ZFS_IOC_SET_PROP,
787fa9e4066Sahrens 	ZFS_IOC_CREATE,
788fa9e4066Sahrens 	ZFS_IOC_DESTROY,
789fa9e4066Sahrens 	ZFS_IOC_ROLLBACK,
790fa9e4066Sahrens 	ZFS_IOC_RENAME,
7913cb34c60Sahrens 	ZFS_IOC_RECV,
7923cb34c60Sahrens 	ZFS_IOC_SEND,
793ea8dc4b6Seschrock 	ZFS_IOC_INJECT_FAULT,
794ea8dc4b6Seschrock 	ZFS_IOC_CLEAR_FAULT,
795ea8dc4b6Seschrock 	ZFS_IOC_INJECT_LIST_NEXT,
796ea8dc4b6Seschrock 	ZFS_IOC_ERROR_LOG,
797ea8dc4b6Seschrock 	ZFS_IOC_CLEAR,
7981d452cf5Sahrens 	ZFS_IOC_PROMOTE,
79955434c77Sek 	ZFS_IOC_SNAPSHOT,
80055434c77Sek 	ZFS_IOC_DSOBJ_TO_DSNAME,
801b1b8ab34Slling 	ZFS_IOC_OBJ_TO_PATH,
802b1b8ab34Slling 	ZFS_IOC_POOL_SET_PROPS,
803ecd6cf80Smarks 	ZFS_IOC_POOL_GET_PROPS,
804ecd6cf80Smarks 	ZFS_IOC_SET_FSACL,
805ecd6cf80Smarks 	ZFS_IOC_GET_FSACL,
806e45ce728Sahrens 	ZFS_IOC_SHARE,
807743a77edSAlan Wright 	ZFS_IOC_INHERIT_PROP,
80814843421SMatthew Ahrens 	ZFS_IOC_SMB_ACL,
80914843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_ONE,
81014843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_MANY,
811842727c2SChris Kirby 	ZFS_IOC_USERSPACE_UPGRADE,
812842727c2SChris Kirby 	ZFS_IOC_HOLD,
813842727c2SChris Kirby 	ZFS_IOC_RELEASE,
81492241e0bSTom Erickson 	ZFS_IOC_GET_HOLDS,
8151195e687SMark J Musante 	ZFS_IOC_OBJSET_RECVD_PROPS,
81699d5e173STim Haley 	ZFS_IOC_VDEV_SPLIT,
81799d5e173STim Haley 	ZFS_IOC_NEXT_OBJ,
81899d5e173STim Haley 	ZFS_IOC_DIFF,
81999d5e173STim Haley 	ZFS_IOC_TMP_SNAPSHOT,
820e9103aaeSGarrett D'Amore 	ZFS_IOC_OBJ_TO_STATS,
82119b94df9SMatthew Ahrens 	ZFS_IOC_SPACE_WRITTEN,
82219b94df9SMatthew Ahrens 	ZFS_IOC_SPACE_SNAPS,
8234445fffbSMatthew Ahrens 	ZFS_IOC_DESTROY_SNAPS,
8244263d13fSGeorge Wilson 	ZFS_IOC_POOL_REGUID,
8254e3c9f44SBill Pijewski 	ZFS_IOC_POOL_REOPEN,
8264445fffbSMatthew Ahrens 	ZFS_IOC_SEND_PROGRESS,
8274445fffbSMatthew Ahrens 	ZFS_IOC_LOG_HISTORY,
8284445fffbSMatthew Ahrens 	ZFS_IOC_SEND_NEW,
8294445fffbSMatthew Ahrens 	ZFS_IOC_SEND_SPACE,
8304445fffbSMatthew Ahrens 	ZFS_IOC_CLONE,
8314445fffbSMatthew Ahrens 	ZFS_IOC_LAST
832fa9e4066Sahrens } zfs_ioc_t;
833fa9e4066Sahrens 
834ea8dc4b6Seschrock /*
835ea8dc4b6Seschrock  * Internal SPA load state.  Used by FMA diagnosis engine.
836ea8dc4b6Seschrock  */
837ea8dc4b6Seschrock typedef enum {
8389eb19f4dSGeorge Wilson 	SPA_LOAD_NONE,		/* no load in progress	*/
8399eb19f4dSGeorge Wilson 	SPA_LOAD_OPEN,		/* normal open		*/
8409eb19f4dSGeorge Wilson 	SPA_LOAD_IMPORT,	/* import in progress	*/
841468c413aSTim Haley 	SPA_LOAD_TRYIMPORT,	/* tryimport in progress */
8429eb19f4dSGeorge Wilson 	SPA_LOAD_RECOVER,	/* recovery requested	*/
8439eb19f4dSGeorge Wilson 	SPA_LOAD_ERROR		/* load failed		*/
844ea8dc4b6Seschrock } spa_load_state_t;
845ea8dc4b6Seschrock 
846e9dbad6fSeschrock /*
847e9dbad6fSeschrock  * Bookmark name values.
848e9dbad6fSeschrock  */
84955434c77Sek #define	ZPOOL_ERR_LIST		"error list"
850e9dbad6fSeschrock #define	ZPOOL_ERR_DATASET	"dataset"
851e9dbad6fSeschrock #define	ZPOOL_ERR_OBJECT	"object"
852e9dbad6fSeschrock 
85306eeb2adSek #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
85406eeb2adSek 
85506eeb2adSek /*
85606eeb2adSek  * The following are names used in the nvlist describing
85706eeb2adSek  * the pool's history log.
85806eeb2adSek  */
85906eeb2adSek #define	ZPOOL_HIST_RECORD	"history record"
86006eeb2adSek #define	ZPOOL_HIST_TIME		"history time"
86106eeb2adSek #define	ZPOOL_HIST_CMD		"history command"
862ecd6cf80Smarks #define	ZPOOL_HIST_WHO		"history who"
863ecd6cf80Smarks #define	ZPOOL_HIST_ZONE		"history zone"
864ecd6cf80Smarks #define	ZPOOL_HIST_HOST		"history hostname"
865ecd6cf80Smarks #define	ZPOOL_HIST_TXG		"history txg"
866ecd6cf80Smarks #define	ZPOOL_HIST_INT_EVENT	"history internal event"
867ecd6cf80Smarks #define	ZPOOL_HIST_INT_STR	"history internal str"
8684445fffbSMatthew Ahrens #define	ZPOOL_HIST_INT_NAME	"internal_name"
8694445fffbSMatthew Ahrens #define	ZPOOL_HIST_IOCTL	"ioctl"
8704445fffbSMatthew Ahrens #define	ZPOOL_HIST_INPUT_NVL	"in_nvl"
8714445fffbSMatthew Ahrens #define	ZPOOL_HIST_OUTPUT_NVL	"out_nvl"
8724445fffbSMatthew Ahrens #define	ZPOOL_HIST_DSNAME	"dsname"
8734445fffbSMatthew Ahrens #define	ZPOOL_HIST_DSID		"dsid"
87406eeb2adSek 
8753d7072f8Seschrock /*
8763d7072f8Seschrock  * Flags for ZFS_IOC_VDEV_SET_STATE
8773d7072f8Seschrock  */
8783d7072f8Seschrock #define	ZFS_ONLINE_CHECKREMOVE	0x1
8793d7072f8Seschrock #define	ZFS_ONLINE_UNSPARE	0x2
8803d7072f8Seschrock #define	ZFS_ONLINE_FORCEFAULT	0x4
881573ca77eSGeorge Wilson #define	ZFS_ONLINE_EXPAND	0x8
8823d7072f8Seschrock #define	ZFS_OFFLINE_TEMPORARY	0x1
8833d7072f8Seschrock 
8844b964adaSGeorge Wilson /*
8854b964adaSGeorge Wilson  * Flags for ZFS_IOC_POOL_IMPORT
8864b964adaSGeorge Wilson  */
8874b964adaSGeorge Wilson #define	ZFS_IMPORT_NORMAL	0x0
8884b964adaSGeorge Wilson #define	ZFS_IMPORT_VERBATIM	0x1
8894b964adaSGeorge Wilson #define	ZFS_IMPORT_ANY_HOST	0x2
8904b964adaSGeorge Wilson #define	ZFS_IMPORT_MISSING_LOG	0x4
891f9af39baSGeorge Wilson #define	ZFS_IMPORT_ONLY		0x8
8924b964adaSGeorge Wilson 
8933d7072f8Seschrock /*
8943d7072f8Seschrock  * Sysevent payload members.  ZFS will generate the following sysevents with the
8953d7072f8Seschrock  * given payloads:
8963d7072f8Seschrock  *
8973d7072f8Seschrock  *	ESC_ZFS_RESILVER_START
8983d7072f8Seschrock  *	ESC_ZFS_RESILVER_END
8993d7072f8Seschrock  *	ESC_ZFS_POOL_DESTROY
900e9103aaeSGarrett D'Amore  *	ESC_ZFS_POOL_REGUID
9013d7072f8Seschrock  *
9023d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
9033d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
9043d7072f8Seschrock  *
9053d7072f8Seschrock  *	ESC_ZFS_VDEV_REMOVE
9063d7072f8Seschrock  *	ESC_ZFS_VDEV_CLEAR
9073d7072f8Seschrock  *	ESC_ZFS_VDEV_CHECK
9083d7072f8Seschrock  *
9093d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
9103d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
9113d7072f8Seschrock  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
9123d7072f8Seschrock  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
9133d7072f8Seschrock  */
9143d7072f8Seschrock #define	ZFS_EV_POOL_NAME	"pool_name"
9153d7072f8Seschrock #define	ZFS_EV_POOL_GUID	"pool_guid"
9163d7072f8Seschrock #define	ZFS_EV_VDEV_PATH	"vdev_path"
9173d7072f8Seschrock #define	ZFS_EV_VDEV_GUID	"vdev_guid"
9183d7072f8Seschrock 
919fa9e4066Sahrens #ifdef	__cplusplus
920fa9e4066Sahrens }
921fa9e4066Sahrens #endif
922fa9e4066Sahrens 
923fa9e4066Sahrens #endif	/* _SYS_FS_ZFS_H */
924