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