xref: /illumos-gate/usr/src/uts/common/sys/fs/zfs.h (revision 3d7072f8bd27709dba14f6fe336f149d25d9e207)
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 #include <sys/types.h>
32fa9e4066Sahrens 
33fa9e4066Sahrens #ifdef	__cplusplus
34fa9e4066Sahrens extern "C" {
35fa9e4066Sahrens #endif
36fa9e4066Sahrens 
37fa9e4066Sahrens /*
38fa9e4066Sahrens  * Types and constants shared between userland and the kernel.
39fa9e4066Sahrens  */
40fa9e4066Sahrens 
41fa9e4066Sahrens /*
42fa9e4066Sahrens  * Each dataset can be one of the following types.  These constants can be
43fa9e4066Sahrens  * combined into masks that can be passed to various functions.
44fa9e4066Sahrens  */
45fa9e4066Sahrens typedef enum {
46fa9e4066Sahrens 	ZFS_TYPE_FILESYSTEM	= 0x1,
47fa9e4066Sahrens 	ZFS_TYPE_SNAPSHOT	= 0x2,
48b1b8ab34Slling 	ZFS_TYPE_VOLUME		= 0x4,
49b1b8ab34Slling 	ZFS_TYPE_POOL		= 0x8
50fa9e4066Sahrens } zfs_type_t;
51fa9e4066Sahrens 
52fa9e4066Sahrens #define	ZFS_TYPE_ANY	\
53fa9e4066Sahrens 	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
54fa9e4066Sahrens 
55fa9e4066Sahrens /*
5666e2aaccSgw  * Properties are identified by these constants and must be added to the
57*3d7072f8Seschrock  * end of this list to ensure that external consumers are not affected
5866e2aaccSgw  * by the change. The property list also determines how 'zfs get' will
5966e2aaccSgw  * display them.  If you make any changes to this list, be sure to update
6066e2aaccSgw  * the property table in usr/src/common/zfs/zfs_prop.c.
61fa9e4066Sahrens  */
62fa9e4066Sahrens typedef enum {
6366e2aaccSgw 	ZFS_PROP_CONT = -2,
64fa9e4066Sahrens 	ZFS_PROP_INVAL = -1,
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,
99*3d7072f8Seschrock 	ZPOOL_PROP_BOOTFS,
100*3d7072f8Seschrock 	ZPOOL_PROP_AUTOREPLACE,
101*3d7072f8Seschrock 	ZPOOL_PROP_NAME
102fa9e4066Sahrens } zfs_prop_t;
103fa9e4066Sahrens 
104b1b8ab34Slling typedef zfs_prop_t zpool_prop_t;
105b1b8ab34Slling 
106*3d7072f8Seschrock #define	ZPOOL_PROP_CONT		ZFS_PROP_CONT
107*3d7072f8Seschrock #define	ZPOOL_PROP_INVAL	ZFS_PROP_INVAL
108*3d7072f8Seschrock 
1097f7322feSeschrock #define	ZFS_PROP_VALUE		"value"
1107f7322feSeschrock #define	ZFS_PROP_SOURCE		"source"
1117f7322feSeschrock 
112b1b8ab34Slling typedef enum {
113b1b8ab34Slling 	ZFS_SRC_NONE = 0x1,
114b1b8ab34Slling 	ZFS_SRC_DEFAULT = 0x2,
115b1b8ab34Slling 	ZFS_SRC_TEMPORARY = 0x4,
116b1b8ab34Slling 	ZFS_SRC_LOCAL = 0x8,
117b1b8ab34Slling 	ZFS_SRC_INHERITED = 0x10
118b1b8ab34Slling } zfs_source_t;
119b1b8ab34Slling 
120b1b8ab34Slling #define	ZFS_SRC_ALL	0x1f
121b1b8ab34Slling 
122fa9e4066Sahrens /*
123fa9e4066Sahrens  * The following functions are shared between libzfs and the kernel.
124fa9e4066Sahrens  */
125fa9e4066Sahrens zfs_prop_t zfs_name_to_prop(const char *);
126b1b8ab34Slling zpool_prop_t zpool_name_to_prop(const char *);
127e9dbad6fSeschrock boolean_t zfs_prop_user(const char *);
128fa9e4066Sahrens int zfs_prop_readonly(zfs_prop_t);
1297f7322feSeschrock const char *zfs_prop_default_string(zfs_prop_t);
130e9dbad6fSeschrock const char *zfs_prop_to_name(zfs_prop_t);
131*3d7072f8Seschrock const char *zpool_prop_to_name(zpool_prop_t);
132fa9e4066Sahrens uint64_t zfs_prop_default_numeric(zfs_prop_t);
133e9dbad6fSeschrock int zfs_prop_inheritable(zfs_prop_t);
134acd76fe5Seschrock int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
135acd76fe5Seschrock int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
136*3d7072f8Seschrock uint64_t zpool_prop_default_numeric(zpool_prop_t);
13799653d4eSeschrock 
13866e2aaccSgw /*
13966e2aaccSgw  * Property Iterator
14066e2aaccSgw  */
14166e2aaccSgw typedef zfs_prop_t (*zfs_prop_f)(zfs_prop_t, void *);
142*3d7072f8Seschrock typedef zpool_prop_t (*zpool_prop_f)(zpool_prop_t, void *);
14366e2aaccSgw extern zfs_prop_t zfs_prop_iter(zfs_prop_f, void *, boolean_t);
144b1b8ab34Slling extern zpool_prop_t zpool_prop_iter(zpool_prop_f, void *, boolean_t);
14566e2aaccSgw 
146eaca9bbdSeschrock /*
14799653d4eSeschrock  * On-disk version number.
148eaca9bbdSeschrock  */
14944cd46caSbillm #define	ZFS_VERSION_1			1ULL
15044cd46caSbillm #define	ZFS_VERSION_2			2ULL
15199653d4eSeschrock #define	ZFS_VERSION_3			3ULL
152d7306b64Sek #define	ZFS_VERSION_4			4ULL
153c9431fa1Sahl #define	ZFS_VERSION_5			5ULL
154b1b8ab34Slling #define	ZFS_VERSION_6			6ULL
155b1b8ab34Slling /*
156b1b8ab34Slling  * When bumping up ZFS_VERSION, make sure GRUB ZFS understand the on-disk
157b1b8ab34Slling  * format change. Go to usr/src/grub/grub-0.95/stage2/{zfs-include/, fsys_zfs*},
158b1b8ab34Slling  * and do the appropriate changes.
159b1b8ab34Slling  */
160b1b8ab34Slling #define	ZFS_VERSION			ZFS_VERSION_6
161b1b8ab34Slling #define	ZFS_VERSION_STRING		"6"
16244cd46caSbillm 
16344cd46caSbillm /*
16444cd46caSbillm  * Symbolic names for the changes that caused a ZFS_VERSION switch.
16544cd46caSbillm  * Used in the code when checking for presence or absence of a feature.
16644cd46caSbillm  * Feel free to define multiple symbolic names for each version if there
16744cd46caSbillm  * were multiple changes to on-disk structures during that version.
16844cd46caSbillm  *
16944cd46caSbillm  * NOTE: When checking the current ZFS_VERSION in your code, be sure
17044cd46caSbillm  *       to use spa_version() since it reports the version of the
17144cd46caSbillm  *       last synced uberblock.  Checking the in-flight version can
17244cd46caSbillm  *       be dangerous in some cases.
17344cd46caSbillm  */
17444cd46caSbillm #define	ZFS_VERSION_INITIAL		ZFS_VERSION_1
17544cd46caSbillm #define	ZFS_VERSION_DITTO_BLOCKS	ZFS_VERSION_2
17699653d4eSeschrock #define	ZFS_VERSION_SPARES		ZFS_VERSION_3
17799653d4eSeschrock #define	ZFS_VERSION_RAID6		ZFS_VERSION_3
17899653d4eSeschrock #define	ZFS_VERSION_BPLIST_ACCOUNT	ZFS_VERSION_3
17999653d4eSeschrock #define	ZFS_VERSION_RAIDZ_DEFLATE	ZFS_VERSION_3
18099653d4eSeschrock #define	ZFS_VERSION_DNODE_BYTES		ZFS_VERSION_3
181d7306b64Sek #define	ZFS_VERSION_ZPOOL_HISTORY	ZFS_VERSION_4
182c9431fa1Sahl #define	ZFS_VERSION_GZIP_COMPRESSION	ZFS_VERSION_5
183b1b8ab34Slling #define	ZFS_VERSION_BOOTFS		ZFS_VERSION_6
184eaca9bbdSeschrock 
185fa9e4066Sahrens /*
186fa9e4066Sahrens  * The following are configuration names used in the nvlist describing a pool's
187fa9e4066Sahrens  * configuration.
188fa9e4066Sahrens  */
189fa9e4066Sahrens #define	ZPOOL_CONFIG_VERSION		"version"
190fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_NAME		"name"
191fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_STATE		"state"
192fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_TXG		"txg"
193fa9e4066Sahrens #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
194fa9e4066Sahrens #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
195fa9e4066Sahrens #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
196fa9e4066Sahrens #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
197fa9e4066Sahrens #define	ZPOOL_CONFIG_TYPE		"type"
198fa9e4066Sahrens #define	ZPOOL_CONFIG_CHILDREN		"children"
199fa9e4066Sahrens #define	ZPOOL_CONFIG_ID			"id"
200fa9e4066Sahrens #define	ZPOOL_CONFIG_GUID		"guid"
201fa9e4066Sahrens #define	ZPOOL_CONFIG_PATH		"path"
202fa9e4066Sahrens #define	ZPOOL_CONFIG_DEVID		"devid"
203fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
204fa9e4066Sahrens #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
205fa9e4066Sahrens #define	ZPOOL_CONFIG_ASHIFT		"ashift"
206fa9e4066Sahrens #define	ZPOOL_CONFIG_ASIZE		"asize"
207fa9e4066Sahrens #define	ZPOOL_CONFIG_DTL		"DTL"
208fa9e4066Sahrens #define	ZPOOL_CONFIG_STATS		"stats"
209afefbcddSeschrock #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
210ea8dc4b6Seschrock #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
211ea8dc4b6Seschrock #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
21299653d4eSeschrock #define	ZPOOL_CONFIG_SPARES		"spares"
21399653d4eSeschrock #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
21499653d4eSeschrock #define	ZPOOL_CONFIG_NPARITY		"nparity"
21595173954Sek #define	ZPOOL_CONFIG_HOSTID		"hostid"
21695173954Sek #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
21795173954Sek #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp" /* not stored on disk */
218*3d7072f8Seschrock #define	ZPOOL_CONFIG_UNSPARE		"unspare"
219*3d7072f8Seschrock #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
220*3d7072f8Seschrock /*
221*3d7072f8Seschrock  * The persistent vdev state is stored as separate values rather than a single
222*3d7072f8Seschrock  * 'vdev_state' entry.  This is because a device can be in multiple states, such
223*3d7072f8Seschrock  * as offline and degraded.
224*3d7072f8Seschrock  */
225*3d7072f8Seschrock #define	ZPOOL_CONFIG_OFFLINE		"offline"
226*3d7072f8Seschrock #define	ZPOOL_CONFIG_FAULTED		"faulted"
227*3d7072f8Seschrock #define	ZPOOL_CONFIG_DEGRADED		"degraded"
228*3d7072f8Seschrock #define	ZPOOL_CONFIG_REMOVED		"removed"
229fa9e4066Sahrens 
230fa9e4066Sahrens #define	VDEV_TYPE_ROOT			"root"
231fa9e4066Sahrens #define	VDEV_TYPE_MIRROR		"mirror"
232fa9e4066Sahrens #define	VDEV_TYPE_REPLACING		"replacing"
233fa9e4066Sahrens #define	VDEV_TYPE_RAIDZ			"raidz"
234fa9e4066Sahrens #define	VDEV_TYPE_DISK			"disk"
235fa9e4066Sahrens #define	VDEV_TYPE_FILE			"file"
236fa9e4066Sahrens #define	VDEV_TYPE_MISSING		"missing"
23799653d4eSeschrock #define	VDEV_TYPE_SPARE			"spare"
238fa9e4066Sahrens 
239fa9e4066Sahrens /*
240fa9e4066Sahrens  * This is needed in userland to report the minimum necessary device size.
241fa9e4066Sahrens  */
242fa9e4066Sahrens #define	SPA_MINDEVSIZE		(64ULL << 20)
243fa9e4066Sahrens 
244fa9e4066Sahrens /*
245fa9e4066Sahrens  * The location of the pool configuration repository, shared between kernel and
246fa9e4066Sahrens  * userland.
247fa9e4066Sahrens  */
248fa9e4066Sahrens #define	ZPOOL_CACHE_DIR		"/etc/zfs"
249fa9e4066Sahrens #define	ZPOOL_CACHE_FILE	"zpool.cache"
250fa9e4066Sahrens #define	ZPOOL_CACHE_TMP		".zpool.cache"
251fa9e4066Sahrens 
252fa9e4066Sahrens #define	ZPOOL_CACHE		ZPOOL_CACHE_DIR "/" ZPOOL_CACHE_FILE
253fa9e4066Sahrens 
254fa9e4066Sahrens /*
255fa9e4066Sahrens  * vdev states are ordered from least to most healthy.
256fa9e4066Sahrens  * A vdev that's CANT_OPEN or below is considered unusable.
257fa9e4066Sahrens  */
258fa9e4066Sahrens typedef enum vdev_state {
259fa9e4066Sahrens 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
260fa9e4066Sahrens 	VDEV_STATE_CLOSED,	/* Not currently open			*/
261fa9e4066Sahrens 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
262*3d7072f8Seschrock 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
263fa9e4066Sahrens 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
264*3d7072f8Seschrock 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
265fa9e4066Sahrens 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
266fa9e4066Sahrens 	VDEV_STATE_HEALTHY	/* Presumed good			*/
267fa9e4066Sahrens } vdev_state_t;
268fa9e4066Sahrens 
269*3d7072f8Seschrock #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
270*3d7072f8Seschrock 
271fa9e4066Sahrens /*
272fa9e4066Sahrens  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
273fa9e4066Sahrens  * of the vdev stats structure uses these constants to distinguish why.
274fa9e4066Sahrens  */
275fa9e4066Sahrens typedef enum vdev_aux {
276fa9e4066Sahrens 	VDEV_AUX_NONE,		/* no error				*/
277fa9e4066Sahrens 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
278fa9e4066Sahrens 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
279fa9e4066Sahrens 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
280fa9e4066Sahrens 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
281fa9e4066Sahrens 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
282eaca9bbdSeschrock 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
283eaca9bbdSeschrock 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
28499653d4eSeschrock 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
285*3d7072f8Seschrock 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
286*3d7072f8Seschrock 	VDEV_AUX_ERR_EXCEEDED	/* too many errors			*/
287fa9e4066Sahrens } vdev_aux_t;
288fa9e4066Sahrens 
289fa9e4066Sahrens /*
29046a2abf2Seschrock  * pool state.  The following states are written to disk as part of the normal
29199653d4eSeschrock  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE.  The remaining states are
29246a2abf2Seschrock  * software abstractions used at various levels to communicate pool state.
293fa9e4066Sahrens  */
294fa9e4066Sahrens typedef enum pool_state {
295fa9e4066Sahrens 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
296fa9e4066Sahrens 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
297fa9e4066Sahrens 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
29899653d4eSeschrock 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
299fa9e4066Sahrens 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
30046a2abf2Seschrock 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
30146a2abf2Seschrock 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
302fa9e4066Sahrens } pool_state_t;
303fa9e4066Sahrens 
304fa9e4066Sahrens /*
305fa9e4066Sahrens  * Scrub types.
306fa9e4066Sahrens  */
307fa9e4066Sahrens typedef enum pool_scrub_type {
308fa9e4066Sahrens 	POOL_SCRUB_NONE,
309fa9e4066Sahrens 	POOL_SCRUB_RESILVER,
310fa9e4066Sahrens 	POOL_SCRUB_EVERYTHING,
311fa9e4066Sahrens 	POOL_SCRUB_TYPES
312fa9e4066Sahrens } pool_scrub_type_t;
313fa9e4066Sahrens 
314fa9e4066Sahrens /*
315fa9e4066Sahrens  * ZIO types.  Needed to interpret vdev statistics below.
316fa9e4066Sahrens  */
317fa9e4066Sahrens typedef enum zio_type {
318fa9e4066Sahrens 	ZIO_TYPE_NULL = 0,
319fa9e4066Sahrens 	ZIO_TYPE_READ,
320fa9e4066Sahrens 	ZIO_TYPE_WRITE,
321fa9e4066Sahrens 	ZIO_TYPE_FREE,
322fa9e4066Sahrens 	ZIO_TYPE_CLAIM,
323fa9e4066Sahrens 	ZIO_TYPE_IOCTL,
324fa9e4066Sahrens 	ZIO_TYPES
325fa9e4066Sahrens } zio_type_t;
326fa9e4066Sahrens 
327fa9e4066Sahrens /*
328fa9e4066Sahrens  * Vdev statistics.  Note: all fields should be 64-bit because this
329fa9e4066Sahrens  * is passed between kernel and userland as an nvlist uint64 array.
330fa9e4066Sahrens  */
331fa9e4066Sahrens typedef struct vdev_stat {
332fa9e4066Sahrens 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
333fa9e4066Sahrens 	uint64_t	vs_state;		/* vdev state		*/
334fa9e4066Sahrens 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
335fa9e4066Sahrens 	uint64_t	vs_alloc;		/* space allocated	*/
336fa9e4066Sahrens 	uint64_t	vs_space;		/* total capacity	*/
33799653d4eSeschrock 	uint64_t	vs_dspace;		/* deflated capacity	*/
3382a79c5feSlling 	uint64_t	vs_rsize;		/* replaceable dev size */
339fa9e4066Sahrens 	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
340fa9e4066Sahrens 	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
341fa9e4066Sahrens 	uint64_t	vs_read_errors;		/* read errors		*/
342fa9e4066Sahrens 	uint64_t	vs_write_errors;	/* write errors		*/
343fa9e4066Sahrens 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
344fa9e4066Sahrens 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
345fa9e4066Sahrens 	uint64_t	vs_scrub_type;		/* pool_scrub_type_t	*/
346fa9e4066Sahrens 	uint64_t	vs_scrub_complete;	/* completed?		*/
347fa9e4066Sahrens 	uint64_t	vs_scrub_examined;	/* bytes examined; top	*/
348fa9e4066Sahrens 	uint64_t	vs_scrub_repaired;	/* bytes repaired; leaf	*/
349fa9e4066Sahrens 	uint64_t	vs_scrub_errors;	/* errors during scrub	*/
350fa9e4066Sahrens 	uint64_t	vs_scrub_start;		/* UTC scrub start time	*/
351fa9e4066Sahrens 	uint64_t	vs_scrub_end;		/* UTC scrub end time	*/
352fa9e4066Sahrens } vdev_stat_t;
353fa9e4066Sahrens 
354fa9e4066Sahrens #define	ZFS_DRIVER	"zfs"
355fa9e4066Sahrens #define	ZFS_DEV		"/dev/zfs"
356fa9e4066Sahrens 
357fa9e4066Sahrens /*
358fa9e4066Sahrens  * zvol paths.  Irritatingly, the devfsadm interfaces want all these
359fa9e4066Sahrens  * paths without the /dev prefix, but for some things, we want the
360fa9e4066Sahrens  * /dev prefix.  Below are the names without /dev.
361fa9e4066Sahrens  */
362fa9e4066Sahrens #define	ZVOL_DEV_DIR	"zvol/dsk"
363fa9e4066Sahrens #define	ZVOL_RDEV_DIR	"zvol/rdsk"
364fa9e4066Sahrens 
365fa9e4066Sahrens /*
366fa9e4066Sahrens  * And here are the things we need with /dev, etc. in front of them.
367fa9e4066Sahrens  */
368fa9e4066Sahrens #define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zvol@0:"
369fa9e4066Sahrens #define	ZVOL_FULL_DEV_DIR	"/dev/" ZVOL_DEV_DIR
370fa9e4066Sahrens 
371fa9e4066Sahrens #define	ZVOL_PROP_NAME		"name"
372fa9e4066Sahrens 
373fa9e4066Sahrens /*
374fa9e4066Sahrens  * /dev/zfs ioctl numbers.
375fa9e4066Sahrens  */
376fa9e4066Sahrens #define	ZFS_IOC		('Z' << 8)
377fa9e4066Sahrens 
378fa9e4066Sahrens typedef enum zfs_ioc {
379fa9e4066Sahrens 	ZFS_IOC_POOL_CREATE = ZFS_IOC,
380fa9e4066Sahrens 	ZFS_IOC_POOL_DESTROY,
381fa9e4066Sahrens 	ZFS_IOC_POOL_IMPORT,
382fa9e4066Sahrens 	ZFS_IOC_POOL_EXPORT,
383fa9e4066Sahrens 	ZFS_IOC_POOL_CONFIGS,
384fa9e4066Sahrens 	ZFS_IOC_POOL_STATS,
385fa9e4066Sahrens 	ZFS_IOC_POOL_TRYIMPORT,
386fa9e4066Sahrens 	ZFS_IOC_POOL_SCRUB,
387fa9e4066Sahrens 	ZFS_IOC_POOL_FREEZE,
388eaca9bbdSeschrock 	ZFS_IOC_POOL_UPGRADE,
38906eeb2adSek 	ZFS_IOC_POOL_GET_HISTORY,
39006eeb2adSek 	ZFS_IOC_POOL_LOG_HISTORY,
391fa9e4066Sahrens 	ZFS_IOC_VDEV_ADD,
392fa9e4066Sahrens 	ZFS_IOC_VDEV_REMOVE,
393*3d7072f8Seschrock 	ZFS_IOC_VDEV_SET_STATE,
394fa9e4066Sahrens 	ZFS_IOC_VDEV_ATTACH,
395fa9e4066Sahrens 	ZFS_IOC_VDEV_DETACH,
396c67d9675Seschrock 	ZFS_IOC_VDEV_SETPATH,
397fa9e4066Sahrens 	ZFS_IOC_OBJSET_STATS,
398fa9e4066Sahrens 	ZFS_IOC_DATASET_LIST_NEXT,
399fa9e4066Sahrens 	ZFS_IOC_SNAPSHOT_LIST_NEXT,
400fa9e4066Sahrens 	ZFS_IOC_SET_PROP,
401fa9e4066Sahrens 	ZFS_IOC_CREATE_MINOR,
402fa9e4066Sahrens 	ZFS_IOC_REMOVE_MINOR,
403fa9e4066Sahrens 	ZFS_IOC_CREATE,
404fa9e4066Sahrens 	ZFS_IOC_DESTROY,
405fa9e4066Sahrens 	ZFS_IOC_ROLLBACK,
406fa9e4066Sahrens 	ZFS_IOC_RENAME,
407fa9e4066Sahrens 	ZFS_IOC_RECVBACKUP,
408ea8dc4b6Seschrock 	ZFS_IOC_SENDBACKUP,
409ea8dc4b6Seschrock 	ZFS_IOC_INJECT_FAULT,
410ea8dc4b6Seschrock 	ZFS_IOC_CLEAR_FAULT,
411ea8dc4b6Seschrock 	ZFS_IOC_INJECT_LIST_NEXT,
412ea8dc4b6Seschrock 	ZFS_IOC_ERROR_LOG,
413ea8dc4b6Seschrock 	ZFS_IOC_CLEAR,
4141d452cf5Sahrens 	ZFS_IOC_PROMOTE,
4151d452cf5Sahrens 	ZFS_IOC_DESTROY_SNAPS,
41655434c77Sek 	ZFS_IOC_SNAPSHOT,
41755434c77Sek 	ZFS_IOC_DSOBJ_TO_DSNAME,
418b1b8ab34Slling 	ZFS_IOC_OBJ_TO_PATH,
419b1b8ab34Slling 	ZFS_IOC_POOL_SET_PROPS,
420b1b8ab34Slling 	ZFS_IOC_POOL_GET_PROPS
421fa9e4066Sahrens } zfs_ioc_t;
422fa9e4066Sahrens 
423ea8dc4b6Seschrock /*
424ea8dc4b6Seschrock  * Internal SPA load state.  Used by FMA diagnosis engine.
425ea8dc4b6Seschrock  */
426ea8dc4b6Seschrock typedef enum {
427ea8dc4b6Seschrock 	SPA_LOAD_NONE,		/* no load in progress */
428ea8dc4b6Seschrock 	SPA_LOAD_OPEN,		/* normal open */
429ea8dc4b6Seschrock 	SPA_LOAD_IMPORT,	/* import in progress */
430ea8dc4b6Seschrock 	SPA_LOAD_TRYIMPORT	/* tryimport in progress */
431ea8dc4b6Seschrock } spa_load_state_t;
432ea8dc4b6Seschrock 
433e9dbad6fSeschrock /*
434e9dbad6fSeschrock  * Bookmark name values.
435e9dbad6fSeschrock  */
43655434c77Sek #define	ZPOOL_ERR_LIST		"error list"
437e9dbad6fSeschrock #define	ZPOOL_ERR_DATASET	"dataset"
438e9dbad6fSeschrock #define	ZPOOL_ERR_OBJECT	"object"
439e9dbad6fSeschrock 
44006eeb2adSek #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
44106eeb2adSek 
44206eeb2adSek /*
44306eeb2adSek  * The following are names used in the nvlist describing
44406eeb2adSek  * the pool's history log.
44506eeb2adSek  */
44606eeb2adSek #define	ZPOOL_HIST_RECORD	"history record"
44706eeb2adSek #define	ZPOOL_HIST_TIME		"history time"
44806eeb2adSek #define	ZPOOL_HIST_CMD		"history command"
44906eeb2adSek 
450*3d7072f8Seschrock /*
451*3d7072f8Seschrock  * Flags for ZFS_IOC_VDEV_SET_STATE
452*3d7072f8Seschrock  */
453*3d7072f8Seschrock #define	ZFS_ONLINE_CHECKREMOVE	0x1
454*3d7072f8Seschrock #define	ZFS_ONLINE_UNSPARE	0x2
455*3d7072f8Seschrock #define	ZFS_ONLINE_FORCEFAULT	0x4
456*3d7072f8Seschrock #define	ZFS_OFFLINE_TEMPORARY	0x1
457*3d7072f8Seschrock 
458*3d7072f8Seschrock /*
459*3d7072f8Seschrock  * Sysevent payload members.  ZFS will generate the following sysevents with the
460*3d7072f8Seschrock  * given payloads:
461*3d7072f8Seschrock  *
462*3d7072f8Seschrock  *	ESC_ZFS_RESILVER_START
463*3d7072f8Seschrock  *	ESC_ZFS_RESILVER_END
464*3d7072f8Seschrock  *	ESC_ZFS_POOL_DESTROY
465*3d7072f8Seschrock  *
466*3d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
467*3d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
468*3d7072f8Seschrock  *
469*3d7072f8Seschrock  *	ESC_ZFS_VDEV_REMOVE
470*3d7072f8Seschrock  *	ESC_ZFS_VDEV_CLEAR
471*3d7072f8Seschrock  *	ESC_ZFS_VDEV_CHECK
472*3d7072f8Seschrock  *
473*3d7072f8Seschrock  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
474*3d7072f8Seschrock  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
475*3d7072f8Seschrock  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
476*3d7072f8Seschrock  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
477*3d7072f8Seschrock  */
478*3d7072f8Seschrock #define	ZFS_EV_POOL_NAME	"pool_name"
479*3d7072f8Seschrock #define	ZFS_EV_POOL_GUID	"pool_guid"
480*3d7072f8Seschrock #define	ZFS_EV_VDEV_PATH	"vdev_path"
481*3d7072f8Seschrock #define	ZFS_EV_VDEV_GUID	"vdev_guid"
482*3d7072f8Seschrock 
483fa9e4066Sahrens #ifdef	__cplusplus
484fa9e4066Sahrens }
485fa9e4066Sahrens #endif
486fa9e4066Sahrens 
487fa9e4066Sahrens #endif	/* _SYS_FS_ZFS_H */
488