xref: /titanic_41/usr/src/uts/common/sys/fs/zfs.h (revision ce0bfb39c0479ba97372eb0e5bf2ef4275d0876e)
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 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_FS_ZFS_H
28 #define	_SYS_FS_ZFS_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * Types and constants shared between userland and the kernel.
36  */
37 
38 /*
39  * Each dataset can be one of the following types.  These constants can be
40  * combined into masks that can be passed to various functions.
41  */
42 typedef enum {
43 	ZFS_TYPE_FILESYSTEM	= 0x1,
44 	ZFS_TYPE_SNAPSHOT	= 0x2,
45 	ZFS_TYPE_VOLUME		= 0x4,
46 	ZFS_TYPE_POOL		= 0x8
47 } zfs_type_t;
48 
49 #define	ZFS_TYPE_DATASET	\
50 	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
51 
52 #define	ZAP_MAXNAMELEN 256
53 #define	ZAP_MAXVALUELEN (1024 * 8)
54 #define	ZAP_OLDMAXVALUELEN 1024
55 
56 /*
57  * Dataset properties are identified by these constants and must be added to
58  * the end of this list to ensure that external consumers are not affected
59  * by the change. If you make any changes to this list, be sure to update
60  * the property table in usr/src/common/zfs/zfs_prop.c.
61  */
62 typedef enum {
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 	ZFS_PROP_VERSION,
98 	ZFS_PROP_UTF8ONLY,
99 	ZFS_PROP_NORMALIZE,
100 	ZFS_PROP_CASE,
101 	ZFS_PROP_VSCAN,
102 	ZFS_PROP_NBMAND,
103 	ZFS_PROP_SHARESMB,
104 	ZFS_PROP_REFQUOTA,
105 	ZFS_PROP_REFRESERVATION,
106 	ZFS_PROP_GUID,
107 	ZFS_PROP_PRIMARYCACHE,
108 	ZFS_PROP_SECONDARYCACHE,
109 	ZFS_PROP_USEDSNAP,
110 	ZFS_PROP_USEDDS,
111 	ZFS_PROP_USEDCHILD,
112 	ZFS_PROP_USEDREFRESERV,
113 	ZFS_PROP_USERACCOUNTING,	/* not exposed to the user */
114 	ZFS_PROP_STMF_SHAREINFO,	/* not exposed to the user */
115 	ZFS_NUM_PROPS
116 } zfs_prop_t;
117 
118 typedef enum {
119 	ZFS_PROP_USERUSED,
120 	ZFS_PROP_USERQUOTA,
121 	ZFS_PROP_GROUPUSED,
122 	ZFS_PROP_GROUPQUOTA,
123 	ZFS_NUM_USERQUOTA_PROPS
124 } zfs_userquota_prop_t;
125 
126 extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
127 
128 /*
129  * Pool properties are identified by these constants and must be added to the
130  * end of this list to ensure that external consumers are not affected
131  * by the change. If you make any changes to this list, be sure to update
132  * the property table in usr/src/common/zfs/zpool_prop.c.
133  */
134 typedef enum {
135 	ZPOOL_PROP_NAME,
136 	ZPOOL_PROP_SIZE,
137 	ZPOOL_PROP_USED,
138 	ZPOOL_PROP_AVAILABLE,
139 	ZPOOL_PROP_CAPACITY,
140 	ZPOOL_PROP_ALTROOT,
141 	ZPOOL_PROP_HEALTH,
142 	ZPOOL_PROP_GUID,
143 	ZPOOL_PROP_VERSION,
144 	ZPOOL_PROP_BOOTFS,
145 	ZPOOL_PROP_DELEGATION,
146 	ZPOOL_PROP_AUTOREPLACE,
147 	ZPOOL_PROP_CACHEFILE,
148 	ZPOOL_PROP_FAILUREMODE,
149 	ZPOOL_PROP_LISTSNAPS,
150 	ZPOOL_PROP_AUTOEXPAND,
151 	ZPOOL_NUM_PROPS
152 } zpool_prop_t;
153 
154 #define	ZPROP_CONT		-2
155 #define	ZPROP_INVAL		-1
156 
157 #define	ZPROP_VALUE		"value"
158 #define	ZPROP_SOURCE		"source"
159 
160 typedef enum {
161 	ZPROP_SRC_NONE = 0x1,
162 	ZPROP_SRC_DEFAULT = 0x2,
163 	ZPROP_SRC_TEMPORARY = 0x4,
164 	ZPROP_SRC_LOCAL = 0x8,
165 	ZPROP_SRC_INHERITED = 0x10
166 } zprop_source_t;
167 
168 #define	ZPROP_SRC_ALL	0x1f
169 
170 typedef int (*zprop_func)(int, void *);
171 
172 /*
173  * Properties to be set on the root file system of a new pool
174  * are stuffed into their own nvlist, which is then included in
175  * the properties nvlist with the pool properties.
176  */
177 #define	ZPOOL_ROOTFS_PROPS	"root-props-nvl"
178 
179 /*
180  * Dataset property functions shared between libzfs and kernel.
181  */
182 const char *zfs_prop_default_string(zfs_prop_t);
183 uint64_t zfs_prop_default_numeric(zfs_prop_t);
184 boolean_t zfs_prop_readonly(zfs_prop_t);
185 boolean_t zfs_prop_inheritable(zfs_prop_t);
186 boolean_t zfs_prop_setonce(zfs_prop_t);
187 const char *zfs_prop_to_name(zfs_prop_t);
188 zfs_prop_t zfs_name_to_prop(const char *);
189 boolean_t zfs_prop_user(const char *);
190 boolean_t zfs_prop_userquota(const char *name);
191 int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
192 int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
193 boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
194 
195 /*
196  * Pool property functions shared between libzfs and kernel.
197  */
198 zpool_prop_t zpool_name_to_prop(const char *);
199 const char *zpool_prop_to_name(zpool_prop_t);
200 const char *zpool_prop_default_string(zpool_prop_t);
201 uint64_t zpool_prop_default_numeric(zpool_prop_t);
202 boolean_t zpool_prop_readonly(zpool_prop_t);
203 int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
204 int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
205 
206 /*
207  * Definitions for the Delegation.
208  */
209 typedef enum {
210 	ZFS_DELEG_WHO_UNKNOWN = 0,
211 	ZFS_DELEG_USER = 'u',
212 	ZFS_DELEG_USER_SETS = 'U',
213 	ZFS_DELEG_GROUP = 'g',
214 	ZFS_DELEG_GROUP_SETS = 'G',
215 	ZFS_DELEG_EVERYONE = 'e',
216 	ZFS_DELEG_EVERYONE_SETS = 'E',
217 	ZFS_DELEG_CREATE = 'c',
218 	ZFS_DELEG_CREATE_SETS = 'C',
219 	ZFS_DELEG_NAMED_SET = 's',
220 	ZFS_DELEG_NAMED_SET_SETS = 'S'
221 } zfs_deleg_who_type_t;
222 
223 typedef enum {
224 	ZFS_DELEG_NONE = 0,
225 	ZFS_DELEG_PERM_LOCAL = 1,
226 	ZFS_DELEG_PERM_DESCENDENT = 2,
227 	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
228 	ZFS_DELEG_PERM_CREATE = 4
229 } zfs_deleg_inherit_t;
230 
231 #define	ZFS_DELEG_PERM_UID	"uid"
232 #define	ZFS_DELEG_PERM_GID	"gid"
233 #define	ZFS_DELEG_PERM_GROUPS	"groups"
234 
235 #define	ZFS_SMB_ACL_SRC		"src"
236 #define	ZFS_SMB_ACL_TARGET	"target"
237 
238 typedef enum {
239 	ZFS_CANMOUNT_OFF = 0,
240 	ZFS_CANMOUNT_ON = 1,
241 	ZFS_CANMOUNT_NOAUTO = 2
242 } zfs_canmount_type_t;
243 
244 typedef enum zfs_share_op {
245 	ZFS_SHARE_NFS = 0,
246 	ZFS_UNSHARE_NFS = 1,
247 	ZFS_SHARE_SMB = 2,
248 	ZFS_UNSHARE_SMB = 3
249 } zfs_share_op_t;
250 
251 typedef enum zfs_smb_acl_op {
252 	ZFS_SMB_ACL_ADD,
253 	ZFS_SMB_ACL_REMOVE,
254 	ZFS_SMB_ACL_RENAME,
255 	ZFS_SMB_ACL_PURGE
256 } zfs_smb_acl_op_t;
257 
258 typedef enum zfs_cache_type {
259 	ZFS_CACHE_NONE = 0,
260 	ZFS_CACHE_METADATA = 1,
261 	ZFS_CACHE_ALL = 2
262 } zfs_cache_type_t;
263 
264 
265 /*
266  * On-disk version number.
267  */
268 #define	SPA_VERSION_1			1ULL
269 #define	SPA_VERSION_2			2ULL
270 #define	SPA_VERSION_3			3ULL
271 #define	SPA_VERSION_4			4ULL
272 #define	SPA_VERSION_5			5ULL
273 #define	SPA_VERSION_6			6ULL
274 #define	SPA_VERSION_7			7ULL
275 #define	SPA_VERSION_8			8ULL
276 #define	SPA_VERSION_9			9ULL
277 #define	SPA_VERSION_10			10ULL
278 #define	SPA_VERSION_11			11ULL
279 #define	SPA_VERSION_12			12ULL
280 #define	SPA_VERSION_13			13ULL
281 #define	SPA_VERSION_14			14ULL
282 #define	SPA_VERSION_15			15ULL
283 #define	SPA_VERSION_16			16ULL
284 #define	SPA_VERSION_17			17ULL
285 /*
286  * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
287  * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
288  * and do the appropriate changes.  Also bump the version number in
289  * usr/src/grub/capability.
290  */
291 #define	SPA_VERSION			SPA_VERSION_17
292 #define	SPA_VERSION_STRING		"17"
293 
294 /*
295  * Symbolic names for the changes that caused a SPA_VERSION switch.
296  * Used in the code when checking for presence or absence of a feature.
297  * Feel free to define multiple symbolic names for each version if there
298  * were multiple changes to on-disk structures during that version.
299  *
300  * NOTE: When checking the current SPA_VERSION in your code, be sure
301  *       to use spa_version() since it reports the version of the
302  *       last synced uberblock.  Checking the in-flight version can
303  *       be dangerous in some cases.
304  */
305 #define	SPA_VERSION_INITIAL		SPA_VERSION_1
306 #define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
307 #define	SPA_VERSION_SPARES		SPA_VERSION_3
308 #define	SPA_VERSION_RAIDZ2		SPA_VERSION_3
309 #define	SPA_VERSION_BPLIST_ACCOUNT	SPA_VERSION_3
310 #define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
311 #define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
312 #define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
313 #define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
314 #define	SPA_VERSION_BOOTFS		SPA_VERSION_6
315 #define	SPA_VERSION_SLOGS		SPA_VERSION_7
316 #define	SPA_VERSION_DELEGATED_PERMS	SPA_VERSION_8
317 #define	SPA_VERSION_FUID		SPA_VERSION_9
318 #define	SPA_VERSION_REFRESERVATION	SPA_VERSION_9
319 #define	SPA_VERSION_REFQUOTA		SPA_VERSION_9
320 #define	SPA_VERSION_UNIQUE_ACCURATE	SPA_VERSION_9
321 #define	SPA_VERSION_L2CACHE		SPA_VERSION_10
322 #define	SPA_VERSION_NEXT_CLONES		SPA_VERSION_11
323 #define	SPA_VERSION_ORIGIN		SPA_VERSION_11
324 #define	SPA_VERSION_DSL_SCRUB		SPA_VERSION_11
325 #define	SPA_VERSION_SNAP_PROPS		SPA_VERSION_12
326 #define	SPA_VERSION_USED_BREAKDOWN	SPA_VERSION_13
327 #define	SPA_VERSION_PASSTHROUGH_X	SPA_VERSION_14
328 #define	SPA_VERSION_USERSPACE		SPA_VERSION_15
329 #define	SPA_VERSION_STMF_PROP		SPA_VERSION_16
330 #define	SPA_VERSION_RAIDZ3		SPA_VERSION_17
331 
332 /*
333  * ZPL version - rev'd whenever an incompatible on-disk format change
334  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
335  * also update the version_table[] and help message in zfs_prop.c.
336  *
337  * When changing, be sure to teach GRUB how to read the new format!
338  * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
339  */
340 #define	ZPL_VERSION_1			1ULL
341 #define	ZPL_VERSION_2			2ULL
342 #define	ZPL_VERSION_3			3ULL
343 #define	ZPL_VERSION_4			4ULL
344 #define	ZPL_VERSION			ZPL_VERSION_4
345 #define	ZPL_VERSION_STRING		"4"
346 
347 #define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
348 #define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
349 #define	ZPL_VERSION_FUID		ZPL_VERSION_3
350 #define	ZPL_VERSION_NORMALIZATION	ZPL_VERSION_3
351 #define	ZPL_VERSION_SYSATTR		ZPL_VERSION_3
352 #define	ZPL_VERSION_USERSPACE		ZPL_VERSION_4
353 
354 /*
355  * The following are configuration names used in the nvlist describing a pool's
356  * configuration.
357  */
358 #define	ZPOOL_CONFIG_VERSION		"version"
359 #define	ZPOOL_CONFIG_POOL_NAME		"name"
360 #define	ZPOOL_CONFIG_POOL_STATE		"state"
361 #define	ZPOOL_CONFIG_POOL_TXG		"txg"
362 #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
363 #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
364 #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
365 #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
366 #define	ZPOOL_CONFIG_TYPE		"type"
367 #define	ZPOOL_CONFIG_CHILDREN		"children"
368 #define	ZPOOL_CONFIG_ID			"id"
369 #define	ZPOOL_CONFIG_GUID		"guid"
370 #define	ZPOOL_CONFIG_PATH		"path"
371 #define	ZPOOL_CONFIG_DEVID		"devid"
372 #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
373 #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
374 #define	ZPOOL_CONFIG_ASHIFT		"ashift"
375 #define	ZPOOL_CONFIG_ASIZE		"asize"
376 #define	ZPOOL_CONFIG_DTL		"DTL"
377 #define	ZPOOL_CONFIG_STATS		"stats"
378 #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
379 #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
380 #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
381 #define	ZPOOL_CONFIG_SPARES		"spares"
382 #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
383 #define	ZPOOL_CONFIG_NPARITY		"nparity"
384 #define	ZPOOL_CONFIG_HOSTID		"hostid"
385 #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
386 #define	ZPOOL_CONFIG_UNSPARE		"unspare"
387 #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
388 #define	ZPOOL_CONFIG_IS_LOG		"is_log"
389 #define	ZPOOL_CONFIG_L2CACHE		"l2cache"
390 #define	ZPOOL_CONFIG_SUSPENDED		"suspended"	/* not stored on disk */
391 #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp"	/* not stored on disk */
392 #define	ZPOOL_CONFIG_BOOTFS		"bootfs"	/* not stored on disk */
393 /*
394  * The persistent vdev state is stored as separate values rather than a single
395  * 'vdev_state' entry.  This is because a device can be in multiple states, such
396  * as offline and degraded.
397  */
398 #define	ZPOOL_CONFIG_OFFLINE		"offline"
399 #define	ZPOOL_CONFIG_FAULTED		"faulted"
400 #define	ZPOOL_CONFIG_DEGRADED		"degraded"
401 #define	ZPOOL_CONFIG_REMOVED		"removed"
402 #define	ZPOOL_CONFIG_FRU		"fru"
403 
404 #define	VDEV_TYPE_ROOT			"root"
405 #define	VDEV_TYPE_MIRROR		"mirror"
406 #define	VDEV_TYPE_REPLACING		"replacing"
407 #define	VDEV_TYPE_RAIDZ			"raidz"
408 #define	VDEV_TYPE_DISK			"disk"
409 #define	VDEV_TYPE_FILE			"file"
410 #define	VDEV_TYPE_MISSING		"missing"
411 #define	VDEV_TYPE_SPARE			"spare"
412 #define	VDEV_TYPE_LOG			"log"
413 #define	VDEV_TYPE_L2CACHE		"l2cache"
414 
415 /*
416  * This is needed in userland to report the minimum necessary device size.
417  */
418 #define	SPA_MINDEVSIZE		(64ULL << 20)
419 
420 /*
421  * The location of the pool configuration repository, shared between kernel and
422  * userland.
423  */
424 #define	ZPOOL_CACHE		"/etc/zfs/zpool.cache"
425 
426 /*
427  * vdev states are ordered from least to most healthy.
428  * A vdev that's CANT_OPEN or below is considered unusable.
429  */
430 typedef enum vdev_state {
431 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
432 	VDEV_STATE_CLOSED,	/* Not currently open			*/
433 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
434 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
435 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
436 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
437 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
438 	VDEV_STATE_HEALTHY	/* Presumed good			*/
439 } vdev_state_t;
440 
441 #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
442 
443 /*
444  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
445  * of the vdev stats structure uses these constants to distinguish why.
446  */
447 typedef enum vdev_aux {
448 	VDEV_AUX_NONE,		/* no error				*/
449 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
450 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
451 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
452 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
453 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
454 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
455 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
456 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
457 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
458 	VDEV_AUX_ERR_EXCEEDED,	/* too many errors			*/
459 	VDEV_AUX_IO_FAILURE,	/* experienced I/O failure		*/
460 	VDEV_AUX_BAD_LOG	/* cannot read log chain(s)		*/
461 } vdev_aux_t;
462 
463 /*
464  * pool state.  The following states are written to disk as part of the normal
465  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
466  * states are software abstractions used at various levels to communicate
467  * pool state.
468  */
469 typedef enum pool_state {
470 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
471 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
472 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
473 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
474 	POOL_STATE_L2CACHE,		/* Level 2 ARC device		*/
475 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
476 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
477 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
478 } pool_state_t;
479 
480 /*
481  * Scrub types.
482  */
483 typedef enum pool_scrub_type {
484 	POOL_SCRUB_NONE,
485 	POOL_SCRUB_RESILVER,
486 	POOL_SCRUB_EVERYTHING,
487 	POOL_SCRUB_TYPES
488 } pool_scrub_type_t;
489 
490 /*
491  * ZIO types.  Needed to interpret vdev statistics below.
492  */
493 typedef enum zio_type {
494 	ZIO_TYPE_NULL = 0,
495 	ZIO_TYPE_READ,
496 	ZIO_TYPE_WRITE,
497 	ZIO_TYPE_FREE,
498 	ZIO_TYPE_CLAIM,
499 	ZIO_TYPE_IOCTL,
500 	ZIO_TYPES
501 } zio_type_t;
502 
503 /*
504  * Vdev statistics.  Note: all fields should be 64-bit because this
505  * is passed between kernel and userland as an nvlist uint64 array.
506  */
507 typedef struct vdev_stat {
508 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
509 	uint64_t	vs_state;		/* vdev state		*/
510 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
511 	uint64_t	vs_alloc;		/* space allocated	*/
512 	uint64_t	vs_space;		/* total capacity	*/
513 	uint64_t	vs_dspace;		/* deflated capacity	*/
514 	uint64_t	vs_rsize;		/* replaceable dev size */
515 	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
516 	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
517 	uint64_t	vs_read_errors;		/* read errors		*/
518 	uint64_t	vs_write_errors;	/* write errors		*/
519 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
520 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
521 	uint64_t	vs_scrub_type;		/* pool_scrub_type_t	*/
522 	uint64_t	vs_scrub_complete;	/* completed?		*/
523 	uint64_t	vs_scrub_examined;	/* bytes examined; top	*/
524 	uint64_t	vs_scrub_repaired;	/* bytes repaired; leaf	*/
525 	uint64_t	vs_scrub_errors;	/* errors during scrub	*/
526 	uint64_t	vs_scrub_start;		/* UTC scrub start time	*/
527 	uint64_t	vs_scrub_end;		/* UTC scrub end time	*/
528 } vdev_stat_t;
529 
530 #define	ZVOL_DRIVER	"zvol"
531 #define	ZFS_DRIVER	"zfs"
532 #define	ZFS_DEV		"/dev/zfs"
533 
534 /*
535  * zvol paths.  Irritatingly, the devfsadm interfaces want all these
536  * paths without the /dev prefix, but for some things, we want the
537  * /dev prefix.  Below are the names without /dev.
538  */
539 #define	ZVOL_DEV_DIR	"zvol/dsk"
540 #define	ZVOL_RDEV_DIR	"zvol/rdsk"
541 
542 /*
543  * And here are the things we need with /dev, etc. in front of them.
544  */
545 #define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zfs@0:"
546 #define	ZVOL_FULL_DEV_DIR	"/dev/" ZVOL_DEV_DIR "/"
547 
548 #define	ZVOL_PROP_NAME		"name"
549 
550 /*
551  * /dev/zfs ioctl numbers.
552  */
553 #define	ZFS_IOC		('Z' << 8)
554 
555 typedef enum zfs_ioc {
556 	ZFS_IOC_POOL_CREATE = ZFS_IOC,
557 	ZFS_IOC_POOL_DESTROY,
558 	ZFS_IOC_POOL_IMPORT,
559 	ZFS_IOC_POOL_EXPORT,
560 	ZFS_IOC_POOL_CONFIGS,
561 	ZFS_IOC_POOL_STATS,
562 	ZFS_IOC_POOL_TRYIMPORT,
563 	ZFS_IOC_POOL_SCRUB,
564 	ZFS_IOC_POOL_FREEZE,
565 	ZFS_IOC_POOL_UPGRADE,
566 	ZFS_IOC_POOL_GET_HISTORY,
567 	ZFS_IOC_VDEV_ADD,
568 	ZFS_IOC_VDEV_REMOVE,
569 	ZFS_IOC_VDEV_SET_STATE,
570 	ZFS_IOC_VDEV_ATTACH,
571 	ZFS_IOC_VDEV_DETACH,
572 	ZFS_IOC_VDEV_SETPATH,
573 	ZFS_IOC_VDEV_SETFRU,
574 	ZFS_IOC_OBJSET_STATS,
575 	ZFS_IOC_OBJSET_ZPLPROPS,
576 	ZFS_IOC_DATASET_LIST_NEXT,
577 	ZFS_IOC_SNAPSHOT_LIST_NEXT,
578 	ZFS_IOC_SET_PROP,
579 	ZFS_IOC_CREATE_MINOR,
580 	ZFS_IOC_REMOVE_MINOR,
581 	ZFS_IOC_CREATE,
582 	ZFS_IOC_DESTROY,
583 	ZFS_IOC_ROLLBACK,
584 	ZFS_IOC_RENAME,
585 	ZFS_IOC_RECV,
586 	ZFS_IOC_SEND,
587 	ZFS_IOC_INJECT_FAULT,
588 	ZFS_IOC_CLEAR_FAULT,
589 	ZFS_IOC_INJECT_LIST_NEXT,
590 	ZFS_IOC_ERROR_LOG,
591 	ZFS_IOC_CLEAR,
592 	ZFS_IOC_PROMOTE,
593 	ZFS_IOC_DESTROY_SNAPS,
594 	ZFS_IOC_SNAPSHOT,
595 	ZFS_IOC_DSOBJ_TO_DSNAME,
596 	ZFS_IOC_OBJ_TO_PATH,
597 	ZFS_IOC_POOL_SET_PROPS,
598 	ZFS_IOC_POOL_GET_PROPS,
599 	ZFS_IOC_SET_FSACL,
600 	ZFS_IOC_GET_FSACL,
601 	ZFS_IOC_ISCSI_PERM_CHECK,
602 	ZFS_IOC_SHARE,
603 	ZFS_IOC_INHERIT_PROP,
604 	ZFS_IOC_SMB_ACL,
605 	ZFS_IOC_USERSPACE_ONE,
606 	ZFS_IOC_USERSPACE_MANY,
607 	ZFS_IOC_USERSPACE_UPGRADE
608 } zfs_ioc_t;
609 
610 /*
611  * Internal SPA load state.  Used by FMA diagnosis engine.
612  */
613 typedef enum {
614 	SPA_LOAD_NONE,		/* no load in progress */
615 	SPA_LOAD_OPEN,		/* normal open */
616 	SPA_LOAD_IMPORT,	/* import in progress */
617 	SPA_LOAD_TRYIMPORT	/* tryimport in progress */
618 } spa_load_state_t;
619 
620 /*
621  * Bookmark name values.
622  */
623 #define	ZPOOL_ERR_LIST		"error list"
624 #define	ZPOOL_ERR_DATASET	"dataset"
625 #define	ZPOOL_ERR_OBJECT	"object"
626 
627 #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
628 
629 /*
630  * The following are names used in the nvlist describing
631  * the pool's history log.
632  */
633 #define	ZPOOL_HIST_RECORD	"history record"
634 #define	ZPOOL_HIST_TIME		"history time"
635 #define	ZPOOL_HIST_CMD		"history command"
636 #define	ZPOOL_HIST_WHO		"history who"
637 #define	ZPOOL_HIST_ZONE		"history zone"
638 #define	ZPOOL_HIST_HOST		"history hostname"
639 #define	ZPOOL_HIST_TXG		"history txg"
640 #define	ZPOOL_HIST_INT_EVENT	"history internal event"
641 #define	ZPOOL_HIST_INT_STR	"history internal str"
642 
643 /*
644  * Flags for ZFS_IOC_VDEV_SET_STATE
645  */
646 #define	ZFS_ONLINE_CHECKREMOVE	0x1
647 #define	ZFS_ONLINE_UNSPARE	0x2
648 #define	ZFS_ONLINE_FORCEFAULT	0x4
649 #define	ZFS_ONLINE_EXPAND	0x8
650 #define	ZFS_OFFLINE_TEMPORARY	0x1
651 
652 /*
653  * Sysevent payload members.  ZFS will generate the following sysevents with the
654  * given payloads:
655  *
656  *	ESC_ZFS_RESILVER_START
657  *	ESC_ZFS_RESILVER_END
658  *	ESC_ZFS_POOL_DESTROY
659  *
660  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
661  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
662  *
663  *	ESC_ZFS_VDEV_REMOVE
664  *	ESC_ZFS_VDEV_CLEAR
665  *	ESC_ZFS_VDEV_CHECK
666  *
667  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
668  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
669  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
670  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
671  */
672 #define	ZFS_EV_POOL_NAME	"pool_name"
673 #define	ZFS_EV_POOL_GUID	"pool_guid"
674 #define	ZFS_EV_VDEV_PATH	"vdev_path"
675 #define	ZFS_EV_VDEV_GUID	"vdev_guid"
676 
677 /*
678  * Note: This is encoded on-disk, so new events must be added to the
679  * end, and unused events can not be removed.  Be sure to edit
680  * zpool_main.c: hist_event_table[].
681  */
682 typedef enum history_internal_events {
683 	LOG_NO_EVENT = 0,
684 	LOG_POOL_CREATE,
685 	LOG_POOL_VDEV_ADD,
686 	LOG_POOL_REMOVE,
687 	LOG_POOL_DESTROY,
688 	LOG_POOL_EXPORT,
689 	LOG_POOL_IMPORT,
690 	LOG_POOL_VDEV_ATTACH,
691 	LOG_POOL_VDEV_REPLACE,
692 	LOG_POOL_VDEV_DETACH,
693 	LOG_POOL_VDEV_ONLINE,
694 	LOG_POOL_VDEV_OFFLINE,
695 	LOG_POOL_UPGRADE,
696 	LOG_POOL_CLEAR,
697 	LOG_POOL_SCRUB,
698 	LOG_POOL_PROPSET,
699 	LOG_DS_CREATE,
700 	LOG_DS_CLONE,
701 	LOG_DS_DESTROY,
702 	LOG_DS_DESTROY_BEGIN,
703 	LOG_DS_INHERIT,
704 	LOG_DS_PROPSET,
705 	LOG_DS_QUOTA,
706 	LOG_DS_PERM_UPDATE,
707 	LOG_DS_PERM_REMOVE,
708 	LOG_DS_PERM_WHO_REMOVE,
709 	LOG_DS_PROMOTE,
710 	LOG_DS_RECEIVE,
711 	LOG_DS_RENAME,
712 	LOG_DS_RESERVATION,
713 	LOG_DS_REPLAY_INC_SYNC,
714 	LOG_DS_REPLAY_FULL_SYNC,
715 	LOG_DS_ROLLBACK,
716 	LOG_DS_SNAPSHOT,
717 	LOG_DS_UPGRADE,
718 	LOG_DS_REFQUOTA,
719 	LOG_DS_REFRESERV,
720 	LOG_POOL_SCRUB_DONE,
721 	LOG_END
722 } history_internal_events_t;
723 
724 #ifdef	__cplusplus
725 }
726 #endif
727 
728 #endif	/* _SYS_FS_ZFS_H */
729