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