xref: /illumos-gate/usr/src/uts/common/sys/fs/zfs.h (revision 3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5)
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.
24fa9e4066Sahrens  */
25fa9e4066Sahrens 
2655da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */
2755da60b9SMark J Musante 
28fa9e4066Sahrens #ifndef	_SYS_FS_ZFS_H
29fa9e4066Sahrens #define	_SYS_FS_ZFS_H
30fa9e4066Sahrens 
31842727c2SChris Kirby #include <sys/time.h>
32842727c2SChris Kirby 
33fa9e4066Sahrens #ifdef	__cplusplus
34fa9e4066Sahrens extern "C" {
35fa9e4066Sahrens #endif
36fa9e4066Sahrens 
37fa9e4066Sahrens /*
38fa9e4066Sahrens  * Types and constants shared between userland and the kernel.
39fa9e4066Sahrens  */
40fa9e4066Sahrens 
41fa9e4066Sahrens /*
42fa9e4066Sahrens  * Each dataset can be one of the following types.  These constants can be
43fa9e4066Sahrens  * combined into masks that can be passed to various functions.
44fa9e4066Sahrens  */
45fa9e4066Sahrens typedef enum {
46fa9e4066Sahrens 	ZFS_TYPE_FILESYSTEM	= 0x1,
47fa9e4066Sahrens 	ZFS_TYPE_SNAPSHOT	= 0x2,
48b1b8ab34Slling 	ZFS_TYPE_VOLUME		= 0x4,
49b1b8ab34Slling 	ZFS_TYPE_POOL		= 0x8
50fa9e4066Sahrens } zfs_type_t;
51fa9e4066Sahrens 
52990b4856Slling #define	ZFS_TYPE_DATASET	\
53fa9e4066Sahrens 	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
54fa9e4066Sahrens 
55478ed9adSEric Taylor #define	ZAP_MAXNAMELEN 256
56478ed9adSEric Taylor #define	ZAP_MAXVALUELEN (1024 * 8)
57478ed9adSEric Taylor #define	ZAP_OLDMAXVALUELEN 1024
58478ed9adSEric Taylor 
59fa9e4066Sahrens /*
60990b4856Slling  * Dataset properties are identified by these constants and must be added to
61990b4856Slling  * the end of this list to ensure that external consumers are not affected
62990b4856Slling  * by the change. If you make any changes to this list, be sure to update
6366e2aaccSgw  * the property table in usr/src/common/zfs/zfs_prop.c.
64fa9e4066Sahrens  */
65fa9e4066Sahrens typedef enum {
66fa9e4066Sahrens 	ZFS_PROP_TYPE,
67fa9e4066Sahrens 	ZFS_PROP_CREATION,
68fa9e4066Sahrens 	ZFS_PROP_USED,
69fa9e4066Sahrens 	ZFS_PROP_AVAILABLE,
70fa9e4066Sahrens 	ZFS_PROP_REFERENCED,
71fa9e4066Sahrens 	ZFS_PROP_COMPRESSRATIO,
72fa9e4066Sahrens 	ZFS_PROP_MOUNTED,
73fa9e4066Sahrens 	ZFS_PROP_ORIGIN,
74fa9e4066Sahrens 	ZFS_PROP_QUOTA,
75fa9e4066Sahrens 	ZFS_PROP_RESERVATION,
76fa9e4066Sahrens 	ZFS_PROP_VOLSIZE,
77fa9e4066Sahrens 	ZFS_PROP_VOLBLOCKSIZE,
78fa9e4066Sahrens 	ZFS_PROP_RECORDSIZE,
79fa9e4066Sahrens 	ZFS_PROP_MOUNTPOINT,
80fa9e4066Sahrens 	ZFS_PROP_SHARENFS,
81fa9e4066Sahrens 	ZFS_PROP_CHECKSUM,
82fa9e4066Sahrens 	ZFS_PROP_COMPRESSION,
83fa9e4066Sahrens 	ZFS_PROP_ATIME,
84fa9e4066Sahrens 	ZFS_PROP_DEVICES,
85fa9e4066Sahrens 	ZFS_PROP_EXEC,
86fa9e4066Sahrens 	ZFS_PROP_SETUID,
87fa9e4066Sahrens 	ZFS_PROP_READONLY,
88fa9e4066Sahrens 	ZFS_PROP_ZONED,
89fa9e4066Sahrens 	ZFS_PROP_SNAPDIR,
9027dd1e87SMark Shellenbaum 	ZFS_PROP_PRIVATE,		/* not exposed to user, temporary */
91fa9e4066Sahrens 	ZFS_PROP_ACLINHERIT,
9266e2aaccSgw 	ZFS_PROP_CREATETXG,		/* not exposed to the user */
9366e2aaccSgw 	ZFS_PROP_NAME,			/* not exposed to the user */
94e9dbad6fSeschrock 	ZFS_PROP_CANMOUNT,
9566e2aaccSgw 	ZFS_PROP_ISCSIOPTIONS,		/* not exposed to the user */
967b55fa8eSck 	ZFS_PROP_XATTR,
97d0ad202dSahrens 	ZFS_PROP_NUMCLONES,		/* not exposed to the user */
98b1b8ab34Slling 	ZFS_PROP_COPIES,
99e7437265Sahrens 	ZFS_PROP_VERSION,
100da6c28aaSamw 	ZFS_PROP_UTF8ONLY,
101da6c28aaSamw 	ZFS_PROP_NORMALIZE,
102da6c28aaSamw 	ZFS_PROP_CASE,
103da6c28aaSamw 	ZFS_PROP_VSCAN,
104da6c28aaSamw 	ZFS_PROP_NBMAND,
105da6c28aaSamw 	ZFS_PROP_SHARESMB,
106a9799022Sck 	ZFS_PROP_REFQUOTA,
107a9799022Sck 	ZFS_PROP_REFRESERVATION,
108c5904d13Seschrock 	ZFS_PROP_GUID,
1093baa08fcSek 	ZFS_PROP_PRIMARYCACHE,
1103baa08fcSek 	ZFS_PROP_SECONDARYCACHE,
11174e7dc98SMatthew Ahrens 	ZFS_PROP_USEDSNAP,
11274e7dc98SMatthew Ahrens 	ZFS_PROP_USEDDS,
11374e7dc98SMatthew Ahrens 	ZFS_PROP_USEDCHILD,
11474e7dc98SMatthew Ahrens 	ZFS_PROP_USEDREFRESERV,
11514843421SMatthew Ahrens 	ZFS_PROP_USERACCOUNTING,	/* not exposed to the user */
116478ed9adSEric Taylor 	ZFS_PROP_STMF_SHAREINFO,	/* not exposed to the user */
117842727c2SChris Kirby 	ZFS_PROP_DEFER_DESTROY,
118842727c2SChris Kirby 	ZFS_PROP_USERREFS,
119e09fa4daSNeil Perrin 	ZFS_PROP_LOGBIAS,
1201d713200SEric Schrock 	ZFS_PROP_UNIQUE,		/* not exposed to the user */
1211d713200SEric Schrock 	ZFS_PROP_OBJSETID,		/* not exposed to the user */
122b24ab676SJeff Bonwick 	ZFS_PROP_DEDUP,
1234201a95eSRic Aleshire 	ZFS_PROP_MLSLABEL,
12455da60b9SMark J Musante 	ZFS_PROP_SYNC,
12591ebeef5Sahrens 	ZFS_NUM_PROPS
126fa9e4066Sahrens } zfs_prop_t;
127fa9e4066Sahrens 
12814843421SMatthew Ahrens typedef enum {
12914843421SMatthew Ahrens 	ZFS_PROP_USERUSED,
13014843421SMatthew Ahrens 	ZFS_PROP_USERQUOTA,
13114843421SMatthew Ahrens 	ZFS_PROP_GROUPUSED,
13214843421SMatthew Ahrens 	ZFS_PROP_GROUPQUOTA,
13314843421SMatthew Ahrens 	ZFS_NUM_USERQUOTA_PROPS
13414843421SMatthew Ahrens } zfs_userquota_prop_t;
13514843421SMatthew Ahrens 
13614843421SMatthew Ahrens extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
13714843421SMatthew Ahrens 
138990b4856Slling /*
139990b4856Slling  * Pool properties are identified by these constants and must be added to the
140b87f3af3Sperrin  * end of this list to ensure that external consumers are not affected
141990b4856Slling  * by the change. If you make any changes to this list, be sure to update
142990b4856Slling  * the property table in usr/src/common/zfs/zpool_prop.c.
143990b4856Slling  */
144990b4856Slling typedef enum {
145990b4856Slling 	ZPOOL_PROP_NAME,
146990b4856Slling 	ZPOOL_PROP_SIZE,
147990b4856Slling 	ZPOOL_PROP_CAPACITY,
148990b4856Slling 	ZPOOL_PROP_ALTROOT,
149990b4856Slling 	ZPOOL_PROP_HEALTH,
150990b4856Slling 	ZPOOL_PROP_GUID,
151990b4856Slling 	ZPOOL_PROP_VERSION,
152990b4856Slling 	ZPOOL_PROP_BOOTFS,
153990b4856Slling 	ZPOOL_PROP_DELEGATION,
154990b4856Slling 	ZPOOL_PROP_AUTOREPLACE,
1552f8aaab3Seschrock 	ZPOOL_PROP_CACHEFILE,
1560a4e9518Sgw 	ZPOOL_PROP_FAILUREMODE,
157d5b5bb25SRich Morris 	ZPOOL_PROP_LISTSNAPS,
158573ca77eSGeorge Wilson 	ZPOOL_PROP_AUTOEXPAND,
159b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPDITTO,
160b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPRATIO,
161485bbbf5SGeorge Wilson 	ZPOOL_PROP_FREE,
162485bbbf5SGeorge Wilson 	ZPOOL_PROP_ALLOCATED,
163990b4856Slling 	ZPOOL_NUM_PROPS
164990b4856Slling } zpool_prop_t;
165b1b8ab34Slling 
166990b4856Slling #define	ZPROP_CONT		-2
167990b4856Slling #define	ZPROP_INVAL		-1
1683d7072f8Seschrock 
169990b4856Slling #define	ZPROP_VALUE		"value"
170990b4856Slling #define	ZPROP_SOURCE		"source"
1717f7322feSeschrock 
172b1b8ab34Slling typedef enum {
173990b4856Slling 	ZPROP_SRC_NONE = 0x1,
174990b4856Slling 	ZPROP_SRC_DEFAULT = 0x2,
175990b4856Slling 	ZPROP_SRC_TEMPORARY = 0x4,
176990b4856Slling 	ZPROP_SRC_LOCAL = 0x8,
17792241e0bSTom Erickson 	ZPROP_SRC_INHERITED = 0x10,
17892241e0bSTom Erickson 	ZPROP_SRC_RECEIVED = 0x20
179990b4856Slling } zprop_source_t;
180990b4856Slling 
18192241e0bSTom Erickson #define	ZPROP_SRC_ALL	0x3f
18292241e0bSTom Erickson 
18392241e0bSTom Erickson #define	ZPROP_SOURCE_VAL_RECVD	"$recvd"
18492241e0bSTom Erickson #define	ZPROP_N_MORE_ERRORS	"N_MORE_ERRORS"
18592241e0bSTom Erickson /*
18692241e0bSTom Erickson  * Dataset flag implemented as a special entry in the props zap object
18792241e0bSTom Erickson  * indicating that the dataset has received properties on or after
18892241e0bSTom Erickson  * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
18992241e0bSTom Erickson  * just as it did in earlier versions, and thereafter, local properties are
19092241e0bSTom Erickson  * preserved.
19192241e0bSTom Erickson  */
19292241e0bSTom Erickson #define	ZPROP_HAS_RECVD		"$hasrecvd"
19392241e0bSTom Erickson 
19492241e0bSTom Erickson typedef enum {
19592241e0bSTom Erickson 	ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
19692241e0bSTom Erickson 	ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
19792241e0bSTom Erickson } zprop_errflags_t;
198990b4856Slling 
199990b4856Slling typedef int (*zprop_func)(int, void *);
200990b4856Slling 
2010a48a24eStimh /*
2020a48a24eStimh  * Properties to be set on the root file system of a new pool
2030a48a24eStimh  * are stuffed into their own nvlist, which is then included in
2040a48a24eStimh  * the properties nvlist with the pool properties.
2050a48a24eStimh  */
2060a48a24eStimh #define	ZPOOL_ROOTFS_PROPS	"root-props-nvl"
2070a48a24eStimh 
208990b4856Slling /*
209990b4856Slling  * Dataset property functions shared between libzfs and kernel.
210990b4856Slling  */
211990b4856Slling const char *zfs_prop_default_string(zfs_prop_t);
212990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t);
213990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t);
214990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t);
215da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t);
216990b4856Slling const char *zfs_prop_to_name(zfs_prop_t);
217990b4856Slling zfs_prop_t zfs_name_to_prop(const char *);
218990b4856Slling boolean_t zfs_prop_user(const char *);
21992241e0bSTom Erickson boolean_t zfs_prop_userquota(const char *);
220990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
221990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
222b24ab676SJeff Bonwick uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
2234853e976Sgw boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
224b1b8ab34Slling 
225990b4856Slling /*
226990b4856Slling  * Pool property functions shared between libzfs and kernel.
227990b4856Slling  */
228990b4856Slling zpool_prop_t zpool_name_to_prop(const char *);
229990b4856Slling const char *zpool_prop_to_name(zpool_prop_t);
230990b4856Slling const char *zpool_prop_default_string(zpool_prop_t);
231990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t);
232990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t);
233990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
234990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
235b24ab676SJeff Bonwick uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
236b1b8ab34Slling 
237990b4856Slling /*
238990b4856Slling  * Definitions for the Delegation.
239990b4856Slling  */
240ecd6cf80Smarks typedef enum {
241ecd6cf80Smarks 	ZFS_DELEG_WHO_UNKNOWN = 0,
242ecd6cf80Smarks 	ZFS_DELEG_USER = 'u',
243ecd6cf80Smarks 	ZFS_DELEG_USER_SETS = 'U',
244ecd6cf80Smarks 	ZFS_DELEG_GROUP = 'g',
245ecd6cf80Smarks 	ZFS_DELEG_GROUP_SETS = 'G',
246ecd6cf80Smarks 	ZFS_DELEG_EVERYONE = 'e',
247ecd6cf80Smarks 	ZFS_DELEG_EVERYONE_SETS = 'E',
248ecd6cf80Smarks 	ZFS_DELEG_CREATE = 'c',
249ecd6cf80Smarks 	ZFS_DELEG_CREATE_SETS = 'C',
250ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET = 's',
251ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET_SETS = 'S'
252ecd6cf80Smarks } zfs_deleg_who_type_t;
253ecd6cf80Smarks 
254ecd6cf80Smarks typedef enum {
255ecd6cf80Smarks 	ZFS_DELEG_NONE = 0,
256ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCAL = 1,
257ecd6cf80Smarks 	ZFS_DELEG_PERM_DESCENDENT = 2,
258ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
259ecd6cf80Smarks 	ZFS_DELEG_PERM_CREATE = 4
260ecd6cf80Smarks } zfs_deleg_inherit_t;
261ecd6cf80Smarks 
262ecd6cf80Smarks #define	ZFS_DELEG_PERM_UID	"uid"
263ecd6cf80Smarks #define	ZFS_DELEG_PERM_GID	"gid"
264ecd6cf80Smarks #define	ZFS_DELEG_PERM_GROUPS	"groups"
265ecd6cf80Smarks 
2664201a95eSRic Aleshire #define	ZFS_MLSLABEL_DEFAULT	"none"
2674201a95eSRic Aleshire 
268743a77edSAlan Wright #define	ZFS_SMB_ACL_SRC		"src"
269743a77edSAlan Wright #define	ZFS_SMB_ACL_TARGET	"target"
270743a77edSAlan Wright 
271a227b7f4Shs typedef enum {
272a227b7f4Shs 	ZFS_CANMOUNT_OFF = 0,
273a227b7f4Shs 	ZFS_CANMOUNT_ON = 1,
274a227b7f4Shs 	ZFS_CANMOUNT_NOAUTO = 2
275a227b7f4Shs } zfs_canmount_type_t;
276a227b7f4Shs 
277e09fa4daSNeil Perrin typedef enum {
278e09fa4daSNeil Perrin 	ZFS_LOGBIAS_LATENCY = 0,
279e09fa4daSNeil Perrin 	ZFS_LOGBIAS_THROUGHPUT = 1
280e09fa4daSNeil Perrin } zfs_logbias_op_t;
281e09fa4daSNeil Perrin 
282da6c28aaSamw typedef enum zfs_share_op {
283da6c28aaSamw 	ZFS_SHARE_NFS = 0,
284da6c28aaSamw 	ZFS_UNSHARE_NFS = 1,
285da6c28aaSamw 	ZFS_SHARE_SMB = 2,
286da6c28aaSamw 	ZFS_UNSHARE_SMB = 3
287da6c28aaSamw } zfs_share_op_t;
288da6c28aaSamw 
289743a77edSAlan Wright typedef enum zfs_smb_acl_op {
290743a77edSAlan Wright 	ZFS_SMB_ACL_ADD,
291743a77edSAlan Wright 	ZFS_SMB_ACL_REMOVE,
292743a77edSAlan Wright 	ZFS_SMB_ACL_RENAME,
293743a77edSAlan Wright 	ZFS_SMB_ACL_PURGE
294743a77edSAlan Wright } zfs_smb_acl_op_t;
295743a77edSAlan Wright 
2963baa08fcSek typedef enum zfs_cache_type {
2973baa08fcSek 	ZFS_CACHE_NONE = 0,
2983baa08fcSek 	ZFS_CACHE_METADATA = 1,
2993baa08fcSek 	ZFS_CACHE_ALL = 2
3003baa08fcSek } zfs_cache_type_t;
3013baa08fcSek 
30255da60b9SMark J Musante typedef enum {
30355da60b9SMark J Musante 	ZFS_SYNC_STANDARD = 0,
30455da60b9SMark J Musante 	ZFS_SYNC_ALWAYS = 1,
30555da60b9SMark J Musante 	ZFS_SYNC_DISABLED = 2
30655da60b9SMark J Musante } zfs_sync_type_t;
30755da60b9SMark J Musante 
3083baa08fcSek 
309eaca9bbdSeschrock /*
31099653d4eSeschrock  * On-disk version number.
311eaca9bbdSeschrock  */
312e7437265Sahrens #define	SPA_VERSION_1			1ULL
313e7437265Sahrens #define	SPA_VERSION_2			2ULL
314e7437265Sahrens #define	SPA_VERSION_3			3ULL
315e7437265Sahrens #define	SPA_VERSION_4			4ULL
316e7437265Sahrens #define	SPA_VERSION_5			5ULL
317e7437265Sahrens #define	SPA_VERSION_6			6ULL
318e7437265Sahrens #define	SPA_VERSION_7			7ULL
319e7437265Sahrens #define	SPA_VERSION_8			8ULL
320da6c28aaSamw #define	SPA_VERSION_9			9ULL
321fa94a07fSbrendan #define	SPA_VERSION_10			10ULL
322088f3894Sahrens #define	SPA_VERSION_11			11ULL
323bb0ade09Sahrens #define	SPA_VERSION_12			12ULL
32474e7dc98SMatthew Ahrens #define	SPA_VERSION_13			13ULL
325d0f3f37eSMark Shellenbaum #define	SPA_VERSION_14			14ULL
32614843421SMatthew Ahrens #define	SPA_VERSION_15			15ULL
327478ed9adSEric Taylor #define	SPA_VERSION_16			16ULL
328f94275ceSAdam Leventhal #define	SPA_VERSION_17			17ULL
329842727c2SChris Kirby #define	SPA_VERSION_18			18ULL
33088ecc943SGeorge Wilson #define	SPA_VERSION_19			19ULL
331b24ab676SJeff Bonwick #define	SPA_VERSION_20			20ULL
332b24ab676SJeff Bonwick #define	SPA_VERSION_21			21ULL
33392241e0bSTom Erickson #define	SPA_VERSION_22			22ULL
3346e1f5caaSNeil Perrin #define	SPA_VERSION_23			23ULL
3350a586ceaSMark Shellenbaum #define	SPA_VERSION_24			24ULL
336*3f9d6ad7SLin Ling #define	SPA_VERSION_25			25ULL
337b1b8ab34Slling /*
338e7cbe64fSgw  * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
339478ed9adSEric Taylor  * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
34014843421SMatthew Ahrens  * and do the appropriate changes.  Also bump the version number in
34114843421SMatthew Ahrens  * usr/src/grub/capability.
342b1b8ab34Slling  */
343*3f9d6ad7SLin Ling #define	SPA_VERSION			SPA_VERSION_25
344*3f9d6ad7SLin Ling #define	SPA_VERSION_STRING		"25"
34544cd46caSbillm 
34644cd46caSbillm /*
347e7437265Sahrens  * Symbolic names for the changes that caused a SPA_VERSION switch.
34844cd46caSbillm  * Used in the code when checking for presence or absence of a feature.
34944cd46caSbillm  * Feel free to define multiple symbolic names for each version if there
35044cd46caSbillm  * were multiple changes to on-disk structures during that version.
35144cd46caSbillm  *
352e7437265Sahrens  * NOTE: When checking the current SPA_VERSION in your code, be sure
35344cd46caSbillm  *       to use spa_version() since it reports the version of the
35444cd46caSbillm  *       last synced uberblock.  Checking the in-flight version can
35544cd46caSbillm  *       be dangerous in some cases.
35644cd46caSbillm  */
357e7437265Sahrens #define	SPA_VERSION_INITIAL		SPA_VERSION_1
358e7437265Sahrens #define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
359e7437265Sahrens #define	SPA_VERSION_SPARES		SPA_VERSION_3
360f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ2		SPA_VERSION_3
361e7437265Sahrens #define	SPA_VERSION_BPLIST_ACCOUNT	SPA_VERSION_3
362e7437265Sahrens #define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
363e7437265Sahrens #define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
364e7437265Sahrens #define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
365e7437265Sahrens #define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
366e7437265Sahrens #define	SPA_VERSION_BOOTFS		SPA_VERSION_6
367990b4856Slling #define	SPA_VERSION_SLOGS		SPA_VERSION_7
368990b4856Slling #define	SPA_VERSION_DELEGATED_PERMS	SPA_VERSION_8
369da6c28aaSamw #define	SPA_VERSION_FUID		SPA_VERSION_9
370a9799022Sck #define	SPA_VERSION_REFRESERVATION	SPA_VERSION_9
371a9799022Sck #define	SPA_VERSION_REFQUOTA		SPA_VERSION_9
372a9799022Sck #define	SPA_VERSION_UNIQUE_ACCURATE	SPA_VERSION_9
373fa94a07fSbrendan #define	SPA_VERSION_L2CACHE		SPA_VERSION_10
374088f3894Sahrens #define	SPA_VERSION_NEXT_CLONES		SPA_VERSION_11
375088f3894Sahrens #define	SPA_VERSION_ORIGIN		SPA_VERSION_11
376088f3894Sahrens #define	SPA_VERSION_DSL_SCRUB		SPA_VERSION_11
377bb0ade09Sahrens #define	SPA_VERSION_SNAP_PROPS		SPA_VERSION_12
37874e7dc98SMatthew Ahrens #define	SPA_VERSION_USED_BREAKDOWN	SPA_VERSION_13
379d0f3f37eSMark Shellenbaum #define	SPA_VERSION_PASSTHROUGH_X	SPA_VERSION_14
38014843421SMatthew Ahrens #define	SPA_VERSION_USERSPACE		SPA_VERSION_15
381478ed9adSEric Taylor #define	SPA_VERSION_STMF_PROP		SPA_VERSION_16
382f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ3		SPA_VERSION_17
383842727c2SChris Kirby #define	SPA_VERSION_USERREFS		SPA_VERSION_18
38488ecc943SGeorge Wilson #define	SPA_VERSION_HOLES		SPA_VERSION_19
385b24ab676SJeff Bonwick #define	SPA_VERSION_ZLE_COMPRESSION	SPA_VERSION_20
386b24ab676SJeff Bonwick #define	SPA_VERSION_DEDUP		SPA_VERSION_21
38792241e0bSTom Erickson #define	SPA_VERSION_RECVD_PROPS		SPA_VERSION_22
3886e1f5caaSNeil Perrin #define	SPA_VERSION_SLIM_ZIL		SPA_VERSION_23
3890a586ceaSMark Shellenbaum #define	SPA_VERSION_SA			SPA_VERSION_24
390*3f9d6ad7SLin Ling #define	SPA_VERSION_SCAN		SPA_VERSION_25
391e7437265Sahrens 
392e7437265Sahrens /*
393e7437265Sahrens  * ZPL version - rev'd whenever an incompatible on-disk format change
394e7437265Sahrens  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
395e7437265Sahrens  * also update the version_table[] and help message in zfs_prop.c.
396e7437265Sahrens  *
397e7437265Sahrens  * When changing, be sure to teach GRUB how to read the new format!
398478ed9adSEric Taylor  * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
399e7437265Sahrens  */
400e7437265Sahrens #define	ZPL_VERSION_1			1ULL
401e7437265Sahrens #define	ZPL_VERSION_2			2ULL
402da6c28aaSamw #define	ZPL_VERSION_3			3ULL
40314843421SMatthew Ahrens #define	ZPL_VERSION_4			4ULL
4040a586ceaSMark Shellenbaum #define	ZPL_VERSION_5			5ULL
4050a586ceaSMark Shellenbaum #define	ZPL_VERSION			ZPL_VERSION_5
4060a586ceaSMark Shellenbaum #define	ZPL_VERSION_STRING		"5"
407e7437265Sahrens 
408e7437265Sahrens #define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
409e7437265Sahrens #define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
410da6c28aaSamw #define	ZPL_VERSION_FUID		ZPL_VERSION_3
411de8267e0Stimh #define	ZPL_VERSION_NORMALIZATION	ZPL_VERSION_3
412da6c28aaSamw #define	ZPL_VERSION_SYSATTR		ZPL_VERSION_3
41314843421SMatthew Ahrens #define	ZPL_VERSION_USERSPACE		ZPL_VERSION_4
4140a586ceaSMark Shellenbaum #define	ZPL_VERSION_SA			ZPL_VERSION_5
415eaca9bbdSeschrock 
416468c413aSTim Haley /* Rewind request information */
417c8ee1847SVictor Latushkin #define	ZPOOL_NO_REWIND		1  /* No policy - default behavior */
418c8ee1847SVictor Latushkin #define	ZPOOL_NEVER_REWIND	2  /* Do not search for best txg or rewind */
419c8ee1847SVictor Latushkin #define	ZPOOL_TRY_REWIND	4  /* Search for best txg, but do not rewind */
420c8ee1847SVictor Latushkin #define	ZPOOL_DO_REWIND		8  /* Rewind to best txg w/in deferred frees */
421c8ee1847SVictor Latushkin #define	ZPOOL_EXTREME_REWIND	16 /* Allow extreme measures to find best txg */
422c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_MASK	28 /* All the possible rewind bits */
423c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_POLICIES	31 /* All the possible policy bits */
424468c413aSTim Haley 
425468c413aSTim Haley typedef struct zpool_rewind_policy {
426468c413aSTim Haley 	uint32_t	zrp_request;	/* rewind behavior requested */
427c8ee1847SVictor Latushkin 	uint64_t	zrp_maxmeta;	/* max acceptable meta-data errors */
428c8ee1847SVictor Latushkin 	uint64_t	zrp_maxdata;	/* max acceptable data errors */
429468c413aSTim Haley 	uint64_t	zrp_txg;	/* specific txg to load */
430468c413aSTim Haley } zpool_rewind_policy_t;
431468c413aSTim Haley 
432fa9e4066Sahrens /*
433fa9e4066Sahrens  * The following are configuration names used in the nvlist describing a pool's
434fa9e4066Sahrens  * configuration.
435fa9e4066Sahrens  */
436fa9e4066Sahrens #define	ZPOOL_CONFIG_VERSION		"version"
437fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_NAME		"name"
438fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_STATE		"state"
439fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_TXG		"txg"
440fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
441fa9e4066Sahrens #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
442fa9e4066Sahrens #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
443fa9e4066Sahrens #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
444fa9e4066Sahrens #define	ZPOOL_CONFIG_TYPE		"type"
445fa9e4066Sahrens #define	ZPOOL_CONFIG_CHILDREN		"children"
446fa9e4066Sahrens #define	ZPOOL_CONFIG_ID			"id"
447fa9e4066Sahrens #define	ZPOOL_CONFIG_GUID		"guid"
448fa9e4066Sahrens #define	ZPOOL_CONFIG_PATH		"path"
449fa9e4066Sahrens #define	ZPOOL_CONFIG_DEVID		"devid"
450fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
451fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
452fa9e4066Sahrens #define	ZPOOL_CONFIG_ASHIFT		"ashift"
453fa9e4066Sahrens #define	ZPOOL_CONFIG_ASIZE		"asize"
454fa9e4066Sahrens #define	ZPOOL_CONFIG_DTL		"DTL"
455*3f9d6ad7SLin Ling #define	ZPOOL_CONFIG_SCAN_STATS		"scan_stats"	/* not stored on disk */
456*3f9d6ad7SLin Ling #define	ZPOOL_CONFIG_VDEV_STATS		"vdev_stats"	/* not stored on disk */
457afefbcddSeschrock #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
458ea8dc4b6Seschrock #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
459ea8dc4b6Seschrock #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
46099653d4eSeschrock #define	ZPOOL_CONFIG_SPARES		"spares"
46199653d4eSeschrock #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
46299653d4eSeschrock #define	ZPOOL_CONFIG_NPARITY		"nparity"
46395173954Sek #define	ZPOOL_CONFIG_HOSTID		"hostid"
46495173954Sek #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
4653d7072f8Seschrock #define	ZPOOL_CONFIG_UNSPARE		"unspare"
4663d7072f8Seschrock #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
4678654d025Sperrin #define	ZPOOL_CONFIG_IS_LOG		"is_log"
468fa94a07fSbrendan #define	ZPOOL_CONFIG_L2CACHE		"l2cache"
46988ecc943SGeorge Wilson #define	ZPOOL_CONFIG_HOLE_ARRAY		"hole_array"
47088ecc943SGeorge Wilson #define	ZPOOL_CONFIG_VDEV_CHILDREN	"vdev_children"
47188ecc943SGeorge Wilson #define	ZPOOL_CONFIG_IS_HOLE		"is_hole"
4729eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_HISTOGRAM	"ddt_histogram"
4739eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_OBJ_STATS	"ddt_object_stats"
4749eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_STATS		"ddt_stats"
4751195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT		"splitcfg"
4761195e687SMark J Musante #define	ZPOOL_CONFIG_ORIG_GUID		"orig_guid"
4771195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_GUID		"split_guid"
4781195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_LIST		"guid_list"
479*3f9d6ad7SLin Ling #define	ZPOOL_CONFIG_REMOVING		"removing"
480e14bb325SJeff Bonwick #define	ZPOOL_CONFIG_SUSPENDED		"suspended"	/* not stored on disk */
481e7cbe64fSgw #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp"	/* not stored on disk */
482e7cbe64fSgw #define	ZPOOL_CONFIG_BOOTFS		"bootfs"	/* not stored on disk */
4833d7072f8Seschrock /*
4843d7072f8Seschrock  * The persistent vdev state is stored as separate values rather than a single
4853d7072f8Seschrock  * 'vdev_state' entry.  This is because a device can be in multiple states, such
4863d7072f8Seschrock  * as offline and degraded.
4873d7072f8Seschrock  */
4883d7072f8Seschrock #define	ZPOOL_CONFIG_OFFLINE		"offline"
4893d7072f8Seschrock #define	ZPOOL_CONFIG_FAULTED		"faulted"
4903d7072f8Seschrock #define	ZPOOL_CONFIG_DEGRADED		"degraded"
4913d7072f8Seschrock #define	ZPOOL_CONFIG_REMOVED		"removed"
4926809eb4eSEric Schrock #define	ZPOOL_CONFIG_FRU		"fru"
493069f55e2SEric Schrock #define	ZPOOL_CONFIG_AUX_STATE		"aux_state"
494fa9e4066Sahrens 
495468c413aSTim Haley /* Rewind policy parameters */
496468c413aSTim Haley #define	ZPOOL_REWIND_POLICY		"rewind-policy"
497468c413aSTim Haley #define	ZPOOL_REWIND_REQUEST		"rewind-request"
498468c413aSTim Haley #define	ZPOOL_REWIND_REQUEST_TXG	"rewind-request-txg"
499468c413aSTim Haley #define	ZPOOL_REWIND_META_THRESH	"rewind-meta-thresh"
500468c413aSTim Haley #define	ZPOOL_REWIND_DATA_THRESH	"rewind-data-thresh"
501468c413aSTim Haley 
502468c413aSTim Haley /* Rewind data discovered */
503468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_TIME		"rewind_txg_ts"
504468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_DATA_ERRORS	"verify_data_errors"
505468c413aSTim Haley #define	ZPOOL_CONFIG_REWIND_TIME	"seconds_of_rewind"
506468c413aSTim Haley 
507fa9e4066Sahrens #define	VDEV_TYPE_ROOT			"root"
508fa9e4066Sahrens #define	VDEV_TYPE_MIRROR		"mirror"
509fa9e4066Sahrens #define	VDEV_TYPE_REPLACING		"replacing"
510fa9e4066Sahrens #define	VDEV_TYPE_RAIDZ			"raidz"
511fa9e4066Sahrens #define	VDEV_TYPE_DISK			"disk"
512fa9e4066Sahrens #define	VDEV_TYPE_FILE			"file"
513fa9e4066Sahrens #define	VDEV_TYPE_MISSING		"missing"
51488ecc943SGeorge Wilson #define	VDEV_TYPE_HOLE			"hole"
51599653d4eSeschrock #define	VDEV_TYPE_SPARE			"spare"
5168654d025Sperrin #define	VDEV_TYPE_LOG			"log"
517fa94a07fSbrendan #define	VDEV_TYPE_L2CACHE		"l2cache"
518fa9e4066Sahrens 
519fa9e4066Sahrens /*
520fa9e4066Sahrens  * This is needed in userland to report the minimum necessary device size.
521fa9e4066Sahrens  */
522fa9e4066Sahrens #define	SPA_MINDEVSIZE		(64ULL << 20)
523fa9e4066Sahrens 
524fa9e4066Sahrens /*
525fa9e4066Sahrens  * The location of the pool configuration repository, shared between kernel and
526fa9e4066Sahrens  * userland.
527fa9e4066Sahrens  */
528c5904d13Seschrock #define	ZPOOL_CACHE		"/etc/zfs/zpool.cache"
529fa9e4066Sahrens 
530fa9e4066Sahrens /*
531fa9e4066Sahrens  * vdev states are ordered from least to most healthy.
532fa9e4066Sahrens  * A vdev that's CANT_OPEN or below is considered unusable.
533fa9e4066Sahrens  */
534fa9e4066Sahrens typedef enum vdev_state {
535fa9e4066Sahrens 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
536fa9e4066Sahrens 	VDEV_STATE_CLOSED,	/* Not currently open			*/
537fa9e4066Sahrens 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
5383d7072f8Seschrock 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
539fa9e4066Sahrens 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
5403d7072f8Seschrock 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
541fa9e4066Sahrens 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
542fa9e4066Sahrens 	VDEV_STATE_HEALTHY	/* Presumed good			*/
543fa9e4066Sahrens } vdev_state_t;
544fa9e4066Sahrens 
5453d7072f8Seschrock #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
5463d7072f8Seschrock 
547fa9e4066Sahrens /*
548fa9e4066Sahrens  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
549fa9e4066Sahrens  * of the vdev stats structure uses these constants to distinguish why.
550fa9e4066Sahrens  */
551fa9e4066Sahrens typedef enum vdev_aux {
552fa9e4066Sahrens 	VDEV_AUX_NONE,		/* no error				*/
553fa9e4066Sahrens 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
554fa9e4066Sahrens 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
555fa9e4066Sahrens 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
556fa9e4066Sahrens 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
557fa9e4066Sahrens 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
558eaca9bbdSeschrock 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
559eaca9bbdSeschrock 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
56099653d4eSeschrock 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
5613d7072f8Seschrock 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
56232b87932Sek 	VDEV_AUX_ERR_EXCEEDED,	/* too many errors			*/
563b87f3af3Sperrin 	VDEV_AUX_IO_FAILURE,	/* experienced I/O failure		*/
564069f55e2SEric Schrock 	VDEV_AUX_BAD_LOG,	/* cannot read log chain(s)		*/
5651195e687SMark J Musante 	VDEV_AUX_EXTERNAL,	/* external diagnosis			*/
5661195e687SMark J Musante 	VDEV_AUX_SPLIT_POOL	/* vdev was split off into another pool	*/
567fa9e4066Sahrens } vdev_aux_t;
568fa9e4066Sahrens 
569fa9e4066Sahrens /*
57046a2abf2Seschrock  * pool state.  The following states are written to disk as part of the normal
571fa94a07fSbrendan  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
572fa94a07fSbrendan  * states are software abstractions used at various levels to communicate
573fa94a07fSbrendan  * pool state.
574fa9e4066Sahrens  */
575fa9e4066Sahrens typedef enum pool_state {
576fa9e4066Sahrens 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
577fa9e4066Sahrens 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
578fa9e4066Sahrens 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
57999653d4eSeschrock 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
580fa94a07fSbrendan 	POOL_STATE_L2CACHE,		/* Level 2 ARC device		*/
581fa9e4066Sahrens 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
58246a2abf2Seschrock 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
58346a2abf2Seschrock 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
584fa9e4066Sahrens } pool_state_t;
585fa9e4066Sahrens 
586fa9e4066Sahrens /*
587*3f9d6ad7SLin Ling  * Scan Functions.
588fa9e4066Sahrens  */
589*3f9d6ad7SLin Ling typedef enum pool_scan_func {
590*3f9d6ad7SLin Ling 	POOL_SCAN_NONE,
591*3f9d6ad7SLin Ling 	POOL_SCAN_SCRUB,
592*3f9d6ad7SLin Ling 	POOL_SCAN_RESILVER,
593*3f9d6ad7SLin Ling 	POOL_SCAN_FUNCS
594*3f9d6ad7SLin Ling } pool_scan_func_t;
595fa9e4066Sahrens 
596fa9e4066Sahrens /*
597fa9e4066Sahrens  * ZIO types.  Needed to interpret vdev statistics below.
598fa9e4066Sahrens  */
599fa9e4066Sahrens typedef enum zio_type {
600fa9e4066Sahrens 	ZIO_TYPE_NULL = 0,
601fa9e4066Sahrens 	ZIO_TYPE_READ,
602fa9e4066Sahrens 	ZIO_TYPE_WRITE,
603fa9e4066Sahrens 	ZIO_TYPE_FREE,
604fa9e4066Sahrens 	ZIO_TYPE_CLAIM,
605fa9e4066Sahrens 	ZIO_TYPE_IOCTL,
606fa9e4066Sahrens 	ZIO_TYPES
607fa9e4066Sahrens } zio_type_t;
608fa9e4066Sahrens 
609*3f9d6ad7SLin Ling /*
610*3f9d6ad7SLin Ling  * Pool statistics.  Note: all fields should be 64-bit because this
611*3f9d6ad7SLin Ling  * is passed between kernel and userland as an nvlist uint64 array.
612*3f9d6ad7SLin Ling  */
613*3f9d6ad7SLin Ling typedef struct pool_scan_stat {
614*3f9d6ad7SLin Ling 	/* values stored on disk */
615*3f9d6ad7SLin Ling 	uint64_t	pss_func;	/* pool_scan_func_t */
616*3f9d6ad7SLin Ling 	uint64_t	pss_state;	/* dsl_scan_state_t */
617*3f9d6ad7SLin Ling 	uint64_t	pss_start_time;	/* scan start time */
618*3f9d6ad7SLin Ling 	uint64_t	pss_end_time;	/* scan end time */
619*3f9d6ad7SLin Ling 	uint64_t	pss_to_examine;	/* total bytes to scan */
620*3f9d6ad7SLin Ling 	uint64_t	pss_examined;	/* total examined bytes	*/
621*3f9d6ad7SLin Ling 	uint64_t	pss_to_process; /* total bytes to process */
622*3f9d6ad7SLin Ling 	uint64_t	pss_processed;	/* total processed bytes */
623*3f9d6ad7SLin Ling 	uint64_t	pss_errors;	/* scan errors	*/
624*3f9d6ad7SLin Ling 
625*3f9d6ad7SLin Ling 	/* values not stored on disk */
626*3f9d6ad7SLin Ling 	uint64_t	pss_pass_exam;	/* examined bytes per scan pass */
627*3f9d6ad7SLin Ling 	uint64_t	pss_pass_start;	/* start time of a scan pass */
628*3f9d6ad7SLin Ling } pool_scan_stat_t;
629*3f9d6ad7SLin Ling 
630*3f9d6ad7SLin Ling typedef enum dsl_scan_state {
631*3f9d6ad7SLin Ling 	DSS_NONE,
632*3f9d6ad7SLin Ling 	DSS_SCANNING,
633*3f9d6ad7SLin Ling 	DSS_FINISHED,
634*3f9d6ad7SLin Ling 	DSS_CANCELED,
635*3f9d6ad7SLin Ling 	DSS_NUM_STATES
636*3f9d6ad7SLin Ling } dsl_scan_state_t;
637*3f9d6ad7SLin Ling 
638*3f9d6ad7SLin Ling 
639fa9e4066Sahrens /*
640fa9e4066Sahrens  * Vdev statistics.  Note: all fields should be 64-bit because this
641fa9e4066Sahrens  * is passed between kernel and userland as an nvlist uint64 array.
642fa9e4066Sahrens  */
643fa9e4066Sahrens typedef struct vdev_stat {
644fa9e4066Sahrens 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
645fa9e4066Sahrens 	uint64_t	vs_state;		/* vdev state		*/
646fa9e4066Sahrens 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
647fa9e4066Sahrens 	uint64_t	vs_alloc;		/* space allocated	*/
648fa9e4066Sahrens 	uint64_t	vs_space;		/* total capacity	*/
64999653d4eSeschrock 	uint64_t	vs_dspace;		/* deflated capacity	*/
6502a79c5feSlling 	uint64_t	vs_rsize;		/* replaceable dev size */
651fa9e4066Sahrens 	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
652fa9e4066Sahrens 	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
653fa9e4066Sahrens 	uint64_t	vs_read_errors;		/* read errors		*/
654fa9e4066Sahrens 	uint64_t	vs_write_errors;	/* write errors		*/
655fa9e4066Sahrens 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
656fa9e4066Sahrens 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
657*3f9d6ad7SLin Ling 	uint64_t	vs_scan_removing;	/* removing?	*/
658*3f9d6ad7SLin Ling 	uint64_t	vs_scan_processed;	/* scan processed bytes	*/
659fa9e4066Sahrens } vdev_stat_t;
660fa9e4066Sahrens 
6619eb19f4dSGeorge Wilson /*
6629eb19f4dSGeorge Wilson  * DDT statistics.  Note: all fields should be 64-bit because this
6639eb19f4dSGeorge Wilson  * is passed between kernel and userland as an nvlist uint64 array.
6649eb19f4dSGeorge Wilson  */
6659eb19f4dSGeorge Wilson typedef struct ddt_object {
6669eb19f4dSGeorge Wilson 	uint64_t	ddo_count;	/* number of elments in ddt 	*/
6679eb19f4dSGeorge Wilson 	uint64_t	ddo_dspace;	/* size of ddt on disk		*/
6689eb19f4dSGeorge Wilson 	uint64_t	ddo_mspace;	/* size of ddt in-core		*/
6699eb19f4dSGeorge Wilson } ddt_object_t;
6709eb19f4dSGeorge Wilson 
6719eb19f4dSGeorge Wilson typedef struct ddt_stat {
6729eb19f4dSGeorge Wilson 	uint64_t	dds_blocks;	/* blocks			*/
6739eb19f4dSGeorge Wilson 	uint64_t	dds_lsize;	/* logical size			*/
6749eb19f4dSGeorge Wilson 	uint64_t	dds_psize;	/* physical size		*/
6759eb19f4dSGeorge Wilson 	uint64_t	dds_dsize;	/* deflated allocated size	*/
6769eb19f4dSGeorge Wilson 	uint64_t	dds_ref_blocks;	/* referenced blocks		*/
6779eb19f4dSGeorge Wilson 	uint64_t	dds_ref_lsize;	/* referenced lsize * refcnt	*/
6789eb19f4dSGeorge Wilson 	uint64_t	dds_ref_psize;	/* referenced psize * refcnt	*/
6799eb19f4dSGeorge Wilson 	uint64_t	dds_ref_dsize;	/* referenced dsize * refcnt	*/
6809eb19f4dSGeorge Wilson } ddt_stat_t;
6819eb19f4dSGeorge Wilson 
6829eb19f4dSGeorge Wilson typedef struct ddt_histogram {
6839eb19f4dSGeorge Wilson 	ddt_stat_t	ddh_stat[64];	/* power-of-two histogram buckets */
6849eb19f4dSGeorge Wilson } ddt_histogram_t;
6859eb19f4dSGeorge Wilson 
686e7cbe64fSgw #define	ZVOL_DRIVER	"zvol"
687fa9e4066Sahrens #define	ZFS_DRIVER	"zfs"
688fa9e4066Sahrens #define	ZFS_DEV		"/dev/zfs"
689fa9e4066Sahrens 
690681d9761SEric Taylor /* general zvol path */
691681d9761SEric Taylor #define	ZVOL_DIR		"/dev/zvol"
692681d9761SEric Taylor /* expansion */
693573ca77eSGeorge Wilson #define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zfs@0:"
694681d9761SEric Taylor /* for dump and swap */
695681d9761SEric Taylor #define	ZVOL_FULL_DEV_DIR	ZVOL_DIR "/dsk/"
696681d9761SEric Taylor #define	ZVOL_FULL_RDEV_DIR	ZVOL_DIR "/rdsk/"
697fa9e4066Sahrens 
698fa9e4066Sahrens #define	ZVOL_PROP_NAME		"name"
699c1449561SEric Taylor #define	ZVOL_DEFAULT_BLOCKSIZE	8192
700fa9e4066Sahrens 
701fa9e4066Sahrens /*
702fa9e4066Sahrens  * /dev/zfs ioctl numbers.
703fa9e4066Sahrens  */
704fa9e4066Sahrens #define	ZFS_IOC		('Z' << 8)
705fa9e4066Sahrens 
706fa9e4066Sahrens typedef enum zfs_ioc {
707fa9e4066Sahrens 	ZFS_IOC_POOL_CREATE = ZFS_IOC,
708fa9e4066Sahrens 	ZFS_IOC_POOL_DESTROY,
709fa9e4066Sahrens 	ZFS_IOC_POOL_IMPORT,
710fa9e4066Sahrens 	ZFS_IOC_POOL_EXPORT,
711fa9e4066Sahrens 	ZFS_IOC_POOL_CONFIGS,
712fa9e4066Sahrens 	ZFS_IOC_POOL_STATS,
713fa9e4066Sahrens 	ZFS_IOC_POOL_TRYIMPORT,
714*3f9d6ad7SLin Ling 	ZFS_IOC_POOL_SCAN,
715fa9e4066Sahrens 	ZFS_IOC_POOL_FREEZE,
716eaca9bbdSeschrock 	ZFS_IOC_POOL_UPGRADE,
71706eeb2adSek 	ZFS_IOC_POOL_GET_HISTORY,
718fa9e4066Sahrens 	ZFS_IOC_VDEV_ADD,
719fa9e4066Sahrens 	ZFS_IOC_VDEV_REMOVE,
7203d7072f8Seschrock 	ZFS_IOC_VDEV_SET_STATE,
721fa9e4066Sahrens 	ZFS_IOC_VDEV_ATTACH,
722fa9e4066Sahrens 	ZFS_IOC_VDEV_DETACH,
723c67d9675Seschrock 	ZFS_IOC_VDEV_SETPATH,
7246809eb4eSEric Schrock 	ZFS_IOC_VDEV_SETFRU,
725fa9e4066Sahrens 	ZFS_IOC_OBJSET_STATS,
726de8267e0Stimh 	ZFS_IOC_OBJSET_ZPLPROPS,
727fa9e4066Sahrens 	ZFS_IOC_DATASET_LIST_NEXT,
728fa9e4066Sahrens 	ZFS_IOC_SNAPSHOT_LIST_NEXT,
729fa9e4066Sahrens 	ZFS_IOC_SET_PROP,
730fa9e4066Sahrens 	ZFS_IOC_CREATE,
731fa9e4066Sahrens 	ZFS_IOC_DESTROY,
732fa9e4066Sahrens 	ZFS_IOC_ROLLBACK,
733fa9e4066Sahrens 	ZFS_IOC_RENAME,
7343cb34c60Sahrens 	ZFS_IOC_RECV,
7353cb34c60Sahrens 	ZFS_IOC_SEND,
736ea8dc4b6Seschrock 	ZFS_IOC_INJECT_FAULT,
737ea8dc4b6Seschrock 	ZFS_IOC_CLEAR_FAULT,
738ea8dc4b6Seschrock 	ZFS_IOC_INJECT_LIST_NEXT,
739ea8dc4b6Seschrock 	ZFS_IOC_ERROR_LOG,
740ea8dc4b6Seschrock 	ZFS_IOC_CLEAR,
7411d452cf5Sahrens 	ZFS_IOC_PROMOTE,
7421d452cf5Sahrens 	ZFS_IOC_DESTROY_SNAPS,
74355434c77Sek 	ZFS_IOC_SNAPSHOT,
74455434c77Sek 	ZFS_IOC_DSOBJ_TO_DSNAME,
745b1b8ab34Slling 	ZFS_IOC_OBJ_TO_PATH,
746b1b8ab34Slling 	ZFS_IOC_POOL_SET_PROPS,
747ecd6cf80Smarks 	ZFS_IOC_POOL_GET_PROPS,
748ecd6cf80Smarks 	ZFS_IOC_SET_FSACL,
749ecd6cf80Smarks 	ZFS_IOC_GET_FSACL,
750e45ce728Sahrens 	ZFS_IOC_SHARE,
751743a77edSAlan Wright 	ZFS_IOC_INHERIT_PROP,
75214843421SMatthew Ahrens 	ZFS_IOC_SMB_ACL,
75314843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_ONE,
75414843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_MANY,
755842727c2SChris Kirby 	ZFS_IOC_USERSPACE_UPGRADE,
756842727c2SChris Kirby 	ZFS_IOC_HOLD,
757842727c2SChris Kirby 	ZFS_IOC_RELEASE,
75892241e0bSTom Erickson 	ZFS_IOC_GET_HOLDS,
7591195e687SMark J Musante 	ZFS_IOC_OBJSET_RECVD_PROPS,
7601195e687SMark J Musante 	ZFS_IOC_VDEV_SPLIT
761fa9e4066Sahrens } zfs_ioc_t;
762fa9e4066Sahrens 
763ea8dc4b6Seschrock /*
764ea8dc4b6Seschrock  * Internal SPA load state.  Used by FMA diagnosis engine.
765ea8dc4b6Seschrock  */
766ea8dc4b6Seschrock typedef enum {
7679eb19f4dSGeorge Wilson 	SPA_LOAD_NONE,		/* no load in progress	*/
7689eb19f4dSGeorge Wilson 	SPA_LOAD_OPEN,		/* normal open		*/
7699eb19f4dSGeorge Wilson 	SPA_LOAD_IMPORT,	/* import in progress	*/
770468c413aSTim Haley 	SPA_LOAD_TRYIMPORT,	/* tryimport in progress */
7719eb19f4dSGeorge Wilson 	SPA_LOAD_RECOVER,	/* recovery requested	*/
7729eb19f4dSGeorge Wilson 	SPA_LOAD_ERROR		/* load failed		*/
773ea8dc4b6Seschrock } spa_load_state_t;
774ea8dc4b6Seschrock 
775e9dbad6fSeschrock /*
776e9dbad6fSeschrock  * Bookmark name values.
777e9dbad6fSeschrock  */
77855434c77Sek #define	ZPOOL_ERR_LIST		"error list"
779e9dbad6fSeschrock #define	ZPOOL_ERR_DATASET	"dataset"
780e9dbad6fSeschrock #define	ZPOOL_ERR_OBJECT	"object"
781e9dbad6fSeschrock 
78206eeb2adSek #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
78306eeb2adSek 
78406eeb2adSek /*
78506eeb2adSek  * The following are names used in the nvlist describing
78606eeb2adSek  * the pool's history log.
78706eeb2adSek  */
78806eeb2adSek #define	ZPOOL_HIST_RECORD	"history record"
78906eeb2adSek #define	ZPOOL_HIST_TIME		"history time"
79006eeb2adSek #define	ZPOOL_HIST_CMD		"history command"
791ecd6cf80Smarks #define	ZPOOL_HIST_WHO		"history who"
792ecd6cf80Smarks #define	ZPOOL_HIST_ZONE		"history zone"
793ecd6cf80Smarks #define	ZPOOL_HIST_HOST		"history hostname"
794ecd6cf80Smarks #define	ZPOOL_HIST_TXG		"history txg"
795ecd6cf80Smarks #define	ZPOOL_HIST_INT_EVENT	"history internal event"
796ecd6cf80Smarks #define	ZPOOL_HIST_INT_STR	"history internal str"
79706eeb2adSek 
7983d7072f8Seschrock /*
7993d7072f8Seschrock  * Flags for ZFS_IOC_VDEV_SET_STATE
8003d7072f8Seschrock  */
8013d7072f8Seschrock #define	ZFS_ONLINE_CHECKREMOVE	0x1
8023d7072f8Seschrock #define	ZFS_ONLINE_UNSPARE	0x2
8033d7072f8Seschrock #define	ZFS_ONLINE_FORCEFAULT	0x4
804573ca77eSGeorge Wilson #define	ZFS_ONLINE_EXPAND	0x8
8053d7072f8Seschrock #define	ZFS_OFFLINE_TEMPORARY	0x1
8063d7072f8Seschrock 
8073d7072f8Seschrock /*
8083d7072f8Seschrock  * Sysevent payload members.  ZFS will generate the following sysevents with the
8093d7072f8Seschrock  * given payloads:
8103d7072f8Seschrock  *
8113d7072f8Seschrock  *	ESC_ZFS_RESILVER_START
8123d7072f8Seschrock  *	ESC_ZFS_RESILVER_END
8133d7072f8Seschrock  *	ESC_ZFS_POOL_DESTROY
8143d7072f8Seschrock  *
8153d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
8163d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
8173d7072f8Seschrock  *
8183d7072f8Seschrock  *	ESC_ZFS_VDEV_REMOVE
8193d7072f8Seschrock  *	ESC_ZFS_VDEV_CLEAR
8203d7072f8Seschrock  *	ESC_ZFS_VDEV_CHECK
8213d7072f8Seschrock  *
8223d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
8233d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
8243d7072f8Seschrock  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
8253d7072f8Seschrock  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
8263d7072f8Seschrock  */
8273d7072f8Seschrock #define	ZFS_EV_POOL_NAME	"pool_name"
8283d7072f8Seschrock #define	ZFS_EV_POOL_GUID	"pool_guid"
8293d7072f8Seschrock #define	ZFS_EV_VDEV_PATH	"vdev_path"
8303d7072f8Seschrock #define	ZFS_EV_VDEV_GUID	"vdev_guid"
8313d7072f8Seschrock 
832088f3894Sahrens /*
833088f3894Sahrens  * Note: This is encoded on-disk, so new events must be added to the
834088f3894Sahrens  * end, and unused events can not be removed.  Be sure to edit
8358f18d1faSGeorge Wilson  * libzfs_pool.c: hist_event_table[].
836088f3894Sahrens  */
837ecd6cf80Smarks typedef enum history_internal_events {
838ecd6cf80Smarks 	LOG_NO_EVENT = 0,
839ecd6cf80Smarks 	LOG_POOL_CREATE,
840ecd6cf80Smarks 	LOG_POOL_VDEV_ADD,
841ecd6cf80Smarks 	LOG_POOL_REMOVE,
842ecd6cf80Smarks 	LOG_POOL_DESTROY,
843ecd6cf80Smarks 	LOG_POOL_EXPORT,
844ecd6cf80Smarks 	LOG_POOL_IMPORT,
845ecd6cf80Smarks 	LOG_POOL_VDEV_ATTACH,
846ecd6cf80Smarks 	LOG_POOL_VDEV_REPLACE,
847ecd6cf80Smarks 	LOG_POOL_VDEV_DETACH,
848ecd6cf80Smarks 	LOG_POOL_VDEV_ONLINE,
849ecd6cf80Smarks 	LOG_POOL_VDEV_OFFLINE,
850ecd6cf80Smarks 	LOG_POOL_UPGRADE,
851ecd6cf80Smarks 	LOG_POOL_CLEAR,
852*3f9d6ad7SLin Ling 	LOG_POOL_SCAN,
853ecd6cf80Smarks 	LOG_POOL_PROPSET,
854ecd6cf80Smarks 	LOG_DS_CREATE,
855ecd6cf80Smarks 	LOG_DS_CLONE,
856ecd6cf80Smarks 	LOG_DS_DESTROY,
857ecd6cf80Smarks 	LOG_DS_DESTROY_BEGIN,
858ecd6cf80Smarks 	LOG_DS_INHERIT,
859ecd6cf80Smarks 	LOG_DS_PROPSET,
860ecd6cf80Smarks 	LOG_DS_QUOTA,
861ecd6cf80Smarks 	LOG_DS_PERM_UPDATE,
862ecd6cf80Smarks 	LOG_DS_PERM_REMOVE,
863ecd6cf80Smarks 	LOG_DS_PERM_WHO_REMOVE,
864ecd6cf80Smarks 	LOG_DS_PROMOTE,
865ecd6cf80Smarks 	LOG_DS_RECEIVE,
866ecd6cf80Smarks 	LOG_DS_RENAME,
867ecd6cf80Smarks 	LOG_DS_RESERVATION,
868ecd6cf80Smarks 	LOG_DS_REPLAY_INC_SYNC,
869ecd6cf80Smarks 	LOG_DS_REPLAY_FULL_SYNC,
870ecd6cf80Smarks 	LOG_DS_ROLLBACK,
871ecd6cf80Smarks 	LOG_DS_SNAPSHOT,
872e7437265Sahrens 	LOG_DS_UPGRADE,
873a9799022Sck 	LOG_DS_REFQUOTA,
874a9799022Sck 	LOG_DS_REFRESERV,
875*3f9d6ad7SLin Ling 	LOG_POOL_SCAN_DONE,
876842727c2SChris Kirby 	LOG_DS_USER_HOLD,
877842727c2SChris Kirby 	LOG_DS_USER_RELEASE,
8781195e687SMark J Musante 	LOG_POOL_SPLIT,
879ecd6cf80Smarks 	LOG_END
880ecd6cf80Smarks } history_internal_events_t;
881ecd6cf80Smarks 
882fa9e4066Sahrens #ifdef	__cplusplus
883fa9e4066Sahrens }
884fa9e4066Sahrens #endif
885fa9e4066Sahrens 
886fa9e4066Sahrens #endif	/* _SYS_FS_ZFS_H */
887