xref: /illumos-gate/usr/src/uts/common/sys/fs/zfs.h (revision 4263d13f)
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*4263d13fSGeorge Wilson  * Copyright (c) 2012 by Delphix. All rights reserved.
25e9103aaeSGarrett D'Amore  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
26fa9e4066Sahrens  */
27fa9e4066Sahrens 
2855da60b9SMark J Musante /* Portions Copyright 2010 Robert Milkowski */
2955da60b9SMark J Musante 
30fa9e4066Sahrens #ifndef	_SYS_FS_ZFS_H
31fa9e4066Sahrens #define	_SYS_FS_ZFS_H
32fa9e4066Sahrens 
33842727c2SChris Kirby #include <sys/time.h>
34842727c2SChris Kirby 
35fa9e4066Sahrens #ifdef	__cplusplus
36fa9e4066Sahrens extern "C" {
37fa9e4066Sahrens #endif
38fa9e4066Sahrens 
39fa9e4066Sahrens /*
40fa9e4066Sahrens  * Types and constants shared between userland and the kernel.
41fa9e4066Sahrens  */
42fa9e4066Sahrens 
43fa9e4066Sahrens /*
44fa9e4066Sahrens  * Each dataset can be one of the following types.  These constants can be
45fa9e4066Sahrens  * combined into masks that can be passed to various functions.
46fa9e4066Sahrens  */
47fa9e4066Sahrens typedef enum {
48fa9e4066Sahrens 	ZFS_TYPE_FILESYSTEM	= 0x1,
49fa9e4066Sahrens 	ZFS_TYPE_SNAPSHOT	= 0x2,
50b1b8ab34Slling 	ZFS_TYPE_VOLUME		= 0x4,
51b1b8ab34Slling 	ZFS_TYPE_POOL		= 0x8
52fa9e4066Sahrens } zfs_type_t;
53fa9e4066Sahrens 
54990b4856Slling #define	ZFS_TYPE_DATASET	\
55fa9e4066Sahrens 	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
56fa9e4066Sahrens 
57478ed9adSEric Taylor #define	ZAP_MAXNAMELEN 256
58478ed9adSEric Taylor #define	ZAP_MAXVALUELEN (1024 * 8)
59478ed9adSEric Taylor #define	ZAP_OLDMAXVALUELEN 1024
60478ed9adSEric Taylor 
61fa9e4066Sahrens /*
62990b4856Slling  * Dataset properties are identified by these constants and must be added to
63990b4856Slling  * the end of this list to ensure that external consumers are not affected
64990b4856Slling  * by the change. If you make any changes to this list, be sure to update
6566e2aaccSgw  * the property table in usr/src/common/zfs/zfs_prop.c.
66fa9e4066Sahrens  */
67fa9e4066Sahrens typedef enum {
68fa9e4066Sahrens 	ZFS_PROP_TYPE,
69fa9e4066Sahrens 	ZFS_PROP_CREATION,
70fa9e4066Sahrens 	ZFS_PROP_USED,
71fa9e4066Sahrens 	ZFS_PROP_AVAILABLE,
72fa9e4066Sahrens 	ZFS_PROP_REFERENCED,
73fa9e4066Sahrens 	ZFS_PROP_COMPRESSRATIO,
74fa9e4066Sahrens 	ZFS_PROP_MOUNTED,
75fa9e4066Sahrens 	ZFS_PROP_ORIGIN,
76fa9e4066Sahrens 	ZFS_PROP_QUOTA,
77fa9e4066Sahrens 	ZFS_PROP_RESERVATION,
78fa9e4066Sahrens 	ZFS_PROP_VOLSIZE,
79fa9e4066Sahrens 	ZFS_PROP_VOLBLOCKSIZE,
80fa9e4066Sahrens 	ZFS_PROP_RECORDSIZE,
81fa9e4066Sahrens 	ZFS_PROP_MOUNTPOINT,
82fa9e4066Sahrens 	ZFS_PROP_SHARENFS,
83fa9e4066Sahrens 	ZFS_PROP_CHECKSUM,
84fa9e4066Sahrens 	ZFS_PROP_COMPRESSION,
85fa9e4066Sahrens 	ZFS_PROP_ATIME,
86fa9e4066Sahrens 	ZFS_PROP_DEVICES,
87fa9e4066Sahrens 	ZFS_PROP_EXEC,
88fa9e4066Sahrens 	ZFS_PROP_SETUID,
89fa9e4066Sahrens 	ZFS_PROP_READONLY,
90fa9e4066Sahrens 	ZFS_PROP_ZONED,
91fa9e4066Sahrens 	ZFS_PROP_SNAPDIR,
92a3c49ce1SAlbert Lee 	ZFS_PROP_ACLMODE,
93fa9e4066Sahrens 	ZFS_PROP_ACLINHERIT,
9466e2aaccSgw 	ZFS_PROP_CREATETXG,		/* not exposed to the user */
9566e2aaccSgw 	ZFS_PROP_NAME,			/* not exposed to the user */
96e9dbad6fSeschrock 	ZFS_PROP_CANMOUNT,
9766e2aaccSgw 	ZFS_PROP_ISCSIOPTIONS,		/* not exposed to the user */
987b55fa8eSck 	ZFS_PROP_XATTR,
99d0ad202dSahrens 	ZFS_PROP_NUMCLONES,		/* not exposed to the user */
100b1b8ab34Slling 	ZFS_PROP_COPIES,
101e7437265Sahrens 	ZFS_PROP_VERSION,
102da6c28aaSamw 	ZFS_PROP_UTF8ONLY,
103da6c28aaSamw 	ZFS_PROP_NORMALIZE,
104da6c28aaSamw 	ZFS_PROP_CASE,
105da6c28aaSamw 	ZFS_PROP_VSCAN,
106da6c28aaSamw 	ZFS_PROP_NBMAND,
107da6c28aaSamw 	ZFS_PROP_SHARESMB,
108a9799022Sck 	ZFS_PROP_REFQUOTA,
109a9799022Sck 	ZFS_PROP_REFRESERVATION,
110c5904d13Seschrock 	ZFS_PROP_GUID,
1113baa08fcSek 	ZFS_PROP_PRIMARYCACHE,
1123baa08fcSek 	ZFS_PROP_SECONDARYCACHE,
11374e7dc98SMatthew Ahrens 	ZFS_PROP_USEDSNAP,
11474e7dc98SMatthew Ahrens 	ZFS_PROP_USEDDS,
11574e7dc98SMatthew Ahrens 	ZFS_PROP_USEDCHILD,
11674e7dc98SMatthew Ahrens 	ZFS_PROP_USEDREFRESERV,
11714843421SMatthew Ahrens 	ZFS_PROP_USERACCOUNTING,	/* not exposed to the user */
118478ed9adSEric Taylor 	ZFS_PROP_STMF_SHAREINFO,	/* not exposed to the user */
119842727c2SChris Kirby 	ZFS_PROP_DEFER_DESTROY,
120842727c2SChris Kirby 	ZFS_PROP_USERREFS,
121e09fa4daSNeil Perrin 	ZFS_PROP_LOGBIAS,
1221d713200SEric Schrock 	ZFS_PROP_UNIQUE,		/* not exposed to the user */
1231d713200SEric Schrock 	ZFS_PROP_OBJSETID,		/* not exposed to the user */
124b24ab676SJeff Bonwick 	ZFS_PROP_DEDUP,
1254201a95eSRic Aleshire 	ZFS_PROP_MLSLABEL,
12655da60b9SMark J Musante 	ZFS_PROP_SYNC,
127187d6ac0SMatt Ahrens 	ZFS_PROP_REFRATIO,
12819b94df9SMatthew Ahrens 	ZFS_PROP_WRITTEN,
12919b94df9SMatthew Ahrens 	ZFS_PROP_CLONES,
13091ebeef5Sahrens 	ZFS_NUM_PROPS
131fa9e4066Sahrens } zfs_prop_t;
132fa9e4066Sahrens 
13314843421SMatthew Ahrens typedef enum {
13414843421SMatthew Ahrens 	ZFS_PROP_USERUSED,
13514843421SMatthew Ahrens 	ZFS_PROP_USERQUOTA,
13614843421SMatthew Ahrens 	ZFS_PROP_GROUPUSED,
13714843421SMatthew Ahrens 	ZFS_PROP_GROUPQUOTA,
13814843421SMatthew Ahrens 	ZFS_NUM_USERQUOTA_PROPS
13914843421SMatthew Ahrens } zfs_userquota_prop_t;
14014843421SMatthew Ahrens 
14114843421SMatthew Ahrens extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
14214843421SMatthew Ahrens 
143990b4856Slling /*
144990b4856Slling  * Pool properties are identified by these constants and must be added to the
145b87f3af3Sperrin  * end of this list to ensure that external consumers are not affected
146990b4856Slling  * by the change. If you make any changes to this list, be sure to update
147990b4856Slling  * the property table in usr/src/common/zfs/zpool_prop.c.
148990b4856Slling  */
149990b4856Slling typedef enum {
150990b4856Slling 	ZPOOL_PROP_NAME,
151990b4856Slling 	ZPOOL_PROP_SIZE,
152990b4856Slling 	ZPOOL_PROP_CAPACITY,
153990b4856Slling 	ZPOOL_PROP_ALTROOT,
154990b4856Slling 	ZPOOL_PROP_HEALTH,
155990b4856Slling 	ZPOOL_PROP_GUID,
156990b4856Slling 	ZPOOL_PROP_VERSION,
157990b4856Slling 	ZPOOL_PROP_BOOTFS,
158990b4856Slling 	ZPOOL_PROP_DELEGATION,
159990b4856Slling 	ZPOOL_PROP_AUTOREPLACE,
1602f8aaab3Seschrock 	ZPOOL_PROP_CACHEFILE,
1610a4e9518Sgw 	ZPOOL_PROP_FAILUREMODE,
162d5b5bb25SRich Morris 	ZPOOL_PROP_LISTSNAPS,
163573ca77eSGeorge Wilson 	ZPOOL_PROP_AUTOEXPAND,
164b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPDITTO,
165b24ab676SJeff Bonwick 	ZPOOL_PROP_DEDUPRATIO,
166485bbbf5SGeorge Wilson 	ZPOOL_PROP_FREE,
167485bbbf5SGeorge Wilson 	ZPOOL_PROP_ALLOCATED,
168f9af39baSGeorge Wilson 	ZPOOL_PROP_READONLY,
1698704186eSDan McDonald 	ZPOOL_PROP_COMMENT,
170*4263d13fSGeorge Wilson 	ZPOOL_PROP_EXPANDSZ,
171990b4856Slling 	ZPOOL_NUM_PROPS
172990b4856Slling } zpool_prop_t;
173b1b8ab34Slling 
1748704186eSDan McDonald /* Small enough to not hog a whole line of printout in zpool(1M). */
1758704186eSDan McDonald #define	ZPROP_MAX_COMMENT	32
1768704186eSDan McDonald 
177990b4856Slling #define	ZPROP_CONT		-2
178990b4856Slling #define	ZPROP_INVAL		-1
1793d7072f8Seschrock 
180990b4856Slling #define	ZPROP_VALUE		"value"
181990b4856Slling #define	ZPROP_SOURCE		"source"
1827f7322feSeschrock 
183b1b8ab34Slling typedef enum {
184990b4856Slling 	ZPROP_SRC_NONE = 0x1,
185990b4856Slling 	ZPROP_SRC_DEFAULT = 0x2,
186990b4856Slling 	ZPROP_SRC_TEMPORARY = 0x4,
187990b4856Slling 	ZPROP_SRC_LOCAL = 0x8,
18892241e0bSTom Erickson 	ZPROP_SRC_INHERITED = 0x10,
18992241e0bSTom Erickson 	ZPROP_SRC_RECEIVED = 0x20
190990b4856Slling } zprop_source_t;
191990b4856Slling 
19292241e0bSTom Erickson #define	ZPROP_SRC_ALL	0x3f
19392241e0bSTom Erickson 
19492241e0bSTom Erickson #define	ZPROP_SOURCE_VAL_RECVD	"$recvd"
19592241e0bSTom Erickson #define	ZPROP_N_MORE_ERRORS	"N_MORE_ERRORS"
19692241e0bSTom Erickson /*
19792241e0bSTom Erickson  * Dataset flag implemented as a special entry in the props zap object
19892241e0bSTom Erickson  * indicating that the dataset has received properties on or after
19992241e0bSTom Erickson  * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
20092241e0bSTom Erickson  * just as it did in earlier versions, and thereafter, local properties are
20192241e0bSTom Erickson  * preserved.
20292241e0bSTom Erickson  */
20392241e0bSTom Erickson #define	ZPROP_HAS_RECVD		"$hasrecvd"
20492241e0bSTom Erickson 
20592241e0bSTom Erickson typedef enum {
20692241e0bSTom Erickson 	ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
20792241e0bSTom Erickson 	ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
20892241e0bSTom Erickson } zprop_errflags_t;
209990b4856Slling 
210990b4856Slling typedef int (*zprop_func)(int, void *);
211990b4856Slling 
2120a48a24eStimh /*
2130a48a24eStimh  * Properties to be set on the root file system of a new pool
2140a48a24eStimh  * are stuffed into their own nvlist, which is then included in
2150a48a24eStimh  * the properties nvlist with the pool properties.
2160a48a24eStimh  */
2170a48a24eStimh #define	ZPOOL_ROOTFS_PROPS	"root-props-nvl"
2180a48a24eStimh 
219990b4856Slling /*
220990b4856Slling  * Dataset property functions shared between libzfs and kernel.
221990b4856Slling  */
222990b4856Slling const char *zfs_prop_default_string(zfs_prop_t);
223990b4856Slling uint64_t zfs_prop_default_numeric(zfs_prop_t);
224990b4856Slling boolean_t zfs_prop_readonly(zfs_prop_t);
225990b4856Slling boolean_t zfs_prop_inheritable(zfs_prop_t);
226da6c28aaSamw boolean_t zfs_prop_setonce(zfs_prop_t);
227990b4856Slling const char *zfs_prop_to_name(zfs_prop_t);
228990b4856Slling zfs_prop_t zfs_name_to_prop(const char *);
229990b4856Slling boolean_t zfs_prop_user(const char *);
23092241e0bSTom Erickson boolean_t zfs_prop_userquota(const char *);
23119b94df9SMatthew Ahrens boolean_t zfs_prop_written(const char *);
232990b4856Slling int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
233990b4856Slling int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
234b24ab676SJeff Bonwick uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
2354853e976Sgw boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
236b1b8ab34Slling 
237990b4856Slling /*
238990b4856Slling  * Pool property functions shared between libzfs and kernel.
239990b4856Slling  */
240990b4856Slling zpool_prop_t zpool_name_to_prop(const char *);
241990b4856Slling const char *zpool_prop_to_name(zpool_prop_t);
242990b4856Slling const char *zpool_prop_default_string(zpool_prop_t);
243990b4856Slling uint64_t zpool_prop_default_numeric(zpool_prop_t);
244990b4856Slling boolean_t zpool_prop_readonly(zpool_prop_t);
245990b4856Slling int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
246990b4856Slling int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
247b24ab676SJeff Bonwick uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
248b1b8ab34Slling 
249990b4856Slling /*
250990b4856Slling  * Definitions for the Delegation.
251990b4856Slling  */
252ecd6cf80Smarks typedef enum {
253ecd6cf80Smarks 	ZFS_DELEG_WHO_UNKNOWN = 0,
254ecd6cf80Smarks 	ZFS_DELEG_USER = 'u',
255ecd6cf80Smarks 	ZFS_DELEG_USER_SETS = 'U',
256ecd6cf80Smarks 	ZFS_DELEG_GROUP = 'g',
257ecd6cf80Smarks 	ZFS_DELEG_GROUP_SETS = 'G',
258ecd6cf80Smarks 	ZFS_DELEG_EVERYONE = 'e',
259ecd6cf80Smarks 	ZFS_DELEG_EVERYONE_SETS = 'E',
260ecd6cf80Smarks 	ZFS_DELEG_CREATE = 'c',
261ecd6cf80Smarks 	ZFS_DELEG_CREATE_SETS = 'C',
262ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET = 's',
263ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET_SETS = 'S'
264ecd6cf80Smarks } zfs_deleg_who_type_t;
265ecd6cf80Smarks 
266ecd6cf80Smarks typedef enum {
267ecd6cf80Smarks 	ZFS_DELEG_NONE = 0,
268ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCAL = 1,
269ecd6cf80Smarks 	ZFS_DELEG_PERM_DESCENDENT = 2,
270ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
271ecd6cf80Smarks 	ZFS_DELEG_PERM_CREATE = 4
272ecd6cf80Smarks } zfs_deleg_inherit_t;
273ecd6cf80Smarks 
274ecd6cf80Smarks #define	ZFS_DELEG_PERM_UID	"uid"
275ecd6cf80Smarks #define	ZFS_DELEG_PERM_GID	"gid"
276ecd6cf80Smarks #define	ZFS_DELEG_PERM_GROUPS	"groups"
277ecd6cf80Smarks 
2784201a95eSRic Aleshire #define	ZFS_MLSLABEL_DEFAULT	"none"
2794201a95eSRic Aleshire 
280743a77edSAlan Wright #define	ZFS_SMB_ACL_SRC		"src"
281743a77edSAlan Wright #define	ZFS_SMB_ACL_TARGET	"target"
282743a77edSAlan Wright 
283a227b7f4Shs typedef enum {
284a227b7f4Shs 	ZFS_CANMOUNT_OFF = 0,
285a227b7f4Shs 	ZFS_CANMOUNT_ON = 1,
286a227b7f4Shs 	ZFS_CANMOUNT_NOAUTO = 2
287a227b7f4Shs } zfs_canmount_type_t;
288a227b7f4Shs 
289e09fa4daSNeil Perrin typedef enum {
290e09fa4daSNeil Perrin 	ZFS_LOGBIAS_LATENCY = 0,
291e09fa4daSNeil Perrin 	ZFS_LOGBIAS_THROUGHPUT = 1
292e09fa4daSNeil Perrin } zfs_logbias_op_t;
293e09fa4daSNeil Perrin 
294da6c28aaSamw typedef enum zfs_share_op {
295da6c28aaSamw 	ZFS_SHARE_NFS = 0,
296da6c28aaSamw 	ZFS_UNSHARE_NFS = 1,
297da6c28aaSamw 	ZFS_SHARE_SMB = 2,
298da6c28aaSamw 	ZFS_UNSHARE_SMB = 3
299da6c28aaSamw } zfs_share_op_t;
300da6c28aaSamw 
301743a77edSAlan Wright typedef enum zfs_smb_acl_op {
302743a77edSAlan Wright 	ZFS_SMB_ACL_ADD,
303743a77edSAlan Wright 	ZFS_SMB_ACL_REMOVE,
304743a77edSAlan Wright 	ZFS_SMB_ACL_RENAME,
305743a77edSAlan Wright 	ZFS_SMB_ACL_PURGE
306743a77edSAlan Wright } zfs_smb_acl_op_t;
307743a77edSAlan Wright 
3083baa08fcSek typedef enum zfs_cache_type {
3093baa08fcSek 	ZFS_CACHE_NONE = 0,
3103baa08fcSek 	ZFS_CACHE_METADATA = 1,
3113baa08fcSek 	ZFS_CACHE_ALL = 2
3123baa08fcSek } zfs_cache_type_t;
3133baa08fcSek 
31455da60b9SMark J Musante typedef enum {
31555da60b9SMark J Musante 	ZFS_SYNC_STANDARD = 0,
31655da60b9SMark J Musante 	ZFS_SYNC_ALWAYS = 1,
31755da60b9SMark J Musante 	ZFS_SYNC_DISABLED = 2
31855da60b9SMark J Musante } zfs_sync_type_t;
31955da60b9SMark J Musante 
3203baa08fcSek 
321eaca9bbdSeschrock /*
32299653d4eSeschrock  * On-disk version number.
323eaca9bbdSeschrock  */
324e7437265Sahrens #define	SPA_VERSION_1			1ULL
325e7437265Sahrens #define	SPA_VERSION_2			2ULL
326e7437265Sahrens #define	SPA_VERSION_3			3ULL
327e7437265Sahrens #define	SPA_VERSION_4			4ULL
328e7437265Sahrens #define	SPA_VERSION_5			5ULL
329e7437265Sahrens #define	SPA_VERSION_6			6ULL
330e7437265Sahrens #define	SPA_VERSION_7			7ULL
331e7437265Sahrens #define	SPA_VERSION_8			8ULL
332da6c28aaSamw #define	SPA_VERSION_9			9ULL
333fa94a07fSbrendan #define	SPA_VERSION_10			10ULL
334088f3894Sahrens #define	SPA_VERSION_11			11ULL
335bb0ade09Sahrens #define	SPA_VERSION_12			12ULL
33674e7dc98SMatthew Ahrens #define	SPA_VERSION_13			13ULL
337d0f3f37eSMark Shellenbaum #define	SPA_VERSION_14			14ULL
33814843421SMatthew Ahrens #define	SPA_VERSION_15			15ULL
339478ed9adSEric Taylor #define	SPA_VERSION_16			16ULL
340f94275ceSAdam Leventhal #define	SPA_VERSION_17			17ULL
341842727c2SChris Kirby #define	SPA_VERSION_18			18ULL
34288ecc943SGeorge Wilson #define	SPA_VERSION_19			19ULL
343b24ab676SJeff Bonwick #define	SPA_VERSION_20			20ULL
344b24ab676SJeff Bonwick #define	SPA_VERSION_21			21ULL
34592241e0bSTom Erickson #define	SPA_VERSION_22			22ULL
3466e1f5caaSNeil Perrin #define	SPA_VERSION_23			23ULL
3470a586ceaSMark Shellenbaum #define	SPA_VERSION_24			24ULL
3483f9d6ad7SLin Ling #define	SPA_VERSION_25			25ULL
349cde58dbcSMatthew Ahrens #define	SPA_VERSION_26			26ULL
3506e0cbcaaSMatthew Ahrens #define	SPA_VERSION_27			27ULL
351cb04b873SMark J Musante #define	SPA_VERSION_28			28ULL
352cb04b873SMark J Musante 
353b1b8ab34Slling /*
354e7cbe64fSgw  * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
355478ed9adSEric Taylor  * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
35614843421SMatthew Ahrens  * and do the appropriate changes.  Also bump the version number in
35714843421SMatthew Ahrens  * usr/src/grub/capability.
358b1b8ab34Slling  */
359cb04b873SMark J Musante #define	SPA_VERSION			SPA_VERSION_28
360cb04b873SMark J Musante #define	SPA_VERSION_STRING		"28"
36144cd46caSbillm 
36244cd46caSbillm /*
363e7437265Sahrens  * Symbolic names for the changes that caused a SPA_VERSION switch.
36444cd46caSbillm  * Used in the code when checking for presence or absence of a feature.
36544cd46caSbillm  * Feel free to define multiple symbolic names for each version if there
36644cd46caSbillm  * were multiple changes to on-disk structures during that version.
36744cd46caSbillm  *
368e7437265Sahrens  * NOTE: When checking the current SPA_VERSION in your code, be sure
36944cd46caSbillm  *       to use spa_version() since it reports the version of the
37044cd46caSbillm  *       last synced uberblock.  Checking the in-flight version can
37144cd46caSbillm  *       be dangerous in some cases.
37244cd46caSbillm  */
373e7437265Sahrens #define	SPA_VERSION_INITIAL		SPA_VERSION_1
374e7437265Sahrens #define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
375e7437265Sahrens #define	SPA_VERSION_SPARES		SPA_VERSION_3
376f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ2		SPA_VERSION_3
377cde58dbcSMatthew Ahrens #define	SPA_VERSION_BPOBJ_ACCOUNT	SPA_VERSION_3
378e7437265Sahrens #define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
379e7437265Sahrens #define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
380e7437265Sahrens #define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
381e7437265Sahrens #define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
382e7437265Sahrens #define	SPA_VERSION_BOOTFS		SPA_VERSION_6
383990b4856Slling #define	SPA_VERSION_SLOGS		SPA_VERSION_7
384990b4856Slling #define	SPA_VERSION_DELEGATED_PERMS	SPA_VERSION_8
385da6c28aaSamw #define	SPA_VERSION_FUID		SPA_VERSION_9
386a9799022Sck #define	SPA_VERSION_REFRESERVATION	SPA_VERSION_9
387a9799022Sck #define	SPA_VERSION_REFQUOTA		SPA_VERSION_9
388a9799022Sck #define	SPA_VERSION_UNIQUE_ACCURATE	SPA_VERSION_9
389fa94a07fSbrendan #define	SPA_VERSION_L2CACHE		SPA_VERSION_10
390088f3894Sahrens #define	SPA_VERSION_NEXT_CLONES		SPA_VERSION_11
391088f3894Sahrens #define	SPA_VERSION_ORIGIN		SPA_VERSION_11
392088f3894Sahrens #define	SPA_VERSION_DSL_SCRUB		SPA_VERSION_11
393bb0ade09Sahrens #define	SPA_VERSION_SNAP_PROPS		SPA_VERSION_12
39474e7dc98SMatthew Ahrens #define	SPA_VERSION_USED_BREAKDOWN	SPA_VERSION_13
395d0f3f37eSMark Shellenbaum #define	SPA_VERSION_PASSTHROUGH_X	SPA_VERSION_14
39614843421SMatthew Ahrens #define	SPA_VERSION_USERSPACE		SPA_VERSION_15
397478ed9adSEric Taylor #define	SPA_VERSION_STMF_PROP		SPA_VERSION_16
398f94275ceSAdam Leventhal #define	SPA_VERSION_RAIDZ3		SPA_VERSION_17
399842727c2SChris Kirby #define	SPA_VERSION_USERREFS		SPA_VERSION_18
40088ecc943SGeorge Wilson #define	SPA_VERSION_HOLES		SPA_VERSION_19
401b24ab676SJeff Bonwick #define	SPA_VERSION_ZLE_COMPRESSION	SPA_VERSION_20
402b24ab676SJeff Bonwick #define	SPA_VERSION_DEDUP		SPA_VERSION_21
40392241e0bSTom Erickson #define	SPA_VERSION_RECVD_PROPS		SPA_VERSION_22
4046e1f5caaSNeil Perrin #define	SPA_VERSION_SLIM_ZIL		SPA_VERSION_23
4050a586ceaSMark Shellenbaum #define	SPA_VERSION_SA			SPA_VERSION_24
4063f9d6ad7SLin Ling #define	SPA_VERSION_SCAN		SPA_VERSION_25
407cde58dbcSMatthew Ahrens #define	SPA_VERSION_DIR_CLONES		SPA_VERSION_26
408cde58dbcSMatthew Ahrens #define	SPA_VERSION_DEADLISTS		SPA_VERSION_26
4096e0cbcaaSMatthew Ahrens #define	SPA_VERSION_FAST_SNAP		SPA_VERSION_27
410cb04b873SMark J Musante #define	SPA_VERSION_MULTI_REPLACE	SPA_VERSION_28
411e7437265Sahrens 
412e7437265Sahrens /*
413e7437265Sahrens  * ZPL version - rev'd whenever an incompatible on-disk format change
414e7437265Sahrens  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
415e7437265Sahrens  * also update the version_table[] and help message in zfs_prop.c.
416e7437265Sahrens  *
417e7437265Sahrens  * When changing, be sure to teach GRUB how to read the new format!
418478ed9adSEric Taylor  * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
419e7437265Sahrens  */
420e7437265Sahrens #define	ZPL_VERSION_1			1ULL
421e7437265Sahrens #define	ZPL_VERSION_2			2ULL
422da6c28aaSamw #define	ZPL_VERSION_3			3ULL
42314843421SMatthew Ahrens #define	ZPL_VERSION_4			4ULL
4240a586ceaSMark Shellenbaum #define	ZPL_VERSION_5			5ULL
4250a586ceaSMark Shellenbaum #define	ZPL_VERSION			ZPL_VERSION_5
4260a586ceaSMark Shellenbaum #define	ZPL_VERSION_STRING		"5"
427e7437265Sahrens 
428e7437265Sahrens #define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
429e7437265Sahrens #define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
430da6c28aaSamw #define	ZPL_VERSION_FUID		ZPL_VERSION_3
431de8267e0Stimh #define	ZPL_VERSION_NORMALIZATION	ZPL_VERSION_3
432da6c28aaSamw #define	ZPL_VERSION_SYSATTR		ZPL_VERSION_3
43314843421SMatthew Ahrens #define	ZPL_VERSION_USERSPACE		ZPL_VERSION_4
4340a586ceaSMark Shellenbaum #define	ZPL_VERSION_SA			ZPL_VERSION_5
435eaca9bbdSeschrock 
436468c413aSTim Haley /* Rewind request information */
437c8ee1847SVictor Latushkin #define	ZPOOL_NO_REWIND		1  /* No policy - default behavior */
438c8ee1847SVictor Latushkin #define	ZPOOL_NEVER_REWIND	2  /* Do not search for best txg or rewind */
439c8ee1847SVictor Latushkin #define	ZPOOL_TRY_REWIND	4  /* Search for best txg, but do not rewind */
440c8ee1847SVictor Latushkin #define	ZPOOL_DO_REWIND		8  /* Rewind to best txg w/in deferred frees */
441c8ee1847SVictor Latushkin #define	ZPOOL_EXTREME_REWIND	16 /* Allow extreme measures to find best txg */
442c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_MASK	28 /* All the possible rewind bits */
443c8ee1847SVictor Latushkin #define	ZPOOL_REWIND_POLICIES	31 /* All the possible policy bits */
444468c413aSTim Haley 
445468c413aSTim Haley typedef struct zpool_rewind_policy {
446468c413aSTim Haley 	uint32_t	zrp_request;	/* rewind behavior requested */
447c8ee1847SVictor Latushkin 	uint64_t	zrp_maxmeta;	/* max acceptable meta-data errors */
448c8ee1847SVictor Latushkin 	uint64_t	zrp_maxdata;	/* max acceptable data errors */
449468c413aSTim Haley 	uint64_t	zrp_txg;	/* specific txg to load */
450468c413aSTim Haley } zpool_rewind_policy_t;
451468c413aSTim Haley 
452fa9e4066Sahrens /*
453fa9e4066Sahrens  * The following are configuration names used in the nvlist describing a pool's
454fa9e4066Sahrens  * configuration.
455fa9e4066Sahrens  */
456fa9e4066Sahrens #define	ZPOOL_CONFIG_VERSION		"version"
457fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_NAME		"name"
458fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_STATE		"state"
459fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_TXG		"txg"
460fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
461fa9e4066Sahrens #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
462fa9e4066Sahrens #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
463fa9e4066Sahrens #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
464fa9e4066Sahrens #define	ZPOOL_CONFIG_TYPE		"type"
465fa9e4066Sahrens #define	ZPOOL_CONFIG_CHILDREN		"children"
466fa9e4066Sahrens #define	ZPOOL_CONFIG_ID			"id"
467fa9e4066Sahrens #define	ZPOOL_CONFIG_GUID		"guid"
468fa9e4066Sahrens #define	ZPOOL_CONFIG_PATH		"path"
469fa9e4066Sahrens #define	ZPOOL_CONFIG_DEVID		"devid"
470fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
471fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
472fa9e4066Sahrens #define	ZPOOL_CONFIG_ASHIFT		"ashift"
473fa9e4066Sahrens #define	ZPOOL_CONFIG_ASIZE		"asize"
474fa9e4066Sahrens #define	ZPOOL_CONFIG_DTL		"DTL"
4753f9d6ad7SLin Ling #define	ZPOOL_CONFIG_SCAN_STATS		"scan_stats"	/* not stored on disk */
4763f9d6ad7SLin Ling #define	ZPOOL_CONFIG_VDEV_STATS		"vdev_stats"	/* not stored on disk */
477afefbcddSeschrock #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
478ea8dc4b6Seschrock #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
479ea8dc4b6Seschrock #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
48099653d4eSeschrock #define	ZPOOL_CONFIG_SPARES		"spares"
48199653d4eSeschrock #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
48299653d4eSeschrock #define	ZPOOL_CONFIG_NPARITY		"nparity"
48395173954Sek #define	ZPOOL_CONFIG_HOSTID		"hostid"
48495173954Sek #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
48511027bc7STim Haley #define	ZPOOL_CONFIG_LOADED_TIME	"initial_load_time"
4863d7072f8Seschrock #define	ZPOOL_CONFIG_UNSPARE		"unspare"
4873d7072f8Seschrock #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
4888654d025Sperrin #define	ZPOOL_CONFIG_IS_LOG		"is_log"
489fa94a07fSbrendan #define	ZPOOL_CONFIG_L2CACHE		"l2cache"
49088ecc943SGeorge Wilson #define	ZPOOL_CONFIG_HOLE_ARRAY		"hole_array"
49188ecc943SGeorge Wilson #define	ZPOOL_CONFIG_VDEV_CHILDREN	"vdev_children"
49288ecc943SGeorge Wilson #define	ZPOOL_CONFIG_IS_HOLE		"is_hole"
4939eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_HISTOGRAM	"ddt_histogram"
4949eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_OBJ_STATS	"ddt_object_stats"
4959eb19f4dSGeorge Wilson #define	ZPOOL_CONFIG_DDT_STATS		"ddt_stats"
4961195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT		"splitcfg"
4971195e687SMark J Musante #define	ZPOOL_CONFIG_ORIG_GUID		"orig_guid"
4981195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_GUID		"split_guid"
4991195e687SMark J Musante #define	ZPOOL_CONFIG_SPLIT_LIST		"guid_list"
5003f9d6ad7SLin Ling #define	ZPOOL_CONFIG_REMOVING		"removing"
501cb04b873SMark J Musante #define	ZPOOL_CONFIG_RESILVERING	"resilvering"
5028704186eSDan McDonald #define	ZPOOL_CONFIG_COMMENT		"comment"
503e14bb325SJeff Bonwick #define	ZPOOL_CONFIG_SUSPENDED		"suspended"	/* not stored on disk */
504e7cbe64fSgw #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp"	/* not stored on disk */
505e7cbe64fSgw #define	ZPOOL_CONFIG_BOOTFS		"bootfs"	/* not stored on disk */
5064b964adaSGeorge Wilson #define	ZPOOL_CONFIG_MISSING_DEVICES	"missing_vdevs"	/* not stored on disk */
5074b964adaSGeorge Wilson #define	ZPOOL_CONFIG_LOAD_INFO		"load_info"	/* not stored on disk */
5083d7072f8Seschrock /*
5093d7072f8Seschrock  * The persistent vdev state is stored as separate values rather than a single
5103d7072f8Seschrock  * 'vdev_state' entry.  This is because a device can be in multiple states, such
5113d7072f8Seschrock  * as offline and degraded.
5123d7072f8Seschrock  */
5133d7072f8Seschrock #define	ZPOOL_CONFIG_OFFLINE		"offline"
5143d7072f8Seschrock #define	ZPOOL_CONFIG_FAULTED		"faulted"
5153d7072f8Seschrock #define	ZPOOL_CONFIG_DEGRADED		"degraded"
5163d7072f8Seschrock #define	ZPOOL_CONFIG_REMOVED		"removed"
5176809eb4eSEric Schrock #define	ZPOOL_CONFIG_FRU		"fru"
518069f55e2SEric Schrock #define	ZPOOL_CONFIG_AUX_STATE		"aux_state"
519fa9e4066Sahrens 
520468c413aSTim Haley /* Rewind policy parameters */
521468c413aSTim Haley #define	ZPOOL_REWIND_POLICY		"rewind-policy"
522468c413aSTim Haley #define	ZPOOL_REWIND_REQUEST		"rewind-request"
523468c413aSTim Haley #define	ZPOOL_REWIND_REQUEST_TXG	"rewind-request-txg"
524468c413aSTim Haley #define	ZPOOL_REWIND_META_THRESH	"rewind-meta-thresh"
525468c413aSTim Haley #define	ZPOOL_REWIND_DATA_THRESH	"rewind-data-thresh"
526468c413aSTim Haley 
527468c413aSTim Haley /* Rewind data discovered */
528468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_TIME		"rewind_txg_ts"
529468c413aSTim Haley #define	ZPOOL_CONFIG_LOAD_DATA_ERRORS	"verify_data_errors"
530468c413aSTim Haley #define	ZPOOL_CONFIG_REWIND_TIME	"seconds_of_rewind"
531468c413aSTim Haley 
532fa9e4066Sahrens #define	VDEV_TYPE_ROOT			"root"
533fa9e4066Sahrens #define	VDEV_TYPE_MIRROR		"mirror"
534fa9e4066Sahrens #define	VDEV_TYPE_REPLACING		"replacing"
535fa9e4066Sahrens #define	VDEV_TYPE_RAIDZ			"raidz"
536fa9e4066Sahrens #define	VDEV_TYPE_DISK			"disk"
537fa9e4066Sahrens #define	VDEV_TYPE_FILE			"file"
538fa9e4066Sahrens #define	VDEV_TYPE_MISSING		"missing"
53988ecc943SGeorge Wilson #define	VDEV_TYPE_HOLE			"hole"
54099653d4eSeschrock #define	VDEV_TYPE_SPARE			"spare"
5418654d025Sperrin #define	VDEV_TYPE_LOG			"log"
542fa94a07fSbrendan #define	VDEV_TYPE_L2CACHE		"l2cache"
543fa9e4066Sahrens 
544fa9e4066Sahrens /*
545fa9e4066Sahrens  * This is needed in userland to report the minimum necessary device size.
546fa9e4066Sahrens  */
547fa9e4066Sahrens #define	SPA_MINDEVSIZE		(64ULL << 20)
548fa9e4066Sahrens 
549fa9e4066Sahrens /*
550fa9e4066Sahrens  * The location of the pool configuration repository, shared between kernel and
551fa9e4066Sahrens  * userland.
552fa9e4066Sahrens  */
553c5904d13Seschrock #define	ZPOOL_CACHE		"/etc/zfs/zpool.cache"
554fa9e4066Sahrens 
555fa9e4066Sahrens /*
556fa9e4066Sahrens  * vdev states are ordered from least to most healthy.
557fa9e4066Sahrens  * A vdev that's CANT_OPEN or below is considered unusable.
558fa9e4066Sahrens  */
559fa9e4066Sahrens typedef enum vdev_state {
560fa9e4066Sahrens 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
561fa9e4066Sahrens 	VDEV_STATE_CLOSED,	/* Not currently open			*/
562fa9e4066Sahrens 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
5633d7072f8Seschrock 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
564fa9e4066Sahrens 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
5653d7072f8Seschrock 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
566fa9e4066Sahrens 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
567fa9e4066Sahrens 	VDEV_STATE_HEALTHY	/* Presumed good			*/
568fa9e4066Sahrens } vdev_state_t;
569fa9e4066Sahrens 
5703d7072f8Seschrock #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
5713d7072f8Seschrock 
572fa9e4066Sahrens /*
573fa9e4066Sahrens  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
574fa9e4066Sahrens  * of the vdev stats structure uses these constants to distinguish why.
575fa9e4066Sahrens  */
576fa9e4066Sahrens typedef enum vdev_aux {
577fa9e4066Sahrens 	VDEV_AUX_NONE,		/* no error				*/
578fa9e4066Sahrens 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
579fa9e4066Sahrens 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
580fa9e4066Sahrens 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
581fa9e4066Sahrens 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
582fa9e4066Sahrens 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
583eaca9bbdSeschrock 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
584eaca9bbdSeschrock 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
58599653d4eSeschrock 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
5863d7072f8Seschrock 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
58732b87932Sek 	VDEV_AUX_ERR_EXCEEDED,	/* too many errors			*/
588b87f3af3Sperrin 	VDEV_AUX_IO_FAILURE,	/* experienced I/O failure		*/
589069f55e2SEric Schrock 	VDEV_AUX_BAD_LOG,	/* cannot read log chain(s)		*/
5901195e687SMark J Musante 	VDEV_AUX_EXTERNAL,	/* external diagnosis			*/
5911195e687SMark J Musante 	VDEV_AUX_SPLIT_POOL	/* vdev was split off into another pool	*/
592fa9e4066Sahrens } vdev_aux_t;
593fa9e4066Sahrens 
594fa9e4066Sahrens /*
59546a2abf2Seschrock  * pool state.  The following states are written to disk as part of the normal
596fa94a07fSbrendan  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
597fa94a07fSbrendan  * states are software abstractions used at various levels to communicate
598fa94a07fSbrendan  * pool state.
599fa9e4066Sahrens  */
600fa9e4066Sahrens typedef enum pool_state {
601fa9e4066Sahrens 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
602fa9e4066Sahrens 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
603fa9e4066Sahrens 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
60499653d4eSeschrock 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
605fa94a07fSbrendan 	POOL_STATE_L2CACHE,		/* Level 2 ARC device		*/
606fa9e4066Sahrens 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
60746a2abf2Seschrock 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
60846a2abf2Seschrock 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
609fa9e4066Sahrens } pool_state_t;
610fa9e4066Sahrens 
611fa9e4066Sahrens /*
6123f9d6ad7SLin Ling  * Scan Functions.
613fa9e4066Sahrens  */
6143f9d6ad7SLin Ling typedef enum pool_scan_func {
6153f9d6ad7SLin Ling 	POOL_SCAN_NONE,
6163f9d6ad7SLin Ling 	POOL_SCAN_SCRUB,
6173f9d6ad7SLin Ling 	POOL_SCAN_RESILVER,
6183f9d6ad7SLin Ling 	POOL_SCAN_FUNCS
6193f9d6ad7SLin Ling } pool_scan_func_t;
620fa9e4066Sahrens 
621fa9e4066Sahrens /*
622fa9e4066Sahrens  * ZIO types.  Needed to interpret vdev statistics below.
623fa9e4066Sahrens  */
624fa9e4066Sahrens typedef enum zio_type {
625fa9e4066Sahrens 	ZIO_TYPE_NULL = 0,
626fa9e4066Sahrens 	ZIO_TYPE_READ,
627fa9e4066Sahrens 	ZIO_TYPE_WRITE,
628fa9e4066Sahrens 	ZIO_TYPE_FREE,
629fa9e4066Sahrens 	ZIO_TYPE_CLAIM,
630fa9e4066Sahrens 	ZIO_TYPE_IOCTL,
631fa9e4066Sahrens 	ZIO_TYPES
632fa9e4066Sahrens } zio_type_t;
633fa9e4066Sahrens 
6343f9d6ad7SLin Ling /*
6353f9d6ad7SLin Ling  * Pool statistics.  Note: all fields should be 64-bit because this
6363f9d6ad7SLin Ling  * is passed between kernel and userland as an nvlist uint64 array.
6373f9d6ad7SLin Ling  */
6383f9d6ad7SLin Ling typedef struct pool_scan_stat {
6393f9d6ad7SLin Ling 	/* values stored on disk */
6403f9d6ad7SLin Ling 	uint64_t	pss_func;	/* pool_scan_func_t */
6413f9d6ad7SLin Ling 	uint64_t	pss_state;	/* dsl_scan_state_t */
6423f9d6ad7SLin Ling 	uint64_t	pss_start_time;	/* scan start time */
6433f9d6ad7SLin Ling 	uint64_t	pss_end_time;	/* scan end time */
6443f9d6ad7SLin Ling 	uint64_t	pss_to_examine;	/* total bytes to scan */
6453f9d6ad7SLin Ling 	uint64_t	pss_examined;	/* total examined bytes	*/
6463f9d6ad7SLin Ling 	uint64_t	pss_to_process; /* total bytes to process */
6473f9d6ad7SLin Ling 	uint64_t	pss_processed;	/* total processed bytes */
6483f9d6ad7SLin Ling 	uint64_t	pss_errors;	/* scan errors	*/
6493f9d6ad7SLin Ling 
6503f9d6ad7SLin Ling 	/* values not stored on disk */
6513f9d6ad7SLin Ling 	uint64_t	pss_pass_exam;	/* examined bytes per scan pass */
6523f9d6ad7SLin Ling 	uint64_t	pss_pass_start;	/* start time of a scan pass */
6533f9d6ad7SLin Ling } pool_scan_stat_t;
6543f9d6ad7SLin Ling 
6553f9d6ad7SLin Ling typedef enum dsl_scan_state {
6563f9d6ad7SLin Ling 	DSS_NONE,
6573f9d6ad7SLin Ling 	DSS_SCANNING,
6583f9d6ad7SLin Ling 	DSS_FINISHED,
6593f9d6ad7SLin Ling 	DSS_CANCELED,
6603f9d6ad7SLin Ling 	DSS_NUM_STATES
6613f9d6ad7SLin Ling } dsl_scan_state_t;
6623f9d6ad7SLin Ling 
6633f9d6ad7SLin Ling 
664fa9e4066Sahrens /*
665fa9e4066Sahrens  * Vdev statistics.  Note: all fields should be 64-bit because this
666fa9e4066Sahrens  * is passed between kernel and userland as an nvlist uint64 array.
667fa9e4066Sahrens  */
668fa9e4066Sahrens typedef struct vdev_stat {
669fa9e4066Sahrens 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
670fa9e4066Sahrens 	uint64_t	vs_state;		/* vdev state		*/
671fa9e4066Sahrens 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
672fa9e4066Sahrens 	uint64_t	vs_alloc;		/* space allocated	*/
673fa9e4066Sahrens 	uint64_t	vs_space;		/* total capacity	*/
67499653d4eSeschrock 	uint64_t	vs_dspace;		/* deflated capacity	*/
6752a79c5feSlling 	uint64_t	vs_rsize;		/* replaceable dev size */
676*4263d13fSGeorge Wilson 	uint64_t	vs_esize;		/* expandable dev size */
677fa9e4066Sahrens 	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
678fa9e4066Sahrens 	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
679fa9e4066Sahrens 	uint64_t	vs_read_errors;		/* read errors		*/
680fa9e4066Sahrens 	uint64_t	vs_write_errors;	/* write errors		*/
681fa9e4066Sahrens 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
682fa9e4066Sahrens 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
6833f9d6ad7SLin Ling 	uint64_t	vs_scan_removing;	/* removing?	*/
6843f9d6ad7SLin Ling 	uint64_t	vs_scan_processed;	/* scan processed bytes	*/
685fa9e4066Sahrens } vdev_stat_t;
686fa9e4066Sahrens 
6879eb19f4dSGeorge Wilson /*
6889eb19f4dSGeorge Wilson  * DDT statistics.  Note: all fields should be 64-bit because this
6899eb19f4dSGeorge Wilson  * is passed between kernel and userland as an nvlist uint64 array.
6909eb19f4dSGeorge Wilson  */
6919eb19f4dSGeorge Wilson typedef struct ddt_object {
6929eb19f4dSGeorge Wilson 	uint64_t	ddo_count;	/* number of elments in ddt 	*/
6939eb19f4dSGeorge Wilson 	uint64_t	ddo_dspace;	/* size of ddt on disk		*/
6949eb19f4dSGeorge Wilson 	uint64_t	ddo_mspace;	/* size of ddt in-core		*/
6959eb19f4dSGeorge Wilson } ddt_object_t;
6969eb19f4dSGeorge Wilson 
6979eb19f4dSGeorge Wilson typedef struct ddt_stat {
6989eb19f4dSGeorge Wilson 	uint64_t	dds_blocks;	/* blocks			*/
6999eb19f4dSGeorge Wilson 	uint64_t	dds_lsize;	/* logical size			*/
7009eb19f4dSGeorge Wilson 	uint64_t	dds_psize;	/* physical size		*/
7019eb19f4dSGeorge Wilson 	uint64_t	dds_dsize;	/* deflated allocated size	*/
7029eb19f4dSGeorge Wilson 	uint64_t	dds_ref_blocks;	/* referenced blocks		*/
7039eb19f4dSGeorge Wilson 	uint64_t	dds_ref_lsize;	/* referenced lsize * refcnt	*/
7049eb19f4dSGeorge Wilson 	uint64_t	dds_ref_psize;	/* referenced psize * refcnt	*/
7059eb19f4dSGeorge Wilson 	uint64_t	dds_ref_dsize;	/* referenced dsize * refcnt	*/
7069eb19f4dSGeorge Wilson } ddt_stat_t;
7079eb19f4dSGeorge Wilson 
7089eb19f4dSGeorge Wilson typedef struct ddt_histogram {
7099eb19f4dSGeorge Wilson 	ddt_stat_t	ddh_stat[64];	/* power-of-two histogram buckets */
7109eb19f4dSGeorge Wilson } ddt_histogram_t;
7119eb19f4dSGeorge Wilson 
712e7cbe64fSgw #define	ZVOL_DRIVER	"zvol"
713fa9e4066Sahrens #define	ZFS_DRIVER	"zfs"
714fa9e4066Sahrens #define	ZFS_DEV		"/dev/zfs"
715fa9e4066Sahrens 
716681d9761SEric Taylor /* general zvol path */
717681d9761SEric Taylor #define	ZVOL_DIR		"/dev/zvol"
718681d9761SEric Taylor /* expansion */
719573ca77eSGeorge Wilson #define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zfs@0:"
720681d9761SEric Taylor /* for dump and swap */
721681d9761SEric Taylor #define	ZVOL_FULL_DEV_DIR	ZVOL_DIR "/dsk/"
722681d9761SEric Taylor #define	ZVOL_FULL_RDEV_DIR	ZVOL_DIR "/rdsk/"
723fa9e4066Sahrens 
724fa9e4066Sahrens #define	ZVOL_PROP_NAME		"name"
725c1449561SEric Taylor #define	ZVOL_DEFAULT_BLOCKSIZE	8192
726fa9e4066Sahrens 
727fa9e4066Sahrens /*
728fa9e4066Sahrens  * /dev/zfs ioctl numbers.
729fa9e4066Sahrens  */
730fa9e4066Sahrens #define	ZFS_IOC		('Z' << 8)
731fa9e4066Sahrens 
732fa9e4066Sahrens typedef enum zfs_ioc {
733fa9e4066Sahrens 	ZFS_IOC_POOL_CREATE = ZFS_IOC,
734fa9e4066Sahrens 	ZFS_IOC_POOL_DESTROY,
735fa9e4066Sahrens 	ZFS_IOC_POOL_IMPORT,
736fa9e4066Sahrens 	ZFS_IOC_POOL_EXPORT,
737fa9e4066Sahrens 	ZFS_IOC_POOL_CONFIGS,
738fa9e4066Sahrens 	ZFS_IOC_POOL_STATS,
739fa9e4066Sahrens 	ZFS_IOC_POOL_TRYIMPORT,
7403f9d6ad7SLin Ling 	ZFS_IOC_POOL_SCAN,
741fa9e4066Sahrens 	ZFS_IOC_POOL_FREEZE,
742eaca9bbdSeschrock 	ZFS_IOC_POOL_UPGRADE,
74306eeb2adSek 	ZFS_IOC_POOL_GET_HISTORY,
744fa9e4066Sahrens 	ZFS_IOC_VDEV_ADD,
745fa9e4066Sahrens 	ZFS_IOC_VDEV_REMOVE,
7463d7072f8Seschrock 	ZFS_IOC_VDEV_SET_STATE,
747fa9e4066Sahrens 	ZFS_IOC_VDEV_ATTACH,
748fa9e4066Sahrens 	ZFS_IOC_VDEV_DETACH,
749c67d9675Seschrock 	ZFS_IOC_VDEV_SETPATH,
7506809eb4eSEric Schrock 	ZFS_IOC_VDEV_SETFRU,
751fa9e4066Sahrens 	ZFS_IOC_OBJSET_STATS,
752de8267e0Stimh 	ZFS_IOC_OBJSET_ZPLPROPS,
753fa9e4066Sahrens 	ZFS_IOC_DATASET_LIST_NEXT,
754fa9e4066Sahrens 	ZFS_IOC_SNAPSHOT_LIST_NEXT,
755fa9e4066Sahrens 	ZFS_IOC_SET_PROP,
756fa9e4066Sahrens 	ZFS_IOC_CREATE,
757fa9e4066Sahrens 	ZFS_IOC_DESTROY,
758fa9e4066Sahrens 	ZFS_IOC_ROLLBACK,
759fa9e4066Sahrens 	ZFS_IOC_RENAME,
7603cb34c60Sahrens 	ZFS_IOC_RECV,
7613cb34c60Sahrens 	ZFS_IOC_SEND,
762ea8dc4b6Seschrock 	ZFS_IOC_INJECT_FAULT,
763ea8dc4b6Seschrock 	ZFS_IOC_CLEAR_FAULT,
764ea8dc4b6Seschrock 	ZFS_IOC_INJECT_LIST_NEXT,
765ea8dc4b6Seschrock 	ZFS_IOC_ERROR_LOG,
766ea8dc4b6Seschrock 	ZFS_IOC_CLEAR,
7671d452cf5Sahrens 	ZFS_IOC_PROMOTE,
76855434c77Sek 	ZFS_IOC_SNAPSHOT,
76955434c77Sek 	ZFS_IOC_DSOBJ_TO_DSNAME,
770b1b8ab34Slling 	ZFS_IOC_OBJ_TO_PATH,
771b1b8ab34Slling 	ZFS_IOC_POOL_SET_PROPS,
772ecd6cf80Smarks 	ZFS_IOC_POOL_GET_PROPS,
773ecd6cf80Smarks 	ZFS_IOC_SET_FSACL,
774ecd6cf80Smarks 	ZFS_IOC_GET_FSACL,
775e45ce728Sahrens 	ZFS_IOC_SHARE,
776743a77edSAlan Wright 	ZFS_IOC_INHERIT_PROP,
77714843421SMatthew Ahrens 	ZFS_IOC_SMB_ACL,
77814843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_ONE,
77914843421SMatthew Ahrens 	ZFS_IOC_USERSPACE_MANY,
780842727c2SChris Kirby 	ZFS_IOC_USERSPACE_UPGRADE,
781842727c2SChris Kirby 	ZFS_IOC_HOLD,
782842727c2SChris Kirby 	ZFS_IOC_RELEASE,
78392241e0bSTom Erickson 	ZFS_IOC_GET_HOLDS,
7841195e687SMark J Musante 	ZFS_IOC_OBJSET_RECVD_PROPS,
78599d5e173STim Haley 	ZFS_IOC_VDEV_SPLIT,
78699d5e173STim Haley 	ZFS_IOC_NEXT_OBJ,
78799d5e173STim Haley 	ZFS_IOC_DIFF,
78899d5e173STim Haley 	ZFS_IOC_TMP_SNAPSHOT,
789e9103aaeSGarrett D'Amore 	ZFS_IOC_OBJ_TO_STATS,
79019b94df9SMatthew Ahrens 	ZFS_IOC_SPACE_WRITTEN,
79119b94df9SMatthew Ahrens 	ZFS_IOC_SPACE_SNAPS,
79219b94df9SMatthew Ahrens 	ZFS_IOC_DESTROY_SNAPS_NVL,
793*4263d13fSGeorge Wilson 	ZFS_IOC_POOL_REGUID,
794*4263d13fSGeorge Wilson 	ZFS_IOC_POOL_REOPEN
795fa9e4066Sahrens } zfs_ioc_t;
796fa9e4066Sahrens 
797ea8dc4b6Seschrock /*
798ea8dc4b6Seschrock  * Internal SPA load state.  Used by FMA diagnosis engine.
799ea8dc4b6Seschrock  */
800ea8dc4b6Seschrock typedef enum {
8019eb19f4dSGeorge Wilson 	SPA_LOAD_NONE,		/* no load in progress	*/
8029eb19f4dSGeorge Wilson 	SPA_LOAD_OPEN,		/* normal open		*/
8039eb19f4dSGeorge Wilson 	SPA_LOAD_IMPORT,	/* import in progress	*/
804468c413aSTim Haley 	SPA_LOAD_TRYIMPORT,	/* tryimport in progress */
8059eb19f4dSGeorge Wilson 	SPA_LOAD_RECOVER,	/* recovery requested	*/
8069eb19f4dSGeorge Wilson 	SPA_LOAD_ERROR		/* load failed		*/
807ea8dc4b6Seschrock } spa_load_state_t;
808ea8dc4b6Seschrock 
809e9dbad6fSeschrock /*
810e9dbad6fSeschrock  * Bookmark name values.
811e9dbad6fSeschrock  */
81255434c77Sek #define	ZPOOL_ERR_LIST		"error list"
813e9dbad6fSeschrock #define	ZPOOL_ERR_DATASET	"dataset"
814e9dbad6fSeschrock #define	ZPOOL_ERR_OBJECT	"object"
815e9dbad6fSeschrock 
81606eeb2adSek #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
81706eeb2adSek 
81806eeb2adSek /*
81906eeb2adSek  * The following are names used in the nvlist describing
82006eeb2adSek  * the pool's history log.
82106eeb2adSek  */
82206eeb2adSek #define	ZPOOL_HIST_RECORD	"history record"
82306eeb2adSek #define	ZPOOL_HIST_TIME		"history time"
82406eeb2adSek #define	ZPOOL_HIST_CMD		"history command"
825ecd6cf80Smarks #define	ZPOOL_HIST_WHO		"history who"
826ecd6cf80Smarks #define	ZPOOL_HIST_ZONE		"history zone"
827ecd6cf80Smarks #define	ZPOOL_HIST_HOST		"history hostname"
828ecd6cf80Smarks #define	ZPOOL_HIST_TXG		"history txg"
829ecd6cf80Smarks #define	ZPOOL_HIST_INT_EVENT	"history internal event"
830ecd6cf80Smarks #define	ZPOOL_HIST_INT_STR	"history internal str"
83106eeb2adSek 
8323d7072f8Seschrock /*
8333d7072f8Seschrock  * Flags for ZFS_IOC_VDEV_SET_STATE
8343d7072f8Seschrock  */
8353d7072f8Seschrock #define	ZFS_ONLINE_CHECKREMOVE	0x1
8363d7072f8Seschrock #define	ZFS_ONLINE_UNSPARE	0x2
8373d7072f8Seschrock #define	ZFS_ONLINE_FORCEFAULT	0x4
838573ca77eSGeorge Wilson #define	ZFS_ONLINE_EXPAND	0x8
8393d7072f8Seschrock #define	ZFS_OFFLINE_TEMPORARY	0x1
8403d7072f8Seschrock 
8414b964adaSGeorge Wilson /*
8424b964adaSGeorge Wilson  * Flags for ZFS_IOC_POOL_IMPORT
8434b964adaSGeorge Wilson  */
8444b964adaSGeorge Wilson #define	ZFS_IMPORT_NORMAL	0x0
8454b964adaSGeorge Wilson #define	ZFS_IMPORT_VERBATIM	0x1
8464b964adaSGeorge Wilson #define	ZFS_IMPORT_ANY_HOST	0x2
8474b964adaSGeorge Wilson #define	ZFS_IMPORT_MISSING_LOG	0x4
848f9af39baSGeorge Wilson #define	ZFS_IMPORT_ONLY		0x8
8494b964adaSGeorge Wilson 
8503d7072f8Seschrock /*
8513d7072f8Seschrock  * Sysevent payload members.  ZFS will generate the following sysevents with the
8523d7072f8Seschrock  * given payloads:
8533d7072f8Seschrock  *
8543d7072f8Seschrock  *	ESC_ZFS_RESILVER_START
8553d7072f8Seschrock  *	ESC_ZFS_RESILVER_END
8563d7072f8Seschrock  *	ESC_ZFS_POOL_DESTROY
857e9103aaeSGarrett D'Amore  *	ESC_ZFS_POOL_REGUID
8583d7072f8Seschrock  *
8593d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
8603d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
8613d7072f8Seschrock  *
8623d7072f8Seschrock  *	ESC_ZFS_VDEV_REMOVE
8633d7072f8Seschrock  *	ESC_ZFS_VDEV_CLEAR
8643d7072f8Seschrock  *	ESC_ZFS_VDEV_CHECK
8653d7072f8Seschrock  *
8663d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
8673d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
8683d7072f8Seschrock  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
8693d7072f8Seschrock  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
8703d7072f8Seschrock  */
8713d7072f8Seschrock #define	ZFS_EV_POOL_NAME	"pool_name"
8723d7072f8Seschrock #define	ZFS_EV_POOL_GUID	"pool_guid"
8733d7072f8Seschrock #define	ZFS_EV_VDEV_PATH	"vdev_path"
8743d7072f8Seschrock #define	ZFS_EV_VDEV_GUID	"vdev_guid"
8753d7072f8Seschrock 
876088f3894Sahrens /*
877088f3894Sahrens  * Note: This is encoded on-disk, so new events must be added to the
878088f3894Sahrens  * end, and unused events can not be removed.  Be sure to edit
8798f18d1faSGeorge Wilson  * libzfs_pool.c: hist_event_table[].
880088f3894Sahrens  */
881ecd6cf80Smarks typedef enum history_internal_events {
882ecd6cf80Smarks 	LOG_NO_EVENT = 0,
883ecd6cf80Smarks 	LOG_POOL_CREATE,
884ecd6cf80Smarks 	LOG_POOL_VDEV_ADD,
885ecd6cf80Smarks 	LOG_POOL_REMOVE,
886ecd6cf80Smarks 	LOG_POOL_DESTROY,
887ecd6cf80Smarks 	LOG_POOL_EXPORT,
888ecd6cf80Smarks 	LOG_POOL_IMPORT,
889ecd6cf80Smarks 	LOG_POOL_VDEV_ATTACH,
890ecd6cf80Smarks 	LOG_POOL_VDEV_REPLACE,
891ecd6cf80Smarks 	LOG_POOL_VDEV_DETACH,
892ecd6cf80Smarks 	LOG_POOL_VDEV_ONLINE,
893ecd6cf80Smarks 	LOG_POOL_VDEV_OFFLINE,
894ecd6cf80Smarks 	LOG_POOL_UPGRADE,
895ecd6cf80Smarks 	LOG_POOL_CLEAR,
8963f9d6ad7SLin Ling 	LOG_POOL_SCAN,
897ecd6cf80Smarks 	LOG_POOL_PROPSET,
898ecd6cf80Smarks 	LOG_DS_CREATE,
899ecd6cf80Smarks 	LOG_DS_CLONE,
900ecd6cf80Smarks 	LOG_DS_DESTROY,
901ecd6cf80Smarks 	LOG_DS_DESTROY_BEGIN,
902ecd6cf80Smarks 	LOG_DS_INHERIT,
903ecd6cf80Smarks 	LOG_DS_PROPSET,
904ecd6cf80Smarks 	LOG_DS_QUOTA,
905ecd6cf80Smarks 	LOG_DS_PERM_UPDATE,
906ecd6cf80Smarks 	LOG_DS_PERM_REMOVE,
907ecd6cf80Smarks 	LOG_DS_PERM_WHO_REMOVE,
908ecd6cf80Smarks 	LOG_DS_PROMOTE,
909ecd6cf80Smarks 	LOG_DS_RECEIVE,
910ecd6cf80Smarks 	LOG_DS_RENAME,
911ecd6cf80Smarks 	LOG_DS_RESERVATION,
912ecd6cf80Smarks 	LOG_DS_REPLAY_INC_SYNC,
913ecd6cf80Smarks 	LOG_DS_REPLAY_FULL_SYNC,
914ecd6cf80Smarks 	LOG_DS_ROLLBACK,
915ecd6cf80Smarks 	LOG_DS_SNAPSHOT,
916e7437265Sahrens 	LOG_DS_UPGRADE,
917a9799022Sck 	LOG_DS_REFQUOTA,
918a9799022Sck 	LOG_DS_REFRESERV,
9193f9d6ad7SLin Ling 	LOG_POOL_SCAN_DONE,
920842727c2SChris Kirby 	LOG_DS_USER_HOLD,
921842727c2SChris Kirby 	LOG_DS_USER_RELEASE,
9221195e687SMark J Musante 	LOG_POOL_SPLIT,
923ecd6cf80Smarks 	LOG_END
924ecd6cf80Smarks } history_internal_events_t;
925ecd6cf80Smarks 
926fa9e4066Sahrens #ifdef	__cplusplus
927fa9e4066Sahrens }
928fa9e4066Sahrens #endif
929fa9e4066Sahrens 
930fa9e4066Sahrens #endif	/* _SYS_FS_ZFS_H */
931