zfs.h revision 325534
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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
25 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
26 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
27 * Copyright (c) 2012, Martin Matuska <mm@FreeBSD.org>. All rights reserved.
28 * Copyright (c) 2014 Integros [integros.com]
29 * Copyright (c) 2017 Datto Inc.
30 */
31
32/* Portions Copyright 2010 Robert Milkowski */
33
34#ifndef	_SYS_FS_ZFS_H
35#define	_SYS_FS_ZFS_H
36
37#include <sys/types.h>
38#include <sys/ioccom.h>
39#include <sys/time.h>
40
41#ifdef	__cplusplus
42extern "C" {
43#endif
44
45/*
46 * Types and constants shared between userland and the kernel.
47 */
48
49/*
50 * Each dataset can be one of the following types.  These constants can be
51 * combined into masks that can be passed to various functions.
52 */
53typedef enum {
54	ZFS_TYPE_FILESYSTEM	= (1 << 0),
55	ZFS_TYPE_SNAPSHOT	= (1 << 1),
56	ZFS_TYPE_VOLUME		= (1 << 2),
57	ZFS_TYPE_POOL		= (1 << 3),
58	ZFS_TYPE_BOOKMARK	= (1 << 4)
59} zfs_type_t;
60
61/*
62 * NB: lzc_dataset_type should be updated whenever a new objset type is added,
63 * if it represents a real type of a dataset that can be created from userland.
64 */
65typedef enum dmu_objset_type {
66	DMU_OST_NONE,
67	DMU_OST_META,
68	DMU_OST_ZFS,
69	DMU_OST_ZVOL,
70	DMU_OST_OTHER,			/* For testing only! */
71	DMU_OST_ANY,			/* Be careful! */
72	DMU_OST_NUMTYPES
73} dmu_objset_type_t;
74
75#define	ZFS_TYPE_DATASET	\
76	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
77
78/*
79 * All of these include the terminating NUL byte.
80 */
81#define	ZAP_MAXNAMELEN 256
82#define	ZAP_MAXVALUELEN (1024 * 8)
83#define	ZAP_OLDMAXVALUELEN 1024
84#define	ZFS_MAX_DATASET_NAME_LEN 256
85
86/*
87 * Dataset properties are identified by these constants and must be added to
88 * the end of this list to ensure that external consumers are not affected
89 * by the change. If you make any changes to this list, be sure to update
90 * the property table in usr/src/common/zfs/zfs_prop.c.
91 */
92typedef enum {
93	ZFS_PROP_TYPE,
94	ZFS_PROP_CREATION,
95	ZFS_PROP_USED,
96	ZFS_PROP_AVAILABLE,
97	ZFS_PROP_REFERENCED,
98	ZFS_PROP_COMPRESSRATIO,
99	ZFS_PROP_MOUNTED,
100	ZFS_PROP_ORIGIN,
101	ZFS_PROP_QUOTA,
102	ZFS_PROP_RESERVATION,
103	ZFS_PROP_VOLSIZE,
104	ZFS_PROP_VOLBLOCKSIZE,
105	ZFS_PROP_RECORDSIZE,
106	ZFS_PROP_MOUNTPOINT,
107	ZFS_PROP_SHARENFS,
108	ZFS_PROP_CHECKSUM,
109	ZFS_PROP_COMPRESSION,
110	ZFS_PROP_ATIME,
111	ZFS_PROP_DEVICES,
112	ZFS_PROP_EXEC,
113	ZFS_PROP_SETUID,
114	ZFS_PROP_READONLY,
115	ZFS_PROP_ZONED,
116	ZFS_PROP_SNAPDIR,
117	ZFS_PROP_ACLMODE,
118	ZFS_PROP_ACLINHERIT,
119	ZFS_PROP_CREATETXG,		/* not exposed to the user */
120	ZFS_PROP_NAME,			/* not exposed to the user */
121	ZFS_PROP_CANMOUNT,
122	ZFS_PROP_ISCSIOPTIONS,		/* not exposed to the user */
123	ZFS_PROP_XATTR,
124	ZFS_PROP_NUMCLONES,		/* not exposed to the user */
125	ZFS_PROP_COPIES,
126	ZFS_PROP_VERSION,
127	ZFS_PROP_UTF8ONLY,
128	ZFS_PROP_NORMALIZE,
129	ZFS_PROP_CASE,
130	ZFS_PROP_VSCAN,
131	ZFS_PROP_NBMAND,
132	ZFS_PROP_SHARESMB,
133	ZFS_PROP_REFQUOTA,
134	ZFS_PROP_REFRESERVATION,
135	ZFS_PROP_GUID,
136	ZFS_PROP_PRIMARYCACHE,
137	ZFS_PROP_SECONDARYCACHE,
138	ZFS_PROP_USEDSNAP,
139	ZFS_PROP_USEDDS,
140	ZFS_PROP_USEDCHILD,
141	ZFS_PROP_USEDREFRESERV,
142	ZFS_PROP_USERACCOUNTING,	/* not exposed to the user */
143	ZFS_PROP_STMF_SHAREINFO,	/* not exposed to the user */
144	ZFS_PROP_DEFER_DESTROY,
145	ZFS_PROP_USERREFS,
146	ZFS_PROP_LOGBIAS,
147	ZFS_PROP_UNIQUE,		/* not exposed to the user */
148	ZFS_PROP_OBJSETID,		/* not exposed to the user */
149	ZFS_PROP_DEDUP,
150	ZFS_PROP_MLSLABEL,
151	ZFS_PROP_SYNC,
152	ZFS_PROP_REFRATIO,
153	ZFS_PROP_WRITTEN,
154	ZFS_PROP_CLONES,
155	ZFS_PROP_LOGICALUSED,
156	ZFS_PROP_LOGICALREFERENCED,
157	ZFS_PROP_INCONSISTENT,		/* not exposed to the user */
158	ZFS_PROP_VOLMODE,
159	ZFS_PROP_FILESYSTEM_LIMIT,
160	ZFS_PROP_SNAPSHOT_LIMIT,
161	ZFS_PROP_FILESYSTEM_COUNT,
162	ZFS_PROP_SNAPSHOT_COUNT,
163	ZFS_PROP_REDUNDANT_METADATA,
164	ZFS_PROP_PREV_SNAP,
165	ZFS_PROP_RECEIVE_RESUME_TOKEN,
166	ZFS_NUM_PROPS
167} zfs_prop_t;
168
169typedef enum {
170	ZFS_PROP_USERUSED,
171	ZFS_PROP_USERQUOTA,
172	ZFS_PROP_GROUPUSED,
173	ZFS_PROP_GROUPQUOTA,
174	ZFS_NUM_USERQUOTA_PROPS
175} zfs_userquota_prop_t;
176
177extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
178
179/*
180 * Pool properties are identified by these constants and must be added to the
181 * end of this list to ensure that external consumers are not affected
182 * by the change. If you make any changes to this list, be sure to update
183 * the property table in usr/src/common/zfs/zpool_prop.c.
184 */
185typedef enum {
186	ZPOOL_PROP_NAME,
187	ZPOOL_PROP_SIZE,
188	ZPOOL_PROP_CAPACITY,
189	ZPOOL_PROP_ALTROOT,
190	ZPOOL_PROP_HEALTH,
191	ZPOOL_PROP_GUID,
192	ZPOOL_PROP_VERSION,
193	ZPOOL_PROP_BOOTFS,
194	ZPOOL_PROP_DELEGATION,
195	ZPOOL_PROP_AUTOREPLACE,
196	ZPOOL_PROP_CACHEFILE,
197	ZPOOL_PROP_FAILUREMODE,
198	ZPOOL_PROP_LISTSNAPS,
199	ZPOOL_PROP_AUTOEXPAND,
200	ZPOOL_PROP_DEDUPDITTO,
201	ZPOOL_PROP_DEDUPRATIO,
202	ZPOOL_PROP_FREE,
203	ZPOOL_PROP_ALLOCATED,
204	ZPOOL_PROP_READONLY,
205	ZPOOL_PROP_COMMENT,
206	ZPOOL_PROP_EXPANDSZ,
207	ZPOOL_PROP_FREEING,
208	ZPOOL_PROP_FRAGMENTATION,
209	ZPOOL_PROP_LEAKED,
210	ZPOOL_PROP_MAXBLOCKSIZE,
211	ZPOOL_NUM_PROPS
212} zpool_prop_t;
213
214/* Small enough to not hog a whole line of printout in zpool(1M). */
215#define	ZPROP_MAX_COMMENT	32
216
217#define	ZPROP_CONT		-2
218#define	ZPROP_INVAL		-1
219
220#define	ZPROP_VALUE		"value"
221#define	ZPROP_SOURCE		"source"
222
223typedef enum {
224	ZPROP_SRC_NONE = 0x1,
225	ZPROP_SRC_DEFAULT = 0x2,
226	ZPROP_SRC_TEMPORARY = 0x4,
227	ZPROP_SRC_LOCAL = 0x8,
228	ZPROP_SRC_INHERITED = 0x10,
229	ZPROP_SRC_RECEIVED = 0x20
230} zprop_source_t;
231
232#define	ZPROP_SRC_ALL	0x3f
233
234#define	ZPROP_SOURCE_VAL_RECVD	"$recvd"
235#define	ZPROP_N_MORE_ERRORS	"N_MORE_ERRORS"
236/*
237 * Dataset flag implemented as a special entry in the props zap object
238 * indicating that the dataset has received properties on or after
239 * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
240 * just as it did in earlier versions, and thereafter, local properties are
241 * preserved.
242 */
243#define	ZPROP_HAS_RECVD		"$hasrecvd"
244
245typedef enum {
246	ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
247	ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
248} zprop_errflags_t;
249
250typedef int (*zprop_func)(int, void *);
251
252/*
253 * Properties to be set on the root file system of a new pool
254 * are stuffed into their own nvlist, which is then included in
255 * the properties nvlist with the pool properties.
256 */
257#define	ZPOOL_ROOTFS_PROPS	"root-props-nvl"
258
259/*
260 * Length of 'written@' and 'written#'
261 */
262#define	ZFS_WRITTEN_PROP_PREFIX_LEN	8
263
264/*
265 * Dataset property functions shared between libzfs and kernel.
266 */
267const char *zfs_prop_default_string(zfs_prop_t);
268uint64_t zfs_prop_default_numeric(zfs_prop_t);
269boolean_t zfs_prop_readonly(zfs_prop_t);
270boolean_t zfs_prop_visible(zfs_prop_t prop);
271boolean_t zfs_prop_inheritable(zfs_prop_t);
272boolean_t zfs_prop_setonce(zfs_prop_t);
273const char *zfs_prop_to_name(zfs_prop_t);
274zfs_prop_t zfs_name_to_prop(const char *);
275boolean_t zfs_prop_user(const char *);
276boolean_t zfs_prop_userquota(const char *);
277int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
278int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
279uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
280boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
281
282/*
283 * Pool property functions shared between libzfs and kernel.
284 */
285zpool_prop_t zpool_name_to_prop(const char *);
286const char *zpool_prop_to_name(zpool_prop_t);
287const char *zpool_prop_default_string(zpool_prop_t);
288uint64_t zpool_prop_default_numeric(zpool_prop_t);
289boolean_t zpool_prop_readonly(zpool_prop_t);
290boolean_t zpool_prop_feature(const char *);
291boolean_t zpool_prop_unsupported(const char *name);
292int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
293int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
294uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
295
296/*
297 * Definitions for the Delegation.
298 */
299typedef enum {
300	ZFS_DELEG_WHO_UNKNOWN = 0,
301	ZFS_DELEG_USER = 'u',
302	ZFS_DELEG_USER_SETS = 'U',
303	ZFS_DELEG_GROUP = 'g',
304	ZFS_DELEG_GROUP_SETS = 'G',
305	ZFS_DELEG_EVERYONE = 'e',
306	ZFS_DELEG_EVERYONE_SETS = 'E',
307	ZFS_DELEG_CREATE = 'c',
308	ZFS_DELEG_CREATE_SETS = 'C',
309	ZFS_DELEG_NAMED_SET = 's',
310	ZFS_DELEG_NAMED_SET_SETS = 'S'
311} zfs_deleg_who_type_t;
312
313typedef enum {
314	ZFS_DELEG_NONE = 0,
315	ZFS_DELEG_PERM_LOCAL = 1,
316	ZFS_DELEG_PERM_DESCENDENT = 2,
317	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
318	ZFS_DELEG_PERM_CREATE = 4
319} zfs_deleg_inherit_t;
320
321#define	ZFS_DELEG_PERM_UID	"uid"
322#define	ZFS_DELEG_PERM_GID	"gid"
323#define	ZFS_DELEG_PERM_GROUPS	"groups"
324
325#define	ZFS_MLSLABEL_DEFAULT	"none"
326
327#define	ZFS_SMB_ACL_SRC		"src"
328#define	ZFS_SMB_ACL_TARGET	"target"
329
330typedef enum {
331	ZFS_CANMOUNT_OFF = 0,
332	ZFS_CANMOUNT_ON = 1,
333	ZFS_CANMOUNT_NOAUTO = 2
334} zfs_canmount_type_t;
335
336typedef enum {
337	ZFS_LOGBIAS_LATENCY = 0,
338	ZFS_LOGBIAS_THROUGHPUT = 1
339} zfs_logbias_op_t;
340
341typedef enum zfs_share_op {
342	ZFS_SHARE_NFS = 0,
343	ZFS_UNSHARE_NFS = 1,
344	ZFS_SHARE_SMB = 2,
345	ZFS_UNSHARE_SMB = 3
346} zfs_share_op_t;
347
348typedef enum zfs_smb_acl_op {
349	ZFS_SMB_ACL_ADD,
350	ZFS_SMB_ACL_REMOVE,
351	ZFS_SMB_ACL_RENAME,
352	ZFS_SMB_ACL_PURGE
353} zfs_smb_acl_op_t;
354
355typedef enum zfs_cache_type {
356	ZFS_CACHE_NONE = 0,
357	ZFS_CACHE_METADATA = 1,
358	ZFS_CACHE_ALL = 2
359} zfs_cache_type_t;
360
361typedef enum {
362	ZFS_SYNC_STANDARD = 0,
363	ZFS_SYNC_ALWAYS = 1,
364	ZFS_SYNC_DISABLED = 2
365} zfs_sync_type_t;
366
367typedef enum {
368	ZFS_VOLMODE_DEFAULT = 0,
369	ZFS_VOLMODE_GEOM = 1,
370	ZFS_VOLMODE_DEV = 2,
371	ZFS_VOLMODE_NONE = 3
372} zfs_volmode_t;
373
374typedef enum {
375	ZFS_REDUNDANT_METADATA_ALL,
376	ZFS_REDUNDANT_METADATA_MOST
377} zfs_redundant_metadata_type_t;
378
379/*
380 * On-disk version number.
381 */
382#define	SPA_VERSION_1			1ULL
383#define	SPA_VERSION_2			2ULL
384#define	SPA_VERSION_3			3ULL
385#define	SPA_VERSION_4			4ULL
386#define	SPA_VERSION_5			5ULL
387#define	SPA_VERSION_6			6ULL
388#define	SPA_VERSION_7			7ULL
389#define	SPA_VERSION_8			8ULL
390#define	SPA_VERSION_9			9ULL
391#define	SPA_VERSION_10			10ULL
392#define	SPA_VERSION_11			11ULL
393#define	SPA_VERSION_12			12ULL
394#define	SPA_VERSION_13			13ULL
395#define	SPA_VERSION_14			14ULL
396#define	SPA_VERSION_15			15ULL
397#define	SPA_VERSION_16			16ULL
398#define	SPA_VERSION_17			17ULL
399#define	SPA_VERSION_18			18ULL
400#define	SPA_VERSION_19			19ULL
401#define	SPA_VERSION_20			20ULL
402#define	SPA_VERSION_21			21ULL
403#define	SPA_VERSION_22			22ULL
404#define	SPA_VERSION_23			23ULL
405#define	SPA_VERSION_24			24ULL
406#define	SPA_VERSION_25			25ULL
407#define	SPA_VERSION_26			26ULL
408#define	SPA_VERSION_27			27ULL
409#define	SPA_VERSION_28			28ULL
410#define	SPA_VERSION_5000		5000ULL
411
412/*
413 * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
414 * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
415 * and do the appropriate changes.  Also bump the version number in
416 * usr/src/grub/capability.
417 */
418#define	SPA_VERSION			SPA_VERSION_5000
419#define	SPA_VERSION_STRING		"5000"
420
421/*
422 * Symbolic names for the changes that caused a SPA_VERSION switch.
423 * Used in the code when checking for presence or absence of a feature.
424 * Feel free to define multiple symbolic names for each version if there
425 * were multiple changes to on-disk structures during that version.
426 *
427 * NOTE: When checking the current SPA_VERSION in your code, be sure
428 *       to use spa_version() since it reports the version of the
429 *       last synced uberblock.  Checking the in-flight version can
430 *       be dangerous in some cases.
431 */
432#define	SPA_VERSION_INITIAL		SPA_VERSION_1
433#define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
434#define	SPA_VERSION_SPARES		SPA_VERSION_3
435#define	SPA_VERSION_RAIDZ2		SPA_VERSION_3
436#define	SPA_VERSION_BPOBJ_ACCOUNT	SPA_VERSION_3
437#define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
438#define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
439#define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
440#define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
441#define	SPA_VERSION_BOOTFS		SPA_VERSION_6
442#define	SPA_VERSION_SLOGS		SPA_VERSION_7
443#define	SPA_VERSION_DELEGATED_PERMS	SPA_VERSION_8
444#define	SPA_VERSION_FUID		SPA_VERSION_9
445#define	SPA_VERSION_REFRESERVATION	SPA_VERSION_9
446#define	SPA_VERSION_REFQUOTA		SPA_VERSION_9
447#define	SPA_VERSION_UNIQUE_ACCURATE	SPA_VERSION_9
448#define	SPA_VERSION_L2CACHE		SPA_VERSION_10
449#define	SPA_VERSION_NEXT_CLONES		SPA_VERSION_11
450#define	SPA_VERSION_ORIGIN		SPA_VERSION_11
451#define	SPA_VERSION_DSL_SCRUB		SPA_VERSION_11
452#define	SPA_VERSION_SNAP_PROPS		SPA_VERSION_12
453#define	SPA_VERSION_USED_BREAKDOWN	SPA_VERSION_13
454#define	SPA_VERSION_PASSTHROUGH_X	SPA_VERSION_14
455#define	SPA_VERSION_USERSPACE		SPA_VERSION_15
456#define	SPA_VERSION_STMF_PROP		SPA_VERSION_16
457#define	SPA_VERSION_RAIDZ3		SPA_VERSION_17
458#define	SPA_VERSION_USERREFS		SPA_VERSION_18
459#define	SPA_VERSION_HOLES		SPA_VERSION_19
460#define	SPA_VERSION_ZLE_COMPRESSION	SPA_VERSION_20
461#define	SPA_VERSION_DEDUP		SPA_VERSION_21
462#define	SPA_VERSION_RECVD_PROPS		SPA_VERSION_22
463#define	SPA_VERSION_SLIM_ZIL		SPA_VERSION_23
464#define	SPA_VERSION_SA			SPA_VERSION_24
465#define	SPA_VERSION_SCAN		SPA_VERSION_25
466#define	SPA_VERSION_DIR_CLONES		SPA_VERSION_26
467#define	SPA_VERSION_DEADLISTS		SPA_VERSION_26
468#define	SPA_VERSION_FAST_SNAP		SPA_VERSION_27
469#define	SPA_VERSION_MULTI_REPLACE	SPA_VERSION_28
470#define	SPA_VERSION_BEFORE_FEATURES	SPA_VERSION_28
471#define	SPA_VERSION_FEATURES		SPA_VERSION_5000
472
473#define	SPA_VERSION_IS_SUPPORTED(v) \
474	(((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
475	((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
476
477/*
478 * ZPL version - rev'd whenever an incompatible on-disk format change
479 * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
480 * also update the version_table[] and help message in zfs_prop.c.
481 *
482 * When changing, be sure to teach GRUB how to read the new format!
483 * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
484 */
485#define	ZPL_VERSION_1			1ULL
486#define	ZPL_VERSION_2			2ULL
487#define	ZPL_VERSION_3			3ULL
488#define	ZPL_VERSION_4			4ULL
489#define	ZPL_VERSION_5			5ULL
490#define	ZPL_VERSION			ZPL_VERSION_5
491#define	ZPL_VERSION_STRING		"5"
492
493#define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
494#define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
495#define	ZPL_VERSION_FUID		ZPL_VERSION_3
496#define	ZPL_VERSION_NORMALIZATION	ZPL_VERSION_3
497#define	ZPL_VERSION_SYSATTR		ZPL_VERSION_3
498#define	ZPL_VERSION_USERSPACE		ZPL_VERSION_4
499#define	ZPL_VERSION_SA			ZPL_VERSION_5
500
501/* Rewind request information */
502#define	ZPOOL_NO_REWIND		1  /* No policy - default behavior */
503#define	ZPOOL_NEVER_REWIND	2  /* Do not search for best txg or rewind */
504#define	ZPOOL_TRY_REWIND	4  /* Search for best txg, but do not rewind */
505#define	ZPOOL_DO_REWIND		8  /* Rewind to best txg w/in deferred frees */
506#define	ZPOOL_EXTREME_REWIND	16 /* Allow extreme measures to find best txg */
507#define	ZPOOL_REWIND_MASK	28 /* All the possible rewind bits */
508#define	ZPOOL_REWIND_POLICIES	31 /* All the possible policy bits */
509
510typedef struct zpool_rewind_policy {
511	uint32_t	zrp_request;	/* rewind behavior requested */
512	uint64_t	zrp_maxmeta;	/* max acceptable meta-data errors */
513	uint64_t	zrp_maxdata;	/* max acceptable data errors */
514	uint64_t	zrp_txg;	/* specific txg to load */
515} zpool_rewind_policy_t;
516
517/*
518 * The following are configuration names used in the nvlist describing a pool's
519 * configuration.
520 */
521#define	ZPOOL_CONFIG_VERSION		"version"
522#define	ZPOOL_CONFIG_POOL_NAME		"name"
523#define	ZPOOL_CONFIG_POOL_STATE		"state"
524#define	ZPOOL_CONFIG_POOL_TXG		"txg"
525#define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
526#define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
527#define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
528#define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
529#define	ZPOOL_CONFIG_TYPE		"type"
530#define	ZPOOL_CONFIG_CHILDREN		"children"
531#define	ZPOOL_CONFIG_ID			"id"
532#define	ZPOOL_CONFIG_GUID		"guid"
533#define	ZPOOL_CONFIG_PATH		"path"
534#define	ZPOOL_CONFIG_DEVID		"devid"
535#define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
536#define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
537#define	ZPOOL_CONFIG_ASHIFT		"ashift"
538#define	ZPOOL_CONFIG_ASIZE		"asize"
539#define	ZPOOL_CONFIG_DTL		"DTL"
540#define	ZPOOL_CONFIG_SCAN_STATS		"scan_stats"	/* not stored on disk */
541#define	ZPOOL_CONFIG_VDEV_STATS		"vdev_stats"	/* not stored on disk */
542#define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
543#define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
544#define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
545#define	ZPOOL_CONFIG_SPARES		"spares"
546#define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
547#define	ZPOOL_CONFIG_NPARITY		"nparity"
548#define	ZPOOL_CONFIG_HOSTID		"hostid"
549#define	ZPOOL_CONFIG_HOSTNAME		"hostname"
550#define	ZPOOL_CONFIG_LOADED_TIME	"initial_load_time"
551#define	ZPOOL_CONFIG_UNSPARE		"unspare"
552#define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
553#define	ZPOOL_CONFIG_IS_LOG		"is_log"
554#define	ZPOOL_CONFIG_L2CACHE		"l2cache"
555#define	ZPOOL_CONFIG_HOLE_ARRAY		"hole_array"
556#define	ZPOOL_CONFIG_VDEV_CHILDREN	"vdev_children"
557#define	ZPOOL_CONFIG_IS_HOLE		"is_hole"
558#define	ZPOOL_CONFIG_DDT_HISTOGRAM	"ddt_histogram"
559#define	ZPOOL_CONFIG_DDT_OBJ_STATS	"ddt_object_stats"
560#define	ZPOOL_CONFIG_DDT_STATS		"ddt_stats"
561#define	ZPOOL_CONFIG_SPLIT		"splitcfg"
562#define	ZPOOL_CONFIG_ORIG_GUID		"orig_guid"
563#define	ZPOOL_CONFIG_SPLIT_GUID		"split_guid"
564#define	ZPOOL_CONFIG_SPLIT_LIST		"guid_list"
565#define	ZPOOL_CONFIG_REMOVING		"removing"
566#define	ZPOOL_CONFIG_RESILVER_TXG	"resilver_txg"
567#define	ZPOOL_CONFIG_COMMENT		"comment"
568#define	ZPOOL_CONFIG_SUSPENDED		"suspended"	/* not stored on disk */
569#define	ZPOOL_CONFIG_TIMESTAMP		"timestamp"	/* not stored on disk */
570#define	ZPOOL_CONFIG_BOOTFS		"bootfs"	/* not stored on disk */
571#define	ZPOOL_CONFIG_MISSING_DEVICES	"missing_vdevs"	/* not stored on disk */
572#define	ZPOOL_CONFIG_LOAD_INFO		"load_info"	/* not stored on disk */
573#define	ZPOOL_CONFIG_REWIND_INFO	"rewind_info"	/* not stored on disk */
574#define	ZPOOL_CONFIG_UNSUP_FEAT		"unsup_feat"	/* not stored on disk */
575#define	ZPOOL_CONFIG_ENABLED_FEAT	"enabled_feat"	/* not stored on disk */
576#define	ZPOOL_CONFIG_CAN_RDONLY		"can_rdonly"	/* not stored on disk */
577#define	ZPOOL_CONFIG_FEATURES_FOR_READ	"features_for_read"
578#define	ZPOOL_CONFIG_FEATURE_STATS	"feature_stats"	/* not stored on disk */
579#define	ZPOOL_CONFIG_VDEV_TOP_ZAP	"com.delphix:vdev_zap_top"
580#define	ZPOOL_CONFIG_VDEV_LEAF_ZAP	"com.delphix:vdev_zap_leaf"
581#define	ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS	"com.delphix:has_per_vdev_zaps"
582/*
583 * The persistent vdev state is stored as separate values rather than a single
584 * 'vdev_state' entry.  This is because a device can be in multiple states, such
585 * as offline and degraded.
586 */
587#define	ZPOOL_CONFIG_OFFLINE		"offline"
588#define	ZPOOL_CONFIG_FAULTED		"faulted"
589#define	ZPOOL_CONFIG_DEGRADED		"degraded"
590#define	ZPOOL_CONFIG_REMOVED		"removed"
591#define	ZPOOL_CONFIG_FRU		"fru"
592#define	ZPOOL_CONFIG_AUX_STATE		"aux_state"
593
594/* Rewind policy parameters */
595#define	ZPOOL_REWIND_POLICY		"rewind-policy"
596#define	ZPOOL_REWIND_REQUEST		"rewind-request"
597#define	ZPOOL_REWIND_REQUEST_TXG	"rewind-request-txg"
598#define	ZPOOL_REWIND_META_THRESH	"rewind-meta-thresh"
599#define	ZPOOL_REWIND_DATA_THRESH	"rewind-data-thresh"
600
601/* Rewind data discovered */
602#define	ZPOOL_CONFIG_LOAD_TIME		"rewind_txg_ts"
603#define	ZPOOL_CONFIG_LOAD_DATA_ERRORS	"verify_data_errors"
604#define	ZPOOL_CONFIG_REWIND_TIME	"seconds_of_rewind"
605
606#define	VDEV_TYPE_ROOT			"root"
607#define	VDEV_TYPE_MIRROR		"mirror"
608#define	VDEV_TYPE_REPLACING		"replacing"
609#define	VDEV_TYPE_RAIDZ			"raidz"
610#define	VDEV_TYPE_DISK			"disk"
611#define	VDEV_TYPE_FILE			"file"
612#define	VDEV_TYPE_MISSING		"missing"
613#define	VDEV_TYPE_HOLE			"hole"
614#define	VDEV_TYPE_SPARE			"spare"
615#define	VDEV_TYPE_LOG			"log"
616#define	VDEV_TYPE_L2CACHE		"l2cache"
617
618/*
619 * This is needed in userland to report the minimum necessary device size.
620 *
621 * Note that the zfs test suite uses 64MB vdevs.
622 */
623#define	SPA_MINDEVSIZE		(64ULL << 20)
624
625/*
626 * Set if the fragmentation has not yet been calculated. This can happen
627 * because the space maps have not been upgraded or the histogram feature
628 * is not enabled.
629 */
630#define	ZFS_FRAG_INVALID	UINT64_MAX
631
632/*
633 * The location of the pool configuration repository, shared between kernel and
634 * userland.
635 */
636#define	ZPOOL_CACHE		"/boot/zfs/zpool.cache"
637
638/*
639 * vdev states are ordered from least to most healthy.
640 * A vdev that's CANT_OPEN or below is considered unusable.
641 */
642typedef enum vdev_state {
643	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
644	VDEV_STATE_CLOSED,	/* Not currently open			*/
645	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
646	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
647	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
648	VDEV_STATE_FAULTED,	/* External request to fault device	*/
649	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
650	VDEV_STATE_HEALTHY	/* Presumed good			*/
651} vdev_state_t;
652
653#define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
654
655/*
656 * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
657 * of the vdev stats structure uses these constants to distinguish why.
658 */
659typedef enum vdev_aux {
660	VDEV_AUX_NONE,		/* no error				*/
661	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
662	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
663	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
664	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
665	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
666	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
667	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
668	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
669	VDEV_AUX_UNSUP_FEAT,	/* unsupported features			*/
670	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
671	VDEV_AUX_ERR_EXCEEDED,	/* too many errors			*/
672	VDEV_AUX_IO_FAILURE,	/* experienced I/O failure		*/
673	VDEV_AUX_BAD_LOG,	/* cannot read log chain(s)		*/
674	VDEV_AUX_EXTERNAL,	/* external diagnosis			*/
675	VDEV_AUX_SPLIT_POOL,	/* vdev was split off into another pool	*/
676	VDEV_AUX_ASHIFT_TOO_BIG /* vdev's min block size is too large   */
677} vdev_aux_t;
678
679/*
680 * pool state.  The following states are written to disk as part of the normal
681 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
682 * states are software abstractions used at various levels to communicate
683 * pool state.
684 */
685typedef enum pool_state {
686	POOL_STATE_ACTIVE = 0,		/* In active use		*/
687	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
688	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
689	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
690	POOL_STATE_L2CACHE,		/* Level 2 ARC device		*/
691	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
692	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
693	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
694} pool_state_t;
695
696/*
697 * Scan Functions.
698 */
699typedef enum pool_scan_func {
700	POOL_SCAN_NONE,
701	POOL_SCAN_SCRUB,
702	POOL_SCAN_RESILVER,
703	POOL_SCAN_FUNCS
704} pool_scan_func_t;
705
706/*
707 * Used to control scrub pause and resume.
708 */
709typedef enum pool_scrub_cmd {
710	POOL_SCRUB_NORMAL = 0,
711	POOL_SCRUB_PAUSE,
712	POOL_SCRUB_FLAGS_END
713} pool_scrub_cmd_t;
714
715
716/*
717 * ZIO types.  Needed to interpret vdev statistics below.
718 */
719typedef enum zio_type {
720	ZIO_TYPE_NULL = 0,
721	ZIO_TYPE_READ,
722	ZIO_TYPE_WRITE,
723	ZIO_TYPE_FREE,
724	ZIO_TYPE_CLAIM,
725	ZIO_TYPE_IOCTL,
726	ZIO_TYPES
727} zio_type_t;
728
729/*
730 * Pool statistics.  Note: all fields should be 64-bit because this
731 * is passed between kernel and userland as an nvlist uint64 array.
732 */
733typedef struct pool_scan_stat {
734	/* values stored on disk */
735	uint64_t	pss_func;	/* pool_scan_func_t */
736	uint64_t	pss_state;	/* dsl_scan_state_t */
737	uint64_t	pss_start_time;	/* scan start time */
738	uint64_t	pss_end_time;	/* scan end time */
739	uint64_t	pss_to_examine;	/* total bytes to scan */
740	uint64_t	pss_examined;	/* total examined bytes	*/
741	uint64_t	pss_to_process; /* total bytes to process */
742	uint64_t	pss_processed;	/* total processed bytes */
743	uint64_t	pss_errors;	/* scan errors	*/
744
745	/* values not stored on disk */
746	uint64_t	pss_pass_exam;	/* examined bytes per scan pass */
747	uint64_t	pss_pass_start;	/* start time of a scan pass */
748	uint64_t	pss_pass_scrub_pause; /* pause time of a scurb pass */
749	/* cumulative time scrub spent paused, needed for rate calculation */
750	uint64_t	pss_pass_scrub_spent_paused;
751} pool_scan_stat_t;
752
753typedef enum dsl_scan_state {
754	DSS_NONE,
755	DSS_SCANNING,
756	DSS_FINISHED,
757	DSS_CANCELED,
758	DSS_NUM_STATES
759} dsl_scan_state_t;
760
761
762/*
763 * Vdev statistics.  Note: all fields should be 64-bit because this
764 * is passed between kernel and userland as an nvlist uint64 array.
765 */
766typedef struct vdev_stat {
767	hrtime_t	vs_timestamp;		/* time since vdev load	*/
768	uint64_t	vs_state;		/* vdev state		*/
769	uint64_t	vs_aux;			/* see vdev_aux_t	*/
770	uint64_t	vs_alloc;		/* space allocated	*/
771	uint64_t	vs_space;		/* total capacity	*/
772	uint64_t	vs_dspace;		/* deflated capacity	*/
773	uint64_t	vs_rsize;		/* replaceable dev size */
774	uint64_t	vs_esize;		/* expandable dev size */
775	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
776	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
777	uint64_t	vs_read_errors;		/* read errors		*/
778	uint64_t	vs_write_errors;	/* write errors		*/
779	uint64_t	vs_checksum_errors;	/* checksum errors	*/
780	uint64_t	vs_self_healed;		/* self-healed bytes	*/
781	uint64_t	vs_scan_removing;	/* removing?	*/
782	uint64_t	vs_scan_processed;	/* scan processed bytes	*/
783 	uint64_t	vs_configured_ashift;	/* TLV vdev_ashift      */
784 	uint64_t	vs_logical_ashift;	/* vdev_logical_ashift  */
785 	uint64_t	vs_physical_ashift;	/* vdev_physical_ashift */
786	uint64_t	vs_fragmentation;	/* device fragmentation */
787} vdev_stat_t;
788#define VDEV_STAT_VALID(field, uint64_t_field_count) \
789    ((uint64_t_field_count * sizeof(uint64_t)) >= \
790     (offsetof(vdev_stat_t, field) + sizeof(((vdev_stat_t *)NULL)->field)))
791
792/*
793 * DDT statistics.  Note: all fields should be 64-bit because this
794 * is passed between kernel and userland as an nvlist uint64 array.
795 */
796typedef struct ddt_object {
797	uint64_t	ddo_count;	/* number of elments in ddt 	*/
798	uint64_t	ddo_dspace;	/* size of ddt on disk		*/
799	uint64_t	ddo_mspace;	/* size of ddt in-core		*/
800} ddt_object_t;
801
802typedef struct ddt_stat {
803	uint64_t	dds_blocks;	/* blocks			*/
804	uint64_t	dds_lsize;	/* logical size			*/
805	uint64_t	dds_psize;	/* physical size		*/
806	uint64_t	dds_dsize;	/* deflated allocated size	*/
807	uint64_t	dds_ref_blocks;	/* referenced blocks		*/
808	uint64_t	dds_ref_lsize;	/* referenced lsize * refcnt	*/
809	uint64_t	dds_ref_psize;	/* referenced psize * refcnt	*/
810	uint64_t	dds_ref_dsize;	/* referenced dsize * refcnt	*/
811} ddt_stat_t;
812
813typedef struct ddt_histogram {
814	ddt_stat_t	ddh_stat[64];	/* power-of-two histogram buckets */
815} ddt_histogram_t;
816
817#define	ZVOL_DRIVER	"zvol"
818#define	ZFS_DRIVER	"zfs"
819#define	ZFS_DEV_NAME	"zfs"
820#define	ZFS_DEV		"/dev/" ZFS_DEV_NAME
821#define	ZFS_DISK_ROOT	"/dev/dsk"
822#define	ZFS_DISK_ROOTD	ZFS_DISK_ROOT "/"
823#define	ZFS_RDISK_ROOT	"/dev/rdsk"
824#define	ZFS_RDISK_ROOTD	ZFS_RDISK_ROOT "/"
825
826/* general zvol path */
827#define	ZVOL_DIR		"/dev/zvol"
828/* expansion */
829#define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zfs@0:"
830/* for dump and swap */
831#define	ZVOL_FULL_DEV_DIR	ZVOL_DIR "/dsk/"
832#define	ZVOL_FULL_RDEV_DIR	ZVOL_DIR "/rdsk/"
833
834#define	ZVOL_PROP_NAME		"name"
835#define	ZVOL_DEFAULT_BLOCKSIZE	8192
836
837/*
838 * /dev/zfs ioctl numbers.
839 */
840typedef enum zfs_ioc {
841	ZFS_IOC_FIRST =	0,
842	ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,
843	ZFS_IOC_POOL_DESTROY,
844	ZFS_IOC_POOL_IMPORT,
845	ZFS_IOC_POOL_EXPORT,
846	ZFS_IOC_POOL_CONFIGS,
847	ZFS_IOC_POOL_STATS,
848	ZFS_IOC_POOL_TRYIMPORT,
849	ZFS_IOC_POOL_SCAN,
850	ZFS_IOC_POOL_FREEZE,
851	ZFS_IOC_POOL_UPGRADE,
852	ZFS_IOC_POOL_GET_HISTORY,
853	ZFS_IOC_VDEV_ADD,
854	ZFS_IOC_VDEV_REMOVE,
855	ZFS_IOC_VDEV_SET_STATE,
856	ZFS_IOC_VDEV_ATTACH,
857	ZFS_IOC_VDEV_DETACH,
858	ZFS_IOC_VDEV_SETPATH,
859	ZFS_IOC_VDEV_SETFRU,
860	ZFS_IOC_OBJSET_STATS,
861	ZFS_IOC_OBJSET_ZPLPROPS,
862	ZFS_IOC_DATASET_LIST_NEXT,
863	ZFS_IOC_SNAPSHOT_LIST_NEXT,
864	ZFS_IOC_SET_PROP,
865	ZFS_IOC_CREATE,
866	ZFS_IOC_DESTROY,
867	ZFS_IOC_ROLLBACK,
868	ZFS_IOC_RENAME,
869	ZFS_IOC_RECV,
870	ZFS_IOC_SEND,
871	ZFS_IOC_INJECT_FAULT,
872	ZFS_IOC_CLEAR_FAULT,
873	ZFS_IOC_INJECT_LIST_NEXT,
874	ZFS_IOC_ERROR_LOG,
875	ZFS_IOC_CLEAR,
876	ZFS_IOC_PROMOTE,
877	ZFS_IOC_DESTROY_SNAPS,
878	ZFS_IOC_SNAPSHOT,
879	ZFS_IOC_DSOBJ_TO_DSNAME,
880	ZFS_IOC_OBJ_TO_PATH,
881	ZFS_IOC_POOL_SET_PROPS,
882	ZFS_IOC_POOL_GET_PROPS,
883	ZFS_IOC_SET_FSACL,
884	ZFS_IOC_GET_FSACL,
885	ZFS_IOC_SHARE,
886	ZFS_IOC_INHERIT_PROP,
887	ZFS_IOC_SMB_ACL,
888	ZFS_IOC_USERSPACE_ONE,
889	ZFS_IOC_USERSPACE_MANY,
890	ZFS_IOC_USERSPACE_UPGRADE,
891	ZFS_IOC_HOLD,
892	ZFS_IOC_RELEASE,
893	ZFS_IOC_GET_HOLDS,
894	ZFS_IOC_OBJSET_RECVD_PROPS,
895	ZFS_IOC_VDEV_SPLIT,
896	ZFS_IOC_NEXT_OBJ,
897	ZFS_IOC_DIFF,
898	ZFS_IOC_TMP_SNAPSHOT,
899	ZFS_IOC_OBJ_TO_STATS,
900	ZFS_IOC_JAIL,
901	ZFS_IOC_UNJAIL,
902	ZFS_IOC_POOL_REGUID,
903	ZFS_IOC_SPACE_WRITTEN,
904	ZFS_IOC_SPACE_SNAPS,
905	ZFS_IOC_SEND_PROGRESS,
906	ZFS_IOC_POOL_REOPEN,
907	ZFS_IOC_LOG_HISTORY,
908	ZFS_IOC_SEND_NEW,
909	ZFS_IOC_SEND_SPACE,
910	ZFS_IOC_CLONE,
911	ZFS_IOC_BOOKMARK,
912	ZFS_IOC_GET_BOOKMARKS,
913	ZFS_IOC_DESTROY_BOOKMARKS,
914#ifdef __FreeBSD__
915	ZFS_IOC_NEXTBOOT,
916#endif
917	ZFS_IOC_CHANNEL_PROGRAM,
918	ZFS_IOC_LAST
919} zfs_ioc_t;
920
921/*
922 * Internal SPA load state.  Used by FMA diagnosis engine.
923 */
924typedef enum {
925	SPA_LOAD_NONE,		/* no load in progress	*/
926	SPA_LOAD_OPEN,		/* normal open		*/
927	SPA_LOAD_IMPORT,	/* import in progress	*/
928	SPA_LOAD_TRYIMPORT,	/* tryimport in progress */
929	SPA_LOAD_RECOVER,	/* recovery requested	*/
930	SPA_LOAD_ERROR,		/* load failed		*/
931	SPA_LOAD_CREATE		/* creation in progress */
932} spa_load_state_t;
933
934/*
935 * Bookmark name values.
936 */
937#define	ZPOOL_ERR_LIST		"error list"
938#define	ZPOOL_ERR_DATASET	"dataset"
939#define	ZPOOL_ERR_OBJECT	"object"
940
941#define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
942
943/*
944 * The following are names used in the nvlist describing
945 * the pool's history log.
946 */
947#define	ZPOOL_HIST_RECORD	"history record"
948#define	ZPOOL_HIST_TIME		"history time"
949#define	ZPOOL_HIST_CMD		"history command"
950#define	ZPOOL_HIST_WHO		"history who"
951#define	ZPOOL_HIST_ZONE		"history zone"
952#define	ZPOOL_HIST_HOST		"history hostname"
953#define	ZPOOL_HIST_TXG		"history txg"
954#define	ZPOOL_HIST_INT_EVENT	"history internal event"
955#define	ZPOOL_HIST_INT_STR	"history internal str"
956#define	ZPOOL_HIST_INT_NAME	"internal_name"
957#define	ZPOOL_HIST_IOCTL	"ioctl"
958#define	ZPOOL_HIST_INPUT_NVL	"in_nvl"
959#define	ZPOOL_HIST_OUTPUT_NVL	"out_nvl"
960#define	ZPOOL_HIST_DSNAME	"dsname"
961#define	ZPOOL_HIST_DSID		"dsid"
962#define	ZPOOL_HIST_ERRNO	"errno"
963
964/*
965 * Flags for ZFS_IOC_VDEV_SET_STATE
966 */
967#define	ZFS_ONLINE_CHECKREMOVE	0x1
968#define	ZFS_ONLINE_UNSPARE	0x2
969#define	ZFS_ONLINE_FORCEFAULT	0x4
970#define	ZFS_ONLINE_EXPAND	0x8
971#define	ZFS_OFFLINE_TEMPORARY	0x1
972
973/*
974 * Flags for ZFS_IOC_POOL_IMPORT
975 */
976#define	ZFS_IMPORT_NORMAL	0x0
977#define	ZFS_IMPORT_VERBATIM	0x1
978#define	ZFS_IMPORT_ANY_HOST	0x2
979#define	ZFS_IMPORT_MISSING_LOG	0x4
980#define	ZFS_IMPORT_ONLY		0x8
981
982/*
983 * Channel program argument/return nvlist keys and defaults.
984 */
985#define	ZCP_ARG_PROGRAM		"program"
986#define	ZCP_ARG_ARGLIST		"arg"
987#define	ZCP_ARG_INSTRLIMIT	"instrlimit"
988#define	ZCP_ARG_MEMLIMIT	"memlimit"
989
990#define	ZCP_ARG_CLIARGV		"argv"
991
992#define	ZCP_RET_ERROR		"error"
993#define	ZCP_RET_RETURN		"return"
994
995#define	ZCP_DEFAULT_INSTRLIMIT	(10 * 1000 * 1000)
996#define	ZCP_MAX_INSTRLIMIT	(10 * ZCP_DEFAULT_INSTRLIMIT)
997#define	ZCP_DEFAULT_MEMLIMIT	(10 * 1024 * 1024)
998#define	ZCP_MAX_MEMLIMIT	(10 * ZCP_DEFAULT_MEMLIMIT)
999
1000/*
1001 * Sysevent payload members.  ZFS will generate the following sysevents with the
1002 * given payloads:
1003 *
1004 *	ESC_ZFS_RESILVER_START
1005 *	ESC_ZFS_RESILVER_END
1006 *	ESC_ZFS_POOL_DESTROY
1007 *	ESC_ZFS_POOL_REGUID
1008 *
1009 *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
1010 *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
1011 *
1012 *	ESC_ZFS_VDEV_REMOVE
1013 *	ESC_ZFS_VDEV_CLEAR
1014 *	ESC_ZFS_VDEV_CHECK
1015 *
1016 *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
1017 *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
1018 *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
1019 *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
1020 */
1021#define	ZFS_EV_POOL_NAME	"pool_name"
1022#define	ZFS_EV_POOL_GUID	"pool_guid"
1023#define	ZFS_EV_VDEV_PATH	"vdev_path"
1024#define	ZFS_EV_VDEV_GUID	"vdev_guid"
1025
1026#ifdef	__cplusplus
1027}
1028#endif
1029
1030#endif	/* _SYS_FS_ZFS_H */
1031