xref: /illumos-gate/usr/src/uts/common/sys/fs/zfs.h (revision 91ebeef5)
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  */
21fa9e4066Sahrens /*
2239c23413Seschrock  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23fa9e4066Sahrens  * Use is subject to license terms.
24fa9e4066Sahrens  */
25fa9e4066Sahrens 
26fa9e4066Sahrens #ifndef	_SYS_FS_ZFS_H
27fa9e4066Sahrens #define	_SYS_FS_ZFS_H
28fa9e4066Sahrens 
29fa9e4066Sahrens #pragma ident	"%Z%%M%	%I%	%E% SMI"
30fa9e4066Sahrens 
31fa9e4066Sahrens #ifdef	__cplusplus
32fa9e4066Sahrens extern "C" {
33fa9e4066Sahrens #endif
34fa9e4066Sahrens 
35fa9e4066Sahrens /*
36fa9e4066Sahrens  * Types and constants shared between userland and the kernel.
37fa9e4066Sahrens  */
38fa9e4066Sahrens 
39fa9e4066Sahrens /*
40fa9e4066Sahrens  * Each dataset can be one of the following types.  These constants can be
41fa9e4066Sahrens  * combined into masks that can be passed to various functions.
42fa9e4066Sahrens  */
43fa9e4066Sahrens typedef enum {
44fa9e4066Sahrens 	ZFS_TYPE_FILESYSTEM	= 0x1,
45fa9e4066Sahrens 	ZFS_TYPE_SNAPSHOT	= 0x2,
46b1b8ab34Slling 	ZFS_TYPE_VOLUME		= 0x4,
47b1b8ab34Slling 	ZFS_TYPE_POOL		= 0x8
48fa9e4066Sahrens } zfs_type_t;
49fa9e4066Sahrens 
50fa9e4066Sahrens #define	ZFS_TYPE_ANY	\
51fa9e4066Sahrens 	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
52fa9e4066Sahrens 
53fa9e4066Sahrens /*
5466e2aaccSgw  * Properties are identified by these constants and must be added to the
553d7072f8Seschrock  * end of this list to ensure that external consumers are not affected
5666e2aaccSgw  * by the change. The property list also determines how 'zfs get' will
5766e2aaccSgw  * display them.  If you make any changes to this list, be sure to update
5866e2aaccSgw  * the property table in usr/src/common/zfs/zfs_prop.c.
59fa9e4066Sahrens  */
60fa9e4066Sahrens typedef enum {
6166e2aaccSgw 	ZFS_PROP_CONT = -2,
62fa9e4066Sahrens 	ZFS_PROP_INVAL = -1,
63fa9e4066Sahrens 	ZFS_PROP_TYPE,
64fa9e4066Sahrens 	ZFS_PROP_CREATION,
65fa9e4066Sahrens 	ZFS_PROP_USED,
66fa9e4066Sahrens 	ZFS_PROP_AVAILABLE,
67fa9e4066Sahrens 	ZFS_PROP_REFERENCED,
68fa9e4066Sahrens 	ZFS_PROP_COMPRESSRATIO,
69fa9e4066Sahrens 	ZFS_PROP_MOUNTED,
70fa9e4066Sahrens 	ZFS_PROP_ORIGIN,
71fa9e4066Sahrens 	ZFS_PROP_QUOTA,
72fa9e4066Sahrens 	ZFS_PROP_RESERVATION,
73fa9e4066Sahrens 	ZFS_PROP_VOLSIZE,
74fa9e4066Sahrens 	ZFS_PROP_VOLBLOCKSIZE,
75fa9e4066Sahrens 	ZFS_PROP_RECORDSIZE,
76fa9e4066Sahrens 	ZFS_PROP_MOUNTPOINT,
77fa9e4066Sahrens 	ZFS_PROP_SHARENFS,
78fa9e4066Sahrens 	ZFS_PROP_CHECKSUM,
79fa9e4066Sahrens 	ZFS_PROP_COMPRESSION,
80fa9e4066Sahrens 	ZFS_PROP_ATIME,
81fa9e4066Sahrens 	ZFS_PROP_DEVICES,
82fa9e4066Sahrens 	ZFS_PROP_EXEC,
83fa9e4066Sahrens 	ZFS_PROP_SETUID,
84fa9e4066Sahrens 	ZFS_PROP_READONLY,
85fa9e4066Sahrens 	ZFS_PROP_ZONED,
86fa9e4066Sahrens 	ZFS_PROP_SNAPDIR,
87fa9e4066Sahrens 	ZFS_PROP_ACLMODE,
88fa9e4066Sahrens 	ZFS_PROP_ACLINHERIT,
8966e2aaccSgw 	ZFS_PROP_CREATETXG,		/* not exposed to the user */
9066e2aaccSgw 	ZFS_PROP_NAME,			/* not exposed to the user */
91e9dbad6fSeschrock 	ZFS_PROP_CANMOUNT,
9266e2aaccSgw 	ZFS_PROP_SHAREISCSI,
9366e2aaccSgw 	ZFS_PROP_ISCSIOPTIONS,		/* not exposed to the user */
947b55fa8eSck 	ZFS_PROP_XATTR,
95d0ad202dSahrens 	ZFS_PROP_NUMCLONES,		/* not exposed to the user */
96b1b8ab34Slling 	ZFS_PROP_COPIES,
973d7072f8Seschrock 	ZPOOL_PROP_BOOTFS,
983d7072f8Seschrock 	ZPOOL_PROP_AUTOREPLACE,
99ecd6cf80Smarks 	ZPOOL_PROP_DELEGATION,
100e7437265Sahrens 	ZFS_PROP_VERSION,
101*91ebeef5Sahrens 	ZPOOL_PROP_NAME,
102*91ebeef5Sahrens 	ZFS_NUM_PROPS
103fa9e4066Sahrens } zfs_prop_t;
104fa9e4066Sahrens 
105b1b8ab34Slling typedef zfs_prop_t zpool_prop_t;
106b1b8ab34Slling 
1073d7072f8Seschrock #define	ZPOOL_PROP_CONT		ZFS_PROP_CONT
1083d7072f8Seschrock #define	ZPOOL_PROP_INVAL	ZFS_PROP_INVAL
1093d7072f8Seschrock 
1107f7322feSeschrock #define	ZFS_PROP_VALUE		"value"
1117f7322feSeschrock #define	ZFS_PROP_SOURCE		"source"
1127f7322feSeschrock 
113b1b8ab34Slling typedef enum {
114b1b8ab34Slling 	ZFS_SRC_NONE = 0x1,
115b1b8ab34Slling 	ZFS_SRC_DEFAULT = 0x2,
116b1b8ab34Slling 	ZFS_SRC_TEMPORARY = 0x4,
117b1b8ab34Slling 	ZFS_SRC_LOCAL = 0x8,
118b1b8ab34Slling 	ZFS_SRC_INHERITED = 0x10
119b1b8ab34Slling } zfs_source_t;
120b1b8ab34Slling 
121b1b8ab34Slling #define	ZFS_SRC_ALL	0x1f
122b1b8ab34Slling 
123ecd6cf80Smarks typedef enum {
124ecd6cf80Smarks 	ZFS_DELEG_WHO_UNKNOWN = 0,
125ecd6cf80Smarks 	ZFS_DELEG_USER = 'u',
126ecd6cf80Smarks 	ZFS_DELEG_USER_SETS = 'U',
127ecd6cf80Smarks 	ZFS_DELEG_GROUP = 'g',
128ecd6cf80Smarks 	ZFS_DELEG_GROUP_SETS = 'G',
129ecd6cf80Smarks 	ZFS_DELEG_EVERYONE = 'e',
130ecd6cf80Smarks 	ZFS_DELEG_EVERYONE_SETS = 'E',
131ecd6cf80Smarks 	ZFS_DELEG_CREATE = 'c',
132ecd6cf80Smarks 	ZFS_DELEG_CREATE_SETS = 'C',
133ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET = 's',
134ecd6cf80Smarks 	ZFS_DELEG_NAMED_SET_SETS = 'S'
135ecd6cf80Smarks } zfs_deleg_who_type_t;
136ecd6cf80Smarks 
137ecd6cf80Smarks typedef enum {
138ecd6cf80Smarks 	ZFS_DELEG_NONE = 0,
139ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCAL = 1,
140ecd6cf80Smarks 	ZFS_DELEG_PERM_DESCENDENT = 2,
141ecd6cf80Smarks 	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
142ecd6cf80Smarks 	ZFS_DELEG_PERM_CREATE = 4
143ecd6cf80Smarks } zfs_deleg_inherit_t;
144ecd6cf80Smarks 
145ecd6cf80Smarks #define	ZFS_DELEG_PERM_UID	"uid"
146ecd6cf80Smarks #define	ZFS_DELEG_PERM_GID	"gid"
147ecd6cf80Smarks #define	ZFS_DELEG_PERM_GROUPS	"groups"
148ecd6cf80Smarks 
149fa9e4066Sahrens /*
150fa9e4066Sahrens  * The following functions are shared between libzfs and the kernel.
151fa9e4066Sahrens  */
152fa9e4066Sahrens zfs_prop_t zfs_name_to_prop(const char *);
153b1b8ab34Slling zpool_prop_t zpool_name_to_prop(const char *);
154e9dbad6fSeschrock boolean_t zfs_prop_user(const char *);
155fa9e4066Sahrens int zfs_prop_readonly(zfs_prop_t);
1567f7322feSeschrock const char *zfs_prop_default_string(zfs_prop_t);
157e9dbad6fSeschrock const char *zfs_prop_to_name(zfs_prop_t);
1583d7072f8Seschrock const char *zpool_prop_to_name(zpool_prop_t);
159fa9e4066Sahrens uint64_t zfs_prop_default_numeric(zfs_prop_t);
160e9dbad6fSeschrock int zfs_prop_inheritable(zfs_prop_t);
161acd76fe5Seschrock int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
162acd76fe5Seschrock int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
1633d7072f8Seschrock uint64_t zpool_prop_default_numeric(zpool_prop_t);
16499653d4eSeschrock 
16566e2aaccSgw /*
16666e2aaccSgw  * Property Iterator
16766e2aaccSgw  */
16866e2aaccSgw typedef zfs_prop_t (*zfs_prop_f)(zfs_prop_t, void *);
1693d7072f8Seschrock typedef zpool_prop_t (*zpool_prop_f)(zpool_prop_t, void *);
170*91ebeef5Sahrens extern zfs_prop_t zfs_prop_iter(zfs_prop_f, void *);
171*91ebeef5Sahrens extern zfs_prop_t zfs_prop_iter_ordered(zfs_prop_f, void *);
172*91ebeef5Sahrens extern zpool_prop_t zpool_prop_iter(zpool_prop_f, void *);
17366e2aaccSgw 
174eaca9bbdSeschrock /*
17599653d4eSeschrock  * On-disk version number.
176eaca9bbdSeschrock  */
177e7437265Sahrens #define	SPA_VERSION_1			1ULL
178e7437265Sahrens #define	SPA_VERSION_2			2ULL
179e7437265Sahrens #define	SPA_VERSION_3			3ULL
180e7437265Sahrens #define	SPA_VERSION_4			4ULL
181e7437265Sahrens #define	SPA_VERSION_5			5ULL
182e7437265Sahrens #define	SPA_VERSION_6			6ULL
183e7437265Sahrens #define	SPA_VERSION_7			7ULL
184e7437265Sahrens #define	SPA_VERSION_8			8ULL
185b1b8ab34Slling /*
186e7437265Sahrens  * When bumping up SPA_VERSION, make sure GRUB ZFS understand the on-disk
187b1b8ab34Slling  * format change. Go to usr/src/grub/grub-0.95/stage2/{zfs-include/, fsys_zfs*},
188b1b8ab34Slling  * and do the appropriate changes.
189b1b8ab34Slling  */
190e7437265Sahrens #define	SPA_VERSION			SPA_VERSION_8
191e7437265Sahrens #define	SPA_VERSION_STRING		"8"
19244cd46caSbillm 
19344cd46caSbillm /*
194e7437265Sahrens  * Symbolic names for the changes that caused a SPA_VERSION switch.
19544cd46caSbillm  * Used in the code when checking for presence or absence of a feature.
19644cd46caSbillm  * Feel free to define multiple symbolic names for each version if there
19744cd46caSbillm  * were multiple changes to on-disk structures during that version.
19844cd46caSbillm  *
199e7437265Sahrens  * NOTE: When checking the current SPA_VERSION in your code, be sure
20044cd46caSbillm  *       to use spa_version() since it reports the version of the
20144cd46caSbillm  *       last synced uberblock.  Checking the in-flight version can
20244cd46caSbillm  *       be dangerous in some cases.
20344cd46caSbillm  */
204e7437265Sahrens #define	SPA_VERSION_INITIAL		SPA_VERSION_1
205e7437265Sahrens #define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
206e7437265Sahrens #define	SPA_VERSION_SPARES		SPA_VERSION_3
207e7437265Sahrens #define	SPA_VERSION_RAID6		SPA_VERSION_3
208e7437265Sahrens #define	SPA_VERSION_BPLIST_ACCOUNT	SPA_VERSION_3
209e7437265Sahrens #define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
210e7437265Sahrens #define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
211e7437265Sahrens #define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
212e7437265Sahrens #define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
213e7437265Sahrens #define	SPA_VERSION_BOOTFS		SPA_VERSION_6
214e7437265Sahrens #define	ZFS_VERSION_SLOGS		SPA_VERSION_7
215e7437265Sahrens #define	ZFS_VERSION_DELEGATED_PERMS	SPA_VERSION_8
216e7437265Sahrens 
217e7437265Sahrens /*
218e7437265Sahrens  * ZPL version - rev'd whenever an incompatible on-disk format change
219e7437265Sahrens  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
220e7437265Sahrens  * also update the version_table[] and help message in zfs_prop.c.
221e7437265Sahrens  *
222e7437265Sahrens  * When changing, be sure to teach GRUB how to read the new format!
223e7437265Sahrens  * See usr/src/grub/grub-0.95/stage2/{zfs-include/,fsys_zfs*}
224e7437265Sahrens  */
225e7437265Sahrens #define	ZPL_VERSION_1			1ULL
226e7437265Sahrens #define	ZPL_VERSION_2			2ULL
227e7437265Sahrens #define	ZPL_VERSION			ZPL_VERSION_2
228e7437265Sahrens #define	ZPL_VERSION_STRING		"2"
229e7437265Sahrens 
230e7437265Sahrens #define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
231e7437265Sahrens #define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
232eaca9bbdSeschrock 
233fa9e4066Sahrens /*
234fa9e4066Sahrens  * The following are configuration names used in the nvlist describing a pool's
235fa9e4066Sahrens  * configuration.
236fa9e4066Sahrens  */
237fa9e4066Sahrens #define	ZPOOL_CONFIG_VERSION		"version"
238fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_NAME		"name"
239fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_STATE		"state"
240fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_TXG		"txg"
241fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
242fa9e4066Sahrens #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
243fa9e4066Sahrens #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
244fa9e4066Sahrens #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
245fa9e4066Sahrens #define	ZPOOL_CONFIG_TYPE		"type"
246fa9e4066Sahrens #define	ZPOOL_CONFIG_CHILDREN		"children"
247fa9e4066Sahrens #define	ZPOOL_CONFIG_ID			"id"
248fa9e4066Sahrens #define	ZPOOL_CONFIG_GUID		"guid"
249fa9e4066Sahrens #define	ZPOOL_CONFIG_PATH		"path"
250fa9e4066Sahrens #define	ZPOOL_CONFIG_DEVID		"devid"
251fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
252fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
253fa9e4066Sahrens #define	ZPOOL_CONFIG_ASHIFT		"ashift"
254fa9e4066Sahrens #define	ZPOOL_CONFIG_ASIZE		"asize"
255fa9e4066Sahrens #define	ZPOOL_CONFIG_DTL		"DTL"
256fa9e4066Sahrens #define	ZPOOL_CONFIG_STATS		"stats"
257afefbcddSeschrock #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
258ea8dc4b6Seschrock #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
259ea8dc4b6Seschrock #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
26099653d4eSeschrock #define	ZPOOL_CONFIG_SPARES		"spares"
26199653d4eSeschrock #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
26299653d4eSeschrock #define	ZPOOL_CONFIG_NPARITY		"nparity"
26395173954Sek #define	ZPOOL_CONFIG_HOSTID		"hostid"
26495173954Sek #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
26595173954Sek #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp" /* not stored on disk */
2663d7072f8Seschrock #define	ZPOOL_CONFIG_UNSPARE		"unspare"
2673d7072f8Seschrock #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
2688654d025Sperrin #define	ZPOOL_CONFIG_IS_LOG		"is_log"
2693d7072f8Seschrock /*
2703d7072f8Seschrock  * The persistent vdev state is stored as separate values rather than a single
2713d7072f8Seschrock  * 'vdev_state' entry.  This is because a device can be in multiple states, such
2723d7072f8Seschrock  * as offline and degraded.
2733d7072f8Seschrock  */
2743d7072f8Seschrock #define	ZPOOL_CONFIG_OFFLINE		"offline"
2753d7072f8Seschrock #define	ZPOOL_CONFIG_FAULTED		"faulted"
2763d7072f8Seschrock #define	ZPOOL_CONFIG_DEGRADED		"degraded"
2773d7072f8Seschrock #define	ZPOOL_CONFIG_REMOVED		"removed"
278fa9e4066Sahrens 
279fa9e4066Sahrens #define	VDEV_TYPE_ROOT			"root"
280fa9e4066Sahrens #define	VDEV_TYPE_MIRROR		"mirror"
281fa9e4066Sahrens #define	VDEV_TYPE_REPLACING		"replacing"
282fa9e4066Sahrens #define	VDEV_TYPE_RAIDZ			"raidz"
283fa9e4066Sahrens #define	VDEV_TYPE_DISK			"disk"
284fa9e4066Sahrens #define	VDEV_TYPE_FILE			"file"
285fa9e4066Sahrens #define	VDEV_TYPE_MISSING		"missing"
28699653d4eSeschrock #define	VDEV_TYPE_SPARE			"spare"
2878654d025Sperrin #define	VDEV_TYPE_LOG			"log"
288fa9e4066Sahrens 
289fa9e4066Sahrens /*
290fa9e4066Sahrens  * This is needed in userland to report the minimum necessary device size.
291fa9e4066Sahrens  */
292fa9e4066Sahrens #define	SPA_MINDEVSIZE		(64ULL << 20)
293fa9e4066Sahrens 
294fa9e4066Sahrens /*
295fa9e4066Sahrens  * The location of the pool configuration repository, shared between kernel and
296fa9e4066Sahrens  * userland.
297fa9e4066Sahrens  */
298fa9e4066Sahrens #define	ZPOOL_CACHE_DIR		"/etc/zfs"
299fa9e4066Sahrens #define	ZPOOL_CACHE_FILE	"zpool.cache"
300fa9e4066Sahrens #define	ZPOOL_CACHE_TMP		".zpool.cache"
301fa9e4066Sahrens 
302fa9e4066Sahrens #define	ZPOOL_CACHE		ZPOOL_CACHE_DIR "/" ZPOOL_CACHE_FILE
303fa9e4066Sahrens 
304fa9e4066Sahrens /*
305fa9e4066Sahrens  * vdev states are ordered from least to most healthy.
306fa9e4066Sahrens  * A vdev that's CANT_OPEN or below is considered unusable.
307fa9e4066Sahrens  */
308fa9e4066Sahrens typedef enum vdev_state {
309fa9e4066Sahrens 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
310fa9e4066Sahrens 	VDEV_STATE_CLOSED,	/* Not currently open			*/
311fa9e4066Sahrens 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
3123d7072f8Seschrock 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
313fa9e4066Sahrens 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
3143d7072f8Seschrock 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
315fa9e4066Sahrens 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
316fa9e4066Sahrens 	VDEV_STATE_HEALTHY	/* Presumed good			*/
317fa9e4066Sahrens } vdev_state_t;
318fa9e4066Sahrens 
3193d7072f8Seschrock #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
3203d7072f8Seschrock 
321fa9e4066Sahrens /*
322fa9e4066Sahrens  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
323fa9e4066Sahrens  * of the vdev stats structure uses these constants to distinguish why.
324fa9e4066Sahrens  */
325fa9e4066Sahrens typedef enum vdev_aux {
326fa9e4066Sahrens 	VDEV_AUX_NONE,		/* no error				*/
327fa9e4066Sahrens 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
328fa9e4066Sahrens 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
329fa9e4066Sahrens 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
330fa9e4066Sahrens 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
331fa9e4066Sahrens 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
332eaca9bbdSeschrock 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
333eaca9bbdSeschrock 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
33499653d4eSeschrock 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
3353d7072f8Seschrock 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
3363d7072f8Seschrock 	VDEV_AUX_ERR_EXCEEDED	/* too many errors			*/
337fa9e4066Sahrens } vdev_aux_t;
338fa9e4066Sahrens 
339fa9e4066Sahrens /*
34046a2abf2Seschrock  * pool state.  The following states are written to disk as part of the normal
34199653d4eSeschrock  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE.  The remaining states are
34246a2abf2Seschrock  * software abstractions used at various levels to communicate pool state.
343fa9e4066Sahrens  */
344fa9e4066Sahrens typedef enum pool_state {
345fa9e4066Sahrens 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
346fa9e4066Sahrens 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
347fa9e4066Sahrens 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
34899653d4eSeschrock 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
349fa9e4066Sahrens 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
35046a2abf2Seschrock 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
35146a2abf2Seschrock 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
352fa9e4066Sahrens } pool_state_t;
353fa9e4066Sahrens 
354fa9e4066Sahrens /*
355fa9e4066Sahrens  * Scrub types.
356fa9e4066Sahrens  */
357fa9e4066Sahrens typedef enum pool_scrub_type {
358fa9e4066Sahrens 	POOL_SCRUB_NONE,
359fa9e4066Sahrens 	POOL_SCRUB_RESILVER,
360fa9e4066Sahrens 	POOL_SCRUB_EVERYTHING,
361fa9e4066Sahrens 	POOL_SCRUB_TYPES
362fa9e4066Sahrens } pool_scrub_type_t;
363fa9e4066Sahrens 
364fa9e4066Sahrens /*
365fa9e4066Sahrens  * ZIO types.  Needed to interpret vdev statistics below.
366fa9e4066Sahrens  */
367fa9e4066Sahrens typedef enum zio_type {
368fa9e4066Sahrens 	ZIO_TYPE_NULL = 0,
369fa9e4066Sahrens 	ZIO_TYPE_READ,
370fa9e4066Sahrens 	ZIO_TYPE_WRITE,
371fa9e4066Sahrens 	ZIO_TYPE_FREE,
372fa9e4066Sahrens 	ZIO_TYPE_CLAIM,
373fa9e4066Sahrens 	ZIO_TYPE_IOCTL,
374fa9e4066Sahrens 	ZIO_TYPES
375fa9e4066Sahrens } zio_type_t;
376fa9e4066Sahrens 
377fa9e4066Sahrens /*
378fa9e4066Sahrens  * Vdev statistics.  Note: all fields should be 64-bit because this
379fa9e4066Sahrens  * is passed between kernel and userland as an nvlist uint64 array.
380fa9e4066Sahrens  */
381fa9e4066Sahrens typedef struct vdev_stat {
382fa9e4066Sahrens 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
383fa9e4066Sahrens 	uint64_t	vs_state;		/* vdev state		*/
384fa9e4066Sahrens 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
385fa9e4066Sahrens 	uint64_t	vs_alloc;		/* space allocated	*/
386fa9e4066Sahrens 	uint64_t	vs_space;		/* total capacity	*/
38799653d4eSeschrock 	uint64_t	vs_dspace;		/* deflated capacity	*/
3882a79c5feSlling 	uint64_t	vs_rsize;		/* replaceable dev size */
389fa9e4066Sahrens 	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
390fa9e4066Sahrens 	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
391fa9e4066Sahrens 	uint64_t	vs_read_errors;		/* read errors		*/
392fa9e4066Sahrens 	uint64_t	vs_write_errors;	/* write errors		*/
393fa9e4066Sahrens 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
394fa9e4066Sahrens 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
395fa9e4066Sahrens 	uint64_t	vs_scrub_type;		/* pool_scrub_type_t	*/
396fa9e4066Sahrens 	uint64_t	vs_scrub_complete;	/* completed?		*/
397fa9e4066Sahrens 	uint64_t	vs_scrub_examined;	/* bytes examined; top	*/
398fa9e4066Sahrens 	uint64_t	vs_scrub_repaired;	/* bytes repaired; leaf	*/
399fa9e4066Sahrens 	uint64_t	vs_scrub_errors;	/* errors during scrub	*/
400fa9e4066Sahrens 	uint64_t	vs_scrub_start;		/* UTC scrub start time	*/
401fa9e4066Sahrens 	uint64_t	vs_scrub_end;		/* UTC scrub end time	*/
402fa9e4066Sahrens } vdev_stat_t;
403fa9e4066Sahrens 
404fa9e4066Sahrens #define	ZFS_DRIVER	"zfs"
405fa9e4066Sahrens #define	ZFS_DEV		"/dev/zfs"
406fa9e4066Sahrens 
407fa9e4066Sahrens /*
408fa9e4066Sahrens  * zvol paths.  Irritatingly, the devfsadm interfaces want all these
409fa9e4066Sahrens  * paths without the /dev prefix, but for some things, we want the
410fa9e4066Sahrens  * /dev prefix.  Below are the names without /dev.
411fa9e4066Sahrens  */
412fa9e4066Sahrens #define	ZVOL_DEV_DIR	"zvol/dsk"
413fa9e4066Sahrens #define	ZVOL_RDEV_DIR	"zvol/rdsk"
414fa9e4066Sahrens 
415fa9e4066Sahrens /*
416fa9e4066Sahrens  * And here are the things we need with /dev, etc. in front of them.
417fa9e4066Sahrens  */
418fa9e4066Sahrens #define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zvol@0:"
419fa9e4066Sahrens #define	ZVOL_FULL_DEV_DIR	"/dev/" ZVOL_DEV_DIR
420fa9e4066Sahrens 
421fa9e4066Sahrens #define	ZVOL_PROP_NAME		"name"
422fa9e4066Sahrens 
423fa9e4066Sahrens /*
424fa9e4066Sahrens  * /dev/zfs ioctl numbers.
425fa9e4066Sahrens  */
426fa9e4066Sahrens #define	ZFS_IOC		('Z' << 8)
427fa9e4066Sahrens 
428fa9e4066Sahrens typedef enum zfs_ioc {
429fa9e4066Sahrens 	ZFS_IOC_POOL_CREATE = ZFS_IOC,
430fa9e4066Sahrens 	ZFS_IOC_POOL_DESTROY,
431fa9e4066Sahrens 	ZFS_IOC_POOL_IMPORT,
432fa9e4066Sahrens 	ZFS_IOC_POOL_EXPORT,
433fa9e4066Sahrens 	ZFS_IOC_POOL_CONFIGS,
434fa9e4066Sahrens 	ZFS_IOC_POOL_STATS,
435fa9e4066Sahrens 	ZFS_IOC_POOL_TRYIMPORT,
436fa9e4066Sahrens 	ZFS_IOC_POOL_SCRUB,
437fa9e4066Sahrens 	ZFS_IOC_POOL_FREEZE,
438eaca9bbdSeschrock 	ZFS_IOC_POOL_UPGRADE,
43906eeb2adSek 	ZFS_IOC_POOL_GET_HISTORY,
440fa9e4066Sahrens 	ZFS_IOC_VDEV_ADD,
441fa9e4066Sahrens 	ZFS_IOC_VDEV_REMOVE,
4423d7072f8Seschrock 	ZFS_IOC_VDEV_SET_STATE,
443fa9e4066Sahrens 	ZFS_IOC_VDEV_ATTACH,
444fa9e4066Sahrens 	ZFS_IOC_VDEV_DETACH,
445c67d9675Seschrock 	ZFS_IOC_VDEV_SETPATH,
446fa9e4066Sahrens 	ZFS_IOC_OBJSET_STATS,
447fa9e4066Sahrens 	ZFS_IOC_DATASET_LIST_NEXT,
448fa9e4066Sahrens 	ZFS_IOC_SNAPSHOT_LIST_NEXT,
449fa9e4066Sahrens 	ZFS_IOC_SET_PROP,
450fa9e4066Sahrens 	ZFS_IOC_CREATE_MINOR,
451fa9e4066Sahrens 	ZFS_IOC_REMOVE_MINOR,
452fa9e4066Sahrens 	ZFS_IOC_CREATE,
453fa9e4066Sahrens 	ZFS_IOC_DESTROY,
454fa9e4066Sahrens 	ZFS_IOC_ROLLBACK,
455fa9e4066Sahrens 	ZFS_IOC_RENAME,
456fa9e4066Sahrens 	ZFS_IOC_RECVBACKUP,
457ea8dc4b6Seschrock 	ZFS_IOC_SENDBACKUP,
458ea8dc4b6Seschrock 	ZFS_IOC_INJECT_FAULT,
459ea8dc4b6Seschrock 	ZFS_IOC_CLEAR_FAULT,
460ea8dc4b6Seschrock 	ZFS_IOC_INJECT_LIST_NEXT,
461ea8dc4b6Seschrock 	ZFS_IOC_ERROR_LOG,
462ea8dc4b6Seschrock 	ZFS_IOC_CLEAR,
4631d452cf5Sahrens 	ZFS_IOC_PROMOTE,
4641d452cf5Sahrens 	ZFS_IOC_DESTROY_SNAPS,
46555434c77Sek 	ZFS_IOC_SNAPSHOT,
46655434c77Sek 	ZFS_IOC_DSOBJ_TO_DSNAME,
467b1b8ab34Slling 	ZFS_IOC_OBJ_TO_PATH,
468b1b8ab34Slling 	ZFS_IOC_POOL_SET_PROPS,
469ecd6cf80Smarks 	ZFS_IOC_POOL_GET_PROPS,
470ecd6cf80Smarks 	ZFS_IOC_SET_FSACL,
471ecd6cf80Smarks 	ZFS_IOC_GET_FSACL,
472ecd6cf80Smarks 	ZFS_IOC_ISCSI_PERM_CHECK,
473ecd6cf80Smarks 	ZFS_IOC_SHARE
474fa9e4066Sahrens } zfs_ioc_t;
475fa9e4066Sahrens 
476ea8dc4b6Seschrock /*
477ea8dc4b6Seschrock  * Internal SPA load state.  Used by FMA diagnosis engine.
478ea8dc4b6Seschrock  */
479ea8dc4b6Seschrock typedef enum {
480ea8dc4b6Seschrock 	SPA_LOAD_NONE,		/* no load in progress */
481ea8dc4b6Seschrock 	SPA_LOAD_OPEN,		/* normal open */
482ea8dc4b6Seschrock 	SPA_LOAD_IMPORT,	/* import in progress */
483ea8dc4b6Seschrock 	SPA_LOAD_TRYIMPORT	/* tryimport in progress */
484ea8dc4b6Seschrock } spa_load_state_t;
485ea8dc4b6Seschrock 
486e9dbad6fSeschrock /*
487e9dbad6fSeschrock  * Bookmark name values.
488e9dbad6fSeschrock  */
48955434c77Sek #define	ZPOOL_ERR_LIST		"error list"
490e9dbad6fSeschrock #define	ZPOOL_ERR_DATASET	"dataset"
491e9dbad6fSeschrock #define	ZPOOL_ERR_OBJECT	"object"
492e9dbad6fSeschrock 
49306eeb2adSek #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
49406eeb2adSek 
49506eeb2adSek /*
49606eeb2adSek  * The following are names used in the nvlist describing
49706eeb2adSek  * the pool's history log.
49806eeb2adSek  */
49906eeb2adSek #define	ZPOOL_HIST_RECORD	"history record"
50006eeb2adSek #define	ZPOOL_HIST_TIME		"history time"
50106eeb2adSek #define	ZPOOL_HIST_CMD		"history command"
502ecd6cf80Smarks #define	ZPOOL_HIST_WHO		"history who"
503ecd6cf80Smarks #define	ZPOOL_HIST_ZONE		"history zone"
504ecd6cf80Smarks #define	ZPOOL_HIST_HOST		"history hostname"
505ecd6cf80Smarks #define	ZPOOL_HIST_TXG		"history txg"
506ecd6cf80Smarks #define	ZPOOL_HIST_INT_EVENT	"history internal event"
507ecd6cf80Smarks #define	ZPOOL_HIST_INT_STR	"history internal str"
50806eeb2adSek 
5093d7072f8Seschrock /*
5103d7072f8Seschrock  * Flags for ZFS_IOC_VDEV_SET_STATE
5113d7072f8Seschrock  */
5123d7072f8Seschrock #define	ZFS_ONLINE_CHECKREMOVE	0x1
5133d7072f8Seschrock #define	ZFS_ONLINE_UNSPARE	0x2
5143d7072f8Seschrock #define	ZFS_ONLINE_FORCEFAULT	0x4
5153d7072f8Seschrock #define	ZFS_OFFLINE_TEMPORARY	0x1
5163d7072f8Seschrock 
5173d7072f8Seschrock /*
5183d7072f8Seschrock  * Sysevent payload members.  ZFS will generate the following sysevents with the
5193d7072f8Seschrock  * given payloads:
5203d7072f8Seschrock  *
5213d7072f8Seschrock  *	ESC_ZFS_RESILVER_START
5223d7072f8Seschrock  *	ESC_ZFS_RESILVER_END
5233d7072f8Seschrock  *	ESC_ZFS_POOL_DESTROY
5243d7072f8Seschrock  *
5253d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
5263d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
5273d7072f8Seschrock  *
5283d7072f8Seschrock  *	ESC_ZFS_VDEV_REMOVE
5293d7072f8Seschrock  *	ESC_ZFS_VDEV_CLEAR
5303d7072f8Seschrock  *	ESC_ZFS_VDEV_CHECK
5313d7072f8Seschrock  *
5323d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
5333d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
5343d7072f8Seschrock  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
5353d7072f8Seschrock  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
5363d7072f8Seschrock  */
5373d7072f8Seschrock #define	ZFS_EV_POOL_NAME	"pool_name"
5383d7072f8Seschrock #define	ZFS_EV_POOL_GUID	"pool_guid"
5393d7072f8Seschrock #define	ZFS_EV_VDEV_PATH	"vdev_path"
5403d7072f8Seschrock #define	ZFS_EV_VDEV_GUID	"vdev_guid"
5413d7072f8Seschrock 
542ecd6cf80Smarks typedef enum history_internal_events {
543ecd6cf80Smarks 	LOG_NO_EVENT = 0,
544ecd6cf80Smarks 	LOG_POOL_CREATE,
545ecd6cf80Smarks 	LOG_POOL_VDEV_ADD,
546ecd6cf80Smarks 	LOG_POOL_REMOVE,
547ecd6cf80Smarks 	LOG_POOL_DESTROY,
548ecd6cf80Smarks 	LOG_POOL_EXPORT,
549ecd6cf80Smarks 	LOG_POOL_IMPORT,
550ecd6cf80Smarks 	LOG_POOL_VDEV_ATTACH,
551ecd6cf80Smarks 	LOG_POOL_VDEV_REPLACE,
552ecd6cf80Smarks 	LOG_POOL_VDEV_DETACH,
553ecd6cf80Smarks 	LOG_POOL_VDEV_ONLINE,
554ecd6cf80Smarks 	LOG_POOL_VDEV_OFFLINE,
555ecd6cf80Smarks 	LOG_POOL_UPGRADE,
556ecd6cf80Smarks 	LOG_POOL_CLEAR,
557ecd6cf80Smarks 	LOG_POOL_SCRUB,
558ecd6cf80Smarks 	LOG_POOL_PROPSET,
559ecd6cf80Smarks 	LOG_DS_CREATE,
560ecd6cf80Smarks 	LOG_DS_CLONE,
561ecd6cf80Smarks 	LOG_DS_DESTROY,
562ecd6cf80Smarks 	LOG_DS_DESTROY_BEGIN,
563ecd6cf80Smarks 	LOG_DS_INHERIT,
564ecd6cf80Smarks 	LOG_DS_PROPSET,
565ecd6cf80Smarks 	LOG_DS_QUOTA,
566ecd6cf80Smarks 	LOG_DS_PERM_UPDATE,
567ecd6cf80Smarks 	LOG_DS_PERM_REMOVE,
568ecd6cf80Smarks 	LOG_DS_PERM_WHO_REMOVE,
569ecd6cf80Smarks 	LOG_DS_PROMOTE,
570ecd6cf80Smarks 	LOG_DS_RECEIVE,
571ecd6cf80Smarks 	LOG_DS_RENAME,
572ecd6cf80Smarks 	LOG_DS_RESERVATION,
573ecd6cf80Smarks 	LOG_DS_REPLAY_INC_SYNC,
574ecd6cf80Smarks 	LOG_DS_REPLAY_FULL_SYNC,
575ecd6cf80Smarks 	LOG_DS_ROLLBACK,
576ecd6cf80Smarks 	LOG_DS_SNAPSHOT,
577e7437265Sahrens 	LOG_DS_UPGRADE,
578ecd6cf80Smarks 	LOG_END
579ecd6cf80Smarks } history_internal_events_t;
580ecd6cf80Smarks 
581fa9e4066Sahrens #ifdef	__cplusplus
582fa9e4066Sahrens }
583fa9e4066Sahrens #endif
584fa9e4066Sahrens 
585fa9e4066Sahrens #endif	/* _SYS_FS_ZFS_H */
586