xref: /freebsd/sys/contrib/openzfs/include/sys/fs/zfs.h (revision 1719886f)
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 https://opensource.org/licenses/CDDL-1.0.
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, 2024 by Delphix. All rights reserved.
25  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
26  * Copyright (c) 2013, 2017 Joyent, Inc. All rights reserved.
27  * Copyright (c) 2014 Integros [integros.com]
28  * Copyright (c) 2017, Intel Corporation.
29  * Copyright (c) 2019 Datto Inc.
30  * Portions Copyright 2010 Robert Milkowski
31  * Copyright (c) 2021, Colm Buckley <colm@tuatha.org>
32  * Copyright (c) 2022 Hewlett Packard Enterprise Development LP.
33  */
34 
35 #ifndef	_SYS_FS_ZFS_H
36 #define	_SYS_FS_ZFS_H extern __attribute__((visibility("default")))
37 
38 #include <sys/time.h>
39 #include <sys/zio_priority.h>
40 
41 #ifdef	__cplusplus
42 extern "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  */
53 typedef enum {
54 	ZFS_TYPE_INVALID	= 0,
55 	ZFS_TYPE_FILESYSTEM	= (1 << 0),
56 	ZFS_TYPE_SNAPSHOT	= (1 << 1),
57 	ZFS_TYPE_VOLUME		= (1 << 2),
58 	ZFS_TYPE_POOL		= (1 << 3),
59 	ZFS_TYPE_BOOKMARK	= (1 << 4),
60 	ZFS_TYPE_VDEV		= (1 << 5),
61 } zfs_type_t;
62 
63 /*
64  * NB: lzc_dataset_type should be updated whenever a new objset type is added,
65  * if it represents a real type of a dataset that can be created from userland.
66  */
67 typedef enum dmu_objset_type {
68 	DMU_OST_NONE,
69 	DMU_OST_META,
70 	DMU_OST_ZFS,
71 	DMU_OST_ZVOL,
72 	DMU_OST_OTHER,			/* For testing only! */
73 	DMU_OST_ANY,			/* Be careful! */
74 	DMU_OST_NUMTYPES
75 } dmu_objset_type_t;
76 
77 #define	ZFS_TYPE_DATASET	\
78 	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
79 
80 /*
81  * All of these include the terminating NUL byte.
82  */
83 #define	ZAP_MAXNAMELEN 256
84 #define	ZAP_MAXVALUELEN (1024 * 8)
85 #define	ZAP_OLDMAXVALUELEN 1024
86 #define	ZFS_MAX_DATASET_NAME_LEN 256
87 
88 /*
89  * Dataset properties are identified by these constants and must be added to
90  * the end of this list to ensure that external consumers are not affected
91  * by the change. If you make any changes to this list, be sure to update
92  * the property table in module/zcommon/zfs_prop.c.
93  */
94 typedef enum {
95 	ZPROP_CONT = -2,
96 	ZPROP_INVAL = -1,
97 	ZPROP_USERPROP = ZPROP_INVAL,
98 	ZFS_PROP_TYPE = 0,
99 	ZFS_PROP_CREATION,
100 	ZFS_PROP_USED,
101 	ZFS_PROP_AVAILABLE,
102 	ZFS_PROP_REFERENCED,
103 	ZFS_PROP_COMPRESSRATIO,
104 	ZFS_PROP_MOUNTED,
105 	ZFS_PROP_ORIGIN,
106 	ZFS_PROP_QUOTA,
107 	ZFS_PROP_RESERVATION,
108 	ZFS_PROP_VOLSIZE,
109 	ZFS_PROP_VOLBLOCKSIZE,
110 	ZFS_PROP_RECORDSIZE,
111 	ZFS_PROP_MOUNTPOINT,
112 	ZFS_PROP_SHARENFS,
113 	ZFS_PROP_CHECKSUM,
114 	ZFS_PROP_COMPRESSION,
115 	ZFS_PROP_ATIME,
116 	ZFS_PROP_DEVICES,
117 	ZFS_PROP_EXEC,
118 	ZFS_PROP_SETUID,
119 	ZFS_PROP_READONLY,
120 	ZFS_PROP_ZONED,
121 	ZFS_PROP_SNAPDIR,
122 	ZFS_PROP_ACLMODE,
123 	ZFS_PROP_ACLINHERIT,
124 	ZFS_PROP_CREATETXG,
125 	ZFS_PROP_NAME,			/* not exposed to the user */
126 	ZFS_PROP_CANMOUNT,
127 	ZFS_PROP_ISCSIOPTIONS,		/* not exposed to the user */
128 	ZFS_PROP_XATTR,
129 	ZFS_PROP_NUMCLONES,		/* not exposed to the user */
130 	ZFS_PROP_COPIES,
131 	ZFS_PROP_VERSION,
132 	ZFS_PROP_UTF8ONLY,
133 	ZFS_PROP_NORMALIZE,
134 	ZFS_PROP_CASE,
135 	ZFS_PROP_VSCAN,
136 	ZFS_PROP_NBMAND,
137 	ZFS_PROP_SHARESMB,
138 	ZFS_PROP_REFQUOTA,
139 	ZFS_PROP_REFRESERVATION,
140 	ZFS_PROP_GUID,
141 	ZFS_PROP_PRIMARYCACHE,
142 	ZFS_PROP_SECONDARYCACHE,
143 	ZFS_PROP_USEDSNAP,
144 	ZFS_PROP_USEDDS,
145 	ZFS_PROP_USEDCHILD,
146 	ZFS_PROP_USEDREFRESERV,
147 	ZFS_PROP_USERACCOUNTING,	/* not exposed to the user */
148 	ZFS_PROP_STMF_SHAREINFO,	/* not exposed to the user */
149 	ZFS_PROP_DEFER_DESTROY,
150 	ZFS_PROP_USERREFS,
151 	ZFS_PROP_LOGBIAS,
152 	ZFS_PROP_UNIQUE,		/* not exposed to the user */
153 	ZFS_PROP_OBJSETID,
154 	ZFS_PROP_DEDUP,
155 	ZFS_PROP_MLSLABEL,
156 	ZFS_PROP_SYNC,
157 	ZFS_PROP_DNODESIZE,
158 	ZFS_PROP_REFRATIO,
159 	ZFS_PROP_WRITTEN,
160 	ZFS_PROP_CLONES,
161 	ZFS_PROP_LOGICALUSED,
162 	ZFS_PROP_LOGICALREFERENCED,
163 	ZFS_PROP_INCONSISTENT,		/* not exposed to the user */
164 	ZFS_PROP_VOLMODE,
165 	ZFS_PROP_FILESYSTEM_LIMIT,
166 	ZFS_PROP_SNAPSHOT_LIMIT,
167 	ZFS_PROP_FILESYSTEM_COUNT,
168 	ZFS_PROP_SNAPSHOT_COUNT,
169 	ZFS_PROP_SNAPDEV,
170 	ZFS_PROP_ACLTYPE,
171 	ZFS_PROP_SELINUX_CONTEXT,
172 	ZFS_PROP_SELINUX_FSCONTEXT,
173 	ZFS_PROP_SELINUX_DEFCONTEXT,
174 	ZFS_PROP_SELINUX_ROOTCONTEXT,
175 	ZFS_PROP_RELATIME,
176 	ZFS_PROP_REDUNDANT_METADATA,
177 	ZFS_PROP_OVERLAY,
178 	ZFS_PROP_PREV_SNAP,
179 	ZFS_PROP_RECEIVE_RESUME_TOKEN,
180 	ZFS_PROP_ENCRYPTION,
181 	ZFS_PROP_KEYLOCATION,
182 	ZFS_PROP_KEYFORMAT,
183 	ZFS_PROP_PBKDF2_SALT,
184 	ZFS_PROP_PBKDF2_ITERS,
185 	ZFS_PROP_ENCRYPTION_ROOT,
186 	ZFS_PROP_KEY_GUID,
187 	ZFS_PROP_KEYSTATUS,
188 	ZFS_PROP_REMAPTXG,		/* obsolete - no longer used */
189 	ZFS_PROP_SPECIAL_SMALL_BLOCKS,
190 	ZFS_PROP_IVSET_GUID,		/* not exposed to the user */
191 	ZFS_PROP_REDACTED,
192 	ZFS_PROP_REDACT_SNAPS,
193 	ZFS_PROP_SNAPSHOTS_CHANGED,
194 	ZFS_PROP_PREFETCH,
195 	ZFS_PROP_VOLTHREADING,
196 	ZFS_NUM_PROPS
197 } zfs_prop_t;
198 
199 typedef enum {
200 	ZFS_PROP_USERUSED,
201 	ZFS_PROP_USERQUOTA,
202 	ZFS_PROP_GROUPUSED,
203 	ZFS_PROP_GROUPQUOTA,
204 	ZFS_PROP_USEROBJUSED,
205 	ZFS_PROP_USEROBJQUOTA,
206 	ZFS_PROP_GROUPOBJUSED,
207 	ZFS_PROP_GROUPOBJQUOTA,
208 	ZFS_PROP_PROJECTUSED,
209 	ZFS_PROP_PROJECTQUOTA,
210 	ZFS_PROP_PROJECTOBJUSED,
211 	ZFS_PROP_PROJECTOBJQUOTA,
212 	ZFS_NUM_USERQUOTA_PROPS
213 } zfs_userquota_prop_t;
214 
215 _SYS_FS_ZFS_H const char *const zfs_userquota_prop_prefixes[
216     ZFS_NUM_USERQUOTA_PROPS];
217 
218 /*
219  * Pool properties are identified by these constants and must be added to the
220  * end of this list to ensure that external consumers are not affected
221  * by the change.  Properties must be registered in zfs_prop_init().
222  */
223 typedef enum {
224 	ZPOOL_PROP_INVAL = -1,
225 	ZPOOL_PROP_NAME,
226 	ZPOOL_PROP_SIZE,
227 	ZPOOL_PROP_CAPACITY,
228 	ZPOOL_PROP_ALTROOT,
229 	ZPOOL_PROP_HEALTH,
230 	ZPOOL_PROP_GUID,
231 	ZPOOL_PROP_VERSION,
232 	ZPOOL_PROP_BOOTFS,
233 	ZPOOL_PROP_DELEGATION,
234 	ZPOOL_PROP_AUTOREPLACE,
235 	ZPOOL_PROP_CACHEFILE,
236 	ZPOOL_PROP_FAILUREMODE,
237 	ZPOOL_PROP_LISTSNAPS,
238 	ZPOOL_PROP_AUTOEXPAND,
239 	ZPOOL_PROP_DEDUPDITTO,
240 	ZPOOL_PROP_DEDUPRATIO,
241 	ZPOOL_PROP_FREE,
242 	ZPOOL_PROP_ALLOCATED,
243 	ZPOOL_PROP_READONLY,
244 	ZPOOL_PROP_ASHIFT,
245 	ZPOOL_PROP_COMMENT,
246 	ZPOOL_PROP_EXPANDSZ,
247 	ZPOOL_PROP_FREEING,
248 	ZPOOL_PROP_FRAGMENTATION,
249 	ZPOOL_PROP_LEAKED,
250 	ZPOOL_PROP_MAXBLOCKSIZE,
251 	ZPOOL_PROP_TNAME,
252 	ZPOOL_PROP_MAXDNODESIZE,
253 	ZPOOL_PROP_MULTIHOST,
254 	ZPOOL_PROP_CHECKPOINT,
255 	ZPOOL_PROP_LOAD_GUID,
256 	ZPOOL_PROP_AUTOTRIM,
257 	ZPOOL_PROP_COMPATIBILITY,
258 	ZPOOL_PROP_BCLONEUSED,
259 	ZPOOL_PROP_BCLONESAVED,
260 	ZPOOL_PROP_BCLONERATIO,
261 	ZPOOL_NUM_PROPS
262 } zpool_prop_t;
263 
264 /* Small enough to not hog a whole line of printout in zpool(8). */
265 #define	ZPROP_MAX_COMMENT	32
266 #define	ZPROP_BOOLEAN_NA	2
267 
268 #define	ZPROP_VALUE		"value"
269 #define	ZPROP_SOURCE		"source"
270 
271 typedef enum {
272 	ZPROP_SRC_NONE = 0x1,
273 	ZPROP_SRC_DEFAULT = 0x2,
274 	ZPROP_SRC_TEMPORARY = 0x4,
275 	ZPROP_SRC_LOCAL = 0x8,
276 	ZPROP_SRC_INHERITED = 0x10,
277 	ZPROP_SRC_RECEIVED = 0x20
278 } zprop_source_t;
279 
280 #define	ZPROP_SRC_ALL	0x3f
281 
282 #define	ZPROP_SOURCE_VAL_RECVD	"$recvd"
283 #define	ZPROP_N_MORE_ERRORS	"N_MORE_ERRORS"
284 
285 /*
286  * Dataset flag implemented as a special entry in the props zap object
287  * indicating that the dataset has received properties on or after
288  * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
289  * just as it did in earlier versions, and thereafter, local properties are
290  * preserved.
291  */
292 #define	ZPROP_HAS_RECVD		"$hasrecvd"
293 
294 typedef enum {
295 	ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
296 	ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
297 } zprop_errflags_t;
298 
299 typedef int (*zprop_func)(int, void *);
300 
301 /*
302  * Properties to be set on the root file system of a new pool
303  * are stuffed into their own nvlist, which is then included in
304  * the properties nvlist with the pool properties.
305  */
306 #define	ZPOOL_ROOTFS_PROPS	"root-props-nvl"
307 
308 /*
309  * Length of 'written@' and 'written#'
310  */
311 #define	ZFS_WRITTEN_PROP_PREFIX_LEN	8
312 
313 /*
314  * VDEV properties are identified by these constants and must be added to the
315  * end of this list to ensure that external consumers are not affected
316  * by the change. If you make any changes to this list, be sure to update
317  * the property table in usr/src/common/zfs/zpool_prop.c.
318  */
319 typedef enum {
320 	VDEV_PROP_INVAL = -1,
321 	VDEV_PROP_USERPROP = VDEV_PROP_INVAL,
322 	VDEV_PROP_NAME,
323 	VDEV_PROP_CAPACITY,
324 	VDEV_PROP_STATE,
325 	VDEV_PROP_GUID,
326 	VDEV_PROP_ASIZE,
327 	VDEV_PROP_PSIZE,
328 	VDEV_PROP_ASHIFT,
329 	VDEV_PROP_SIZE,
330 	VDEV_PROP_FREE,
331 	VDEV_PROP_ALLOCATED,
332 	VDEV_PROP_COMMENT,
333 	VDEV_PROP_EXPANDSZ,
334 	VDEV_PROP_FRAGMENTATION,
335 	VDEV_PROP_BOOTSIZE,
336 	VDEV_PROP_PARITY,
337 	VDEV_PROP_PATH,
338 	VDEV_PROP_DEVID,
339 	VDEV_PROP_PHYS_PATH,
340 	VDEV_PROP_ENC_PATH,
341 	VDEV_PROP_FRU,
342 	VDEV_PROP_PARENT,
343 	VDEV_PROP_CHILDREN,
344 	VDEV_PROP_NUMCHILDREN,
345 	VDEV_PROP_READ_ERRORS,
346 	VDEV_PROP_WRITE_ERRORS,
347 	VDEV_PROP_CHECKSUM_ERRORS,
348 	VDEV_PROP_INITIALIZE_ERRORS,
349 	VDEV_PROP_OPS_NULL,
350 	VDEV_PROP_OPS_READ,
351 	VDEV_PROP_OPS_WRITE,
352 	VDEV_PROP_OPS_FREE,
353 	VDEV_PROP_OPS_CLAIM,
354 	VDEV_PROP_OPS_TRIM,
355 	VDEV_PROP_BYTES_NULL,
356 	VDEV_PROP_BYTES_READ,
357 	VDEV_PROP_BYTES_WRITE,
358 	VDEV_PROP_BYTES_FREE,
359 	VDEV_PROP_BYTES_CLAIM,
360 	VDEV_PROP_BYTES_TRIM,
361 	VDEV_PROP_REMOVING,
362 	VDEV_PROP_ALLOCATING,
363 	VDEV_PROP_FAILFAST,
364 	VDEV_PROP_CHECKSUM_N,
365 	VDEV_PROP_CHECKSUM_T,
366 	VDEV_PROP_IO_N,
367 	VDEV_PROP_IO_T,
368 	VDEV_PROP_RAIDZ_EXPANDING,
369 	VDEV_PROP_SLOW_IO_N,
370 	VDEV_PROP_SLOW_IO_T,
371 	VDEV_NUM_PROPS
372 } vdev_prop_t;
373 
374 /*
375  * Dataset property functions shared between libzfs and kernel.
376  */
377 _SYS_FS_ZFS_H const char *zfs_prop_default_string(zfs_prop_t);
378 _SYS_FS_ZFS_H uint64_t zfs_prop_default_numeric(zfs_prop_t);
379 _SYS_FS_ZFS_H boolean_t zfs_prop_readonly(zfs_prop_t);
380 _SYS_FS_ZFS_H boolean_t zfs_prop_visible(zfs_prop_t prop);
381 _SYS_FS_ZFS_H boolean_t zfs_prop_inheritable(zfs_prop_t);
382 _SYS_FS_ZFS_H boolean_t zfs_prop_setonce(zfs_prop_t);
383 _SYS_FS_ZFS_H boolean_t zfs_prop_encryption_key_param(zfs_prop_t);
384 _SYS_FS_ZFS_H boolean_t zfs_prop_valid_keylocation(const char *, boolean_t);
385 _SYS_FS_ZFS_H const char *zfs_prop_to_name(zfs_prop_t);
386 _SYS_FS_ZFS_H zfs_prop_t zfs_name_to_prop(const char *);
387 _SYS_FS_ZFS_H boolean_t zfs_prop_user(const char *);
388 _SYS_FS_ZFS_H boolean_t zfs_prop_userquota(const char *);
389 _SYS_FS_ZFS_H boolean_t zfs_prop_written(const char *);
390 _SYS_FS_ZFS_H int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
391 _SYS_FS_ZFS_H int zfs_prop_string_to_index(zfs_prop_t, const char *,
392     uint64_t *);
393 _SYS_FS_ZFS_H uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
394 _SYS_FS_ZFS_H boolean_t zfs_prop_valid_for_type(int, zfs_type_t, boolean_t);
395 
396 /*
397  * Pool property functions shared between libzfs and kernel.
398  */
399 _SYS_FS_ZFS_H zpool_prop_t zpool_name_to_prop(const char *);
400 _SYS_FS_ZFS_H const char *zpool_prop_to_name(zpool_prop_t);
401 _SYS_FS_ZFS_H const char *zpool_prop_default_string(zpool_prop_t);
402 _SYS_FS_ZFS_H uint64_t zpool_prop_default_numeric(zpool_prop_t);
403 _SYS_FS_ZFS_H boolean_t zpool_prop_readonly(zpool_prop_t);
404 _SYS_FS_ZFS_H boolean_t zpool_prop_setonce(zpool_prop_t);
405 _SYS_FS_ZFS_H boolean_t zpool_prop_feature(const char *);
406 _SYS_FS_ZFS_H boolean_t zpool_prop_unsupported(const char *);
407 _SYS_FS_ZFS_H int zpool_prop_index_to_string(zpool_prop_t, uint64_t,
408     const char **);
409 _SYS_FS_ZFS_H int zpool_prop_string_to_index(zpool_prop_t, const char *,
410     uint64_t *);
411 _SYS_FS_ZFS_H uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
412 
413 /*
414  * VDEV property functions shared between libzfs and kernel.
415  */
416 _SYS_FS_ZFS_H vdev_prop_t vdev_name_to_prop(const char *);
417 _SYS_FS_ZFS_H boolean_t vdev_prop_user(const char *name);
418 _SYS_FS_ZFS_H const char *vdev_prop_to_name(vdev_prop_t);
419 _SYS_FS_ZFS_H const char *vdev_prop_default_string(vdev_prop_t);
420 _SYS_FS_ZFS_H uint64_t vdev_prop_default_numeric(vdev_prop_t);
421 _SYS_FS_ZFS_H boolean_t vdev_prop_readonly(vdev_prop_t prop);
422 _SYS_FS_ZFS_H int vdev_prop_index_to_string(vdev_prop_t, uint64_t,
423     const char **);
424 _SYS_FS_ZFS_H int vdev_prop_string_to_index(vdev_prop_t, const char *,
425     uint64_t *);
426 _SYS_FS_ZFS_H boolean_t zpool_prop_vdev(const char *name);
427 _SYS_FS_ZFS_H uint64_t vdev_prop_random_value(vdev_prop_t prop, uint64_t seed);
428 
429 /*
430  * Definitions for the Delegation.
431  */
432 typedef enum {
433 	ZFS_DELEG_WHO_UNKNOWN = 0,
434 	ZFS_DELEG_USER = 'u',
435 	ZFS_DELEG_USER_SETS = 'U',
436 	ZFS_DELEG_GROUP = 'g',
437 	ZFS_DELEG_GROUP_SETS = 'G',
438 	ZFS_DELEG_EVERYONE = 'e',
439 	ZFS_DELEG_EVERYONE_SETS = 'E',
440 	ZFS_DELEG_CREATE = 'c',
441 	ZFS_DELEG_CREATE_SETS = 'C',
442 	ZFS_DELEG_NAMED_SET = 's',
443 	ZFS_DELEG_NAMED_SET_SETS = 'S'
444 } zfs_deleg_who_type_t;
445 
446 typedef enum {
447 	ZFS_DELEG_NONE = 0,
448 	ZFS_DELEG_PERM_LOCAL = 1,
449 	ZFS_DELEG_PERM_DESCENDENT = 2,
450 	ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
451 	ZFS_DELEG_PERM_CREATE = 4
452 } zfs_deleg_inherit_t;
453 
454 #define	ZFS_DELEG_PERM_UID	"uid"
455 #define	ZFS_DELEG_PERM_GID	"gid"
456 #define	ZFS_DELEG_PERM_GROUPS	"groups"
457 
458 #define	ZFS_MLSLABEL_DEFAULT	"none"
459 
460 #define	ZFS_SMB_ACL_SRC		"src"
461 #define	ZFS_SMB_ACL_TARGET	"target"
462 
463 typedef enum {
464 	ZFS_CANMOUNT_OFF = 0,
465 	ZFS_CANMOUNT_ON = 1,
466 	ZFS_CANMOUNT_NOAUTO = 2
467 } zfs_canmount_type_t;
468 
469 typedef enum {
470 	ZFS_LOGBIAS_LATENCY = 0,
471 	ZFS_LOGBIAS_THROUGHPUT = 1
472 } zfs_logbias_op_t;
473 
474 typedef enum zfs_share_op {
475 	ZFS_SHARE_NFS = 0,
476 	ZFS_UNSHARE_NFS = 1,
477 	ZFS_SHARE_SMB = 2,
478 	ZFS_UNSHARE_SMB = 3
479 } zfs_share_op_t;
480 
481 typedef enum zfs_smb_acl_op {
482 	ZFS_SMB_ACL_ADD,
483 	ZFS_SMB_ACL_REMOVE,
484 	ZFS_SMB_ACL_RENAME,
485 	ZFS_SMB_ACL_PURGE
486 } zfs_smb_acl_op_t;
487 
488 typedef enum zfs_cache_type {
489 	ZFS_CACHE_NONE = 0,
490 	ZFS_CACHE_METADATA = 1,
491 	ZFS_CACHE_ALL = 2
492 } zfs_cache_type_t;
493 
494 typedef enum {
495 	ZFS_SYNC_STANDARD = 0,
496 	ZFS_SYNC_ALWAYS = 1,
497 	ZFS_SYNC_DISABLED = 2
498 } zfs_sync_type_t;
499 
500 typedef enum {
501 	ZFS_XATTR_OFF = 0,
502 	ZFS_XATTR_DIR = 1,
503 	ZFS_XATTR_SA = 2
504 } zfs_xattr_type_t;
505 
506 typedef enum {
507 	ZFS_DNSIZE_LEGACY = 0,
508 	ZFS_DNSIZE_AUTO = 1,
509 	ZFS_DNSIZE_1K = 1024,
510 	ZFS_DNSIZE_2K = 2048,
511 	ZFS_DNSIZE_4K = 4096,
512 	ZFS_DNSIZE_8K = 8192,
513 	ZFS_DNSIZE_16K = 16384
514 } zfs_dnsize_type_t;
515 
516 typedef enum {
517 	ZFS_REDUNDANT_METADATA_ALL,
518 	ZFS_REDUNDANT_METADATA_MOST,
519 	ZFS_REDUNDANT_METADATA_SOME,
520 	ZFS_REDUNDANT_METADATA_NONE
521 } zfs_redundant_metadata_type_t;
522 
523 typedef enum {
524 	ZFS_VOLMODE_DEFAULT = 0,
525 	ZFS_VOLMODE_GEOM = 1,
526 	ZFS_VOLMODE_DEV = 2,
527 	ZFS_VOLMODE_NONE = 3
528 } zfs_volmode_t;
529 
530 typedef enum zfs_keystatus {
531 	ZFS_KEYSTATUS_NONE = 0,
532 	ZFS_KEYSTATUS_UNAVAILABLE,
533 	ZFS_KEYSTATUS_AVAILABLE,
534 } zfs_keystatus_t;
535 
536 typedef enum zfs_keyformat {
537 	ZFS_KEYFORMAT_NONE = 0,
538 	ZFS_KEYFORMAT_RAW,
539 	ZFS_KEYFORMAT_HEX,
540 	ZFS_KEYFORMAT_PASSPHRASE,
541 	ZFS_KEYFORMAT_FORMATS
542 } zfs_keyformat_t;
543 
544 typedef enum zfs_key_location {
545 	ZFS_KEYLOCATION_NONE = 0,
546 	ZFS_KEYLOCATION_PROMPT,
547 	ZFS_KEYLOCATION_URI,
548 	ZFS_KEYLOCATION_LOCATIONS
549 } zfs_keylocation_t;
550 
551 typedef enum {
552 	ZFS_PREFETCH_NONE = 0,
553 	ZFS_PREFETCH_METADATA = 1,
554 	ZFS_PREFETCH_ALL = 2
555 } zfs_prefetch_type_t;
556 
557 #define	DEFAULT_PBKDF2_ITERATIONS 350000
558 #define	MIN_PBKDF2_ITERATIONS 100000
559 
560 /*
561  * On-disk version number.
562  */
563 #define	SPA_VERSION_1			1ULL
564 #define	SPA_VERSION_2			2ULL
565 #define	SPA_VERSION_3			3ULL
566 #define	SPA_VERSION_4			4ULL
567 #define	SPA_VERSION_5			5ULL
568 #define	SPA_VERSION_6			6ULL
569 #define	SPA_VERSION_7			7ULL
570 #define	SPA_VERSION_8			8ULL
571 #define	SPA_VERSION_9			9ULL
572 #define	SPA_VERSION_10			10ULL
573 #define	SPA_VERSION_11			11ULL
574 #define	SPA_VERSION_12			12ULL
575 #define	SPA_VERSION_13			13ULL
576 #define	SPA_VERSION_14			14ULL
577 #define	SPA_VERSION_15			15ULL
578 #define	SPA_VERSION_16			16ULL
579 #define	SPA_VERSION_17			17ULL
580 #define	SPA_VERSION_18			18ULL
581 #define	SPA_VERSION_19			19ULL
582 #define	SPA_VERSION_20			20ULL
583 #define	SPA_VERSION_21			21ULL
584 #define	SPA_VERSION_22			22ULL
585 #define	SPA_VERSION_23			23ULL
586 #define	SPA_VERSION_24			24ULL
587 #define	SPA_VERSION_25			25ULL
588 #define	SPA_VERSION_26			26ULL
589 #define	SPA_VERSION_27			27ULL
590 #define	SPA_VERSION_28			28ULL
591 #define	SPA_VERSION_5000		5000ULL
592 
593 /*
594  * The incrementing pool version number has been replaced by pool feature
595  * flags.  For more details, see zfeature.c.
596  */
597 #define	SPA_VERSION			SPA_VERSION_5000
598 #define	SPA_VERSION_STRING		"5000"
599 
600 /*
601  * Symbolic names for the changes that caused a SPA_VERSION switch.
602  * Used in the code when checking for presence or absence of a feature.
603  * Feel free to define multiple symbolic names for each version if there
604  * were multiple changes to on-disk structures during that version.
605  *
606  * NOTE: When checking the current SPA_VERSION in your code, be sure
607  *       to use spa_version() since it reports the version of the
608  *       last synced uberblock.  Checking the in-flight version can
609  *       be dangerous in some cases.
610  */
611 #define	SPA_VERSION_INITIAL		SPA_VERSION_1
612 #define	SPA_VERSION_DITTO_BLOCKS	SPA_VERSION_2
613 #define	SPA_VERSION_SPARES		SPA_VERSION_3
614 #define	SPA_VERSION_RAIDZ2		SPA_VERSION_3
615 #define	SPA_VERSION_BPOBJ_ACCOUNT	SPA_VERSION_3
616 #define	SPA_VERSION_RAIDZ_DEFLATE	SPA_VERSION_3
617 #define	SPA_VERSION_DNODE_BYTES		SPA_VERSION_3
618 #define	SPA_VERSION_ZPOOL_HISTORY	SPA_VERSION_4
619 #define	SPA_VERSION_GZIP_COMPRESSION	SPA_VERSION_5
620 #define	SPA_VERSION_BOOTFS		SPA_VERSION_6
621 #define	SPA_VERSION_SLOGS		SPA_VERSION_7
622 #define	SPA_VERSION_DELEGATED_PERMS	SPA_VERSION_8
623 #define	SPA_VERSION_FUID		SPA_VERSION_9
624 #define	SPA_VERSION_REFRESERVATION	SPA_VERSION_9
625 #define	SPA_VERSION_REFQUOTA		SPA_VERSION_9
626 #define	SPA_VERSION_UNIQUE_ACCURATE	SPA_VERSION_9
627 #define	SPA_VERSION_L2CACHE		SPA_VERSION_10
628 #define	SPA_VERSION_NEXT_CLONES		SPA_VERSION_11
629 #define	SPA_VERSION_ORIGIN		SPA_VERSION_11
630 #define	SPA_VERSION_DSL_SCRUB		SPA_VERSION_11
631 #define	SPA_VERSION_SNAP_PROPS		SPA_VERSION_12
632 #define	SPA_VERSION_USED_BREAKDOWN	SPA_VERSION_13
633 #define	SPA_VERSION_PASSTHROUGH_X	SPA_VERSION_14
634 #define	SPA_VERSION_USERSPACE		SPA_VERSION_15
635 #define	SPA_VERSION_STMF_PROP		SPA_VERSION_16
636 #define	SPA_VERSION_RAIDZ3		SPA_VERSION_17
637 #define	SPA_VERSION_USERREFS		SPA_VERSION_18
638 #define	SPA_VERSION_HOLES		SPA_VERSION_19
639 #define	SPA_VERSION_ZLE_COMPRESSION	SPA_VERSION_20
640 #define	SPA_VERSION_DEDUP		SPA_VERSION_21
641 #define	SPA_VERSION_RECVD_PROPS		SPA_VERSION_22
642 #define	SPA_VERSION_SLIM_ZIL		SPA_VERSION_23
643 #define	SPA_VERSION_SA			SPA_VERSION_24
644 #define	SPA_VERSION_SCAN		SPA_VERSION_25
645 #define	SPA_VERSION_DIR_CLONES		SPA_VERSION_26
646 #define	SPA_VERSION_DEADLISTS		SPA_VERSION_26
647 #define	SPA_VERSION_FAST_SNAP		SPA_VERSION_27
648 #define	SPA_VERSION_MULTI_REPLACE	SPA_VERSION_28
649 #define	SPA_VERSION_BEFORE_FEATURES	SPA_VERSION_28
650 #define	SPA_VERSION_FEATURES		SPA_VERSION_5000
651 
652 #define	SPA_VERSION_IS_SUPPORTED(v) \
653 	(((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
654 	((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
655 
656 /*
657  * ZPL version - rev'd whenever an incompatible on-disk format change
658  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
659  * also update the version_table[] and help message in zfs_prop.c.
660  */
661 #define	ZPL_VERSION_1			1ULL
662 #define	ZPL_VERSION_2			2ULL
663 #define	ZPL_VERSION_3			3ULL
664 #define	ZPL_VERSION_4			4ULL
665 #define	ZPL_VERSION_5			5ULL
666 #define	ZPL_VERSION			ZPL_VERSION_5
667 #define	ZPL_VERSION_STRING		"5"
668 
669 #define	ZPL_VERSION_INITIAL		ZPL_VERSION_1
670 #define	ZPL_VERSION_DIRENT_TYPE		ZPL_VERSION_2
671 #define	ZPL_VERSION_FUID		ZPL_VERSION_3
672 #define	ZPL_VERSION_NORMALIZATION	ZPL_VERSION_3
673 #define	ZPL_VERSION_SYSATTR		ZPL_VERSION_3
674 #define	ZPL_VERSION_USERSPACE		ZPL_VERSION_4
675 #define	ZPL_VERSION_SA			ZPL_VERSION_5
676 
677 /* Persistent L2ARC version */
678 #define	L2ARC_PERSISTENT_VERSION_1	1ULL
679 #define	L2ARC_PERSISTENT_VERSION	L2ARC_PERSISTENT_VERSION_1
680 #define	L2ARC_PERSISTENT_VERSION_STRING	"1"
681 
682 /* Rewind policy information */
683 #define	ZPOOL_NO_REWIND		1  /* No policy - default behavior */
684 #define	ZPOOL_NEVER_REWIND	2  /* Do not search for best txg or rewind */
685 #define	ZPOOL_TRY_REWIND	4  /* Search for best txg, but do not rewind */
686 #define	ZPOOL_DO_REWIND		8  /* Rewind to best txg w/in deferred frees */
687 #define	ZPOOL_EXTREME_REWIND	16 /* Allow extreme measures to find best txg */
688 #define	ZPOOL_REWIND_MASK	28 /* All the possible rewind bits */
689 #define	ZPOOL_REWIND_POLICIES	31 /* All the possible policy bits */
690 
691 typedef struct zpool_load_policy {
692 	uint32_t	zlp_rewind;	/* rewind policy requested */
693 	uint64_t	zlp_maxmeta;	/* max acceptable meta-data errors */
694 	uint64_t	zlp_maxdata;	/* max acceptable data errors */
695 	uint64_t	zlp_txg;	/* specific txg to load */
696 } zpool_load_policy_t;
697 
698 /*
699  * The following are configuration names used in the nvlist describing a pool's
700  * configuration.  New on-disk names should be prefixed with "<reversed-DNS>:"
701  * (e.g. "org.openzfs:") to avoid conflicting names being developed
702  * independently.
703  */
704 #define	ZPOOL_CONFIG_VERSION		"version"
705 #define	ZPOOL_CONFIG_POOL_NAME		"name"
706 #define	ZPOOL_CONFIG_POOL_STATE		"state"
707 #define	ZPOOL_CONFIG_POOL_TXG		"txg"
708 #define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
709 #define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
710 #define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
711 #define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
712 #define	ZPOOL_CONFIG_TYPE		"type"
713 #define	ZPOOL_CONFIG_CHILDREN		"children"
714 #define	ZPOOL_CONFIG_ID			"id"
715 #define	ZPOOL_CONFIG_GUID		"guid"
716 #define	ZPOOL_CONFIG_INDIRECT_OBJECT	"com.delphix:indirect_object"
717 #define	ZPOOL_CONFIG_INDIRECT_BIRTHS	"com.delphix:indirect_births"
718 #define	ZPOOL_CONFIG_PREV_INDIRECT_VDEV	"com.delphix:prev_indirect_vdev"
719 #define	ZPOOL_CONFIG_PATH		"path"
720 #define	ZPOOL_CONFIG_DEVID		"devid"
721 #define	ZPOOL_CONFIG_SPARE_ID		"spareid"
722 #define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
723 #define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
724 #define	ZPOOL_CONFIG_ASHIFT		"ashift"
725 #define	ZPOOL_CONFIG_ASIZE		"asize"
726 #define	ZPOOL_CONFIG_DTL		"DTL"
727 #define	ZPOOL_CONFIG_SCAN_STATS		"scan_stats"	/* not stored on disk */
728 #define	ZPOOL_CONFIG_REMOVAL_STATS	"removal_stats"	/* not stored on disk */
729 #define	ZPOOL_CONFIG_CHECKPOINT_STATS	"checkpoint_stats" /* not on disk */
730 #define	ZPOOL_CONFIG_RAIDZ_EXPAND_STATS	"raidz_expand_stats" /* not on disk */
731 #define	ZPOOL_CONFIG_VDEV_STATS		"vdev_stats"	/* not stored on disk */
732 #define	ZPOOL_CONFIG_INDIRECT_SIZE	"indirect_size"	/* not stored on disk */
733 
734 /* container nvlist of extended stats */
735 #define	ZPOOL_CONFIG_VDEV_STATS_EX	"vdev_stats_ex"
736 
737 /* Active queue read/write stats */
738 #define	ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE	"vdev_sync_r_active_queue"
739 #define	ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE	"vdev_sync_w_active_queue"
740 #define	ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE	"vdev_async_r_active_queue"
741 #define	ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE	"vdev_async_w_active_queue"
742 #define	ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE	"vdev_async_scrub_active_queue"
743 #define	ZPOOL_CONFIG_VDEV_TRIM_ACTIVE_QUEUE	"vdev_async_trim_active_queue"
744 #define	ZPOOL_CONFIG_VDEV_REBUILD_ACTIVE_QUEUE	"vdev_rebuild_active_queue"
745 
746 /* Queue sizes */
747 #define	ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE	"vdev_sync_r_pend_queue"
748 #define	ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE	"vdev_sync_w_pend_queue"
749 #define	ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE	"vdev_async_r_pend_queue"
750 #define	ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE	"vdev_async_w_pend_queue"
751 #define	ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE	"vdev_async_scrub_pend_queue"
752 #define	ZPOOL_CONFIG_VDEV_TRIM_PEND_QUEUE	"vdev_async_trim_pend_queue"
753 #define	ZPOOL_CONFIG_VDEV_REBUILD_PEND_QUEUE	"vdev_rebuild_pend_queue"
754 
755 /* Latency read/write histogram stats */
756 #define	ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO	"vdev_tot_r_lat_histo"
757 #define	ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO	"vdev_tot_w_lat_histo"
758 #define	ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO	"vdev_disk_r_lat_histo"
759 #define	ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO	"vdev_disk_w_lat_histo"
760 #define	ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO	"vdev_sync_r_lat_histo"
761 #define	ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO	"vdev_sync_w_lat_histo"
762 #define	ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO	"vdev_async_r_lat_histo"
763 #define	ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO	"vdev_async_w_lat_histo"
764 #define	ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO	"vdev_scrub_histo"
765 #define	ZPOOL_CONFIG_VDEV_TRIM_LAT_HISTO	"vdev_trim_histo"
766 #define	ZPOOL_CONFIG_VDEV_REBUILD_LAT_HISTO	"vdev_rebuild_histo"
767 
768 /* Request size histograms */
769 #define	ZPOOL_CONFIG_VDEV_SYNC_IND_R_HISTO	"vdev_sync_ind_r_histo"
770 #define	ZPOOL_CONFIG_VDEV_SYNC_IND_W_HISTO	"vdev_sync_ind_w_histo"
771 #define	ZPOOL_CONFIG_VDEV_ASYNC_IND_R_HISTO	"vdev_async_ind_r_histo"
772 #define	ZPOOL_CONFIG_VDEV_ASYNC_IND_W_HISTO	"vdev_async_ind_w_histo"
773 #define	ZPOOL_CONFIG_VDEV_IND_SCRUB_HISTO	"vdev_ind_scrub_histo"
774 #define	ZPOOL_CONFIG_VDEV_IND_TRIM_HISTO	"vdev_ind_trim_histo"
775 #define	ZPOOL_CONFIG_VDEV_IND_REBUILD_HISTO	"vdev_ind_rebuild_histo"
776 #define	ZPOOL_CONFIG_VDEV_SYNC_AGG_R_HISTO	"vdev_sync_agg_r_histo"
777 #define	ZPOOL_CONFIG_VDEV_SYNC_AGG_W_HISTO	"vdev_sync_agg_w_histo"
778 #define	ZPOOL_CONFIG_VDEV_ASYNC_AGG_R_HISTO	"vdev_async_agg_r_histo"
779 #define	ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO	"vdev_async_agg_w_histo"
780 #define	ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO	"vdev_agg_scrub_histo"
781 #define	ZPOOL_CONFIG_VDEV_AGG_TRIM_HISTO	"vdev_agg_trim_histo"
782 #define	ZPOOL_CONFIG_VDEV_AGG_REBUILD_HISTO	"vdev_agg_rebuild_histo"
783 
784 /* Number of slow IOs */
785 #define	ZPOOL_CONFIG_VDEV_SLOW_IOS		"vdev_slow_ios"
786 
787 /* vdev enclosure sysfs path */
788 #define	ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH	"vdev_enc_sysfs_path"
789 
790 #define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
791 #define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
792 #define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
793 #define	ZPOOL_CONFIG_SPARES		"spares"
794 #define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
795 #define	ZPOOL_CONFIG_NPARITY		"nparity"
796 #define	ZPOOL_CONFIG_RAIDZ_EXPANDING	"raidz_expanding"
797 #define	ZPOOL_CONFIG_RAIDZ_EXPAND_TXGS	"raidz_expand_txgs"
798 #define	ZPOOL_CONFIG_HOSTID		"hostid"
799 #define	ZPOOL_CONFIG_HOSTNAME		"hostname"
800 #define	ZPOOL_CONFIG_LOADED_TIME	"initial_load_time"
801 #define	ZPOOL_CONFIG_UNSPARE		"unspare"
802 #define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
803 #define	ZPOOL_CONFIG_IS_LOG		"is_log"
804 #define	ZPOOL_CONFIG_L2CACHE		"l2cache"
805 #define	ZPOOL_CONFIG_HOLE_ARRAY		"hole_array"
806 #define	ZPOOL_CONFIG_VDEV_CHILDREN	"vdev_children"
807 #define	ZPOOL_CONFIG_IS_HOLE		"is_hole"
808 #define	ZPOOL_CONFIG_DDT_HISTOGRAM	"ddt_histogram"
809 #define	ZPOOL_CONFIG_DDT_OBJ_STATS	"ddt_object_stats"
810 #define	ZPOOL_CONFIG_DDT_STATS		"ddt_stats"
811 #define	ZPOOL_CONFIG_SPLIT		"splitcfg"
812 #define	ZPOOL_CONFIG_ORIG_GUID		"orig_guid"
813 #define	ZPOOL_CONFIG_SPLIT_GUID		"split_guid"
814 #define	ZPOOL_CONFIG_SPLIT_LIST		"guid_list"
815 #define	ZPOOL_CONFIG_NONALLOCATING	"non_allocating"
816 #define	ZPOOL_CONFIG_REMOVING		"removing"
817 #define	ZPOOL_CONFIG_RESILVER_TXG	"resilver_txg"
818 #define	ZPOOL_CONFIG_REBUILD_TXG	"rebuild_txg"
819 #define	ZPOOL_CONFIG_COMMENT		"comment"
820 #define	ZPOOL_CONFIG_SUSPENDED		"suspended"	/* not stored on disk */
821 #define	ZPOOL_CONFIG_SUSPENDED_REASON	"suspended_reason"	/* not stored */
822 #define	ZPOOL_CONFIG_TIMESTAMP		"timestamp"	/* not stored on disk */
823 #define	ZPOOL_CONFIG_BOOTFS		"bootfs"	/* not stored on disk */
824 #define	ZPOOL_CONFIG_MISSING_DEVICES	"missing_vdevs"	/* not stored on disk */
825 #define	ZPOOL_CONFIG_LOAD_INFO		"load_info"	/* not stored on disk */
826 #define	ZPOOL_CONFIG_REWIND_INFO	"rewind_info"	/* not stored on disk */
827 #define	ZPOOL_CONFIG_UNSUP_FEAT		"unsup_feat"	/* not stored on disk */
828 #define	ZPOOL_CONFIG_ENABLED_FEAT	"enabled_feat"	/* not stored on disk */
829 #define	ZPOOL_CONFIG_CAN_RDONLY		"can_rdonly"	/* not stored on disk */
830 #define	ZPOOL_CONFIG_FEATURES_FOR_READ	"features_for_read"
831 #define	ZPOOL_CONFIG_FEATURE_STATS	"feature_stats"	/* not stored on disk */
832 #define	ZPOOL_CONFIG_ERRATA		"errata"	/* not stored on disk */
833 #define	ZPOOL_CONFIG_VDEV_ROOT_ZAP	"com.klarasystems:vdev_zap_root"
834 #define	ZPOOL_CONFIG_VDEV_TOP_ZAP	"com.delphix:vdev_zap_top"
835 #define	ZPOOL_CONFIG_VDEV_LEAF_ZAP	"com.delphix:vdev_zap_leaf"
836 #define	ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS	"com.delphix:has_per_vdev_zaps"
837 #define	ZPOOL_CONFIG_RESILVER_DEFER	"com.datto:resilver_defer"
838 #define	ZPOOL_CONFIG_CACHEFILE		"cachefile"	/* not stored on disk */
839 #define	ZPOOL_CONFIG_MMP_STATE		"mmp_state"	/* not stored on disk */
840 #define	ZPOOL_CONFIG_MMP_TXG		"mmp_txg"	/* not stored on disk */
841 #define	ZPOOL_CONFIG_MMP_SEQ		"mmp_seq"	/* not stored on disk */
842 #define	ZPOOL_CONFIG_MMP_HOSTNAME	"mmp_hostname"	/* not stored on disk */
843 #define	ZPOOL_CONFIG_MMP_HOSTID		"mmp_hostid"	/* not stored on disk */
844 #define	ZPOOL_CONFIG_ALLOCATION_BIAS	"alloc_bias"	/* not stored on disk */
845 #define	ZPOOL_CONFIG_EXPANSION_TIME	"expansion_time"	/* not stored */
846 #define	ZPOOL_CONFIG_REBUILD_STATS	"org.openzfs:rebuild_stats"
847 #define	ZPOOL_CONFIG_COMPATIBILITY	"compatibility"
848 
849 /*
850  * The persistent vdev state is stored as separate values rather than a single
851  * 'vdev_state' entry.  This is because a device can be in multiple states, such
852  * as offline and degraded.
853  */
854 #define	ZPOOL_CONFIG_OFFLINE		"offline"
855 #define	ZPOOL_CONFIG_FAULTED		"faulted"
856 #define	ZPOOL_CONFIG_DEGRADED		"degraded"
857 #define	ZPOOL_CONFIG_REMOVED		"removed"
858 #define	ZPOOL_CONFIG_FRU		"fru"
859 #define	ZPOOL_CONFIG_AUX_STATE		"aux_state"
860 
861 /* Pool load policy parameters */
862 #define	ZPOOL_LOAD_POLICY		"load-policy"
863 #define	ZPOOL_LOAD_REWIND_POLICY	"load-rewind-policy"
864 #define	ZPOOL_LOAD_REQUEST_TXG		"load-request-txg"
865 #define	ZPOOL_LOAD_META_THRESH		"load-meta-thresh"
866 #define	ZPOOL_LOAD_DATA_THRESH		"load-data-thresh"
867 
868 /* Rewind data discovered */
869 #define	ZPOOL_CONFIG_LOAD_TIME		"rewind_txg_ts"
870 #define	ZPOOL_CONFIG_LOAD_META_ERRORS	"verify_meta_errors"
871 #define	ZPOOL_CONFIG_LOAD_DATA_ERRORS	"verify_data_errors"
872 #define	ZPOOL_CONFIG_REWIND_TIME	"seconds_of_rewind"
873 
874 /* dRAID configuration */
875 #define	ZPOOL_CONFIG_DRAID_NDATA	"draid_ndata"
876 #define	ZPOOL_CONFIG_DRAID_NSPARES	"draid_nspares"
877 #define	ZPOOL_CONFIG_DRAID_NGROUPS	"draid_ngroups"
878 
879 #define	VDEV_TYPE_ROOT			"root"
880 #define	VDEV_TYPE_MIRROR		"mirror"
881 #define	VDEV_TYPE_REPLACING		"replacing"
882 #define	VDEV_TYPE_RAIDZ			"raidz"
883 #define	VDEV_TYPE_DRAID			"draid"
884 #define	VDEV_TYPE_DRAID_SPARE		"dspare"
885 #define	VDEV_TYPE_DISK			"disk"
886 #define	VDEV_TYPE_FILE			"file"
887 #define	VDEV_TYPE_MISSING		"missing"
888 #define	VDEV_TYPE_HOLE			"hole"
889 #define	VDEV_TYPE_SPARE			"spare"
890 #define	VDEV_TYPE_LOG			"log"
891 #define	VDEV_TYPE_L2CACHE		"l2cache"
892 #define	VDEV_TYPE_INDIRECT		"indirect"
893 
894 #define	VDEV_RAIDZ_MAXPARITY		3
895 
896 #define	VDEV_DRAID_MAXPARITY		3
897 #define	VDEV_DRAID_MIN_CHILDREN		2
898 #define	VDEV_DRAID_MAX_CHILDREN		UINT8_MAX
899 
900 /* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */
901 #define	VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \
902 	"com.delphix:indirect_obsolete_sm"
903 #define	VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \
904 	"com.delphix:obsolete_counts_are_precise"
905 #define	VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \
906 	"com.delphix:pool_checkpoint_sm"
907 #define	VDEV_TOP_ZAP_MS_UNFLUSHED_PHYS_TXGS \
908 	"com.delphix:ms_unflushed_phys_txgs"
909 
910 #define	VDEV_TOP_ZAP_VDEV_REBUILD_PHYS \
911 	"org.openzfs:vdev_rebuild"
912 
913 #define	VDEV_TOP_ZAP_ALLOCATION_BIAS \
914 	"org.zfsonlinux:allocation_bias"
915 
916 #define	VDEV_TOP_ZAP_RAIDZ_EXPAND_STATE \
917 	"org.openzfs:raidz_expand_state"
918 #define	VDEV_TOP_ZAP_RAIDZ_EXPAND_START_TIME \
919 	"org.openzfs:raidz_expand_start_time"
920 #define	VDEV_TOP_ZAP_RAIDZ_EXPAND_END_TIME \
921 	"org.openzfs:raidz_expand_end_time"
922 #define	VDEV_TOP_ZAP_RAIDZ_EXPAND_BYTES_COPIED \
923 	"org.openzfs:raidz_expand_bytes_copied"
924 
925 /* vdev metaslab allocation bias */
926 #define	VDEV_ALLOC_BIAS_LOG		"log"
927 #define	VDEV_ALLOC_BIAS_SPECIAL		"special"
928 #define	VDEV_ALLOC_BIAS_DEDUP		"dedup"
929 
930 /* vdev initialize state */
931 #define	VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET	\
932 	"com.delphix:next_offset_to_initialize"
933 #define	VDEV_LEAF_ZAP_INITIALIZE_STATE	\
934 	"com.delphix:vdev_initialize_state"
935 #define	VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME	\
936 	"com.delphix:vdev_initialize_action_time"
937 
938 /* vdev TRIM state */
939 #define	VDEV_LEAF_ZAP_TRIM_LAST_OFFSET	\
940 	"org.zfsonlinux:next_offset_to_trim"
941 #define	VDEV_LEAF_ZAP_TRIM_STATE	\
942 	"org.zfsonlinux:vdev_trim_state"
943 #define	VDEV_LEAF_ZAP_TRIM_ACTION_TIME	\
944 	"org.zfsonlinux:vdev_trim_action_time"
945 #define	VDEV_LEAF_ZAP_TRIM_RATE		\
946 	"org.zfsonlinux:vdev_trim_rate"
947 #define	VDEV_LEAF_ZAP_TRIM_PARTIAL	\
948 	"org.zfsonlinux:vdev_trim_partial"
949 #define	VDEV_LEAF_ZAP_TRIM_SECURE	\
950 	"org.zfsonlinux:vdev_trim_secure"
951 
952 /*
953  * This is needed in userland to report the minimum necessary device size.
954  */
955 #define	SPA_MINDEVSIZE		(64ULL << 20)
956 
957 /*
958  * Set if the fragmentation has not yet been calculated. This can happen
959  * because the space maps have not been upgraded or the histogram feature
960  * is not enabled.
961  */
962 #define	ZFS_FRAG_INVALID	UINT64_MAX
963 
964 /*
965  * The location of the pool configuration repository, shared between kernel and
966  * userland.
967  */
968 #define	ZPOOL_CACHE_BOOT	"/boot/zfs/zpool.cache"
969 #define	ZPOOL_CACHE		"/etc/zfs/zpool.cache"
970 /*
971  * Settings for zpool compatibility features files
972  */
973 #define	ZPOOL_SYSCONF_COMPAT_D	SYSCONFDIR "/zfs/compatibility.d"
974 #define	ZPOOL_DATA_COMPAT_D	PKGDATADIR "/compatibility.d"
975 #define	ZPOOL_COMPAT_MAXSIZE	16384
976 
977 /*
978  * Hard-wired compatibility settings
979  */
980 #define	ZPOOL_COMPAT_LEGACY	"legacy"
981 #define	ZPOOL_COMPAT_OFF	"off"
982 
983 /*
984  * vdev states are ordered from least to most healthy.
985  * A vdev that's CANT_OPEN or below is considered unusable.
986  */
987 typedef enum vdev_state {
988 	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
989 	VDEV_STATE_CLOSED,	/* Not currently open			*/
990 	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
991 	VDEV_STATE_REMOVED,	/* Explicitly removed from system	*/
992 	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
993 	VDEV_STATE_FAULTED,	/* External request to fault device	*/
994 	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
995 	VDEV_STATE_HEALTHY	/* Presumed good			*/
996 } vdev_state_t;
997 
998 #define	VDEV_STATE_ONLINE	VDEV_STATE_HEALTHY
999 
1000 /*
1001  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
1002  * of the vdev stats structure uses these constants to distinguish why.
1003  */
1004 typedef enum vdev_aux {
1005 	VDEV_AUX_NONE,		/* no error				*/
1006 	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
1007 	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
1008 	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
1009 	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
1010 	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
1011 	VDEV_AUX_BAD_LABEL,	/* the label is OK but invalid		*/
1012 	VDEV_AUX_VERSION_NEWER,	/* on-disk version is too new		*/
1013 	VDEV_AUX_VERSION_OLDER,	/* on-disk version is too old		*/
1014 	VDEV_AUX_UNSUP_FEAT,	/* unsupported features			*/
1015 	VDEV_AUX_SPARED,	/* hot spare used in another pool	*/
1016 	VDEV_AUX_ERR_EXCEEDED,	/* too many errors			*/
1017 	VDEV_AUX_IO_FAILURE,	/* experienced I/O failure		*/
1018 	VDEV_AUX_BAD_LOG,	/* cannot read log chain(s)		*/
1019 	VDEV_AUX_EXTERNAL,	/* external diagnosis or forced fault	*/
1020 	VDEV_AUX_SPLIT_POOL,	/* vdev was split off into another pool	*/
1021 	VDEV_AUX_BAD_ASHIFT,	/* vdev ashift is invalid		*/
1022 	VDEV_AUX_EXTERNAL_PERSIST,	/* persistent forced fault	*/
1023 	VDEV_AUX_ACTIVE,	/* vdev active on a different host	*/
1024 	VDEV_AUX_CHILDREN_OFFLINE, /* all children are offline		*/
1025 	VDEV_AUX_ASHIFT_TOO_BIG, /* vdev's min block size is too large   */
1026 } vdev_aux_t;
1027 
1028 /*
1029  * pool state.  The following states are written to disk as part of the normal
1030  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
1031  * states are software abstractions used at various levels to communicate
1032  * pool state.
1033  */
1034 typedef enum pool_state {
1035 	POOL_STATE_ACTIVE = 0,		/* In active use		*/
1036 	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
1037 	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
1038 	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
1039 	POOL_STATE_L2CACHE,		/* Level 2 ARC device		*/
1040 	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
1041 	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
1042 	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
1043 } pool_state_t;
1044 
1045 /*
1046  * mmp state. The following states provide additional detail describing
1047  * why a pool couldn't be safely imported.
1048  */
1049 typedef enum mmp_state {
1050 	MMP_STATE_ACTIVE = 0,		/* In active use		*/
1051 	MMP_STATE_INACTIVE,		/* Inactive and safe to import	*/
1052 	MMP_STATE_NO_HOSTID		/* System hostid is not set	*/
1053 } mmp_state_t;
1054 
1055 /*
1056  * Scan Functions.
1057  */
1058 typedef enum pool_scan_func {
1059 	POOL_SCAN_NONE,
1060 	POOL_SCAN_SCRUB,
1061 	POOL_SCAN_RESILVER,
1062 	POOL_SCAN_ERRORSCRUB,
1063 	POOL_SCAN_FUNCS
1064 } pool_scan_func_t;
1065 
1066 /*
1067  * Used to control scrub pause and resume.
1068  */
1069 typedef enum pool_scrub_cmd {
1070 	POOL_SCRUB_NORMAL = 0,
1071 	POOL_SCRUB_PAUSE,
1072 	POOL_SCRUB_FLAGS_END
1073 } pool_scrub_cmd_t;
1074 
1075 typedef enum {
1076 	CS_NONE,
1077 	CS_CHECKPOINT_EXISTS,
1078 	CS_CHECKPOINT_DISCARDING,
1079 	CS_NUM_STATES
1080 } checkpoint_state_t;
1081 
1082 typedef struct pool_checkpoint_stat {
1083 	uint64_t pcs_state;		/* checkpoint_state_t */
1084 	uint64_t pcs_start_time;	/* time checkpoint/discard started */
1085 	uint64_t pcs_space;		/* checkpointed space */
1086 } pool_checkpoint_stat_t;
1087 
1088 /*
1089  * ZIO types.  Needed to interpret vdev statistics below.
1090  */
1091 typedef enum zio_type {
1092 	ZIO_TYPE_NULL = 0,
1093 	ZIO_TYPE_READ,
1094 	ZIO_TYPE_WRITE,
1095 	ZIO_TYPE_FREE,
1096 	ZIO_TYPE_CLAIM,
1097 	ZIO_TYPE_FLUSH,
1098 	ZIO_TYPE_TRIM,
1099 	ZIO_TYPES
1100 } zio_type_t;
1101 
1102 /*
1103  * Compatibility: _IOCTL was renamed to _FLUSH; keep the old name available to
1104  * user programs.
1105  */
1106 #define	ZIO_TYPE_IOCTL	ZIO_TYPE_FLUSH
1107 
1108 /*
1109  * Pool statistics.  Note: all fields should be 64-bit because this
1110  * is passed between kernel and userland as an nvlist uint64 array.
1111  */
1112 typedef struct pool_scan_stat {
1113 	/* values stored on disk */
1114 	uint64_t	pss_func;	/* pool_scan_func_t */
1115 	uint64_t	pss_state;	/* dsl_scan_state_t */
1116 	uint64_t	pss_start_time;	/* scan start time */
1117 	uint64_t	pss_end_time;	/* scan end time */
1118 	uint64_t	pss_to_examine;	/* total bytes to scan */
1119 	uint64_t	pss_examined;	/* total bytes located by scanner */
1120 	uint64_t	pss_skipped;	/* total bytes skipped by scanner */
1121 	uint64_t	pss_processed;	/* total processed bytes */
1122 	uint64_t	pss_errors;	/* scan errors	*/
1123 
1124 	/* values not stored on disk */
1125 	uint64_t	pss_pass_exam; /* examined bytes per scan pass */
1126 	uint64_t	pss_pass_start;	/* start time of a scan pass */
1127 	uint64_t	pss_pass_scrub_pause; /* pause time of a scrub pass */
1128 	/* cumulative time scrub spent paused, needed for rate calculation */
1129 	uint64_t	pss_pass_scrub_spent_paused;
1130 	uint64_t	pss_pass_issued; /* issued bytes per scan pass */
1131 	uint64_t	pss_issued;	/* total bytes checked by scanner */
1132 
1133 	/* error scrub values stored on disk */
1134 	uint64_t	pss_error_scrub_func;	/* pool_scan_func_t */
1135 	uint64_t	pss_error_scrub_state;	/* dsl_scan_state_t */
1136 	uint64_t	pss_error_scrub_start;	/* error scrub start time */
1137 	uint64_t	pss_error_scrub_end;	/* error scrub end time */
1138 	uint64_t	pss_error_scrub_examined; /* error blocks issued I/O */
1139 	/* error blocks to be issued I/O */
1140 	uint64_t	pss_error_scrub_to_be_examined;
1141 
1142 	/* error scrub values not stored on disk */
1143 	/* error scrub pause time in milliseconds */
1144 	uint64_t	pss_pass_error_scrub_pause;
1145 
1146 } pool_scan_stat_t;
1147 
1148 typedef struct pool_removal_stat {
1149 	uint64_t prs_state; /* dsl_scan_state_t */
1150 	uint64_t prs_removing_vdev;
1151 	uint64_t prs_start_time;
1152 	uint64_t prs_end_time;
1153 	uint64_t prs_to_copy; /* bytes that need to be copied */
1154 	uint64_t prs_copied; /* bytes copied so far */
1155 	/*
1156 	 * bytes of memory used for indirect mappings.
1157 	 * This includes all removed vdevs.
1158 	 */
1159 	uint64_t prs_mapping_memory;
1160 } pool_removal_stat_t;
1161 
1162 typedef struct pool_raidz_expand_stat {
1163 	uint64_t pres_state; /* dsl_scan_state_t */
1164 	uint64_t pres_expanding_vdev;
1165 	uint64_t pres_start_time;
1166 	uint64_t pres_end_time;
1167 	uint64_t pres_to_reflow; /* bytes that need to be moved */
1168 	uint64_t pres_reflowed; /* bytes moved so far */
1169 	uint64_t pres_waiting_for_resilver;
1170 } pool_raidz_expand_stat_t;
1171 
1172 typedef enum dsl_scan_state {
1173 	DSS_NONE,
1174 	DSS_SCANNING,
1175 	DSS_FINISHED,
1176 	DSS_CANCELED,
1177 	DSS_ERRORSCRUBBING,
1178 	DSS_NUM_STATES
1179 } dsl_scan_state_t;
1180 
1181 typedef struct vdev_rebuild_stat {
1182 	uint64_t vrs_state;		/* vdev_rebuild_state_t */
1183 	uint64_t vrs_start_time;	/* time_t */
1184 	uint64_t vrs_end_time;		/* time_t */
1185 	uint64_t vrs_scan_time_ms;	/* total run time (millisecs) */
1186 	uint64_t vrs_bytes_scanned;	/* allocated bytes scanned */
1187 	uint64_t vrs_bytes_issued;	/* read bytes issued */
1188 	uint64_t vrs_bytes_rebuilt;	/* rebuilt bytes */
1189 	uint64_t vrs_bytes_est;		/* total bytes to scan */
1190 	uint64_t vrs_errors;		/* scanning errors */
1191 	uint64_t vrs_pass_time_ms;	/* pass run time (millisecs) */
1192 	uint64_t vrs_pass_bytes_scanned; /* bytes scanned since start/resume */
1193 	uint64_t vrs_pass_bytes_issued;	/* bytes rebuilt since start/resume */
1194 	uint64_t vrs_pass_bytes_skipped; /* bytes skipped since start/resume */
1195 } vdev_rebuild_stat_t;
1196 
1197 /*
1198  * Errata described by https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-ER.
1199  * The ordering of this enum must be maintained to ensure the errata identifiers
1200  * map to the correct documentation.  New errata may only be appended to the
1201  * list and must contain corresponding documentation at the above link.
1202  */
1203 typedef enum zpool_errata {
1204 	ZPOOL_ERRATA_NONE,
1205 	ZPOOL_ERRATA_ZOL_2094_SCRUB,
1206 	ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY,
1207 	ZPOOL_ERRATA_ZOL_6845_ENCRYPTION,
1208 	ZPOOL_ERRATA_ZOL_8308_ENCRYPTION,
1209 } zpool_errata_t;
1210 
1211 /*
1212  * Vdev statistics.  Note: all fields should be 64-bit because this
1213  * is passed between kernel and user land as an nvlist uint64 array.
1214  *
1215  * The vs_ops[] and vs_bytes[] arrays must always be an array size of 6 in
1216  * order to keep subsequent members at their known fixed offsets.  When
1217  * adding a new field it must be added to the end the structure.
1218  */
1219 #define	VS_ZIO_TYPES	6
1220 
1221 typedef struct vdev_stat {
1222 	hrtime_t	vs_timestamp;		/* time since vdev load	*/
1223 	uint64_t	vs_state;		/* vdev state		*/
1224 	uint64_t	vs_aux;			/* see vdev_aux_t	*/
1225 	uint64_t	vs_alloc;		/* space allocated	*/
1226 	uint64_t	vs_space;		/* total capacity	*/
1227 	uint64_t	vs_dspace;		/* deflated capacity	*/
1228 	uint64_t	vs_rsize;		/* replaceable dev size */
1229 	uint64_t	vs_esize;		/* expandable dev size */
1230 	uint64_t	vs_ops[VS_ZIO_TYPES];	/* operation count	*/
1231 	uint64_t	vs_bytes[VS_ZIO_TYPES];	/* bytes read/written	*/
1232 	uint64_t	vs_read_errors;		/* read errors		*/
1233 	uint64_t	vs_write_errors;	/* write errors		*/
1234 	uint64_t	vs_checksum_errors;	/* checksum errors	*/
1235 	uint64_t	vs_initialize_errors;	/* initializing errors	*/
1236 	uint64_t	vs_self_healed;		/* self-healed bytes	*/
1237 	uint64_t	vs_scan_removing;	/* removing?	*/
1238 	uint64_t	vs_scan_processed;	/* scan processed bytes	*/
1239 	uint64_t	vs_fragmentation;	/* device fragmentation */
1240 	uint64_t	vs_initialize_bytes_done; /* bytes initialized */
1241 	uint64_t	vs_initialize_bytes_est; /* total bytes to initialize */
1242 	uint64_t	vs_initialize_state;	/* vdev_initializing_state_t */
1243 	uint64_t	vs_initialize_action_time; /* time_t */
1244 	uint64_t	vs_checkpoint_space;    /* checkpoint-consumed space */
1245 	uint64_t	vs_resilver_deferred;	/* resilver deferred	*/
1246 	uint64_t	vs_slow_ios;		/* slow IOs */
1247 	uint64_t	vs_trim_errors;		/* trimming errors	*/
1248 	uint64_t	vs_trim_notsup;		/* supported by device */
1249 	uint64_t	vs_trim_bytes_done;	/* bytes trimmed */
1250 	uint64_t	vs_trim_bytes_est;	/* total bytes to trim */
1251 	uint64_t	vs_trim_state;		/* vdev_trim_state_t */
1252 	uint64_t	vs_trim_action_time;	/* time_t */
1253 	uint64_t	vs_rebuild_processed;	/* bytes rebuilt */
1254 	uint64_t	vs_configured_ashift;   /* TLV vdev_ashift */
1255 	uint64_t	vs_logical_ashift;	/* vdev_logical_ashift  */
1256 	uint64_t	vs_physical_ashift;	/* vdev_physical_ashift */
1257 	uint64_t	vs_noalloc;		/* allocations halted?	*/
1258 	uint64_t	vs_pspace;		/* physical capacity */
1259 } vdev_stat_t;
1260 
1261 #define	VDEV_STAT_VALID(field, uint64_t_field_count) \
1262 ((uint64_t_field_count * sizeof (uint64_t)) >=	 \
1263 	(offsetof(vdev_stat_t, field) + sizeof (((vdev_stat_t *)NULL)->field)))
1264 
1265 /*
1266  * Extended stats
1267  *
1268  * These are stats which aren't included in the original iostat output.  For
1269  * convenience, they are grouped together in vdev_stat_ex, although each stat
1270  * is individually exported as an nvlist.
1271  */
1272 typedef struct vdev_stat_ex {
1273 	/* Number of ZIOs issued to disk and waiting to finish */
1274 	uint64_t vsx_active_queue[ZIO_PRIORITY_NUM_QUEUEABLE];
1275 
1276 	/* Number of ZIOs pending to be issued to disk */
1277 	uint64_t vsx_pend_queue[ZIO_PRIORITY_NUM_QUEUEABLE];
1278 
1279 	/*
1280 	 * Below are the histograms for various latencies. Buckets are in
1281 	 * units of nanoseconds.
1282 	 */
1283 
1284 	/*
1285 	 * 2^37 nanoseconds = 134s. Timeouts will probably start kicking in
1286 	 * before this.
1287 	 */
1288 #define	VDEV_L_HISTO_BUCKETS 37		/* Latency histo buckets */
1289 #define	VDEV_RQ_HISTO_BUCKETS 25	/* Request size histo buckets */
1290 
1291 	/* Amount of time in ZIO queue (ns) */
1292 	uint64_t vsx_queue_histo[ZIO_PRIORITY_NUM_QUEUEABLE]
1293 	    [VDEV_L_HISTO_BUCKETS];
1294 
1295 	/* Total ZIO latency (ns).  Includes queuing and disk access time */
1296 	uint64_t vsx_total_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS];
1297 
1298 	/* Amount of time to read/write the disk (ns) */
1299 	uint64_t vsx_disk_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS];
1300 
1301 	/* "lookup the bucket for a value" histogram macros */
1302 #define	HISTO(val, buckets) (val != 0 ? MIN(highbit64(val) - 1, \
1303 	    buckets - 1) : 0)
1304 #define	L_HISTO(a) HISTO(a, VDEV_L_HISTO_BUCKETS)
1305 #define	RQ_HISTO(a) HISTO(a, VDEV_RQ_HISTO_BUCKETS)
1306 
1307 	/* Physical IO histogram */
1308 	uint64_t vsx_ind_histo[ZIO_PRIORITY_NUM_QUEUEABLE]
1309 	    [VDEV_RQ_HISTO_BUCKETS];
1310 
1311 	/* Delegated (aggregated) physical IO histogram */
1312 	uint64_t vsx_agg_histo[ZIO_PRIORITY_NUM_QUEUEABLE]
1313 	    [VDEV_RQ_HISTO_BUCKETS];
1314 
1315 } vdev_stat_ex_t;
1316 
1317 /*
1318  * Initialize functions.
1319  */
1320 typedef enum pool_initialize_func {
1321 	POOL_INITIALIZE_START,
1322 	POOL_INITIALIZE_CANCEL,
1323 	POOL_INITIALIZE_SUSPEND,
1324 	POOL_INITIALIZE_UNINIT,
1325 	POOL_INITIALIZE_FUNCS
1326 } pool_initialize_func_t;
1327 
1328 /*
1329  * TRIM functions.
1330  */
1331 typedef enum pool_trim_func {
1332 	POOL_TRIM_START,
1333 	POOL_TRIM_CANCEL,
1334 	POOL_TRIM_SUSPEND,
1335 	POOL_TRIM_FUNCS
1336 } pool_trim_func_t;
1337 
1338 /*
1339  * DDT statistics.  Note: all fields should be 64-bit because this
1340  * is passed between kernel and userland as an nvlist uint64 array.
1341  */
1342 typedef struct ddt_object {
1343 	uint64_t	ddo_count;	/* number of elements in ddt	*/
1344 	uint64_t	ddo_dspace;	/* size of ddt on disk		*/
1345 	uint64_t	ddo_mspace;	/* size of ddt in-core		*/
1346 } ddt_object_t;
1347 
1348 typedef struct ddt_stat {
1349 	uint64_t	dds_blocks;	/* blocks			*/
1350 	uint64_t	dds_lsize;	/* logical size			*/
1351 	uint64_t	dds_psize;	/* physical size		*/
1352 	uint64_t	dds_dsize;	/* deflated allocated size	*/
1353 	uint64_t	dds_ref_blocks;	/* referenced blocks		*/
1354 	uint64_t	dds_ref_lsize;	/* referenced lsize * refcnt	*/
1355 	uint64_t	dds_ref_psize;	/* referenced psize * refcnt	*/
1356 	uint64_t	dds_ref_dsize;	/* referenced dsize * refcnt	*/
1357 } ddt_stat_t;
1358 
1359 typedef struct ddt_histogram {
1360 	ddt_stat_t	ddh_stat[64];	/* power-of-two histogram buckets */
1361 } ddt_histogram_t;
1362 
1363 #define	ZVOL_DRIVER	"zvol"
1364 #define	ZFS_DRIVER	"zfs"
1365 #define	ZFS_DEV		"/dev/zfs"
1366 #define	ZFS_DEVDIR	"/dev"
1367 
1368 #define	ZFS_SUPER_MAGIC	0x2fc12fc1
1369 
1370 /* general zvol path */
1371 #define	ZVOL_DIR		"/dev/zvol/"
1372 
1373 #define	ZVOL_MAJOR		230
1374 #define	ZVOL_MINOR_BITS		4
1375 #define	ZVOL_MINOR_MASK		((1U << ZVOL_MINOR_BITS) - 1)
1376 #define	ZVOL_MINORS		(1 << 4)
1377 #define	ZVOL_DEV_NAME		"zd"
1378 
1379 #define	ZVOL_PROP_NAME		"name"
1380 #define	ZVOL_DEFAULT_BLOCKSIZE	16384
1381 
1382 typedef enum {
1383 	VDEV_INITIALIZE_NONE,
1384 	VDEV_INITIALIZE_ACTIVE,
1385 	VDEV_INITIALIZE_CANCELED,
1386 	VDEV_INITIALIZE_SUSPENDED,
1387 	VDEV_INITIALIZE_COMPLETE
1388 } vdev_initializing_state_t;
1389 
1390 typedef enum {
1391 	VDEV_TRIM_NONE,
1392 	VDEV_TRIM_ACTIVE,
1393 	VDEV_TRIM_CANCELED,
1394 	VDEV_TRIM_SUSPENDED,
1395 	VDEV_TRIM_COMPLETE,
1396 } vdev_trim_state_t;
1397 
1398 typedef enum {
1399 	VDEV_REBUILD_NONE,
1400 	VDEV_REBUILD_ACTIVE,
1401 	VDEV_REBUILD_CANCELED,
1402 	VDEV_REBUILD_COMPLETE,
1403 } vdev_rebuild_state_t;
1404 
1405 /*
1406  * nvlist name constants. Facilitate restricting snapshot iteration range for
1407  * the "list next snapshot" ioctl
1408  */
1409 #define	SNAP_ITER_MIN_TXG	"snap_iter_min_txg"
1410 #define	SNAP_ITER_MAX_TXG	"snap_iter_max_txg"
1411 
1412 /*
1413  * /dev/zfs ioctl numbers.
1414  *
1415  * These numbers cannot change over time. New ioctl numbers must be appended.
1416  */
1417 typedef enum zfs_ioc {
1418 	/*
1419 	 * Core features - 88/128 numbers reserved.
1420 	 */
1421 #ifdef __FreeBSD__
1422 	ZFS_IOC_FIRST =	0,
1423 #else
1424 	ZFS_IOC_FIRST =	('Z' << 8),
1425 #endif
1426 	ZFS_IOC = ZFS_IOC_FIRST,
1427 	ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,	/* 0x5a00 */
1428 	ZFS_IOC_POOL_DESTROY,			/* 0x5a01 */
1429 	ZFS_IOC_POOL_IMPORT,			/* 0x5a02 */
1430 	ZFS_IOC_POOL_EXPORT,			/* 0x5a03 */
1431 	ZFS_IOC_POOL_CONFIGS,			/* 0x5a04 */
1432 	ZFS_IOC_POOL_STATS,			/* 0x5a05 */
1433 	ZFS_IOC_POOL_TRYIMPORT,			/* 0x5a06 */
1434 	ZFS_IOC_POOL_SCAN,			/* 0x5a07 */
1435 	ZFS_IOC_POOL_FREEZE,			/* 0x5a08 */
1436 	ZFS_IOC_POOL_UPGRADE,			/* 0x5a09 */
1437 	ZFS_IOC_POOL_GET_HISTORY,		/* 0x5a0a */
1438 	ZFS_IOC_VDEV_ADD,			/* 0x5a0b */
1439 	ZFS_IOC_VDEV_REMOVE,			/* 0x5a0c */
1440 	ZFS_IOC_VDEV_SET_STATE,			/* 0x5a0d */
1441 	ZFS_IOC_VDEV_ATTACH,			/* 0x5a0e */
1442 	ZFS_IOC_VDEV_DETACH,			/* 0x5a0f */
1443 	ZFS_IOC_VDEV_SETPATH,			/* 0x5a10 */
1444 	ZFS_IOC_VDEV_SETFRU,			/* 0x5a11 */
1445 	ZFS_IOC_OBJSET_STATS,			/* 0x5a12 */
1446 	ZFS_IOC_OBJSET_ZPLPROPS,		/* 0x5a13 */
1447 	ZFS_IOC_DATASET_LIST_NEXT,		/* 0x5a14 */
1448 	ZFS_IOC_SNAPSHOT_LIST_NEXT,		/* 0x5a15 */
1449 	ZFS_IOC_SET_PROP,			/* 0x5a16 */
1450 	ZFS_IOC_CREATE,				/* 0x5a17 */
1451 	ZFS_IOC_DESTROY,			/* 0x5a18 */
1452 	ZFS_IOC_ROLLBACK,			/* 0x5a19 */
1453 	ZFS_IOC_RENAME,				/* 0x5a1a */
1454 	ZFS_IOC_RECV,				/* 0x5a1b */
1455 	ZFS_IOC_SEND,				/* 0x5a1c */
1456 	ZFS_IOC_INJECT_FAULT,			/* 0x5a1d */
1457 	ZFS_IOC_CLEAR_FAULT,			/* 0x5a1e */
1458 	ZFS_IOC_INJECT_LIST_NEXT,		/* 0x5a1f */
1459 	ZFS_IOC_ERROR_LOG,			/* 0x5a20 */
1460 	ZFS_IOC_CLEAR,				/* 0x5a21 */
1461 	ZFS_IOC_PROMOTE,			/* 0x5a22 */
1462 	ZFS_IOC_SNAPSHOT,			/* 0x5a23 */
1463 	ZFS_IOC_DSOBJ_TO_DSNAME,		/* 0x5a24 */
1464 	ZFS_IOC_OBJ_TO_PATH,			/* 0x5a25 */
1465 	ZFS_IOC_POOL_SET_PROPS,			/* 0x5a26 */
1466 	ZFS_IOC_POOL_GET_PROPS,			/* 0x5a27 */
1467 	ZFS_IOC_SET_FSACL,			/* 0x5a28 */
1468 	ZFS_IOC_GET_FSACL,			/* 0x5a29 */
1469 	ZFS_IOC_SHARE,				/* 0x5a2a */
1470 	ZFS_IOC_INHERIT_PROP,			/* 0x5a2b */
1471 	ZFS_IOC_SMB_ACL,			/* 0x5a2c */
1472 	ZFS_IOC_USERSPACE_ONE,			/* 0x5a2d */
1473 	ZFS_IOC_USERSPACE_MANY,			/* 0x5a2e */
1474 	ZFS_IOC_USERSPACE_UPGRADE,		/* 0x5a2f */
1475 	ZFS_IOC_HOLD,				/* 0x5a30 */
1476 	ZFS_IOC_RELEASE,			/* 0x5a31 */
1477 	ZFS_IOC_GET_HOLDS,			/* 0x5a32 */
1478 	ZFS_IOC_OBJSET_RECVD_PROPS,		/* 0x5a33 */
1479 	ZFS_IOC_VDEV_SPLIT,			/* 0x5a34 */
1480 	ZFS_IOC_NEXT_OBJ,			/* 0x5a35 */
1481 	ZFS_IOC_DIFF,				/* 0x5a36 */
1482 	ZFS_IOC_TMP_SNAPSHOT,			/* 0x5a37 */
1483 	ZFS_IOC_OBJ_TO_STATS,			/* 0x5a38 */
1484 	ZFS_IOC_SPACE_WRITTEN,			/* 0x5a39 */
1485 	ZFS_IOC_SPACE_SNAPS,			/* 0x5a3a */
1486 	ZFS_IOC_DESTROY_SNAPS,			/* 0x5a3b */
1487 	ZFS_IOC_POOL_REGUID,			/* 0x5a3c */
1488 	ZFS_IOC_POOL_REOPEN,			/* 0x5a3d */
1489 	ZFS_IOC_SEND_PROGRESS,			/* 0x5a3e */
1490 	ZFS_IOC_LOG_HISTORY,			/* 0x5a3f */
1491 	ZFS_IOC_SEND_NEW,			/* 0x5a40 */
1492 	ZFS_IOC_SEND_SPACE,			/* 0x5a41 */
1493 	ZFS_IOC_CLONE,				/* 0x5a42 */
1494 	ZFS_IOC_BOOKMARK,			/* 0x5a43 */
1495 	ZFS_IOC_GET_BOOKMARKS,			/* 0x5a44 */
1496 	ZFS_IOC_DESTROY_BOOKMARKS,		/* 0x5a45 */
1497 	ZFS_IOC_RECV_NEW,			/* 0x5a46 */
1498 	ZFS_IOC_POOL_SYNC,			/* 0x5a47 */
1499 	ZFS_IOC_CHANNEL_PROGRAM,		/* 0x5a48 */
1500 	ZFS_IOC_LOAD_KEY,			/* 0x5a49 */
1501 	ZFS_IOC_UNLOAD_KEY,			/* 0x5a4a */
1502 	ZFS_IOC_CHANGE_KEY,			/* 0x5a4b */
1503 	ZFS_IOC_REMAP,				/* 0x5a4c */
1504 	ZFS_IOC_POOL_CHECKPOINT,		/* 0x5a4d */
1505 	ZFS_IOC_POOL_DISCARD_CHECKPOINT,	/* 0x5a4e */
1506 	ZFS_IOC_POOL_INITIALIZE,		/* 0x5a4f */
1507 	ZFS_IOC_POOL_TRIM,			/* 0x5a50 */
1508 	ZFS_IOC_REDACT,				/* 0x5a51 */
1509 	ZFS_IOC_GET_BOOKMARK_PROPS,		/* 0x5a52 */
1510 	ZFS_IOC_WAIT,				/* 0x5a53 */
1511 	ZFS_IOC_WAIT_FS,			/* 0x5a54 */
1512 	ZFS_IOC_VDEV_GET_PROPS,			/* 0x5a55 */
1513 	ZFS_IOC_VDEV_SET_PROPS,			/* 0x5a56 */
1514 	ZFS_IOC_POOL_SCRUB,			/* 0x5a57 */
1515 
1516 	/*
1517 	 * Per-platform (Optional) - 8/128 numbers reserved.
1518 	 */
1519 	ZFS_IOC_PLATFORM = ZFS_IOC_FIRST + 0x80,
1520 	ZFS_IOC_EVENTS_NEXT,			/* 0x81 (Linux) */
1521 	ZFS_IOC_EVENTS_CLEAR,			/* 0x82 (Linux) */
1522 	ZFS_IOC_EVENTS_SEEK,			/* 0x83 (Linux) */
1523 	ZFS_IOC_NEXTBOOT,			/* 0x84 (FreeBSD) */
1524 	ZFS_IOC_JAIL,				/* 0x85 (FreeBSD) */
1525 	ZFS_IOC_USERNS_ATTACH = ZFS_IOC_JAIL,	/* 0x85 (Linux) */
1526 	ZFS_IOC_UNJAIL,				/* 0x86 (FreeBSD) */
1527 	ZFS_IOC_USERNS_DETACH = ZFS_IOC_UNJAIL,	/* 0x86 (Linux) */
1528 	ZFS_IOC_SET_BOOTENV,			/* 0x87 */
1529 	ZFS_IOC_GET_BOOTENV,			/* 0x88 */
1530 	ZFS_IOC_LAST
1531 } zfs_ioc_t;
1532 
1533 /*
1534  * zvol ioctl to get dataset name
1535  */
1536 #define	BLKZNAME		_IOR(0x12, 125, char[ZFS_MAX_DATASET_NAME_LEN])
1537 
1538 #ifdef __linux__
1539 
1540 /*
1541  * IOCTLs to update and retrieve additional file level attributes on
1542  * Linux.
1543  */
1544 #define	ZFS_IOC_GETDOSFLAGS	_IOR(0x83, 1, uint64_t)
1545 #define	ZFS_IOC_SETDOSFLAGS	_IOW(0x83, 2, uint64_t)
1546 
1547 /*
1548  * Additional file level attributes, that are stored
1549  * in the upper half of z_pflags
1550  */
1551 #define	ZFS_READONLY		0x0000000100000000ull
1552 #define	ZFS_HIDDEN		0x0000000200000000ull
1553 #define	ZFS_SYSTEM		0x0000000400000000ull
1554 #define	ZFS_ARCHIVE		0x0000000800000000ull
1555 #define	ZFS_IMMUTABLE		0x0000001000000000ull
1556 #define	ZFS_NOUNLINK		0x0000002000000000ull
1557 #define	ZFS_APPENDONLY		0x0000004000000000ull
1558 #define	ZFS_NODUMP		0x0000008000000000ull
1559 #define	ZFS_OPAQUE		0x0000010000000000ull
1560 #define	ZFS_AV_QUARANTINED	0x0000020000000000ull
1561 #define	ZFS_AV_MODIFIED		0x0000040000000000ull
1562 #define	ZFS_REPARSE		0x0000080000000000ull
1563 #define	ZFS_OFFLINE		0x0000100000000000ull
1564 #define	ZFS_SPARSE		0x0000200000000000ull
1565 
1566 #define	ZFS_DOS_FL_USER_VISIBLE	(ZFS_IMMUTABLE | ZFS_APPENDONLY | \
1567 	    ZFS_NOUNLINK | ZFS_ARCHIVE | ZFS_NODUMP | ZFS_SYSTEM | \
1568 	    ZFS_HIDDEN | ZFS_READONLY | ZFS_REPARSE | ZFS_OFFLINE | \
1569 	    ZFS_SPARSE)
1570 
1571 #endif
1572 
1573 /*
1574  * ZFS-specific error codes used for returning descriptive errors
1575  * to the userland through zfs ioctls.
1576  *
1577  * The enum implicitly includes all the error codes from errno.h.
1578  * New code should use and extend this enum for errors that are
1579  * not described precisely by generic errno codes.
1580  *
1581  * These numbers should not change over time. New entries should be appended.
1582  *
1583  * (Keep in sync with contrib/pyzfs/libzfs_core/_constants.py)
1584  */
1585 typedef enum {
1586 	ZFS_ERR_CHECKPOINT_EXISTS = 1024,
1587 	ZFS_ERR_DISCARDING_CHECKPOINT,
1588 	ZFS_ERR_NO_CHECKPOINT,
1589 	ZFS_ERR_DEVRM_IN_PROGRESS,
1590 	ZFS_ERR_VDEV_TOO_BIG,
1591 	ZFS_ERR_IOC_CMD_UNAVAIL,
1592 	ZFS_ERR_IOC_ARG_UNAVAIL,
1593 	ZFS_ERR_IOC_ARG_REQUIRED,
1594 	ZFS_ERR_IOC_ARG_BADTYPE,
1595 	ZFS_ERR_WRONG_PARENT,
1596 	ZFS_ERR_FROM_IVSET_GUID_MISSING,
1597 	ZFS_ERR_FROM_IVSET_GUID_MISMATCH,
1598 	ZFS_ERR_SPILL_BLOCK_FLAG_MISSING,
1599 	ZFS_ERR_UNKNOWN_SEND_STREAM_FEATURE,
1600 	ZFS_ERR_EXPORT_IN_PROGRESS,
1601 	ZFS_ERR_BOOKMARK_SOURCE_NOT_ANCESTOR,
1602 	ZFS_ERR_STREAM_TRUNCATED,
1603 	ZFS_ERR_STREAM_LARGE_BLOCK_MISMATCH,
1604 	ZFS_ERR_RESILVER_IN_PROGRESS,
1605 	ZFS_ERR_REBUILD_IN_PROGRESS,
1606 	ZFS_ERR_BADPROP,
1607 	ZFS_ERR_VDEV_NOTSUP,
1608 	ZFS_ERR_NOT_USER_NAMESPACE,
1609 	ZFS_ERR_RESUME_EXISTS,
1610 	ZFS_ERR_CRYPTO_NOTSUP,
1611 	ZFS_ERR_RAIDZ_EXPAND_IN_PROGRESS,
1612 	ZFS_ERR_ASHIFT_MISMATCH,
1613 } zfs_errno_t;
1614 
1615 /*
1616  * Internal SPA load state.  Used by FMA diagnosis engine.
1617  */
1618 typedef enum {
1619 	SPA_LOAD_NONE,		/* no load in progress	*/
1620 	SPA_LOAD_OPEN,		/* normal open		*/
1621 	SPA_LOAD_IMPORT,	/* import in progress	*/
1622 	SPA_LOAD_TRYIMPORT,	/* tryimport in progress */
1623 	SPA_LOAD_RECOVER,	/* recovery requested	*/
1624 	SPA_LOAD_ERROR,		/* load failed		*/
1625 	SPA_LOAD_CREATE		/* creation in progress */
1626 } spa_load_state_t;
1627 
1628 typedef enum {
1629 	ZPOOL_WAIT_CKPT_DISCARD,
1630 	ZPOOL_WAIT_FREE,
1631 	ZPOOL_WAIT_INITIALIZE,
1632 	ZPOOL_WAIT_REPLACE,
1633 	ZPOOL_WAIT_REMOVE,
1634 	ZPOOL_WAIT_RESILVER,
1635 	ZPOOL_WAIT_SCRUB,
1636 	ZPOOL_WAIT_TRIM,
1637 	ZPOOL_WAIT_RAIDZ_EXPAND,
1638 	ZPOOL_WAIT_NUM_ACTIVITIES
1639 } zpool_wait_activity_t;
1640 
1641 typedef enum {
1642 	ZFS_WAIT_DELETEQ,
1643 	ZFS_WAIT_NUM_ACTIVITIES
1644 } zfs_wait_activity_t;
1645 
1646 /*
1647  * Bookmark name values.
1648  */
1649 #define	ZPOOL_ERR_LIST		"error list"
1650 #define	ZPOOL_ERR_DATASET	"dataset"
1651 #define	ZPOOL_ERR_OBJECT	"object"
1652 
1653 #define	HIS_MAX_RECORD_LEN	(MAXPATHLEN + MAXPATHLEN + 1)
1654 
1655 /*
1656  * The following are names used in the nvlist describing
1657  * the pool's history log.
1658  */
1659 #define	ZPOOL_HIST_RECORD	"history record"
1660 #define	ZPOOL_HIST_TIME		"history time"
1661 #define	ZPOOL_HIST_CMD		"history command"
1662 #define	ZPOOL_HIST_WHO		"history who"
1663 #define	ZPOOL_HIST_ZONE		"history zone"
1664 #define	ZPOOL_HIST_HOST		"history hostname"
1665 #define	ZPOOL_HIST_TXG		"history txg"
1666 #define	ZPOOL_HIST_INT_EVENT	"history internal event"
1667 #define	ZPOOL_HIST_INT_STR	"history internal str"
1668 #define	ZPOOL_HIST_INT_NAME	"internal_name"
1669 #define	ZPOOL_HIST_IOCTL	"ioctl"
1670 #define	ZPOOL_HIST_INPUT_NVL	"in_nvl"
1671 #define	ZPOOL_HIST_OUTPUT_NVL	"out_nvl"
1672 #define	ZPOOL_HIST_OUTPUT_SIZE	"out_size"
1673 #define	ZPOOL_HIST_DSNAME	"dsname"
1674 #define	ZPOOL_HIST_DSID		"dsid"
1675 #define	ZPOOL_HIST_ERRNO	"errno"
1676 #define	ZPOOL_HIST_ELAPSED_NS	"elapsed_ns"
1677 
1678 /*
1679  * Special nvlist name that will not have its args recorded in the pool's
1680  * history log.
1681  */
1682 #define	ZPOOL_HIDDEN_ARGS	"hidden_args"
1683 
1684 /*
1685  * The following are names used when invoking ZFS_IOC_POOL_INITIALIZE.
1686  */
1687 #define	ZPOOL_INITIALIZE_COMMAND	"initialize_command"
1688 #define	ZPOOL_INITIALIZE_VDEVS		"initialize_vdevs"
1689 
1690 /*
1691  * The following are names used when invoking ZFS_IOC_POOL_TRIM.
1692  */
1693 #define	ZPOOL_TRIM_COMMAND		"trim_command"
1694 #define	ZPOOL_TRIM_VDEVS		"trim_vdevs"
1695 #define	ZPOOL_TRIM_RATE			"trim_rate"
1696 #define	ZPOOL_TRIM_SECURE		"trim_secure"
1697 
1698 /*
1699  * The following are names used when invoking ZFS_IOC_POOL_WAIT.
1700  */
1701 #define	ZPOOL_WAIT_ACTIVITY		"wait_activity"
1702 #define	ZPOOL_WAIT_TAG			"wait_tag"
1703 #define	ZPOOL_WAIT_WAITED		"wait_waited"
1704 
1705 /*
1706  * The following are names used when invoking ZFS_IOC_VDEV_GET_PROP.
1707  */
1708 #define	ZPOOL_VDEV_PROPS_GET_VDEV	"vdevprops_get_vdev"
1709 #define	ZPOOL_VDEV_PROPS_GET_PROPS	"vdevprops_get_props"
1710 
1711 /*
1712  * The following are names used when invoking ZFS_IOC_VDEV_SET_PROP.
1713  */
1714 #define	ZPOOL_VDEV_PROPS_SET_VDEV	"vdevprops_set_vdev"
1715 #define	ZPOOL_VDEV_PROPS_SET_PROPS	"vdevprops_set_props"
1716 
1717 /*
1718  * The following are names used when invoking ZFS_IOC_WAIT_FS.
1719  */
1720 #define	ZFS_WAIT_ACTIVITY		"wait_activity"
1721 #define	ZFS_WAIT_WAITED			"wait_waited"
1722 
1723 /*
1724  * Flags for ZFS_IOC_VDEV_SET_STATE
1725  */
1726 #define	ZFS_ONLINE_CHECKREMOVE	0x1
1727 #define	ZFS_ONLINE_UNSPARE	0x2
1728 #define	ZFS_ONLINE_FORCEFAULT	0x4
1729 #define	ZFS_ONLINE_EXPAND	0x8
1730 #define	ZFS_ONLINE_SPARE	0x10
1731 #define	ZFS_OFFLINE_TEMPORARY	0x1
1732 
1733 /*
1734  * Flags for ZFS_IOC_POOL_IMPORT
1735  */
1736 #define	ZFS_IMPORT_NORMAL	0x0
1737 #define	ZFS_IMPORT_VERBATIM	0x1
1738 #define	ZFS_IMPORT_ANY_HOST	0x2
1739 #define	ZFS_IMPORT_MISSING_LOG	0x4
1740 #define	ZFS_IMPORT_ONLY		0x8
1741 #define	ZFS_IMPORT_TEMP_NAME	0x10
1742 #define	ZFS_IMPORT_SKIP_MMP	0x20
1743 #define	ZFS_IMPORT_LOAD_KEYS	0x40
1744 #define	ZFS_IMPORT_CHECKPOINT	0x80
1745 
1746 /*
1747  * Channel program argument/return nvlist keys and defaults.
1748  */
1749 #define	ZCP_ARG_PROGRAM		"program"
1750 #define	ZCP_ARG_ARGLIST		"arg"
1751 #define	ZCP_ARG_SYNC		"sync"
1752 #define	ZCP_ARG_INSTRLIMIT	"instrlimit"
1753 #define	ZCP_ARG_MEMLIMIT	"memlimit"
1754 
1755 #define	ZCP_ARG_CLIARGV		"argv"
1756 
1757 #define	ZCP_RET_ERROR		"error"
1758 #define	ZCP_RET_RETURN		"return"
1759 
1760 #define	ZCP_DEFAULT_INSTRLIMIT	(10 * 1000 * 1000)
1761 #define	ZCP_MAX_INSTRLIMIT	(10 * ZCP_DEFAULT_INSTRLIMIT)
1762 #define	ZCP_DEFAULT_MEMLIMIT	(10 * 1024 * 1024)
1763 #define	ZCP_MAX_MEMLIMIT	(10 * ZCP_DEFAULT_MEMLIMIT)
1764 
1765 /*
1766  * Sysevent payload members.  ZFS will generate the following sysevents with the
1767  * given payloads:
1768  *
1769  *	ESC_ZFS_RESILVER_START
1770  *	ESC_ZFS_RESILVER_FINISH
1771  *
1772  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
1773  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
1774  *		ZFS_EV_RESILVER_TYPE	DATA_TYPE_STRING
1775  *
1776  *	ESC_ZFS_POOL_DESTROY
1777  *	ESC_ZFS_POOL_REGUID
1778  *
1779  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
1780  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
1781  *
1782  *	ESC_ZFS_VDEV_REMOVE
1783  *	ESC_ZFS_VDEV_CLEAR
1784  *	ESC_ZFS_VDEV_CHECK
1785  *
1786  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
1787  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
1788  *		ZFS_EV_VDEV_PATH	DATA_TYPE_STRING	(optional)
1789  *		ZFS_EV_VDEV_GUID	DATA_TYPE_UINT64
1790  *
1791  *	ESC_ZFS_HISTORY_EVENT
1792  *
1793  *		ZFS_EV_POOL_NAME	DATA_TYPE_STRING
1794  *		ZFS_EV_POOL_GUID	DATA_TYPE_UINT64
1795  *		ZFS_EV_HIST_TIME	DATA_TYPE_UINT64	(optional)
1796  *		ZFS_EV_HIST_CMD		DATA_TYPE_STRING	(optional)
1797  *		ZFS_EV_HIST_WHO		DATA_TYPE_UINT64	(optional)
1798  *		ZFS_EV_HIST_ZONE	DATA_TYPE_STRING	(optional)
1799  *		ZFS_EV_HIST_HOST	DATA_TYPE_STRING	(optional)
1800  *		ZFS_EV_HIST_TXG		DATA_TYPE_UINT64	(optional)
1801  *		ZFS_EV_HIST_INT_EVENT	DATA_TYPE_UINT64	(optional)
1802  *		ZFS_EV_HIST_INT_STR	DATA_TYPE_STRING	(optional)
1803  *		ZFS_EV_HIST_INT_NAME	DATA_TYPE_STRING	(optional)
1804  *		ZFS_EV_HIST_IOCTL	DATA_TYPE_STRING	(optional)
1805  *		ZFS_EV_HIST_DSNAME	DATA_TYPE_STRING	(optional)
1806  *		ZFS_EV_HIST_DSID	DATA_TYPE_UINT64	(optional)
1807  *
1808  * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the
1809  * history log nvlist.  The keynames will be free of any spaces or other
1810  * characters that could be potentially unexpected to consumers of the
1811  * sysevents.
1812  */
1813 #define	ZFS_EV_POOL_NAME	"pool_name"
1814 #define	ZFS_EV_POOL_GUID	"pool_guid"
1815 #define	ZFS_EV_VDEV_PATH	"vdev_path"
1816 #define	ZFS_EV_VDEV_GUID	"vdev_guid"
1817 #define	ZFS_EV_HIST_TIME	"history_time"
1818 #define	ZFS_EV_HIST_CMD		"history_command"
1819 #define	ZFS_EV_HIST_WHO		"history_who"
1820 #define	ZFS_EV_HIST_ZONE	"history_zone"
1821 #define	ZFS_EV_HIST_HOST	"history_hostname"
1822 #define	ZFS_EV_HIST_TXG		"history_txg"
1823 #define	ZFS_EV_HIST_INT_EVENT	"history_internal_event"
1824 #define	ZFS_EV_HIST_INT_STR	"history_internal_str"
1825 #define	ZFS_EV_HIST_INT_NAME	"history_internal_name"
1826 #define	ZFS_EV_HIST_IOCTL	"history_ioctl"
1827 #define	ZFS_EV_HIST_DSNAME	"history_dsname"
1828 #define	ZFS_EV_HIST_DSID	"history_dsid"
1829 #define	ZFS_EV_RESILVER_TYPE	"resilver_type"
1830 
1831 /*
1832  * We currently support block sizes from 512 bytes to 16MB.
1833  * The benefits of larger blocks, and thus larger IO, need to be weighed
1834  * against the cost of COWing a giant block to modify one byte, and the
1835  * large latency of reading or writing a large block.
1836  *
1837  * The recordsize property can not be set larger than zfs_max_recordsize
1838  * (default 16MB on 64-bit and 1MB on 32-bit). See the comment near
1839  * zfs_max_recordsize in dsl_dataset.c for details.
1840  *
1841  * Note that although the LSIZE field of the blkptr_t can store sizes up
1842  * to 32MB, the dnode's dn_datablkszsec can only store sizes up to
1843  * 32MB - 512 bytes.  Therefore, we limit SPA_MAXBLOCKSIZE to 16MB.
1844  */
1845 #define	SPA_MINBLOCKSHIFT	9
1846 #define	SPA_OLD_MAXBLOCKSHIFT	17
1847 #define	SPA_MAXBLOCKSHIFT	24
1848 #define	SPA_MINBLOCKSIZE	(1ULL << SPA_MINBLOCKSHIFT)
1849 #define	SPA_OLD_MAXBLOCKSIZE	(1ULL << SPA_OLD_MAXBLOCKSHIFT)
1850 #define	SPA_MAXBLOCKSIZE	(1ULL << SPA_MAXBLOCKSHIFT)
1851 
1852 /* supported encryption algorithms */
1853 enum zio_encrypt {
1854 	ZIO_CRYPT_INHERIT = 0,
1855 	ZIO_CRYPT_ON,
1856 	ZIO_CRYPT_OFF,
1857 	ZIO_CRYPT_AES_128_CCM,
1858 	ZIO_CRYPT_AES_192_CCM,
1859 	ZIO_CRYPT_AES_256_CCM,
1860 	ZIO_CRYPT_AES_128_GCM,
1861 	ZIO_CRYPT_AES_192_GCM,
1862 	ZIO_CRYPT_AES_256_GCM,
1863 	ZIO_CRYPT_FUNCTIONS
1864 };
1865 
1866 #define	ZIO_CRYPT_ON_VALUE	ZIO_CRYPT_AES_256_GCM
1867 #define	ZIO_CRYPT_DEFAULT	ZIO_CRYPT_OFF
1868 
1869 /*
1870  * xattr namespace prefixes.  These are forbidden in xattr names.
1871  *
1872  * For cross-platform compatibility, xattrs in the user namespace should not be
1873  * prefixed with the namespace name, but for backwards compatibility with older
1874  * ZFS on Linux versions we do prefix the namespace.
1875  */
1876 #define	ZFS_XA_NS_FREEBSD_PREFIX		"freebsd:"
1877 #define	ZFS_XA_NS_FREEBSD_PREFIX_LEN		strlen("freebsd:")
1878 #define	ZFS_XA_NS_LINUX_SECURITY_PREFIX		"security."
1879 #define	ZFS_XA_NS_LINUX_SECURITY_PREFIX_LEN	strlen("security.")
1880 #define	ZFS_XA_NS_LINUX_SYSTEM_PREFIX		"system."
1881 #define	ZFS_XA_NS_LINUX_SYSTEM_PREFIX_LEN	strlen("system.")
1882 #define	ZFS_XA_NS_LINUX_TRUSTED_PREFIX		"trusted."
1883 #define	ZFS_XA_NS_LINUX_TRUSTED_PREFIX_LEN	strlen("trusted.")
1884 #define	ZFS_XA_NS_LINUX_USER_PREFIX		"user."
1885 #define	ZFS_XA_NS_LINUX_USER_PREFIX_LEN		strlen("user.")
1886 
1887 #define	ZFS_XA_NS_PREFIX_MATCH(ns, name) \
1888 	(strncmp(name, ZFS_XA_NS_##ns##_PREFIX, \
1889 	ZFS_XA_NS_##ns##_PREFIX_LEN) == 0)
1890 
1891 #define	ZFS_XA_NS_PREFIX_FORBIDDEN(name) \
1892 	(ZFS_XA_NS_PREFIX_MATCH(FREEBSD, name) || \
1893 	    ZFS_XA_NS_PREFIX_MATCH(LINUX_SECURITY, name) || \
1894 	    ZFS_XA_NS_PREFIX_MATCH(LINUX_SYSTEM, name) || \
1895 	    ZFS_XA_NS_PREFIX_MATCH(LINUX_TRUSTED, name) || \
1896 	    ZFS_XA_NS_PREFIX_MATCH(LINUX_USER, name))
1897 
1898 #ifdef	__cplusplus
1899 }
1900 #endif
1901 
1902 #endif	/* _SYS_FS_ZFS_H */
1903