xref: /titanic_44/usr/src/uts/common/sys/fs/zfs.h (revision bf56214c0556fa6864189c826d39dbe156bb22a0)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_FS_ZFS_H
27 #define	_SYS_FS_ZFS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Types and constants shared between userland and the kernel.
37  */
38 
39 /*
40  * Each dataset can be one of the following types.  These constants can be
41  * combined into masks that can be passed to various functions.
42  */
43 typedef enum {
44 	ZFS_TYPE_FILESYSTEM	= 0x1,
45 	ZFS_TYPE_SNAPSHOT	= 0x2,
46 	ZFS_TYPE_VOLUME		= 0x4,
47 	ZFS_TYPE_POOL		= 0x8
48 } zfs_type_t;
49 
50 #define	ZFS_TYPE_ANY	\
51 	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
52 
53 /*
54  * Properties are identified by these constants and must be added to the
55  * end of this list to ensure that external consumers are not affected
56  * by the change. The property list also determines how 'zfs get' will
57  * display them.  If you make any changes to this list, be sure to update
58  * the property table in usr/src/common/zfs/zfs_prop.c.
59  */
60 typedef enum {
61 	ZFS_PROP_CONT = -2,
62 	ZFS_PROP_INVAL = -1,
63 	ZFS_PROP_TYPE,
64 	ZFS_PROP_CREATION,
65 	ZFS_PROP_USED,
66 	ZFS_PROP_AVAILABLE,
67 	ZFS_PROP_REFERENCED,
68 	ZFS_PROP_COMPRESSRATIO,
69 	ZFS_PROP_MOUNTED,
70 	ZFS_PROP_ORIGIN,
71 	ZFS_PROP_QUOTA,
72 	ZFS_PROP_RESERVATION,
73 	ZFS_PROP_VOLSIZE,
74 	ZFS_PROP_VOLBLOCKSIZE,
75 	ZFS_PROP_RECORDSIZE,
76 	ZFS_PROP_MOUNTPOINT,
77 	ZFS_PROP_SHARENFS,
78 	ZFS_PROP_CHECKSUM,
79 	ZFS_PROP_COMPRESSION,
80 	ZFS_PROP_ATIME,
81 	ZFS_PROP_DEVICES,
82 	ZFS_PROP_EXEC,
83 	ZFS_PROP_SETUID,
84 	ZFS_PROP_READONLY,
85 	ZFS_PROP_ZONED,
86 	ZFS_PROP_SNAPDIR,
87 	ZFS_PROP_ACLMODE,
88 	ZFS_PROP_ACLINHERIT,
89 	ZFS_PROP_CREATETXG,		/* not exposed to the user */
90 	ZFS_PROP_NAME,			/* not exposed to the user */
91 	ZFS_PROP_CANMOUNT,
92 	ZFS_PROP_SHAREISCSI,
93 	ZFS_PROP_ISCSIOPTIONS,		/* not exposed to the user */
94 	ZFS_PROP_XATTR,
95 	ZFS_PROP_NUMCLONES,		/* not exposed to the user */
96 	ZFS_PROP_COPIES,
97 	ZPOOL_PROP_BOOTFS,
98 	ZPOOL_PROP_AUTOREPLACE,
99 	ZPOOL_PROP_DELEGATION,
100 	ZFS_PROP_VERSION,
101 	ZPOOL_PROP_NAME			/* XXX must be last! */
102 } zfs_prop_t;
103 
104 typedef zfs_prop_t zpool_prop_t;
105 
106 #define	ZPOOL_PROP_CONT		ZFS_PROP_CONT
107 #define	ZPOOL_PROP_INVAL	ZFS_PROP_INVAL
108 
109 #define	ZFS_PROP_VALUE		"value"
110 #define	ZFS_PROP_SOURCE		"source"
111 
112 typedef enum {
113 	ZFS_SRC_NONE = 0x1,
114 	ZFS_SRC_DEFAULT = 0x2,
115 	ZFS_SRC_TEMPORARY = 0x4,
116 	ZFS_SRC_LOCAL = 0x8,
117 	ZFS_SRC_INHERITED = 0x10
118 } zfs_source_t;
119 
120 #define	ZFS_SRC_ALL	0x1f
121 
122 typedef enum {
123 	ZFS_DELEG_WHO_UNKNOWN = 0,
124 	ZFS_DELEG_USER = 'u',
125 	ZFS_DELEG_USER_SETS = 'U',
126 	ZFS_DELEG_GROUP = 'g',
127 	ZFS_DELEG_GROUP_SETS = 'G',
128 	ZFS_DELEG_EVERYONE = 'e',
129 	ZFS_DELEG_EVERYONE_SETS = 'E',
130 	ZFS_DELEG_CREATE = 'c',
131 	ZFS_DELEG_CREATE_SETS = 'C',
132 	ZFS_DELEG_NAMED_SET = 's',
133 	ZFS_DELEG_NAMED_SET_SETS = 'S'
134 } zfs_deleg_who_type_t;
135 
136 typedef enum {
137 	ZFS_DELEG_NONE = 0,
138 	ZFS_DELEG_PERM_LOCAL = 1,
139 	ZFS_DELEG_PERM_DESCENDENT = 2,
140 	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
141 	ZFS_DELEG_PERM_CREATE = 4
142 } zfs_deleg_inherit_t;
143 
144 #define	ZFS_DELEG_PERM_UID	"uid"
145 #define	ZFS_DELEG_PERM_GID	"gid"
146 #define	ZFS_DELEG_PERM_GROUPS	"groups"
147 
148 /*
149  * The following functions are shared between libzfs and the kernel.
150  */
151 zfs_prop_t zfs_name_to_prop(const char *);
152 zpool_prop_t zpool_name_to_prop(const char *);
153 boolean_t zfs_prop_user(const char *);
154 int zfs_prop_readonly(zfs_prop_t);
155 const char *zfs_prop_default_string(zfs_prop_t);
156 const char *zfs_prop_to_name(zfs_prop_t);
157 const char *zpool_prop_to_name(zpool_prop_t);
158 uint64_t zfs_prop_default_numeric(zfs_prop_t);
159 int zfs_prop_inheritable(zfs_prop_t);
160 int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
161 int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
162 uint64_t zpool_prop_default_numeric(zpool_prop_t);
163 const char *zfs_prop_perm(zfs_prop_t);
164 
165 /*
166  * Property Iterator
167  */
168 typedef zfs_prop_t (*zfs_prop_f)(zfs_prop_t, void *);
169 typedef zpool_prop_t (*zpool_prop_f)(zpool_prop_t, void *);
170 extern zfs_prop_t zfs_prop_iter(zfs_prop_f, void *, boolean_t);
171 extern zfs_prop_t zfs_prop_iter_ordered(zfs_prop_f, void *, boolean_t);
172 extern zpool_prop_t zpool_prop_iter(zpool_prop_f, void *, boolean_t);
173 
174 /*
175  * On-disk version number.
176  */
177 #define	SPA_VERSION_1			1ULL
178 #define	SPA_VERSION_2			2ULL
179 #define	SPA_VERSION_3			3ULL
180 #define	SPA_VERSION_4			4ULL
181 #define	SPA_VERSION_5			5ULL
182 #define	SPA_VERSION_6			6ULL
183 #define	SPA_VERSION_7			7ULL
184 #define	SPA_VERSION_8			8ULL
185 /*
186  * When bumping up SPA_VERSION, make sure GRUB ZFS understand the on-disk
187  * format change. Go to usr/src/grub/grub-0.95/stage2/{zfs-include/, fsys_zfs*},
188  * and do the appropriate changes.
189  */
190 #define	SPA_VERSION			SPA_VERSION_8
191 #define	SPA_VERSION_STRING		"8"
192 
193 /*
194  * Symbolic names for the changes that caused a SPA_VERSION switch.
195  * Used in the code when checking for presence or absence of a feature.
196  * Feel free to define multiple symbolic names for each version if there
197  * were multiple changes to on-disk structures during that version.
198  *
199  * NOTE: When checking the current SPA_VERSION in your code, be sure
200  *       to use spa_version() since it reports the version of the
201  *       last synced uberblock.  Checking the in-flight version can
202  *       be dangerous in some cases.
203  */
204 #define	SPA_VERSION_INITIAL		SPA_VERSION_1
205 #define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
206 #define	SPA_VERSION_SPARES		SPA_VERSION_3
207 #define	SPA_VERSION_RAID6		SPA_VERSION_3
208 #define	SPA_VERSION_BPLIST_ACCOUNT	SPA_VERSION_3
209 #define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
210 #define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
211 #define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
212 #define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
213 #define	SPA_VERSION_BOOTFS		SPA_VERSION_6
214 #define	ZFS_VERSION_SLOGS		SPA_VERSION_7
215 #define	ZFS_VERSION_DELEGATED_PERMS	SPA_VERSION_8
216 
217 /*
218  * ZPL version - rev'd whenever an incompatible on-disk format change
219  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
220  * also update the version_table[] and help message in zfs_prop.c.
221  *
222  * When changing, be sure to teach GRUB how to read the new format!
223  * See usr/src/grub/grub-0.95/stage2/{zfs-include/,fsys_zfs*}
224  */
225 #define	ZPL_VERSION_1			1ULL
226 #define	ZPL_VERSION_2			2ULL
227 #define	ZPL_VERSION			ZPL_VERSION_2
228 #define	ZPL_VERSION_STRING		"2"
229 
230 #define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
231 #define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
232 
233 /*
234  * The following are configuration names used in the nvlist describing a pool's
235  * configuration.
236  */
237 #define	ZPOOL_CONFIG_VERSION		"version"
238 #define	ZPOOL_CONFIG_POOL_NAME		"name"
239 #define	ZPOOL_CONFIG_POOL_STATE		"state"
240 #define	ZPOOL_CONFIG_POOL_TXG		"txg"
241 #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
242 #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
243 #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
244 #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
245 #define	ZPOOL_CONFIG_TYPE		"type"
246 #define	ZPOOL_CONFIG_CHILDREN		"children"
247 #define	ZPOOL_CONFIG_ID			"id"
248 #define	ZPOOL_CONFIG_GUID		"guid"
249 #define	ZPOOL_CONFIG_PATH		"path"
250 #define	ZPOOL_CONFIG_DEVID		"devid"
251 #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
252 #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
253 #define	ZPOOL_CONFIG_ASHIFT		"ashift"
254 #define	ZPOOL_CONFIG_ASIZE		"asize"
255 #define	ZPOOL_CONFIG_DTL		"DTL"
256 #define	ZPOOL_CONFIG_STATS		"stats"
257 #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
258 #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
259 #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
260 #define	ZPOOL_CONFIG_SPARES		"spares"
261 #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
262 #define	ZPOOL_CONFIG_NPARITY		"nparity"
263 #define	ZPOOL_CONFIG_HOSTID		"hostid"
264 #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
265 #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp" /* not stored on disk */
266 #define	ZPOOL_CONFIG_UNSPARE		"unspare"
267 #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
268 #define	ZPOOL_CONFIG_IS_LOG		"is_log"
269 /*
270  * The persistent vdev state is stored as separate values rather than a single
271  * 'vdev_state' entry.  This is because a device can be in multiple states, such
272  * as offline and degraded.
273  */
274 #define	ZPOOL_CONFIG_OFFLINE		"offline"
275 #define	ZPOOL_CONFIG_FAULTED		"faulted"
276 #define	ZPOOL_CONFIG_DEGRADED		"degraded"
277 #define	ZPOOL_CONFIG_REMOVED		"removed"
278 
279 #define	VDEV_TYPE_ROOT			"root"
280 #define	VDEV_TYPE_MIRROR		"mirror"
281 #define	VDEV_TYPE_REPLACING		"replacing"
282 #define	VDEV_TYPE_RAIDZ			"raidz"
283 #define	VDEV_TYPE_DISK			"disk"
284 #define	VDEV_TYPE_FILE			"file"
285 #define	VDEV_TYPE_MISSING		"missing"
286 #define	VDEV_TYPE_SPARE			"spare"
287 #define	VDEV_TYPE_LOG			"log"
288 
289 /*
290  * This is needed in userland to report the minimum necessary device size.
291  */
292 #define	SPA_MINDEVSIZE		(64ULL << 20)
293 
294 /*
295  * The location of the pool configuration repository, shared between kernel and
296  * userland.
297  */
298 #define	ZPOOL_CACHE_DIR		"/etc/zfs"
299 #define	ZPOOL_CACHE_FILE	"zpool.cache"
300 #define	ZPOOL_CACHE_TMP		".zpool.cache"
301 
302 #define	ZPOOL_CACHE		ZPOOL_CACHE_DIR "/" ZPOOL_CACHE_FILE
303 
304 /*
305  * vdev states are ordered from least to most healthy.
306  * A vdev that's CANT_OPEN or below is considered unusable.
307  */
308 typedef enum vdev_state {
309 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
310 	VDEV_STATE_CLOSED,	/* Not currently open			*/
311 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
312 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
313 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
314 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
315 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
316 	VDEV_STATE_HEALTHY	/* Presumed good			*/
317 } vdev_state_t;
318 
319 #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
320 
321 /*
322  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
323  * of the vdev stats structure uses these constants to distinguish why.
324  */
325 typedef enum vdev_aux {
326 	VDEV_AUX_NONE,		/* no error				*/
327 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
328 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
329 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
330 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
331 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
332 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
333 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
334 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
335 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
336 	VDEV_AUX_ERR_EXCEEDED	/* too many errors			*/
337 } vdev_aux_t;
338 
339 /*
340  * pool state.  The following states are written to disk as part of the normal
341  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE.  The remaining states are
342  * software abstractions used at various levels to communicate pool state.
343  */
344 typedef enum pool_state {
345 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
346 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
347 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
348 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
349 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
350 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
351 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
352 } pool_state_t;
353 
354 /*
355  * Scrub types.
356  */
357 typedef enum pool_scrub_type {
358 	POOL_SCRUB_NONE,
359 	POOL_SCRUB_RESILVER,
360 	POOL_SCRUB_EVERYTHING,
361 	POOL_SCRUB_TYPES
362 } pool_scrub_type_t;
363 
364 /*
365  * ZIO types.  Needed to interpret vdev statistics below.
366  */
367 typedef enum zio_type {
368 	ZIO_TYPE_NULL = 0,
369 	ZIO_TYPE_READ,
370 	ZIO_TYPE_WRITE,
371 	ZIO_TYPE_FREE,
372 	ZIO_TYPE_CLAIM,
373 	ZIO_TYPE_IOCTL,
374 	ZIO_TYPES
375 } zio_type_t;
376 
377 /*
378  * Vdev statistics.  Note: all fields should be 64-bit because this
379  * is passed between kernel and userland as an nvlist uint64 array.
380  */
381 typedef struct vdev_stat {
382 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
383 	uint64_t	vs_state;		/* vdev state		*/
384 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
385 	uint64_t	vs_alloc;		/* space allocated	*/
386 	uint64_t	vs_space;		/* total capacity	*/
387 	uint64_t	vs_dspace;		/* deflated capacity	*/
388 	uint64_t	vs_rsize;		/* replaceable dev size */
389 	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
390 	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
391 	uint64_t	vs_read_errors;		/* read errors		*/
392 	uint64_t	vs_write_errors;	/* write errors		*/
393 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
394 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
395 	uint64_t	vs_scrub_type;		/* pool_scrub_type_t	*/
396 	uint64_t	vs_scrub_complete;	/* completed?		*/
397 	uint64_t	vs_scrub_examined;	/* bytes examined; top	*/
398 	uint64_t	vs_scrub_repaired;	/* bytes repaired; leaf	*/
399 	uint64_t	vs_scrub_errors;	/* errors during scrub	*/
400 	uint64_t	vs_scrub_start;		/* UTC scrub start time	*/
401 	uint64_t	vs_scrub_end;		/* UTC scrub end time	*/
402 } vdev_stat_t;
403 
404 #define	ZFS_DRIVER	"zfs"
405 #define	ZFS_DEV		"/dev/zfs"
406 
407 /*
408  * zvol paths.  Irritatingly, the devfsadm interfaces want all these
409  * paths without the /dev prefix, but for some things, we want the
410  * /dev prefix.  Below are the names without /dev.
411  */
412 #define	ZVOL_DEV_DIR	"zvol/dsk"
413 #define	ZVOL_RDEV_DIR	"zvol/rdsk"
414 
415 /*
416  * And here are the things we need with /dev, etc. in front of them.
417  */
418 #define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zvol@0:"
419 #define	ZVOL_FULL_DEV_DIR	"/dev/" ZVOL_DEV_DIR
420 
421 #define	ZVOL_PROP_NAME		"name"
422 
423 /*
424  * /dev/zfs ioctl numbers.
425  */
426 #define	ZFS_IOC		('Z' << 8)
427 
428 typedef enum zfs_ioc {
429 	ZFS_IOC_POOL_CREATE = ZFS_IOC,
430 	ZFS_IOC_POOL_DESTROY,
431 	ZFS_IOC_POOL_IMPORT,
432 	ZFS_IOC_POOL_EXPORT,
433 	ZFS_IOC_POOL_CONFIGS,
434 	ZFS_IOC_POOL_STATS,
435 	ZFS_IOC_POOL_TRYIMPORT,
436 	ZFS_IOC_POOL_SCRUB,
437 	ZFS_IOC_POOL_FREEZE,
438 	ZFS_IOC_POOL_UPGRADE,
439 	ZFS_IOC_POOL_GET_HISTORY,
440 	ZFS_IOC_VDEV_ADD,
441 	ZFS_IOC_VDEV_REMOVE,
442 	ZFS_IOC_VDEV_SET_STATE,
443 	ZFS_IOC_VDEV_ATTACH,
444 	ZFS_IOC_VDEV_DETACH,
445 	ZFS_IOC_VDEV_SETPATH,
446 	ZFS_IOC_OBJSET_STATS,
447 	ZFS_IOC_DATASET_LIST_NEXT,
448 	ZFS_IOC_SNAPSHOT_LIST_NEXT,
449 	ZFS_IOC_SET_PROP,
450 	ZFS_IOC_CREATE_MINOR,
451 	ZFS_IOC_REMOVE_MINOR,
452 	ZFS_IOC_CREATE,
453 	ZFS_IOC_DESTROY,
454 	ZFS_IOC_ROLLBACK,
455 	ZFS_IOC_RENAME,
456 	ZFS_IOC_RECVBACKUP,
457 	ZFS_IOC_SENDBACKUP,
458 	ZFS_IOC_INJECT_FAULT,
459 	ZFS_IOC_CLEAR_FAULT,
460 	ZFS_IOC_INJECT_LIST_NEXT,
461 	ZFS_IOC_ERROR_LOG,
462 	ZFS_IOC_CLEAR,
463 	ZFS_IOC_PROMOTE,
464 	ZFS_IOC_DESTROY_SNAPS,
465 	ZFS_IOC_SNAPSHOT,
466 	ZFS_IOC_DSOBJ_TO_DSNAME,
467 	ZFS_IOC_OBJ_TO_PATH,
468 	ZFS_IOC_POOL_SET_PROPS,
469 	ZFS_IOC_POOL_GET_PROPS,
470 	ZFS_IOC_SET_FSACL,
471 	ZFS_IOC_GET_FSACL,
472 	ZFS_IOC_ISCSI_PERM_CHECK,
473 	ZFS_IOC_SHARE
474 } zfs_ioc_t;
475 
476 /*
477  * Internal SPA load state.  Used by FMA diagnosis engine.
478  */
479 typedef enum {
480 	SPA_LOAD_NONE,		/* no load in progress */
481 	SPA_LOAD_OPEN,		/* normal open */
482 	SPA_LOAD_IMPORT,	/* import in progress */
483 	SPA_LOAD_TRYIMPORT	/* tryimport in progress */
484 } spa_load_state_t;
485 
486 /*
487  * Bookmark name values.
488  */
489 #define	ZPOOL_ERR_LIST		"error list"
490 #define	ZPOOL_ERR_DATASET	"dataset"
491 #define	ZPOOL_ERR_OBJECT	"object"
492 
493 #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
494 
495 /*
496  * The following are names used in the nvlist describing
497  * the pool's history log.
498  */
499 #define	ZPOOL_HIST_RECORD	"history record"
500 #define	ZPOOL_HIST_TIME		"history time"
501 #define	ZPOOL_HIST_CMD		"history command"
502 #define	ZPOOL_HIST_WHO		"history who"
503 #define	ZPOOL_HIST_ZONE		"history zone"
504 #define	ZPOOL_HIST_HOST		"history hostname"
505 #define	ZPOOL_HIST_TXG		"history txg"
506 #define	ZPOOL_HIST_INT_EVENT	"history internal event"
507 #define	ZPOOL_HIST_INT_STR	"history internal str"
508 
509 /*
510  * Flags for ZFS_IOC_VDEV_SET_STATE
511  */
512 #define	ZFS_ONLINE_CHECKREMOVE	0x1
513 #define	ZFS_ONLINE_UNSPARE	0x2
514 #define	ZFS_ONLINE_FORCEFAULT	0x4
515 #define	ZFS_OFFLINE_TEMPORARY	0x1
516 
517 /*
518  * Sysevent payload members.  ZFS will generate the following sysevents with the
519  * given payloads:
520  *
521  *	ESC_ZFS_RESILVER_START
522  *	ESC_ZFS_RESILVER_END
523  *	ESC_ZFS_POOL_DESTROY
524  *
525  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
526  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
527  *
528  *	ESC_ZFS_VDEV_REMOVE
529  *	ESC_ZFS_VDEV_CLEAR
530  *	ESC_ZFS_VDEV_CHECK
531  *
532  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
533  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
534  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
535  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
536  */
537 #define	ZFS_EV_POOL_NAME	"pool_name"
538 #define	ZFS_EV_POOL_GUID	"pool_guid"
539 #define	ZFS_EV_VDEV_PATH	"vdev_path"
540 #define	ZFS_EV_VDEV_GUID	"vdev_guid"
541 
542 typedef enum history_internal_events {
543 	LOG_NO_EVENT = 0,
544 	LOG_POOL_CREATE,
545 	LOG_POOL_VDEV_ADD,
546 	LOG_POOL_REMOVE,
547 	LOG_POOL_DESTROY,
548 	LOG_POOL_EXPORT,
549 	LOG_POOL_IMPORT,
550 	LOG_POOL_VDEV_ATTACH,
551 	LOG_POOL_VDEV_REPLACE,
552 	LOG_POOL_VDEV_DETACH,
553 	LOG_POOL_VDEV_ONLINE,
554 	LOG_POOL_VDEV_OFFLINE,
555 	LOG_POOL_UPGRADE,
556 	LOG_POOL_CLEAR,
557 	LOG_POOL_SCRUB,
558 	LOG_POOL_PROPSET,
559 	LOG_DS_CREATE,
560 	LOG_DS_CLONE,
561 	LOG_DS_DESTROY,
562 	LOG_DS_DESTROY_BEGIN,
563 	LOG_DS_INHERIT,
564 	LOG_DS_PROPSET,
565 	LOG_DS_QUOTA,
566 	LOG_DS_PERM_UPDATE,
567 	LOG_DS_PERM_REMOVE,
568 	LOG_DS_PERM_WHO_REMOVE,
569 	LOG_DS_PROMOTE,
570 	LOG_DS_RECEIVE,
571 	LOG_DS_RENAME,
572 	LOG_DS_RESERVATION,
573 	LOG_DS_REPLAY_INC_SYNC,
574 	LOG_DS_REPLAY_FULL_SYNC,
575 	LOG_DS_ROLLBACK,
576 	LOG_DS_SNAPSHOT,
577 	LOG_DS_UPGRADE,
578 	LOG_END
579 } history_internal_events_t;
580 
581 #ifdef	__cplusplus
582 }
583 #endif
584 
585 #endif	/* _SYS_FS_ZFS_H */
586