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