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