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