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