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