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