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