xref: /illumos-gate/usr/src/uts/common/sys/fs/zfs.h (revision c1449561)
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 /*
231195e687SMark J Musante  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24fa9e4066Sahrens  * Use is subject to license terms.
25fa9e4066Sahrens  */
26fa9e4066Sahrens 
27fa9e4066Sahrens #ifndef	_SYS_FS_ZFS_H
28fa9e4066Sahrens #define	_SYS_FS_ZFS_H
29fa9e4066Sahrens 
30842727c2SChris Kirby #include <sys/time.h>
31842727c2SChris Kirby 
32fa9e4066Sahrens #ifdef	__cplusplus
33fa9e4066Sahrens extern "C" {
34fa9e4066Sahrens #endif
35fa9e4066Sahrens 
36fa9e4066Sahrens /*
37fa9e4066Sahrens  * Types and constants shared between userland and the kernel.
38fa9e4066Sahrens  */
39fa9e4066Sahrens 
40fa9e4066Sahrens /*
41fa9e4066Sahrens  * Each dataset can be one of the following types.  These constants can be
42fa9e4066Sahrens  * combined into masks that can be passed to various functions.
43fa9e4066Sahrens  */
44fa9e4066Sahrens typedef enum {
45fa9e4066Sahrens 	ZFS_TYPE_FILESYSTEM	= 0x1,
46fa9e4066Sahrens 	ZFS_TYPE_SNAPSHOT	= 0x2,
47b1b8ab34Slling 	ZFS_TYPE_VOLUME		= 0x4,
48b1b8ab34Slling 	ZFS_TYPE_POOL		= 0x8
49fa9e4066Sahrens } zfs_type_t;
50fa9e4066Sahrens 
51990b4856Slling #define	ZFS_TYPE_DATASET	\
52fa9e4066Sahrens 	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
53fa9e4066Sahrens 
54478ed9adSEric Taylor #define	ZAP_MAXNAMELEN 256
55478ed9adSEric Taylor #define	ZAP_MAXVALUELEN (1024 * 8)
56478ed9adSEric Taylor #define	ZAP_OLDMAXVALUELEN 1024
57478ed9adSEric Taylor 
58fa9e4066Sahrens /*
59990b4856Slling  * Dataset properties are identified by these constants and must be added to
60990b4856Slling  * the end of this list to ensure that external consumers are not affected
61990b4856Slling  * by the change. If you make any changes to this list, be sure to update
6266e2aaccSgw  * the property table in usr/src/common/zfs/zfs_prop.c.
63fa9e4066Sahrens  */
64fa9e4066Sahrens typedef enum {
65fa9e4066Sahrens 	ZFS_PROP_TYPE,
66fa9e4066Sahrens 	ZFS_PROP_CREATION,
67fa9e4066Sahrens 	ZFS_PROP_USED,
68fa9e4066Sahrens 	ZFS_PROP_AVAILABLE,
69fa9e4066Sahrens 	ZFS_PROP_REFERENCED,
70fa9e4066Sahrens 	ZFS_PROP_COMPRESSRATIO,
71fa9e4066Sahrens 	ZFS_PROP_MOUNTED,
72fa9e4066Sahrens 	ZFS_PROP_ORIGIN,
73fa9e4066Sahrens 	ZFS_PROP_QUOTA,
74fa9e4066Sahrens 	ZFS_PROP_RESERVATION,
75fa9e4066Sahrens 	ZFS_PROP_VOLSIZE,
76fa9e4066Sahrens 	ZFS_PROP_VOLBLOCKSIZE,
77fa9e4066Sahrens 	ZFS_PROP_RECORDSIZE,
78fa9e4066Sahrens 	ZFS_PROP_MOUNTPOINT,
79fa9e4066Sahrens 	ZFS_PROP_SHARENFS,
80fa9e4066Sahrens 	ZFS_PROP_CHECKSUM,
81fa9e4066Sahrens 	ZFS_PROP_COMPRESSION,
82fa9e4066Sahrens 	ZFS_PROP_ATIME,
83fa9e4066Sahrens 	ZFS_PROP_DEVICES,
84fa9e4066Sahrens 	ZFS_PROP_EXEC,
85fa9e4066Sahrens 	ZFS_PROP_SETUID,
86fa9e4066Sahrens 	ZFS_PROP_READONLY,
87fa9e4066Sahrens 	ZFS_PROP_ZONED,
88fa9e4066Sahrens 	ZFS_PROP_SNAPDIR,
89fa9e4066Sahrens 	ZFS_PROP_ACLMODE,
90fa9e4066Sahrens 	ZFS_PROP_ACLINHERIT,
9166e2aaccSgw 	ZFS_PROP_CREATETXG,		/* not exposed to the user */
9266e2aaccSgw 	ZFS_PROP_NAME,			/* not exposed to the user */
93e9dbad6fSeschrock 	ZFS_PROP_CANMOUNT,
9466e2aaccSgw 	ZFS_PROP_SHAREISCSI,
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,
12491ebeef5Sahrens 	ZFS_NUM_PROPS
125fa9e4066Sahrens } zfs_prop_t;
126fa9e4066Sahrens 
12714843421SMatthew Ahrens typedef enum {
12814843421SMatthew Ahrens 	ZFS_PROP_USERUSED,
12914843421SMatthew Ahrens 	ZFS_PROP_USERQUOTA,
13014843421SMatthew Ahrens 	ZFS_PROP_GROUPUSED,
13114843421SMatthew Ahrens 	ZFS_PROP_GROUPQUOTA,
13214843421SMatthew Ahrens 	ZFS_NUM_USERQUOTA_PROPS
13314843421SMatthew Ahrens } zfs_userquota_prop_t;
13414843421SMatthew Ahrens 
13514843421SMatthew Ahrens extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
13614843421SMatthew Ahrens 
137990b4856Slling /*
138990b4856Slling  * Pool properties are identified by these constants and must be added to the
139b87f3af3Sperrin  * end of this list to ensure that external consumers are not affected
140990b4856Slling  * by the change. If you make any changes to this list, be sure to update
141990b4856Slling  * the property table in usr/src/common/zfs/zpool_prop.c.
142990b4856Slling  */
143990b4856Slling typedef enum {
144990b4856Slling 	ZPOOL_PROP_NAME,
145990b4856Slling 	ZPOOL_PROP_SIZE,
146990b4856Slling 	ZPOOL_PROP_CAPACITY,
147990b4856Slling 	ZPOOL_PROP_ALTROOT,
148990b4856Slling 	ZPOOL_PROP_HEALTH,
149990b4856Slling 	ZPOOL_PROP_GUID,
150990b4856Slling 	ZPOOL_PROP_VERSION,
151990b4856Slling 	ZPOOL_PROP_BOOTFS,
152990b4856Slling 	ZPOOL_PROP_DELEGATION,
153990b4856Slling 	ZPOOL_PROP_AUTOREPLACE,
1542f8aaab3Seschrock 	ZPOOL_PROP_CACHEFILE,
1550a4e9518Sgw 	ZPOOL_PROP_FAILUREMODE,
156d5b5bb25SRich Morris 	ZPOOL_PROP_LISTSNAPS,
157573ca77eSGeorge Wilson 	ZPOOL_PROP_AUTOEXPAND,
158b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPDITTO,
159b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPRATIO,
160485bbbf5SGeorge Wilson 	ZPOOL_PROP_FREE,
161485bbbf5SGeorge Wilson 	ZPOOL_PROP_ALLOCATED,
162990b4856Slling 	ZPOOL_NUM_PROPS
163990b4856Slling } zpool_prop_t;
164b1b8ab34Slling 
165990b4856Slling #define	ZPROP_CONT		-2
166990b4856Slling #define	ZPROP_INVAL		-1
1673d7072f8Seschrock 
168990b4856Slling #define	ZPROP_VALUE		"value"
169990b4856Slling #define	ZPROP_SOURCE		"source"
1707f7322feSeschrock 
171b1b8ab34Slling typedef enum {
172990b4856Slling 	ZPROP_SRC_NONE = 0x1,
173990b4856Slling 	ZPROP_SRC_DEFAULT = 0x2,
174990b4856Slling 	ZPROP_SRC_TEMPORARY = 0x4,
175990b4856Slling 	ZPROP_SRC_LOCAL = 0x8,
17692241e0bSTom Erickson 	ZPROP_SRC_INHERITED = 0x10,
17792241e0bSTom Erickson 	ZPROP_SRC_RECEIVED = 0x20
178990b4856Slling } zprop_source_t;
179990b4856Slling 
18092241e0bSTom Erickson #define	ZPROP_SRC_ALL	0x3f
18192241e0bSTom Erickson 
18292241e0bSTom Erickson #define	ZPROP_SOURCE_VAL_RECVD	"$recvd"
18392241e0bSTom Erickson #define	ZPROP_N_MORE_ERRORS	"N_MORE_ERRORS"
18492241e0bSTom Erickson /*
18592241e0bSTom Erickson  * Dataset flag implemented as a special entry in the props zap object
18692241e0bSTom Erickson  * indicating that the dataset has received properties on or after
18792241e0bSTom Erickson  * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
18892241e0bSTom Erickson  * just as it did in earlier versions, and thereafter, local properties are
18992241e0bSTom Erickson  * preserved.
19092241e0bSTom Erickson  */
19192241e0bSTom Erickson #define	ZPROP_HAS_RECVD		"$hasrecvd"
19292241e0bSTom Erickson 
19392241e0bSTom Erickson typedef enum {
19492241e0bSTom Erickson 	ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
19592241e0bSTom Erickson 	ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
19692241e0bSTom Erickson } zprop_errflags_t;
197990b4856Slling 
198990b4856Slling typedef int (*zprop_func)(int, void *);
199990b4856Slling 
2000a48a24eStimh /*
2010a48a24eStimh  * Properties to be set on the root file system of a new pool
2020a48a24eStimh  * are stuffed into their own nvlist, which is then included in
2030a48a24eStimh  * the properties nvlist with the pool properties.
2040a48a24eStimh  */
2050a48a24eStimh #define	ZPOOL_ROOTFS_PROPS	"root-props-nvl"
2060a48a24eStimh 
207990b4856Slling /*
208990b4856Slling  * Dataset property functions shared between libzfs and kernel.
209990b4856Slling  */
210990b4856Slling const char *zfs_prop_default_string(zfs_prop_t);
211990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t);
212990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t);
213990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t);
214da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t);
215990b4856Slling const char *zfs_prop_to_name(zfs_prop_t);
216990b4856Slling zfs_prop_t zfs_name_to_prop(const char *);
217990b4856Slling boolean_t zfs_prop_user(const char *);
21892241e0bSTom Erickson boolean_t zfs_prop_userquota(const char *);
219990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
220990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
221b24ab676SJeff Bonwick uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
2224853e976Sgw boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
223b1b8ab34Slling 
224990b4856Slling /*
225990b4856Slling  * Pool property functions shared between libzfs and kernel.
226990b4856Slling  */
227990b4856Slling zpool_prop_t zpool_name_to_prop(const char *);
228990b4856Slling const char *zpool_prop_to_name(zpool_prop_t);
229990b4856Slling const char *zpool_prop_default_string(zpool_prop_t);
230990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t);
231990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t);
232990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
233990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
234b24ab676SJeff Bonwick uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
235b1b8ab34Slling 
236990b4856Slling /*
237990b4856Slling  * Definitions for the Delegation.
238990b4856Slling  */
239ecd6cf80Smarks typedef enum {
240ecd6cf80Smarks 	ZFS_DELEG_WHO_UNKNOWN = 0,
241ecd6cf80Smarks 	ZFS_DELEG_USER = 'u',
242ecd6cf80Smarks 	ZFS_DELEG_USER_SETS = 'U',
243ecd6cf80Smarks 	ZFS_DELEG_GROUP = 'g',
244ecd6cf80Smarks 	ZFS_DELEG_GROUP_SETS = 'G',
245ecd6cf80Smarks 	ZFS_DELEG_EVERYONE = 'e',
246ecd6cf80Smarks 	ZFS_DELEG_EVERYONE_SETS = 'E',
247ecd6cf80Smarks 	ZFS_DELEG_CREATE = 'c',
248ecd6cf80Smarks 	ZFS_DELEG_CREATE_SETS = 'C',
249ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET = 's',
250ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET_SETS = 'S'
251ecd6cf80Smarks } zfs_deleg_who_type_t;
252ecd6cf80Smarks 
253ecd6cf80Smarks typedef enum {
254ecd6cf80Smarks 	ZFS_DELEG_NONE = 0,
255ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCAL = 1,
256ecd6cf80Smarks 	ZFS_DELEG_PERM_DESCENDENT = 2,
257ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
258ecd6cf80Smarks 	ZFS_DELEG_PERM_CREATE = 4
259ecd6cf80Smarks } zfs_deleg_inherit_t;
260ecd6cf80Smarks 
261ecd6cf80Smarks #define	ZFS_DELEG_PERM_UID	"uid"
262ecd6cf80Smarks #define	ZFS_DELEG_PERM_GID	"gid"
263ecd6cf80Smarks #define	ZFS_DELEG_PERM_GROUPS	"groups"
264ecd6cf80Smarks 
2654201a95eSRic Aleshire #define	ZFS_MLSLABEL_DEFAULT	"none"
2664201a95eSRic Aleshire 
267743a77edSAlan Wright #define	ZFS_SMB_ACL_SRC		"src"
268743a77edSAlan Wright #define	ZFS_SMB_ACL_TARGET	"target"
269743a77edSAlan Wright 
270a227b7f4Shs typedef enum {
271a227b7f4Shs 	ZFS_CANMOUNT_OFF = 0,
272a227b7f4Shs 	ZFS_CANMOUNT_ON = 1,
273a227b7f4Shs 	ZFS_CANMOUNT_NOAUTO = 2
274a227b7f4Shs } zfs_canmount_type_t;
275a227b7f4Shs 
276e09fa4daSNeil Perrin typedef enum {
277e09fa4daSNeil Perrin 	ZFS_LOGBIAS_LATENCY = 0,
278e09fa4daSNeil Perrin 	ZFS_LOGBIAS_THROUGHPUT = 1
279e09fa4daSNeil Perrin } zfs_logbias_op_t;
280e09fa4daSNeil Perrin 
281da6c28aaSamw typedef enum zfs_share_op {
282da6c28aaSamw 	ZFS_SHARE_NFS = 0,
283da6c28aaSamw 	ZFS_UNSHARE_NFS = 1,
284da6c28aaSamw 	ZFS_SHARE_SMB = 2,
285da6c28aaSamw 	ZFS_UNSHARE_SMB = 3
286da6c28aaSamw } zfs_share_op_t;
287da6c28aaSamw 
288743a77edSAlan Wright typedef enum zfs_smb_acl_op {
289743a77edSAlan Wright 	ZFS_SMB_ACL_ADD,
290743a77edSAlan Wright 	ZFS_SMB_ACL_REMOVE,
291743a77edSAlan Wright 	ZFS_SMB_ACL_RENAME,
292743a77edSAlan Wright 	ZFS_SMB_ACL_PURGE
293743a77edSAlan Wright } zfs_smb_acl_op_t;
294743a77edSAlan Wright 
2953baa08fcSek typedef enum zfs_cache_type {
2963baa08fcSek 	ZFS_CACHE_NONE = 0,
2973baa08fcSek 	ZFS_CACHE_METADATA = 1,
2983baa08fcSek 	ZFS_CACHE_ALL = 2
2993baa08fcSek } zfs_cache_type_t;
3003baa08fcSek 
3013baa08fcSek 
302eaca9bbdSeschrock /*
30399653d4eSeschrock  * On-disk version number.
304eaca9bbdSeschrock  */
305e7437265Sahrens #define	SPA_VERSION_1			1ULL
306e7437265Sahrens #define	SPA_VERSION_2			2ULL
307e7437265Sahrens #define	SPA_VERSION_3			3ULL
308e7437265Sahrens #define	SPA_VERSION_4			4ULL
309e7437265Sahrens #define	SPA_VERSION_5			5ULL
310e7437265Sahrens #define	SPA_VERSION_6			6ULL
311e7437265Sahrens #define	SPA_VERSION_7			7ULL
312e7437265Sahrens #define	SPA_VERSION_8			8ULL
313da6c28aaSamw #define	SPA_VERSION_9			9ULL
314fa94a07fSbrendan #define	SPA_VERSION_10			10ULL
315088f3894Sahrens #define	SPA_VERSION_11			11ULL
316bb0ade09Sahrens #define	SPA_VERSION_12			12ULL
31774e7dc98SMatthew Ahrens #define	SPA_VERSION_13			13ULL
318d0f3f37eSMark Shellenbaum #define	SPA_VERSION_14			14ULL
31914843421SMatthew Ahrens #define	SPA_VERSION_15			15ULL
320478ed9adSEric Taylor #define	SPA_VERSION_16			16ULL
321f94275ceSAdam Leventhal #define	SPA_VERSION_17			17ULL
322842727c2SChris Kirby #define	SPA_VERSION_18			18ULL
32388ecc943SGeorge Wilson #define	SPA_VERSION_19			19ULL
324b24ab676SJeff Bonwick #define	SPA_VERSION_20			20ULL
325b24ab676SJeff Bonwick #define	SPA_VERSION_21			21ULL
32692241e0bSTom Erickson #define	SPA_VERSION_22			22ULL
327b1b8ab34Slling /*
328e7cbe64fSgw  * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
329478ed9adSEric Taylor  * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
33014843421SMatthew Ahrens  * and do the appropriate changes.  Also bump the version number in
33114843421SMatthew Ahrens  * usr/src/grub/capability.
332b1b8ab34Slling  */
33392241e0bSTom Erickson #define	SPA_VERSION			SPA_VERSION_22
33492241e0bSTom Erickson #define	SPA_VERSION_STRING		"22"
33544cd46caSbillm 
33644cd46caSbillm /*
337e7437265Sahrens  * Symbolic names for the changes that caused a SPA_VERSION switch.
33844cd46caSbillm  * Used in the code when checking for presence or absence of a feature.
33944cd46caSbillm  * Feel free to define multiple symbolic names for each version if there
34044cd46caSbillm  * were multiple changes to on-disk structures during that version.
34144cd46caSbillm  *
342e7437265Sahrens  * NOTE: When checking the current SPA_VERSION in your code, be sure
34344cd46caSbillm  *       to use spa_version() since it reports the version of the
34444cd46caSbillm  *       last synced uberblock.  Checking the in-flight version can
34544cd46caSbillm  *       be dangerous in some cases.
34644cd46caSbillm  */
347e7437265Sahrens #define	SPA_VERSION_INITIAL		SPA_VERSION_1
348e7437265Sahrens #define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
349e7437265Sahrens #define	SPA_VERSION_SPARES		SPA_VERSION_3
350f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ2		SPA_VERSION_3
351e7437265Sahrens #define	SPA_VERSION_BPLIST_ACCOUNT	SPA_VERSION_3
352e7437265Sahrens #define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
353e7437265Sahrens #define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
354e7437265Sahrens #define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
355e7437265Sahrens #define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
356e7437265Sahrens #define	SPA_VERSION_BOOTFS		SPA_VERSION_6
357990b4856Slling #define	SPA_VERSION_SLOGS		SPA_VERSION_7
358990b4856Slling #define	SPA_VERSION_DELEGATED_PERMS	SPA_VERSION_8
359da6c28aaSamw #define	SPA_VERSION_FUID		SPA_VERSION_9
360a9799022Sck #define	SPA_VERSION_REFRESERVATION	SPA_VERSION_9
361a9799022Sck #define	SPA_VERSION_REFQUOTA		SPA_VERSION_9
362a9799022Sck #define	SPA_VERSION_UNIQUE_ACCURATE	SPA_VERSION_9
363fa94a07fSbrendan #define	SPA_VERSION_L2CACHE		SPA_VERSION_10
364088f3894Sahrens #define	SPA_VERSION_NEXT_CLONES		SPA_VERSION_11
365088f3894Sahrens #define	SPA_VERSION_ORIGIN		SPA_VERSION_11
366088f3894Sahrens #define	SPA_VERSION_DSL_SCRUB		SPA_VERSION_11
367bb0ade09Sahrens #define	SPA_VERSION_SNAP_PROPS		SPA_VERSION_12
36874e7dc98SMatthew Ahrens #define	SPA_VERSION_USED_BREAKDOWN	SPA_VERSION_13
369d0f3f37eSMark Shellenbaum #define	SPA_VERSION_PASSTHROUGH_X	SPA_VERSION_14
37014843421SMatthew Ahrens #define	SPA_VERSION_USERSPACE		SPA_VERSION_15
371478ed9adSEric Taylor #define	SPA_VERSION_STMF_PROP		SPA_VERSION_16
372f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ3		SPA_VERSION_17
373842727c2SChris Kirby #define	SPA_VERSION_USERREFS		SPA_VERSION_18
37488ecc943SGeorge Wilson #define	SPA_VERSION_HOLES		SPA_VERSION_19
375b24ab676SJeff Bonwick #define	SPA_VERSION_ZLE_COMPRESSION	SPA_VERSION_20
376b24ab676SJeff Bonwick #define	SPA_VERSION_DEDUP		SPA_VERSION_21
37792241e0bSTom Erickson #define	SPA_VERSION_RECVD_PROPS		SPA_VERSION_22
378e7437265Sahrens 
379e7437265Sahrens /*
380e7437265Sahrens  * ZPL version - rev'd whenever an incompatible on-disk format change
381e7437265Sahrens  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
382e7437265Sahrens  * also update the version_table[] and help message in zfs_prop.c.
383e7437265Sahrens  *
384e7437265Sahrens  * When changing, be sure to teach GRUB how to read the new format!
385478ed9adSEric Taylor  * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
386e7437265Sahrens  */
387e7437265Sahrens #define	ZPL_VERSION_1			1ULL
388e7437265Sahrens #define	ZPL_VERSION_2			2ULL
389da6c28aaSamw #define	ZPL_VERSION_3			3ULL
39014843421SMatthew Ahrens #define	ZPL_VERSION_4			4ULL
39114843421SMatthew Ahrens #define	ZPL_VERSION			ZPL_VERSION_4
39214843421SMatthew Ahrens #define	ZPL_VERSION_STRING		"4"
393e7437265Sahrens 
394e7437265Sahrens #define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
395e7437265Sahrens #define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
396da6c28aaSamw #define	ZPL_VERSION_FUID		ZPL_VERSION_3
397de8267e0Stimh #define	ZPL_VERSION_NORMALIZATION	ZPL_VERSION_3
398da6c28aaSamw #define	ZPL_VERSION_SYSATTR		ZPL_VERSION_3
39914843421SMatthew Ahrens #define	ZPL_VERSION_USERSPACE		ZPL_VERSION_4
400eaca9bbdSeschrock 
401468c413aSTim Haley /* Rewind request information */
402468c413aSTim Haley #define	ZPOOL_NO_REWIND		0
403468c413aSTim Haley #define	ZPOOL_TRY_REWIND	1 /* Search for best txg, but do not rewind */
404468c413aSTim Haley #define	ZPOOL_DO_REWIND		2 /* Rewind to best txg w/in deferred frees */
405468c413aSTim Haley #define	ZPOOL_EXTREME_REWIND	4 /* Allow extreme measures to find best txg */
406468c413aSTim Haley #define	ZPOOL_REWIND_MASK	7 /* All the possible policy bits */
407468c413aSTim Haley 
408468c413aSTim Haley typedef struct zpool_rewind_policy {
409468c413aSTim Haley 	uint32_t	zrp_request;	/* rewind behavior requested */
410468c413aSTim Haley 	uint32_t	zrp_maxmeta;	/* max acceptable meta-data errors */
411468c413aSTim Haley 	uint32_t	zrp_maxdata;	/* max acceptable data errors */
412468c413aSTim Haley 	uint64_t	zrp_txg;	/* specific txg to load */
413468c413aSTim Haley } zpool_rewind_policy_t;
414468c413aSTim Haley 
415fa9e4066Sahrens /*
416fa9e4066Sahrens  * The following are configuration names used in the nvlist describing a pool's
417fa9e4066Sahrens  * configuration.
418fa9e4066Sahrens  */
419fa9e4066Sahrens #define	ZPOOL_CONFIG_VERSION		"version"
420fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_NAME		"name"
421fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_STATE		"state"
422fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_TXG		"txg"
423fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
424fa9e4066Sahrens #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
425fa9e4066Sahrens #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
426fa9e4066Sahrens #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
427fa9e4066Sahrens #define	ZPOOL_CONFIG_TYPE		"type"
428fa9e4066Sahrens #define	ZPOOL_CONFIG_CHILDREN		"children"
429fa9e4066Sahrens #define	ZPOOL_CONFIG_ID			"id"
430fa9e4066Sahrens #define	ZPOOL_CONFIG_GUID		"guid"
431fa9e4066Sahrens #define	ZPOOL_CONFIG_PATH		"path"
432fa9e4066Sahrens #define	ZPOOL_CONFIG_DEVID		"devid"
433fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
434fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
435fa9e4066Sahrens #define	ZPOOL_CONFIG_ASHIFT		"ashift"
436fa9e4066Sahrens #define	ZPOOL_CONFIG_ASIZE		"asize"
437fa9e4066Sahrens #define	ZPOOL_CONFIG_DTL		"DTL"
438fa9e4066Sahrens #define	ZPOOL_CONFIG_STATS		"stats"
439afefbcddSeschrock #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
440ea8dc4b6Seschrock #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
441ea8dc4b6Seschrock #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
44299653d4eSeschrock #define	ZPOOL_CONFIG_SPARES		"spares"
44399653d4eSeschrock #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
44499653d4eSeschrock #define	ZPOOL_CONFIG_NPARITY		"nparity"
44595173954Sek #define	ZPOOL_CONFIG_HOSTID		"hostid"
44695173954Sek #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
4473d7072f8Seschrock #define	ZPOOL_CONFIG_UNSPARE		"unspare"
4483d7072f8Seschrock #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
4498654d025Sperrin #define	ZPOOL_CONFIG_IS_LOG		"is_log"
450fa94a07fSbrendan #define	ZPOOL_CONFIG_L2CACHE		"l2cache"
45188ecc943SGeorge Wilson #define	ZPOOL_CONFIG_HOLE_ARRAY		"hole_array"
45288ecc943SGeorge Wilson #define	ZPOOL_CONFIG_VDEV_CHILDREN	"vdev_children"
45388ecc943SGeorge Wilson #define	ZPOOL_CONFIG_IS_HOLE		"is_hole"
4549eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_HISTOGRAM	"ddt_histogram"
4559eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_OBJ_STATS	"ddt_object_stats"
4569eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_STATS		"ddt_stats"
4571195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT		"splitcfg"
4581195e687SMark J Musante #define	ZPOOL_CONFIG_ORIG_GUID		"orig_guid"
4591195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_GUID		"split_guid"
4601195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_LIST		"guid_list"
461e14bb325SJeff Bonwick #define	ZPOOL_CONFIG_SUSPENDED		"suspended"	/* not stored on disk */
462e7cbe64fSgw #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp"	/* not stored on disk */
463e7cbe64fSgw #define	ZPOOL_CONFIG_BOOTFS		"bootfs"	/* not stored on disk */
4643d7072f8Seschrock /*
4653d7072f8Seschrock  * The persistent vdev state is stored as separate values rather than a single
4663d7072f8Seschrock  * 'vdev_state' entry.  This is because a device can be in multiple states, such
4673d7072f8Seschrock  * as offline and degraded.
4683d7072f8Seschrock  */
4693d7072f8Seschrock #define	ZPOOL_CONFIG_OFFLINE		"offline"
4703d7072f8Seschrock #define	ZPOOL_CONFIG_FAULTED		"faulted"
4713d7072f8Seschrock #define	ZPOOL_CONFIG_DEGRADED		"degraded"
4723d7072f8Seschrock #define	ZPOOL_CONFIG_REMOVED		"removed"
4736809eb4eSEric Schrock #define	ZPOOL_CONFIG_FRU		"fru"
474069f55e2SEric Schrock #define	ZPOOL_CONFIG_AUX_STATE		"aux_state"
475fa9e4066Sahrens 
476468c413aSTim Haley /* Rewind policy parameters */
477468c413aSTim Haley #define	ZPOOL_REWIND_POLICY		"rewind-policy"
478468c413aSTim Haley #define	ZPOOL_REWIND_REQUEST		"rewind-request"
479468c413aSTim Haley #define	ZPOOL_REWIND_REQUEST_TXG	"rewind-request-txg"
480468c413aSTim Haley #define	ZPOOL_REWIND_META_THRESH	"rewind-meta-thresh"
481468c413aSTim Haley #define	ZPOOL_REWIND_DATA_THRESH	"rewind-data-thresh"
482468c413aSTim Haley 
483468c413aSTim Haley /* Rewind data discovered */
484468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_TIME		"rewind_txg_ts"
485468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_DATA_ERRORS	"verify_data_errors"
486468c413aSTim Haley #define	ZPOOL_CONFIG_REWIND_TIME	"seconds_of_rewind"
487468c413aSTim Haley 
488fa9e4066Sahrens #define	VDEV_TYPE_ROOT			"root"
489fa9e4066Sahrens #define	VDEV_TYPE_MIRROR		"mirror"
490fa9e4066Sahrens #define	VDEV_TYPE_REPLACING		"replacing"
491fa9e4066Sahrens #define	VDEV_TYPE_RAIDZ			"raidz"
492fa9e4066Sahrens #define	VDEV_TYPE_DISK			"disk"
493fa9e4066Sahrens #define	VDEV_TYPE_FILE			"file"
494fa9e4066Sahrens #define	VDEV_TYPE_MISSING		"missing"
49588ecc943SGeorge Wilson #define	VDEV_TYPE_HOLE			"hole"
49699653d4eSeschrock #define	VDEV_TYPE_SPARE			"spare"
4978654d025Sperrin #define	VDEV_TYPE_LOG			"log"
498fa94a07fSbrendan #define	VDEV_TYPE_L2CACHE		"l2cache"
499fa9e4066Sahrens 
500fa9e4066Sahrens /*
501fa9e4066Sahrens  * This is needed in userland to report the minimum necessary device size.
502fa9e4066Sahrens  */
503fa9e4066Sahrens #define	SPA_MINDEVSIZE		(64ULL << 20)
504fa9e4066Sahrens 
505fa9e4066Sahrens /*
506fa9e4066Sahrens  * The location of the pool configuration repository, shared between kernel and
507fa9e4066Sahrens  * userland.
508fa9e4066Sahrens  */
509c5904d13Seschrock #define	ZPOOL_CACHE		"/etc/zfs/zpool.cache"
510fa9e4066Sahrens 
511fa9e4066Sahrens /*
512fa9e4066Sahrens  * vdev states are ordered from least to most healthy.
513fa9e4066Sahrens  * A vdev that's CANT_OPEN or below is considered unusable.
514fa9e4066Sahrens  */
515fa9e4066Sahrens typedef enum vdev_state {
516fa9e4066Sahrens 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
517fa9e4066Sahrens 	VDEV_STATE_CLOSED,	/* Not currently open			*/
518fa9e4066Sahrens 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
5193d7072f8Seschrock 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
520fa9e4066Sahrens 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
5213d7072f8Seschrock 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
522fa9e4066Sahrens 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
523fa9e4066Sahrens 	VDEV_STATE_HEALTHY	/* Presumed good			*/
524fa9e4066Sahrens } vdev_state_t;
525fa9e4066Sahrens 
5263d7072f8Seschrock #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
5273d7072f8Seschrock 
528fa9e4066Sahrens /*
529fa9e4066Sahrens  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
530fa9e4066Sahrens  * of the vdev stats structure uses these constants to distinguish why.
531fa9e4066Sahrens  */
532fa9e4066Sahrens typedef enum vdev_aux {
533fa9e4066Sahrens 	VDEV_AUX_NONE,		/* no error				*/
534fa9e4066Sahrens 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
535fa9e4066Sahrens 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
536fa9e4066Sahrens 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
537fa9e4066Sahrens 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
538fa9e4066Sahrens 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
539eaca9bbdSeschrock 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
540eaca9bbdSeschrock 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
54199653d4eSeschrock 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
5423d7072f8Seschrock 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
54332b87932Sek 	VDEV_AUX_ERR_EXCEEDED,	/* too many errors			*/
544b87f3af3Sperrin 	VDEV_AUX_IO_FAILURE,	/* experienced I/O failure		*/
545069f55e2SEric Schrock 	VDEV_AUX_BAD_LOG,	/* cannot read log chain(s)		*/
5461195e687SMark J Musante 	VDEV_AUX_EXTERNAL,	/* external diagnosis			*/
5471195e687SMark J Musante 	VDEV_AUX_SPLIT_POOL	/* vdev was split off into another pool	*/
548fa9e4066Sahrens } vdev_aux_t;
549fa9e4066Sahrens 
550fa9e4066Sahrens /*
55146a2abf2Seschrock  * pool state.  The following states are written to disk as part of the normal
552fa94a07fSbrendan  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
553fa94a07fSbrendan  * states are software abstractions used at various levels to communicate
554fa94a07fSbrendan  * pool state.
555fa9e4066Sahrens  */
556fa9e4066Sahrens typedef enum pool_state {
557fa9e4066Sahrens 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
558fa9e4066Sahrens 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
559fa9e4066Sahrens 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
56099653d4eSeschrock 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
561fa94a07fSbrendan 	POOL_STATE_L2CACHE,		/* Level 2 ARC device		*/
562fa9e4066Sahrens 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
56346a2abf2Seschrock 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
56446a2abf2Seschrock 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
565fa9e4066Sahrens } pool_state_t;
566fa9e4066Sahrens 
567fa9e4066Sahrens /*
568fa9e4066Sahrens  * Scrub types.
569fa9e4066Sahrens  */
570fa9e4066Sahrens typedef enum pool_scrub_type {
571fa9e4066Sahrens 	POOL_SCRUB_NONE,
572fa9e4066Sahrens 	POOL_SCRUB_RESILVER,
573fa9e4066Sahrens 	POOL_SCRUB_EVERYTHING,
574fa9e4066Sahrens 	POOL_SCRUB_TYPES
575fa9e4066Sahrens } pool_scrub_type_t;
576fa9e4066Sahrens 
577fa9e4066Sahrens /*
578fa9e4066Sahrens  * ZIO types.  Needed to interpret vdev statistics below.
579fa9e4066Sahrens  */
580fa9e4066Sahrens typedef enum zio_type {
581fa9e4066Sahrens 	ZIO_TYPE_NULL = 0,
582fa9e4066Sahrens 	ZIO_TYPE_READ,
583fa9e4066Sahrens 	ZIO_TYPE_WRITE,
584fa9e4066Sahrens 	ZIO_TYPE_FREE,
585fa9e4066Sahrens 	ZIO_TYPE_CLAIM,
586fa9e4066Sahrens 	ZIO_TYPE_IOCTL,
587fa9e4066Sahrens 	ZIO_TYPES
588fa9e4066Sahrens } zio_type_t;
589fa9e4066Sahrens 
590fa9e4066Sahrens /*
591fa9e4066Sahrens  * Vdev statistics.  Note: all fields should be 64-bit because this
592fa9e4066Sahrens  * is passed between kernel and userland as an nvlist uint64 array.
593fa9e4066Sahrens  */
594fa9e4066Sahrens typedef struct vdev_stat {
595fa9e4066Sahrens 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
596fa9e4066Sahrens 	uint64_t	vs_state;		/* vdev state		*/
597fa9e4066Sahrens 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
598fa9e4066Sahrens 	uint64_t	vs_alloc;		/* space allocated	*/
599fa9e4066Sahrens 	uint64_t	vs_space;		/* total capacity	*/
60099653d4eSeschrock 	uint64_t	vs_dspace;		/* deflated capacity	*/
6012a79c5feSlling 	uint64_t	vs_rsize;		/* replaceable dev size */
602fa9e4066Sahrens 	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
603fa9e4066Sahrens 	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
604fa9e4066Sahrens 	uint64_t	vs_read_errors;		/* read errors		*/
605fa9e4066Sahrens 	uint64_t	vs_write_errors;	/* write errors		*/
606fa9e4066Sahrens 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
607fa9e4066Sahrens 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
608fa9e4066Sahrens 	uint64_t	vs_scrub_type;		/* pool_scrub_type_t	*/
609fa9e4066Sahrens 	uint64_t	vs_scrub_complete;	/* completed?		*/
610fa9e4066Sahrens 	uint64_t	vs_scrub_examined;	/* bytes examined; top	*/
611fa9e4066Sahrens 	uint64_t	vs_scrub_repaired;	/* bytes repaired; leaf	*/
612fa9e4066Sahrens 	uint64_t	vs_scrub_errors;	/* errors during scrub	*/
613fa9e4066Sahrens 	uint64_t	vs_scrub_start;		/* UTC scrub start time	*/
614fa9e4066Sahrens 	uint64_t	vs_scrub_end;		/* UTC scrub end time	*/
615fa9e4066Sahrens } vdev_stat_t;
616fa9e4066Sahrens 
6179eb19f4dSGeorge Wilson /*
6189eb19f4dSGeorge Wilson  * DDT statistics.  Note: all fields should be 64-bit because this
6199eb19f4dSGeorge Wilson  * is passed between kernel and userland as an nvlist uint64 array.
6209eb19f4dSGeorge Wilson  */
6219eb19f4dSGeorge Wilson typedef struct ddt_object {
6229eb19f4dSGeorge Wilson 	uint64_t	ddo_count;	/* number of elments in ddt 	*/
6239eb19f4dSGeorge Wilson 	uint64_t	ddo_dspace;	/* size of ddt on disk		*/
6249eb19f4dSGeorge Wilson 	uint64_t	ddo_mspace;	/* size of ddt in-core		*/
6259eb19f4dSGeorge Wilson } ddt_object_t;
6269eb19f4dSGeorge Wilson 
6279eb19f4dSGeorge Wilson typedef struct ddt_stat {
6289eb19f4dSGeorge Wilson 	uint64_t	dds_blocks;	/* blocks			*/
6299eb19f4dSGeorge Wilson 	uint64_t	dds_lsize;	/* logical size			*/
6309eb19f4dSGeorge Wilson 	uint64_t	dds_psize;	/* physical size		*/
6319eb19f4dSGeorge Wilson 	uint64_t	dds_dsize;	/* deflated allocated size	*/
6329eb19f4dSGeorge Wilson 	uint64_t	dds_ref_blocks;	/* referenced blocks		*/
6339eb19f4dSGeorge Wilson 	uint64_t	dds_ref_lsize;	/* referenced lsize * refcnt	*/
6349eb19f4dSGeorge Wilson 	uint64_t	dds_ref_psize;	/* referenced psize * refcnt	*/
6359eb19f4dSGeorge Wilson 	uint64_t	dds_ref_dsize;	/* referenced dsize * refcnt	*/
6369eb19f4dSGeorge Wilson } ddt_stat_t;
6379eb19f4dSGeorge Wilson 
6389eb19f4dSGeorge Wilson typedef struct ddt_histogram {
6399eb19f4dSGeorge Wilson 	ddt_stat_t	ddh_stat[64];	/* power-of-two histogram buckets */
6409eb19f4dSGeorge Wilson } ddt_histogram_t;
6419eb19f4dSGeorge Wilson 
642e7cbe64fSgw #define	ZVOL_DRIVER	"zvol"
643fa9e4066Sahrens #define	ZFS_DRIVER	"zfs"
644fa9e4066Sahrens #define	ZFS_DEV		"/dev/zfs"
645fa9e4066Sahrens 
646681d9761SEric Taylor /* general zvol path */
647681d9761SEric Taylor #define	ZVOL_DIR		"/dev/zvol"
648681d9761SEric Taylor /* expansion */
649573ca77eSGeorge Wilson #define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zfs@0:"
650681d9761SEric Taylor /* for dump and swap */
651681d9761SEric Taylor #define	ZVOL_FULL_DEV_DIR	ZVOL_DIR "/dsk/"
652681d9761SEric Taylor #define	ZVOL_FULL_RDEV_DIR	ZVOL_DIR "/rdsk/"
653fa9e4066Sahrens 
654fa9e4066Sahrens #define	ZVOL_PROP_NAME		"name"
655*c1449561SEric Taylor #define	ZVOL_DEFAULT_BLOCKSIZE	8192
656fa9e4066Sahrens 
657fa9e4066Sahrens /*
658fa9e4066Sahrens  * /dev/zfs ioctl numbers.
659fa9e4066Sahrens  */
660fa9e4066Sahrens #define	ZFS_IOC		('Z' << 8)
661fa9e4066Sahrens 
662fa9e4066Sahrens typedef enum zfs_ioc {
663fa9e4066Sahrens 	ZFS_IOC_POOL_CREATE = ZFS_IOC,
664fa9e4066Sahrens 	ZFS_IOC_POOL_DESTROY,
665fa9e4066Sahrens 	ZFS_IOC_POOL_IMPORT,
666fa9e4066Sahrens 	ZFS_IOC_POOL_EXPORT,
667fa9e4066Sahrens 	ZFS_IOC_POOL_CONFIGS,
668fa9e4066Sahrens 	ZFS_IOC_POOL_STATS,
669fa9e4066Sahrens 	ZFS_IOC_POOL_TRYIMPORT,
670fa9e4066Sahrens 	ZFS_IOC_POOL_SCRUB,
671fa9e4066Sahrens 	ZFS_IOC_POOL_FREEZE,
672eaca9bbdSeschrock 	ZFS_IOC_POOL_UPGRADE,
67306eeb2adSek 	ZFS_IOC_POOL_GET_HISTORY,
674fa9e4066Sahrens 	ZFS_IOC_VDEV_ADD,
675fa9e4066Sahrens 	ZFS_IOC_VDEV_REMOVE,
6763d7072f8Seschrock 	ZFS_IOC_VDEV_SET_STATE,
677fa9e4066Sahrens 	ZFS_IOC_VDEV_ATTACH,
678fa9e4066Sahrens 	ZFS_IOC_VDEV_DETACH,
679c67d9675Seschrock 	ZFS_IOC_VDEV_SETPATH,
6806809eb4eSEric Schrock 	ZFS_IOC_VDEV_SETFRU,
681fa9e4066Sahrens 	ZFS_IOC_OBJSET_STATS,
682de8267e0Stimh 	ZFS_IOC_OBJSET_ZPLPROPS,
683fa9e4066Sahrens 	ZFS_IOC_DATASET_LIST_NEXT,
684fa9e4066Sahrens 	ZFS_IOC_SNAPSHOT_LIST_NEXT,
685fa9e4066Sahrens 	ZFS_IOC_SET_PROP,
686fa9e4066Sahrens 	ZFS_IOC_CREATE,
687fa9e4066Sahrens 	ZFS_IOC_DESTROY,
688fa9e4066Sahrens 	ZFS_IOC_ROLLBACK,
689fa9e4066Sahrens 	ZFS_IOC_RENAME,
6903cb34c60Sahrens 	ZFS_IOC_RECV,
6913cb34c60Sahrens 	ZFS_IOC_SEND,
692ea8dc4b6Seschrock 	ZFS_IOC_INJECT_FAULT,
693ea8dc4b6Seschrock 	ZFS_IOC_CLEAR_FAULT,
694ea8dc4b6Seschrock 	ZFS_IOC_INJECT_LIST_NEXT,
695ea8dc4b6Seschrock 	ZFS_IOC_ERROR_LOG,
696ea8dc4b6Seschrock 	ZFS_IOC_CLEAR,
6971d452cf5Sahrens 	ZFS_IOC_PROMOTE,
6981d452cf5Sahrens 	ZFS_IOC_DESTROY_SNAPS,
69955434c77Sek 	ZFS_IOC_SNAPSHOT,
70055434c77Sek 	ZFS_IOC_DSOBJ_TO_DSNAME,
701b1b8ab34Slling 	ZFS_IOC_OBJ_TO_PATH,
702b1b8ab34Slling 	ZFS_IOC_POOL_SET_PROPS,
703ecd6cf80Smarks 	ZFS_IOC_POOL_GET_PROPS,
704ecd6cf80Smarks 	ZFS_IOC_SET_FSACL,
705ecd6cf80Smarks 	ZFS_IOC_GET_FSACL,
706ecd6cf80Smarks 	ZFS_IOC_ISCSI_PERM_CHECK,
707e45ce728Sahrens 	ZFS_IOC_SHARE,
708743a77edSAlan Wright 	ZFS_IOC_INHERIT_PROP,
70914843421SMatthew Ahrens 	ZFS_IOC_SMB_ACL,
71014843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_ONE,
71114843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_MANY,
712842727c2SChris Kirby 	ZFS_IOC_USERSPACE_UPGRADE,
713842727c2SChris Kirby 	ZFS_IOC_HOLD,
714842727c2SChris Kirby 	ZFS_IOC_RELEASE,
71592241e0bSTom Erickson 	ZFS_IOC_GET_HOLDS,
7161195e687SMark J Musante 	ZFS_IOC_OBJSET_RECVD_PROPS,
7171195e687SMark J Musante 	ZFS_IOC_VDEV_SPLIT
718fa9e4066Sahrens } zfs_ioc_t;
719fa9e4066Sahrens 
720ea8dc4b6Seschrock /*
721ea8dc4b6Seschrock  * Internal SPA load state.  Used by FMA diagnosis engine.
722ea8dc4b6Seschrock  */
723ea8dc4b6Seschrock typedef enum {
7249eb19f4dSGeorge Wilson 	SPA_LOAD_NONE,		/* no load in progress	*/
7259eb19f4dSGeorge Wilson 	SPA_LOAD_OPEN,		/* normal open		*/
7269eb19f4dSGeorge Wilson 	SPA_LOAD_IMPORT,	/* import in progress	*/
727468c413aSTim Haley 	SPA_LOAD_TRYIMPORT,	/* tryimport in progress */
7289eb19f4dSGeorge Wilson 	SPA_LOAD_RECOVER,	/* recovery requested	*/
7299eb19f4dSGeorge Wilson 	SPA_LOAD_ERROR		/* load failed		*/
730ea8dc4b6Seschrock } spa_load_state_t;
731ea8dc4b6Seschrock 
732e9dbad6fSeschrock /*
733e9dbad6fSeschrock  * Bookmark name values.
734e9dbad6fSeschrock  */
73555434c77Sek #define	ZPOOL_ERR_LIST		"error list"
736e9dbad6fSeschrock #define	ZPOOL_ERR_DATASET	"dataset"
737e9dbad6fSeschrock #define	ZPOOL_ERR_OBJECT	"object"
738e9dbad6fSeschrock 
73906eeb2adSek #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
74006eeb2adSek 
74106eeb2adSek /*
74206eeb2adSek  * The following are names used in the nvlist describing
74306eeb2adSek  * the pool's history log.
74406eeb2adSek  */
74506eeb2adSek #define	ZPOOL_HIST_RECORD	"history record"
74606eeb2adSek #define	ZPOOL_HIST_TIME		"history time"
74706eeb2adSek #define	ZPOOL_HIST_CMD		"history command"
748ecd6cf80Smarks #define	ZPOOL_HIST_WHO		"history who"
749ecd6cf80Smarks #define	ZPOOL_HIST_ZONE		"history zone"
750ecd6cf80Smarks #define	ZPOOL_HIST_HOST		"history hostname"
751ecd6cf80Smarks #define	ZPOOL_HIST_TXG		"history txg"
752ecd6cf80Smarks #define	ZPOOL_HIST_INT_EVENT	"history internal event"
753ecd6cf80Smarks #define	ZPOOL_HIST_INT_STR	"history internal str"
75406eeb2adSek 
7553d7072f8Seschrock /*
7563d7072f8Seschrock  * Flags for ZFS_IOC_VDEV_SET_STATE
7573d7072f8Seschrock  */
7583d7072f8Seschrock #define	ZFS_ONLINE_CHECKREMOVE	0x1
7593d7072f8Seschrock #define	ZFS_ONLINE_UNSPARE	0x2
7603d7072f8Seschrock #define	ZFS_ONLINE_FORCEFAULT	0x4
761573ca77eSGeorge Wilson #define	ZFS_ONLINE_EXPAND	0x8
7623d7072f8Seschrock #define	ZFS_OFFLINE_TEMPORARY	0x1
7633d7072f8Seschrock 
7643d7072f8Seschrock /*
7653d7072f8Seschrock  * Sysevent payload members.  ZFS will generate the following sysevents with the
7663d7072f8Seschrock  * given payloads:
7673d7072f8Seschrock  *
7683d7072f8Seschrock  *	ESC_ZFS_RESILVER_START
7693d7072f8Seschrock  *	ESC_ZFS_RESILVER_END
7703d7072f8Seschrock  *	ESC_ZFS_POOL_DESTROY
7713d7072f8Seschrock  *
7723d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
7733d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
7743d7072f8Seschrock  *
7753d7072f8Seschrock  *	ESC_ZFS_VDEV_REMOVE
7763d7072f8Seschrock  *	ESC_ZFS_VDEV_CLEAR
7773d7072f8Seschrock  *	ESC_ZFS_VDEV_CHECK
7783d7072f8Seschrock  *
7793d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
7803d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
7813d7072f8Seschrock  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
7823d7072f8Seschrock  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
7833d7072f8Seschrock  */
7843d7072f8Seschrock #define	ZFS_EV_POOL_NAME	"pool_name"
7853d7072f8Seschrock #define	ZFS_EV_POOL_GUID	"pool_guid"
7863d7072f8Seschrock #define	ZFS_EV_VDEV_PATH	"vdev_path"
7873d7072f8Seschrock #define	ZFS_EV_VDEV_GUID	"vdev_guid"
7883d7072f8Seschrock 
789088f3894Sahrens /*
790088f3894Sahrens  * Note: This is encoded on-disk, so new events must be added to the
791088f3894Sahrens  * end, and unused events can not be removed.  Be sure to edit
7928f18d1faSGeorge Wilson  * libzfs_pool.c: hist_event_table[].
793088f3894Sahrens  */
794ecd6cf80Smarks typedef enum history_internal_events {
795ecd6cf80Smarks 	LOG_NO_EVENT = 0,
796ecd6cf80Smarks 	LOG_POOL_CREATE,
797ecd6cf80Smarks 	LOG_POOL_VDEV_ADD,
798ecd6cf80Smarks 	LOG_POOL_REMOVE,
799ecd6cf80Smarks 	LOG_POOL_DESTROY,
800ecd6cf80Smarks 	LOG_POOL_EXPORT,
801ecd6cf80Smarks 	LOG_POOL_IMPORT,
802ecd6cf80Smarks 	LOG_POOL_VDEV_ATTACH,
803ecd6cf80Smarks 	LOG_POOL_VDEV_REPLACE,
804ecd6cf80Smarks 	LOG_POOL_VDEV_DETACH,
805ecd6cf80Smarks 	LOG_POOL_VDEV_ONLINE,
806ecd6cf80Smarks 	LOG_POOL_VDEV_OFFLINE,
807ecd6cf80Smarks 	LOG_POOL_UPGRADE,
808ecd6cf80Smarks 	LOG_POOL_CLEAR,
809ecd6cf80Smarks 	LOG_POOL_SCRUB,
810ecd6cf80Smarks 	LOG_POOL_PROPSET,
811ecd6cf80Smarks 	LOG_DS_CREATE,
812ecd6cf80Smarks 	LOG_DS_CLONE,
813ecd6cf80Smarks 	LOG_DS_DESTROY,
814ecd6cf80Smarks 	LOG_DS_DESTROY_BEGIN,
815ecd6cf80Smarks 	LOG_DS_INHERIT,
816ecd6cf80Smarks 	LOG_DS_PROPSET,
817ecd6cf80Smarks 	LOG_DS_QUOTA,
818ecd6cf80Smarks 	LOG_DS_PERM_UPDATE,
819ecd6cf80Smarks 	LOG_DS_PERM_REMOVE,
820ecd6cf80Smarks 	LOG_DS_PERM_WHO_REMOVE,
821ecd6cf80Smarks 	LOG_DS_PROMOTE,
822ecd6cf80Smarks 	LOG_DS_RECEIVE,
823ecd6cf80Smarks 	LOG_DS_RENAME,
824ecd6cf80Smarks 	LOG_DS_RESERVATION,
825ecd6cf80Smarks 	LOG_DS_REPLAY_INC_SYNC,
826ecd6cf80Smarks 	LOG_DS_REPLAY_FULL_SYNC,
827ecd6cf80Smarks 	LOG_DS_ROLLBACK,
828ecd6cf80Smarks 	LOG_DS_SNAPSHOT,
829e7437265Sahrens 	LOG_DS_UPGRADE,
830a9799022Sck 	LOG_DS_REFQUOTA,
831a9799022Sck 	LOG_DS_REFRESERV,
832088f3894Sahrens 	LOG_POOL_SCRUB_DONE,
833842727c2SChris Kirby 	LOG_DS_USER_HOLD,
834842727c2SChris Kirby 	LOG_DS_USER_RELEASE,
8351195e687SMark J Musante 	LOG_POOL_SPLIT,
836ecd6cf80Smarks 	LOG_END
837ecd6cf80Smarks } history_internal_events_t;
838ecd6cf80Smarks 
839fa9e4066Sahrens #ifdef	__cplusplus
840fa9e4066Sahrens }
841fa9e4066Sahrens #endif
842fa9e4066Sahrens 
843fa9e4066Sahrens #endif	/* _SYS_FS_ZFS_H */
844