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