]> git.proxmox.com Git - mirror_zfs.git/blame - include/sys/fs/zfs.h
Fix send/recv lost spill block
[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
9 * or http://www.opensolaris.org/os/licensing.
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.
b83a0e2d 24 * Copyright (c) 2011, 2018 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.
34dc7c2f
BB
30 */
31
428870ff
BB
32/* Portions Copyright 2010 Robert Milkowski */
33
34dc7c2f
BB
34#ifndef _SYS_FS_ZFS_H
35#define _SYS_FS_ZFS_H
36
45d1cae3 37#include <sys/time.h>
193a37cb 38#include <sys/zio_priority.h>
45d1cae3 39
34dc7c2f
BB
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/*
45 * Types and constants shared between userland and the kernel.
46 */
47
48/*
49 * Each dataset can be one of the following types. These constants can be
50 * combined into masks that can be passed to various functions.
51 */
52typedef enum {
da536844
MA
53 ZFS_TYPE_FILESYSTEM = (1 << 0),
54 ZFS_TYPE_SNAPSHOT = (1 << 1),
55 ZFS_TYPE_VOLUME = (1 << 2),
56 ZFS_TYPE_POOL = (1 << 3),
57 ZFS_TYPE_BOOKMARK = (1 << 4)
34dc7c2f
BB
58} zfs_type_t;
59
e67a7ffb
GM
60/*
61 * NB: lzc_dataset_type should be updated whenever a new objset type is added,
62 * if it represents a real type of a dataset that can be created from userland.
63 */
6f1ffb06
MA
64typedef enum dmu_objset_type {
65 DMU_OST_NONE,
66 DMU_OST_META,
67 DMU_OST_ZFS,
68 DMU_OST_ZVOL,
69 DMU_OST_OTHER, /* For testing only! */
70 DMU_OST_ANY, /* Be careful! */
71 DMU_OST_NUMTYPES
72} dmu_objset_type_t;
73
34dc7c2f
BB
74#define ZFS_TYPE_DATASET \
75 (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
76
eca7b760
IK
77/*
78 * All of these include the terminating NUL byte.
79 */
9babb374
BB
80#define ZAP_MAXNAMELEN 256
81#define ZAP_MAXVALUELEN (1024 * 8)
82#define ZAP_OLDMAXVALUELEN 1024
eca7b760 83#define ZFS_MAX_DATASET_NAME_LEN 256
9babb374 84
34dc7c2f
BB
85/*
86 * Dataset properties are identified by these constants and must be added to
87 * the end of this list to ensure that external consumers are not affected
88 * by the change. If you make any changes to this list, be sure to update
e77aa730 89 * the property table in module/zcommon/zfs_prop.c.
34dc7c2f
BB
90 */
91typedef enum {
31864e3d
BB
92 ZPROP_CONT = -2,
93 ZPROP_INVAL = -1,
648a09ad 94 ZFS_PROP_TYPE = 0,
34dc7c2f
BB
95 ZFS_PROP_CREATION,
96 ZFS_PROP_USED,
97 ZFS_PROP_AVAILABLE,
98 ZFS_PROP_REFERENCED,
99 ZFS_PROP_COMPRESSRATIO,
100 ZFS_PROP_MOUNTED,
101 ZFS_PROP_ORIGIN,
102 ZFS_PROP_QUOTA,
103 ZFS_PROP_RESERVATION,
104 ZFS_PROP_VOLSIZE,
105 ZFS_PROP_VOLBLOCKSIZE,
106 ZFS_PROP_RECORDSIZE,
107 ZFS_PROP_MOUNTPOINT,
108 ZFS_PROP_SHARENFS,
109 ZFS_PROP_CHECKSUM,
110 ZFS_PROP_COMPRESSION,
111 ZFS_PROP_ATIME,
112 ZFS_PROP_DEVICES,
113 ZFS_PROP_EXEC,
114 ZFS_PROP_SETUID,
115 ZFS_PROP_READONLY,
116 ZFS_PROP_ZONED,
117 ZFS_PROP_SNAPDIR,
428870ff 118 ZFS_PROP_PRIVATE, /* not exposed to user, temporary */
34dc7c2f 119 ZFS_PROP_ACLINHERIT,
305bc4b3 120 ZFS_PROP_CREATETXG,
34dc7c2f
BB
121 ZFS_PROP_NAME, /* not exposed to the user */
122 ZFS_PROP_CANMOUNT,
34dc7c2f
BB
123 ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */
124 ZFS_PROP_XATTR,
125 ZFS_PROP_NUMCLONES, /* not exposed to the user */
126 ZFS_PROP_COPIES,
127 ZFS_PROP_VERSION,
128 ZFS_PROP_UTF8ONLY,
129 ZFS_PROP_NORMALIZE,
130 ZFS_PROP_CASE,
131 ZFS_PROP_VSCAN,
132 ZFS_PROP_NBMAND,
133 ZFS_PROP_SHARESMB,
134 ZFS_PROP_REFQUOTA,
135 ZFS_PROP_REFRESERVATION,
b128c09f
BB
136 ZFS_PROP_GUID,
137 ZFS_PROP_PRIMARYCACHE,
138 ZFS_PROP_SECONDARYCACHE,
139 ZFS_PROP_USEDSNAP,
140 ZFS_PROP_USEDDS,
141 ZFS_PROP_USEDCHILD,
142 ZFS_PROP_USEDREFRESERV,
9babb374
BB
143 ZFS_PROP_USERACCOUNTING, /* not exposed to the user */
144 ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */
45d1cae3
BB
145 ZFS_PROP_DEFER_DESTROY,
146 ZFS_PROP_USERREFS,
428870ff
BB
147 ZFS_PROP_LOGBIAS,
148 ZFS_PROP_UNIQUE, /* not exposed to the user */
a448a255 149 ZFS_PROP_OBJSETID,
428870ff
BB
150 ZFS_PROP_DEDUP,
151 ZFS_PROP_MLSLABEL,
152 ZFS_PROP_SYNC,
50c957f7 153 ZFS_PROP_DNODESIZE,
f5fc4aca 154 ZFS_PROP_REFRATIO,
330d06f9
MA
155 ZFS_PROP_WRITTEN,
156 ZFS_PROP_CLONES,
24a64651
MA
157 ZFS_PROP_LOGICALUSED,
158 ZFS_PROP_LOGICALREFERENCED,
96c2e961 159 ZFS_PROP_INCONSISTENT, /* not exposed to the user */
cf8738d8 160 ZFS_PROP_VOLMODE,
788eb90c
JJ
161 ZFS_PROP_FILESYSTEM_LIMIT,
162 ZFS_PROP_SNAPSHOT_LIMIT,
163 ZFS_PROP_FILESYSTEM_COUNT,
164 ZFS_PROP_SNAPSHOT_COUNT,
0b4d1b58 165 ZFS_PROP_SNAPDEV,
023699cd 166 ZFS_PROP_ACLTYPE,
11b9ec23
MT
167 ZFS_PROP_SELINUX_CONTEXT,
168 ZFS_PROP_SELINUX_FSCONTEXT,
169 ZFS_PROP_SELINUX_DEFCONTEXT,
170 ZFS_PROP_SELINUX_ROOTCONTEXT,
6d111134 171 ZFS_PROP_RELATIME,
faf0f58c 172 ZFS_PROP_REDUNDANT_METADATA,
f67d7090 173 ZFS_PROP_OVERLAY,
1715493f 174 ZFS_PROP_PREV_SNAP,
47dfff3b 175 ZFS_PROP_RECEIVE_RESUME_TOKEN,
b5256303
TC
176 ZFS_PROP_ENCRYPTION,
177 ZFS_PROP_KEYLOCATION,
178 ZFS_PROP_KEYFORMAT,
179 ZFS_PROP_PBKDF2_SALT,
180 ZFS_PROP_PBKDF2_ITERS,
181 ZFS_PROP_ENCRYPTION_ROOT,
182 ZFS_PROP_KEY_GUID,
183 ZFS_PROP_KEYSTATUS,
a1d477c2 184 ZFS_PROP_REMAPTXG, /* not exposed to the user */
cc99f275 185 ZFS_PROP_SPECIAL_SMALL_BLOCKS,
f00ab3f2 186 ZFS_PROP_IVSET_GUID, /* not exposed to the user */
34dc7c2f
BB
187 ZFS_NUM_PROPS
188} zfs_prop_t;
189
9babb374
BB
190typedef enum {
191 ZFS_PROP_USERUSED,
192 ZFS_PROP_USERQUOTA,
193 ZFS_PROP_GROUPUSED,
194 ZFS_PROP_GROUPQUOTA,
1de321e6
JX
195 ZFS_PROP_USEROBJUSED,
196 ZFS_PROP_USEROBJQUOTA,
197 ZFS_PROP_GROUPOBJUSED,
198 ZFS_PROP_GROUPOBJQUOTA,
9c5167d1
NF
199 ZFS_PROP_PROJECTUSED,
200 ZFS_PROP_PROJECTQUOTA,
201 ZFS_PROP_PROJECTOBJUSED,
202 ZFS_PROP_PROJECTOBJQUOTA,
9babb374
BB
203 ZFS_NUM_USERQUOTA_PROPS
204} zfs_userquota_prop_t;
205
206extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
207
34dc7c2f
BB
208/*
209 * Pool properties are identified by these constants and must be added to the
b128c09f 210 * end of this list to ensure that external consumers are not affected
34dc7c2f 211 * by the change. If you make any changes to this list, be sure to update
e77aa730 212 * the property table in module/zcommon/zpool_prop.c.
34dc7c2f
BB
213 */
214typedef enum {
31864e3d 215 ZPOOL_PROP_INVAL = -1,
34dc7c2f
BB
216 ZPOOL_PROP_NAME,
217 ZPOOL_PROP_SIZE,
34dc7c2f
BB
218 ZPOOL_PROP_CAPACITY,
219 ZPOOL_PROP_ALTROOT,
220 ZPOOL_PROP_HEALTH,
221 ZPOOL_PROP_GUID,
222 ZPOOL_PROP_VERSION,
223 ZPOOL_PROP_BOOTFS,
224 ZPOOL_PROP_DELEGATION,
225 ZPOOL_PROP_AUTOREPLACE,
226 ZPOOL_PROP_CACHEFILE,
227 ZPOOL_PROP_FAILUREMODE,
b128c09f 228 ZPOOL_PROP_LISTSNAPS,
9babb374 229 ZPOOL_PROP_AUTOEXPAND,
428870ff
BB
230 ZPOOL_PROP_DEDUPDITTO,
231 ZPOOL_PROP_DEDUPRATIO,
232 ZPOOL_PROP_FREE,
233 ZPOOL_PROP_ALLOCATED,
572e2857 234 ZPOOL_PROP_READONLY,
df30f566 235 ZPOOL_PROP_ASHIFT,
d96eb2b1 236 ZPOOL_PROP_COMMENT,
1bd201e7 237 ZPOOL_PROP_EXPANDSZ,
9ae529ec 238 ZPOOL_PROP_FREEING,
f3a7f661 239 ZPOOL_PROP_FRAGMENTATION,
fbeddd60 240 ZPOOL_PROP_LEAKED,
f1512ee6 241 ZPOOL_PROP_MAXBLOCKSIZE,
83e9986f 242 ZPOOL_PROP_TNAME,
50c957f7 243 ZPOOL_PROP_MAXDNODESIZE,
379ca9cf 244 ZPOOL_PROP_MULTIHOST,
d2734cce 245 ZPOOL_PROP_CHECKPOINT,
a448a255 246 ZPOOL_PROP_LOAD_GUID,
1b939560 247 ZPOOL_PROP_AUTOTRIM,
34dc7c2f
BB
248 ZPOOL_NUM_PROPS
249} zpool_prop_t;
250
d96eb2b1
DM
251/* Small enough to not hog a whole line of printout in zpool(1M). */
252#define ZPROP_MAX_COMMENT 32
253
34dc7c2f
BB
254#define ZPROP_VALUE "value"
255#define ZPROP_SOURCE "source"
256
257typedef enum {
258 ZPROP_SRC_NONE = 0x1,
259 ZPROP_SRC_DEFAULT = 0x2,
260 ZPROP_SRC_TEMPORARY = 0x4,
261 ZPROP_SRC_LOCAL = 0x8,
428870ff
BB
262 ZPROP_SRC_INHERITED = 0x10,
263 ZPROP_SRC_RECEIVED = 0x20
34dc7c2f
BB
264} zprop_source_t;
265
428870ff
BB
266#define ZPROP_SRC_ALL 0x3f
267
268#define ZPROP_SOURCE_VAL_RECVD "$recvd"
269#define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS"
43e52edd 270
428870ff
BB
271/*
272 * Dataset flag implemented as a special entry in the props zap object
273 * indicating that the dataset has received properties on or after
274 * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
275 * just as it did in earlier versions, and thereafter, local properties are
276 * preserved.
277 */
278#define ZPROP_HAS_RECVD "$hasrecvd"
279
280typedef enum {
281 ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
282 ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
283} zprop_errflags_t;
34dc7c2f
BB
284
285typedef int (*zprop_func)(int, void *);
286
b128c09f
BB
287/*
288 * Properties to be set on the root file system of a new pool
289 * are stuffed into their own nvlist, which is then included in
290 * the properties nvlist with the pool properties.
291 */
292#define ZPOOL_ROOTFS_PROPS "root-props-nvl"
293
d99a0153
CW
294/*
295 * Length of 'written@' and 'written#'
296 */
297#define ZFS_WRITTEN_PROP_PREFIX_LEN 8
298
34dc7c2f
BB
299/*
300 * Dataset property functions shared between libzfs and kernel.
301 */
302const char *zfs_prop_default_string(zfs_prop_t);
303uint64_t zfs_prop_default_numeric(zfs_prop_t);
304boolean_t zfs_prop_readonly(zfs_prop_t);
d99a0153 305boolean_t zfs_prop_visible(zfs_prop_t prop);
34dc7c2f
BB
306boolean_t zfs_prop_inheritable(zfs_prop_t);
307boolean_t zfs_prop_setonce(zfs_prop_t);
b5256303
TC
308boolean_t zfs_prop_encryption_key_param(zfs_prop_t);
309boolean_t zfs_prop_valid_keylocation(const char *, boolean_t);
34dc7c2f
BB
310const char *zfs_prop_to_name(zfs_prop_t);
311zfs_prop_t zfs_name_to_prop(const char *);
312boolean_t zfs_prop_user(const char *);
428870ff 313boolean_t zfs_prop_userquota(const char *);
330d06f9 314boolean_t zfs_prop_written(const char *);
34dc7c2f
BB
315int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
316int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
428870ff 317uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
962d5242 318boolean_t zfs_prop_valid_for_type(int, zfs_type_t, boolean_t);
34dc7c2f
BB
319
320/*
321 * Pool property functions shared between libzfs and kernel.
322 */
323zpool_prop_t zpool_name_to_prop(const char *);
324const char *zpool_prop_to_name(zpool_prop_t);
325const char *zpool_prop_default_string(zpool_prop_t);
326uint64_t zpool_prop_default_numeric(zpool_prop_t);
327boolean_t zpool_prop_readonly(zpool_prop_t);
edf60b86 328boolean_t zpool_prop_setonce(zpool_prop_t);
9ae529ec
CS
329boolean_t zpool_prop_feature(const char *);
330boolean_t zpool_prop_unsupported(const char *);
34dc7c2f
BB
331int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
332int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
428870ff 333uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
34dc7c2f
BB
334
335/*
336 * Definitions for the Delegation.
337 */
338typedef enum {
339 ZFS_DELEG_WHO_UNKNOWN = 0,
340 ZFS_DELEG_USER = 'u',
341 ZFS_DELEG_USER_SETS = 'U',
342 ZFS_DELEG_GROUP = 'g',
343 ZFS_DELEG_GROUP_SETS = 'G',
344 ZFS_DELEG_EVERYONE = 'e',
345 ZFS_DELEG_EVERYONE_SETS = 'E',
346 ZFS_DELEG_CREATE = 'c',
347 ZFS_DELEG_CREATE_SETS = 'C',
348 ZFS_DELEG_NAMED_SET = 's',
349 ZFS_DELEG_NAMED_SET_SETS = 'S'
350} zfs_deleg_who_type_t;
351
352typedef enum {
353 ZFS_DELEG_NONE = 0,
354 ZFS_DELEG_PERM_LOCAL = 1,
355 ZFS_DELEG_PERM_DESCENDENT = 2,
356 ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
357 ZFS_DELEG_PERM_CREATE = 4
358} zfs_deleg_inherit_t;
359
360#define ZFS_DELEG_PERM_UID "uid"
361#define ZFS_DELEG_PERM_GID "gid"
362#define ZFS_DELEG_PERM_GROUPS "groups"
363
428870ff
BB
364#define ZFS_MLSLABEL_DEFAULT "none"
365
9babb374
BB
366#define ZFS_SMB_ACL_SRC "src"
367#define ZFS_SMB_ACL_TARGET "target"
368
34dc7c2f
BB
369typedef enum {
370 ZFS_CANMOUNT_OFF = 0,
371 ZFS_CANMOUNT_ON = 1,
372 ZFS_CANMOUNT_NOAUTO = 2
373} zfs_canmount_type_t;
374
428870ff
BB
375typedef enum {
376 ZFS_LOGBIAS_LATENCY = 0,
377 ZFS_LOGBIAS_THROUGHPUT = 1
378} zfs_logbias_op_t;
379
34dc7c2f
BB
380typedef enum zfs_share_op {
381 ZFS_SHARE_NFS = 0,
382 ZFS_UNSHARE_NFS = 1,
383 ZFS_SHARE_SMB = 2,
384 ZFS_UNSHARE_SMB = 3
385} zfs_share_op_t;
386
9babb374
BB
387typedef enum zfs_smb_acl_op {
388 ZFS_SMB_ACL_ADD,
389 ZFS_SMB_ACL_REMOVE,
390 ZFS_SMB_ACL_RENAME,
391 ZFS_SMB_ACL_PURGE
392} zfs_smb_acl_op_t;
393
b128c09f
BB
394typedef enum zfs_cache_type {
395 ZFS_CACHE_NONE = 0,
396 ZFS_CACHE_METADATA = 1,
397 ZFS_CACHE_ALL = 2
398} zfs_cache_type_t;
399
428870ff
BB
400typedef enum {
401 ZFS_SYNC_STANDARD = 0,
402 ZFS_SYNC_ALWAYS = 1,
403 ZFS_SYNC_DISABLED = 2
404} zfs_sync_type_t;
405
82a37189
BB
406typedef enum {
407 ZFS_XATTR_OFF = 0,
408 ZFS_XATTR_DIR = 1,
409 ZFS_XATTR_SA = 2
410} zfs_xattr_type_t;
b128c09f 411
50c957f7
NB
412typedef enum {
413 ZFS_DNSIZE_LEGACY = 0,
414 ZFS_DNSIZE_AUTO = 1,
415 ZFS_DNSIZE_1K = 1024,
416 ZFS_DNSIZE_2K = 2048,
417 ZFS_DNSIZE_4K = 4096,
418 ZFS_DNSIZE_8K = 8192,
419 ZFS_DNSIZE_16K = 16384
420} zfs_dnsize_type_t;
421
faf0f58c
MA
422typedef enum {
423 ZFS_REDUNDANT_METADATA_ALL,
424 ZFS_REDUNDANT_METADATA_MOST
425} zfs_redundant_metadata_type_t;
426
cf8738d8 427typedef enum {
428 ZFS_VOLMODE_DEFAULT = 0,
429 ZFS_VOLMODE_GEOM = 1,
430 ZFS_VOLMODE_DEV = 2,
431 ZFS_VOLMODE_NONE = 3
432} zfs_volmode_t;
433
b5256303
TC
434typedef enum zfs_keystatus {
435 ZFS_KEYSTATUS_NONE = 0,
436 ZFS_KEYSTATUS_UNAVAILABLE,
437 ZFS_KEYSTATUS_AVAILABLE,
438} zfs_keystatus_t;
439
440typedef enum zfs_keyformat {
441 ZFS_KEYFORMAT_NONE = 0,
442 ZFS_KEYFORMAT_RAW,
443 ZFS_KEYFORMAT_HEX,
444 ZFS_KEYFORMAT_PASSPHRASE,
445 ZFS_KEYFORMAT_FORMATS
446} zfs_keyformat_t;
447
448typedef enum zfs_key_location {
449 ZFS_KEYLOCATION_NONE = 0,
450 ZFS_KEYLOCATION_PROMPT,
451 ZFS_KEYLOCATION_URI,
452 ZFS_KEYLOCATION_LOCATIONS
453} zfs_keylocation_t;
454
455#define DEFAULT_PBKDF2_ITERATIONS 350000
456#define MIN_PBKDF2_ITERATIONS 100000
457
34dc7c2f
BB
458/*
459 * On-disk version number.
460 */
461#define SPA_VERSION_1 1ULL
462#define SPA_VERSION_2 2ULL
463#define SPA_VERSION_3 3ULL
464#define SPA_VERSION_4 4ULL
465#define SPA_VERSION_5 5ULL
466#define SPA_VERSION_6 6ULL
467#define SPA_VERSION_7 7ULL
468#define SPA_VERSION_8 8ULL
469#define SPA_VERSION_9 9ULL
470#define SPA_VERSION_10 10ULL
b128c09f
BB
471#define SPA_VERSION_11 11ULL
472#define SPA_VERSION_12 12ULL
473#define SPA_VERSION_13 13ULL
474#define SPA_VERSION_14 14ULL
9babb374
BB
475#define SPA_VERSION_15 15ULL
476#define SPA_VERSION_16 16ULL
45d1cae3
BB
477#define SPA_VERSION_17 17ULL
478#define SPA_VERSION_18 18ULL
428870ff
BB
479#define SPA_VERSION_19 19ULL
480#define SPA_VERSION_20 20ULL
481#define SPA_VERSION_21 21ULL
482#define SPA_VERSION_22 22ULL
483#define SPA_VERSION_23 23ULL
484#define SPA_VERSION_24 24ULL
485#define SPA_VERSION_25 25ULL
486#define SPA_VERSION_26 26ULL
572e2857
BB
487#define SPA_VERSION_27 27ULL
488#define SPA_VERSION_28 28ULL
9ae529ec 489#define SPA_VERSION_5000 5000ULL
572e2857 490
8dda07b3
RL
491/*
492 * The incrementing pool version number has been replaced by pool feature
493 * flags. For more details, see zfeature.c.
494 */
9ae529ec
CS
495#define SPA_VERSION SPA_VERSION_5000
496#define SPA_VERSION_STRING "5000"
34dc7c2f
BB
497
498/*
499 * Symbolic names for the changes that caused a SPA_VERSION switch.
500 * Used in the code when checking for presence or absence of a feature.
501 * Feel free to define multiple symbolic names for each version if there
502 * were multiple changes to on-disk structures during that version.
503 *
504 * NOTE: When checking the current SPA_VERSION in your code, be sure
505 * to use spa_version() since it reports the version of the
506 * last synced uberblock. Checking the in-flight version can
507 * be dangerous in some cases.
508 */
509#define SPA_VERSION_INITIAL SPA_VERSION_1
510#define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2
511#define SPA_VERSION_SPARES SPA_VERSION_3
45d1cae3 512#define SPA_VERSION_RAIDZ2 SPA_VERSION_3
428870ff 513#define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3
34dc7c2f
BB
514#define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3
515#define SPA_VERSION_DNODE_BYTES SPA_VERSION_3
516#define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4
517#define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5
518#define SPA_VERSION_BOOTFS SPA_VERSION_6
519#define SPA_VERSION_SLOGS SPA_VERSION_7
520#define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8
521#define SPA_VERSION_FUID SPA_VERSION_9
522#define SPA_VERSION_REFRESERVATION SPA_VERSION_9
523#define SPA_VERSION_REFQUOTA SPA_VERSION_9
524#define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9
525#define SPA_VERSION_L2CACHE SPA_VERSION_10
b128c09f
BB
526#define SPA_VERSION_NEXT_CLONES SPA_VERSION_11
527#define SPA_VERSION_ORIGIN SPA_VERSION_11
528#define SPA_VERSION_DSL_SCRUB SPA_VERSION_11
529#define SPA_VERSION_SNAP_PROPS SPA_VERSION_12
530#define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13
531#define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14
9babb374
BB
532#define SPA_VERSION_USERSPACE SPA_VERSION_15
533#define SPA_VERSION_STMF_PROP SPA_VERSION_16
45d1cae3
BB
534#define SPA_VERSION_RAIDZ3 SPA_VERSION_17
535#define SPA_VERSION_USERREFS SPA_VERSION_18
428870ff
BB
536#define SPA_VERSION_HOLES SPA_VERSION_19
537#define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20
538#define SPA_VERSION_DEDUP SPA_VERSION_21
539#define SPA_VERSION_RECVD_PROPS SPA_VERSION_22
540#define SPA_VERSION_SLIM_ZIL SPA_VERSION_23
541#define SPA_VERSION_SA SPA_VERSION_24
542#define SPA_VERSION_SCAN SPA_VERSION_25
543#define SPA_VERSION_DIR_CLONES SPA_VERSION_26
544#define SPA_VERSION_DEADLISTS SPA_VERSION_26
572e2857
BB
545#define SPA_VERSION_FAST_SNAP SPA_VERSION_27
546#define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28
9ae529ec
CS
547#define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28
548#define SPA_VERSION_FEATURES SPA_VERSION_5000
549
550#define SPA_VERSION_IS_SUPPORTED(v) \
551 (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
552 ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
34dc7c2f
BB
553
554/*
555 * ZPL version - rev'd whenever an incompatible on-disk format change
556 * occurs. This is independent of SPA/DMU/ZAP versioning. You must
557 * also update the version_table[] and help message in zfs_prop.c.
34dc7c2f
BB
558 */
559#define ZPL_VERSION_1 1ULL
560#define ZPL_VERSION_2 2ULL
561#define ZPL_VERSION_3 3ULL
9babb374 562#define ZPL_VERSION_4 4ULL
428870ff
BB
563#define ZPL_VERSION_5 5ULL
564#define ZPL_VERSION ZPL_VERSION_5
565#define ZPL_VERSION_STRING "5"
34dc7c2f
BB
566
567#define ZPL_VERSION_INITIAL ZPL_VERSION_1
568#define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2
569#define ZPL_VERSION_FUID ZPL_VERSION_3
570#define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3
571#define ZPL_VERSION_SYSATTR ZPL_VERSION_3
9babb374 572#define ZPL_VERSION_USERSPACE ZPL_VERSION_4
428870ff
BB
573#define ZPL_VERSION_SA ZPL_VERSION_5
574
8a393be3 575/* Rewind policy information */
428870ff
BB
576#define ZPOOL_NO_REWIND 1 /* No policy - default behavior */
577#define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */
578#define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */
579#define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */
580#define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */
581#define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */
582#define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */
583
8a393be3
PZ
584typedef struct zpool_load_policy {
585 uint32_t zlp_rewind; /* rewind policy requested */
586 uint64_t zlp_maxmeta; /* max acceptable meta-data errors */
587 uint64_t zlp_maxdata; /* max acceptable data errors */
588 uint64_t zlp_txg; /* specific txg to load */
589} zpool_load_policy_t;
34dc7c2f
BB
590
591/*
592 * The following are configuration names used in the nvlist describing a pool's
a1d477c2
MA
593 * configuration. New on-disk names should be prefixed with "<reverse-DNS>:"
594 * (e.g. "org.open-zfs:") to avoid conflicting names being developed
595 * independently.
34dc7c2f
BB
596 */
597#define ZPOOL_CONFIG_VERSION "version"
598#define ZPOOL_CONFIG_POOL_NAME "name"
599#define ZPOOL_CONFIG_POOL_STATE "state"
600#define ZPOOL_CONFIG_POOL_TXG "txg"
601#define ZPOOL_CONFIG_POOL_GUID "pool_guid"
602#define ZPOOL_CONFIG_CREATE_TXG "create_txg"
603#define ZPOOL_CONFIG_TOP_GUID "top_guid"
604#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
605#define ZPOOL_CONFIG_TYPE "type"
606#define ZPOOL_CONFIG_CHILDREN "children"
607#define ZPOOL_CONFIG_ID "id"
608#define ZPOOL_CONFIG_GUID "guid"
a1d477c2
MA
609#define ZPOOL_CONFIG_INDIRECT_OBJECT "com.delphix:indirect_object"
610#define ZPOOL_CONFIG_INDIRECT_BIRTHS "com.delphix:indirect_births"
611#define ZPOOL_CONFIG_PREV_INDIRECT_VDEV "com.delphix:prev_indirect_vdev"
34dc7c2f
BB
612#define ZPOOL_CONFIG_PATH "path"
613#define ZPOOL_CONFIG_DEVID "devid"
614#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array"
615#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift"
616#define ZPOOL_CONFIG_ASHIFT "ashift"
617#define ZPOOL_CONFIG_ASIZE "asize"
618#define ZPOOL_CONFIG_DTL "DTL"
428870ff 619#define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */
a1d477c2 620#define ZPOOL_CONFIG_REMOVAL_STATS "removal_stats" /* not stored on disk */
d2734cce 621#define ZPOOL_CONFIG_CHECKPOINT_STATS "checkpoint_stats" /* not on disk */
428870ff 622#define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */
a1d477c2 623#define ZPOOL_CONFIG_INDIRECT_SIZE "indirect_size" /* not stored on disk */
193a37cb
TH
624
625/* container nvlist of extended stats */
626#define ZPOOL_CONFIG_VDEV_STATS_EX "vdev_stats_ex"
627
628/* Active queue read/write stats */
629#define ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE "vdev_sync_r_active_queue"
630#define ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE "vdev_sync_w_active_queue"
631#define ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE "vdev_async_r_active_queue"
632#define ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE "vdev_async_w_active_queue"
633#define ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE "vdev_async_scrub_active_queue"
1b939560 634#define ZPOOL_CONFIG_VDEV_TRIM_ACTIVE_QUEUE "vdev_async_trim_active_queue"
193a37cb
TH
635
636/* Queue sizes */
637#define ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE "vdev_sync_r_pend_queue"
638#define ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE "vdev_sync_w_pend_queue"
639#define ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE "vdev_async_r_pend_queue"
640#define ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE "vdev_async_w_pend_queue"
641#define ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE "vdev_async_scrub_pend_queue"
1b939560 642#define ZPOOL_CONFIG_VDEV_TRIM_PEND_QUEUE "vdev_async_trim_pend_queue"
193a37cb
TH
643
644/* Latency read/write histogram stats */
645#define ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO "vdev_tot_r_lat_histo"
646#define ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO "vdev_tot_w_lat_histo"
647#define ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO "vdev_disk_r_lat_histo"
648#define ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO "vdev_disk_w_lat_histo"
649#define ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO "vdev_sync_r_lat_histo"
650#define ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO "vdev_sync_w_lat_histo"
651#define ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO "vdev_async_r_lat_histo"
652#define ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO "vdev_async_w_lat_histo"
653#define ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO "vdev_scrub_histo"
1b939560 654#define ZPOOL_CONFIG_VDEV_TRIM_LAT_HISTO "vdev_trim_histo"
193a37cb 655
7e945072
TH
656/* Request size histograms */
657#define ZPOOL_CONFIG_VDEV_SYNC_IND_R_HISTO "vdev_sync_ind_r_histo"
658#define ZPOOL_CONFIG_VDEV_SYNC_IND_W_HISTO "vdev_sync_ind_w_histo"
659#define ZPOOL_CONFIG_VDEV_ASYNC_IND_R_HISTO "vdev_async_ind_r_histo"
660#define ZPOOL_CONFIG_VDEV_ASYNC_IND_W_HISTO "vdev_async_ind_w_histo"
661#define ZPOOL_CONFIG_VDEV_IND_SCRUB_HISTO "vdev_ind_scrub_histo"
1b939560 662#define ZPOOL_CONFIG_VDEV_IND_TRIM_HISTO "vdev_ind_trim_histo"
7e945072
TH
663#define ZPOOL_CONFIG_VDEV_SYNC_AGG_R_HISTO "vdev_sync_agg_r_histo"
664#define ZPOOL_CONFIG_VDEV_SYNC_AGG_W_HISTO "vdev_sync_agg_w_histo"
665#define ZPOOL_CONFIG_VDEV_ASYNC_AGG_R_HISTO "vdev_async_agg_r_histo"
666#define ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO "vdev_async_agg_w_histo"
667#define ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO "vdev_agg_scrub_histo"
1b939560 668#define ZPOOL_CONFIG_VDEV_AGG_TRIM_HISTO "vdev_agg_trim_histo"
193a37cb 669
ad796b8a
TH
670/* Number of slow IOs */
671#define ZPOOL_CONFIG_VDEV_SLOW_IOS "vdev_slow_ios"
672
1bbd8770
TH
673/* vdev enclosure sysfs path */
674#define ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH "vdev_enc_sysfs_path"
675
34dc7c2f
BB
676#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
677#define ZPOOL_CONFIG_ERRCOUNT "error_count"
678#define ZPOOL_CONFIG_NOT_PRESENT "not_present"
679#define ZPOOL_CONFIG_SPARES "spares"
680#define ZPOOL_CONFIG_IS_SPARE "is_spare"
681#define ZPOOL_CONFIG_NPARITY "nparity"
682#define ZPOOL_CONFIG_HOSTID "hostid"
683#define ZPOOL_CONFIG_HOSTNAME "hostname"
572e2857 684#define ZPOOL_CONFIG_LOADED_TIME "initial_load_time"
34dc7c2f
BB
685#define ZPOOL_CONFIG_UNSPARE "unspare"
686#define ZPOOL_CONFIG_PHYS_PATH "phys_path"
687#define ZPOOL_CONFIG_IS_LOG "is_log"
688#define ZPOOL_CONFIG_L2CACHE "l2cache"
428870ff
BB
689#define ZPOOL_CONFIG_HOLE_ARRAY "hole_array"
690#define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
691#define ZPOOL_CONFIG_IS_HOLE "is_hole"
692#define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
693#define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
694#define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
695#define ZPOOL_CONFIG_SPLIT "splitcfg"
696#define ZPOOL_CONFIG_ORIG_GUID "orig_guid"
697#define ZPOOL_CONFIG_SPLIT_GUID "split_guid"
698#define ZPOOL_CONFIG_SPLIT_LIST "guid_list"
699#define ZPOOL_CONFIG_REMOVING "removing"
5d1f7fb6 700#define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg"
d96eb2b1 701#define ZPOOL_CONFIG_COMMENT "comment"
b128c09f 702#define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */
cec3a0a1 703#define ZPOOL_CONFIG_SUSPENDED_REASON "suspended_reason" /* not stored */
34dc7c2f
BB
704#define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */
705#define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */
572e2857
BB
706#define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */
707#define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */
9ae529ec
CS
708#define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */
709#define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */
b9b24bb4 710#define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */
9ae529ec
CS
711#define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */
712#define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read"
713#define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */
ffe9d382 714#define ZPOOL_CONFIG_ERRATA "errata" /* not stored on disk */
e0ab3ab5
JS
715#define ZPOOL_CONFIG_VDEV_TOP_ZAP "com.delphix:vdev_zap_top"
716#define ZPOOL_CONFIG_VDEV_LEAF_ZAP "com.delphix:vdev_zap_leaf"
717#define ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS "com.delphix:has_per_vdev_zaps"
80a91e74 718#define ZPOOL_CONFIG_RESILVER_DEFER "com.datto:resilver_defer"
6cb8e530 719#define ZPOOL_CONFIG_CACHEFILE "cachefile" /* not stored on disk */
379ca9cf
OF
720#define ZPOOL_CONFIG_MMP_STATE "mmp_state" /* not stored on disk */
721#define ZPOOL_CONFIG_MMP_TXG "mmp_txg" /* not stored on disk */
060f0226 722#define ZPOOL_CONFIG_MMP_SEQ "mmp_seq" /* not stored on disk */
379ca9cf
OF
723#define ZPOOL_CONFIG_MMP_HOSTNAME "mmp_hostname" /* not stored on disk */
724#define ZPOOL_CONFIG_MMP_HOSTID "mmp_hostid" /* not stored on disk */
cc99f275 725#define ZPOOL_CONFIG_ALLOCATION_BIAS "alloc_bias" /* not stored on disk */
d48091de 726#define ZPOOL_CONFIG_EXPANSION_TIME "expansion_time" /* not stored */
379ca9cf 727
34dc7c2f
BB
728/*
729 * The persistent vdev state is stored as separate values rather than a single
730 * 'vdev_state' entry. This is because a device can be in multiple states, such
731 * as offline and degraded.
732 */
733#define ZPOOL_CONFIG_OFFLINE "offline"
734#define ZPOOL_CONFIG_FAULTED "faulted"
735#define ZPOOL_CONFIG_DEGRADED "degraded"
736#define ZPOOL_CONFIG_REMOVED "removed"
9babb374 737#define ZPOOL_CONFIG_FRU "fru"
428870ff
BB
738#define ZPOOL_CONFIG_AUX_STATE "aux_state"
739
8a393be3
PZ
740/* Pool load policy parameters */
741#define ZPOOL_LOAD_POLICY "load-policy"
742#define ZPOOL_LOAD_REWIND_POLICY "load-rewind-policy"
743#define ZPOOL_LOAD_REQUEST_TXG "load-request-txg"
744#define ZPOOL_LOAD_META_THRESH "load-meta-thresh"
745#define ZPOOL_LOAD_DATA_THRESH "load-data-thresh"
428870ff
BB
746
747/* Rewind data discovered */
748#define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts"
749#define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors"
750#define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind"
34dc7c2f
BB
751
752#define VDEV_TYPE_ROOT "root"
753#define VDEV_TYPE_MIRROR "mirror"
754#define VDEV_TYPE_REPLACING "replacing"
755#define VDEV_TYPE_RAIDZ "raidz"
756#define VDEV_TYPE_DISK "disk"
757#define VDEV_TYPE_FILE "file"
758#define VDEV_TYPE_MISSING "missing"
428870ff 759#define VDEV_TYPE_HOLE "hole"
34dc7c2f
BB
760#define VDEV_TYPE_SPARE "spare"
761#define VDEV_TYPE_LOG "log"
762#define VDEV_TYPE_L2CACHE "l2cache"
a1d477c2
MA
763#define VDEV_TYPE_INDIRECT "indirect"
764
765/* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */
766#define VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \
767 "com.delphix:indirect_obsolete_sm"
768#define VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \
769 "com.delphix:obsolete_counts_are_precise"
d2734cce
SD
770#define VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \
771 "com.delphix:pool_checkpoint_sm"
34dc7c2f 772
cc99f275
DB
773#define VDEV_TOP_ZAP_ALLOCATION_BIAS \
774 "org.zfsonlinux:allocation_bias"
775
776/* vdev metaslab allocation bias */
777#define VDEV_ALLOC_BIAS_LOG "log"
778#define VDEV_ALLOC_BIAS_SPECIAL "special"
779#define VDEV_ALLOC_BIAS_DEDUP "dedup"
780
1b939560 781/* vdev initialize state */
619f0976
GW
782#define VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET \
783 "com.delphix:next_offset_to_initialize"
784#define VDEV_LEAF_ZAP_INITIALIZE_STATE \
785 "com.delphix:vdev_initialize_state"
786#define VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME \
787 "com.delphix:vdev_initialize_action_time"
788
1b939560
BB
789/* vdev TRIM state */
790#define VDEV_LEAF_ZAP_TRIM_LAST_OFFSET \
791 "org.zfsonlinux:next_offset_to_trim"
792#define VDEV_LEAF_ZAP_TRIM_STATE \
793 "org.zfsonlinux:vdev_trim_state"
794#define VDEV_LEAF_ZAP_TRIM_ACTION_TIME \
795 "org.zfsonlinux:vdev_trim_action_time"
796#define VDEV_LEAF_ZAP_TRIM_RATE \
797 "org.zfsonlinux:vdev_trim_rate"
798#define VDEV_LEAF_ZAP_TRIM_PARTIAL \
799 "org.zfsonlinux:vdev_trim_partial"
800#define VDEV_LEAF_ZAP_TRIM_SECURE \
801 "org.zfsonlinux:vdev_trim_secure"
802
34dc7c2f
BB
803/*
804 * This is needed in userland to report the minimum necessary device size.
805 */
806#define SPA_MINDEVSIZE (64ULL << 20)
807
f3a7f661
GW
808/*
809 * Set if the fragmentation has not yet been calculated. This can happen
810 * because the space maps have not been upgraded or the histogram feature
811 * is not enabled.
812 */
813#define ZFS_FRAG_INVALID UINT64_MAX
814
34dc7c2f
BB
815/*
816 * The location of the pool configuration repository, shared between kernel and
817 * userland.
818 */
b128c09f 819#define ZPOOL_CACHE "/etc/zfs/zpool.cache"
34dc7c2f
BB
820
821/*
822 * vdev states are ordered from least to most healthy.
823 * A vdev that's CANT_OPEN or below is considered unusable.
824 */
825typedef enum vdev_state {
826 VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */
827 VDEV_STATE_CLOSED, /* Not currently open */
828 VDEV_STATE_OFFLINE, /* Not allowed to open */
829 VDEV_STATE_REMOVED, /* Explicitly removed from system */
830 VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */
831 VDEV_STATE_FAULTED, /* External request to fault device */
832 VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */
833 VDEV_STATE_HEALTHY /* Presumed good */
834} vdev_state_t;
835
836#define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY
837
838/*
839 * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field
840 * of the vdev stats structure uses these constants to distinguish why.
841 */
842typedef enum vdev_aux {
843 VDEV_AUX_NONE, /* no error */
844 VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */
845 VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */
846 VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */
847 VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */
848 VDEV_AUX_TOO_SMALL, /* vdev size is too small */
849 VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */
850 VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */
851 VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */
9ae529ec 852 VDEV_AUX_UNSUP_FEAT, /* unsupported features */
34dc7c2f 853 VDEV_AUX_SPARED, /* hot spare used in another pool */
b128c09f
BB
854 VDEV_AUX_ERR_EXCEEDED, /* too many errors */
855 VDEV_AUX_IO_FAILURE, /* experienced I/O failure */
428870ff 856 VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */
4a283c7f 857 VDEV_AUX_EXTERNAL, /* external diagnosis or forced fault */
ff61d1a4 858 VDEV_AUX_SPLIT_POOL, /* vdev was split off into another pool */
4a283c7f 859 VDEV_AUX_BAD_ASHIFT, /* vdev ashift is invalid */
379ca9cf
OF
860 VDEV_AUX_EXTERNAL_PERSIST, /* persistent forced fault */
861 VDEV_AUX_ACTIVE, /* vdev active on a different host */
6cb8e530 862 VDEV_AUX_CHILDREN_OFFLINE, /* all children are offline */
34dc7c2f
BB
863} vdev_aux_t;
864
865/*
866 * pool state. The following states are written to disk as part of the normal
867 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
868 * states are software abstractions used at various levels to communicate
869 * pool state.
870 */
871typedef enum pool_state {
872 POOL_STATE_ACTIVE = 0, /* In active use */
873 POOL_STATE_EXPORTED, /* Explicitly exported */
874 POOL_STATE_DESTROYED, /* Explicitly destroyed */
875 POOL_STATE_SPARE, /* Reserved for hot spare use */
876 POOL_STATE_L2CACHE, /* Level 2 ARC device */
877 POOL_STATE_UNINITIALIZED, /* Internal spa_t state */
34dc7c2f
BB
878 POOL_STATE_UNAVAIL, /* Internal libzfs state */
879 POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */
880} pool_state_t;
881
379ca9cf
OF
882/*
883 * mmp state. The following states provide additional detail describing
884 * why a pool couldn't be safely imported.
885 */
886typedef enum mmp_state {
887 MMP_STATE_ACTIVE = 0, /* In active use */
888 MMP_STATE_INACTIVE, /* Inactive and safe to import */
889 MMP_STATE_NO_HOSTID /* System hostid is not set */
890} mmp_state_t;
891
34dc7c2f 892/*
428870ff 893 * Scan Functions.
34dc7c2f 894 */
428870ff
BB
895typedef enum pool_scan_func {
896 POOL_SCAN_NONE,
897 POOL_SCAN_SCRUB,
898 POOL_SCAN_RESILVER,
899 POOL_SCAN_FUNCS
900} pool_scan_func_t;
34dc7c2f 901
0ea05c64
AP
902/*
903 * Used to control scrub pause and resume.
904 */
905typedef enum pool_scrub_cmd {
906 POOL_SCRUB_NORMAL = 0,
907 POOL_SCRUB_PAUSE,
908 POOL_SCRUB_FLAGS_END
909} pool_scrub_cmd_t;
910
d2734cce
SD
911typedef enum {
912 CS_NONE,
913 CS_CHECKPOINT_EXISTS,
914 CS_CHECKPOINT_DISCARDING,
915 CS_NUM_STATES
916} checkpoint_state_t;
917
918typedef struct pool_checkpoint_stat {
919 uint64_t pcs_state; /* checkpoint_state_t */
920 uint64_t pcs_start_time; /* time checkpoint/discard started */
921 uint64_t pcs_space; /* checkpointed space */
922} pool_checkpoint_stat_t;
0ea05c64 923
34dc7c2f
BB
924/*
925 * ZIO types. Needed to interpret vdev statistics below.
926 */
927typedef enum zio_type {
928 ZIO_TYPE_NULL = 0,
929 ZIO_TYPE_READ,
930 ZIO_TYPE_WRITE,
931 ZIO_TYPE_FREE,
932 ZIO_TYPE_CLAIM,
933 ZIO_TYPE_IOCTL,
1b939560 934 ZIO_TYPE_TRIM,
34dc7c2f
BB
935 ZIO_TYPES
936} zio_type_t;
937
428870ff
BB
938/*
939 * Pool statistics. Note: all fields should be 64-bit because this
940 * is passed between kernel and userland as an nvlist uint64 array.
941 */
942typedef struct pool_scan_stat {
943 /* values stored on disk */
944 uint64_t pss_func; /* pool_scan_func_t */
945 uint64_t pss_state; /* dsl_scan_state_t */
946 uint64_t pss_start_time; /* scan start time */
947 uint64_t pss_end_time; /* scan end time */
948 uint64_t pss_to_examine; /* total bytes to scan */
d4a72f23 949 uint64_t pss_examined; /* total bytes located by scanner */
428870ff
BB
950 uint64_t pss_to_process; /* total bytes to process */
951 uint64_t pss_processed; /* total processed bytes */
952 uint64_t pss_errors; /* scan errors */
953
954 /* values not stored on disk */
d4a72f23 955 uint64_t pss_pass_exam; /* examined bytes per scan pass */
428870ff 956 uint64_t pss_pass_start; /* start time of a scan pass */
0ea05c64
AP
957 uint64_t pss_pass_scrub_pause; /* pause time of a scurb pass */
958 /* cumulative time scrub spent paused, needed for rate calculation */
959 uint64_t pss_pass_scrub_spent_paused;
d4677269 960 uint64_t pss_pass_issued; /* issued bytes per scan pass */
d4a72f23 961 uint64_t pss_issued; /* total bytes checked by scanner */
428870ff
BB
962} pool_scan_stat_t;
963
a1d477c2
MA
964typedef struct pool_removal_stat {
965 uint64_t prs_state; /* dsl_scan_state_t */
966 uint64_t prs_removing_vdev;
967 uint64_t prs_start_time;
968 uint64_t prs_end_time;
969 uint64_t prs_to_copy; /* bytes that need to be copied */
970 uint64_t prs_copied; /* bytes copied so far */
971 /*
972 * bytes of memory used for indirect mappings.
973 * This includes all removed vdevs.
974 */
975 uint64_t prs_mapping_memory;
976} pool_removal_stat_t;
977
428870ff
BB
978typedef enum dsl_scan_state {
979 DSS_NONE,
980 DSS_SCANNING,
981 DSS_FINISHED,
982 DSS_CANCELED,
983 DSS_NUM_STATES
984} dsl_scan_state_t;
985
ffe9d382
BB
986/*
987 * Errata described by http://zfsonlinux.org/msg/ZFS-8000-ER. The ordering
988 * of this enum must be maintained to ensure the errata identifiers map to
989 * the correct documentation. New errata may only be appended to the list
990 * and must contain corresponding documentation at the above link.
991 */
992typedef enum zpool_errata {
993 ZPOOL_ERRATA_NONE,
4f2dcb3e
RY
994 ZPOOL_ERRATA_ZOL_2094_SCRUB,
995 ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY,
ae76f45c 996 ZPOOL_ERRATA_ZOL_6845_ENCRYPTION,
f00ab3f2 997 ZPOOL_ERRATA_ZOL_8308_ENCRYPTION,
ffe9d382 998} zpool_errata_t;
428870ff 999
34dc7c2f
BB
1000/*
1001 * Vdev statistics. Note: all fields should be 64-bit because this
1b939560
BB
1002 * is passed between kernel and user land as an nvlist uint64 array.
1003 *
1004 * The vs_ops[] and vs_bytes[] arrays must always be an array size of 6 in
1005 * order to keep subsequent members at their known fixed offsets. When
1006 * adding a new field it must be added to the end the structure.
34dc7c2f 1007 */
1b939560
BB
1008#define VS_ZIO_TYPES 6
1009
34dc7c2f
BB
1010typedef struct vdev_stat {
1011 hrtime_t vs_timestamp; /* time since vdev load */
1012 uint64_t vs_state; /* vdev state */
1013 uint64_t vs_aux; /* see vdev_aux_t */
1014 uint64_t vs_alloc; /* space allocated */
1015 uint64_t vs_space; /* total capacity */
1016 uint64_t vs_dspace; /* deflated capacity */
1017 uint64_t vs_rsize; /* replaceable dev size */
1bd201e7 1018 uint64_t vs_esize; /* expandable dev size */
1b939560
BB
1019 uint64_t vs_ops[VS_ZIO_TYPES]; /* operation count */
1020 uint64_t vs_bytes[VS_ZIO_TYPES]; /* bytes read/written */
34dc7c2f
BB
1021 uint64_t vs_read_errors; /* read errors */
1022 uint64_t vs_write_errors; /* write errors */
1023 uint64_t vs_checksum_errors; /* checksum errors */
619f0976 1024 uint64_t vs_initialize_errors; /* initializing errors */
34dc7c2f 1025 uint64_t vs_self_healed; /* self-healed bytes */
428870ff
BB
1026 uint64_t vs_scan_removing; /* removing? */
1027 uint64_t vs_scan_processed; /* scan processed bytes */
f3a7f661 1028 uint64_t vs_fragmentation; /* device fragmentation */
619f0976
GW
1029 uint64_t vs_initialize_bytes_done; /* bytes initialized */
1030 uint64_t vs_initialize_bytes_est; /* total bytes to initialize */
1031 uint64_t vs_initialize_state; /* vdev_initialzing_state_t */
1032 uint64_t vs_initialize_action_time; /* time_t */
d2734cce 1033 uint64_t vs_checkpoint_space; /* checkpoint-consumed space */
80a91e74 1034 uint64_t vs_resilver_deferred; /* resilver deferred */
ad796b8a 1035 uint64_t vs_slow_ios; /* slow IOs */
1b939560
BB
1036 uint64_t vs_trim_errors; /* trimming errors */
1037 uint64_t vs_trim_notsup; /* supported by device */
1038 uint64_t vs_trim_bytes_done; /* bytes trimmed */
1039 uint64_t vs_trim_bytes_est; /* total bytes to trim */
1040 uint64_t vs_trim_state; /* vdev_trim_state_t */
1041 uint64_t vs_trim_action_time; /* time_t */
34dc7c2f
BB
1042} vdev_stat_t;
1043
193a37cb
TH
1044/*
1045 * Extended stats
1046 *
1047 * These are stats which aren't included in the original iostat output. For
1048 * convenience, they are grouped together in vdev_stat_ex, although each stat
d5884c34 1049 * is individually exported as an nvlist.
193a37cb
TH
1050 */
1051typedef struct vdev_stat_ex {
1052 /* Number of ZIOs issued to disk and waiting to finish */
1053 uint64_t vsx_active_queue[ZIO_PRIORITY_NUM_QUEUEABLE];
1054
1055 /* Number of ZIOs pending to be issued to disk */
1056 uint64_t vsx_pend_queue[ZIO_PRIORITY_NUM_QUEUEABLE];
1057
1058 /*
1059 * Below are the histograms for various latencies. Buckets are in
1060 * units of nanoseconds.
1061 */
1062
1063 /*
1064 * 2^37 nanoseconds = 134s. Timeouts will probably start kicking in
1065 * before this.
1066 */
7e945072
TH
1067#define VDEV_L_HISTO_BUCKETS 37 /* Latency histo buckets */
1068#define VDEV_RQ_HISTO_BUCKETS 25 /* Request size histo buckets */
1069
193a37cb
TH
1070 /* Amount of time in ZIO queue (ns) */
1071 uint64_t vsx_queue_histo[ZIO_PRIORITY_NUM_QUEUEABLE]
7e945072 1072 [VDEV_L_HISTO_BUCKETS];
193a37cb
TH
1073
1074 /* Total ZIO latency (ns). Includes queuing and disk access time */
7e945072 1075 uint64_t vsx_total_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS];
193a37cb
TH
1076
1077 /* Amount of time to read/write the disk (ns) */
7e945072
TH
1078 uint64_t vsx_disk_histo[ZIO_TYPES][VDEV_L_HISTO_BUCKETS];
1079
1080 /* "lookup the bucket for a value" histogram macros */
1081#define HISTO(val, buckets) (val != 0 ? MIN(highbit64(val) - 1, \
1082 buckets - 1) : 0)
1083#define L_HISTO(a) HISTO(a, VDEV_L_HISTO_BUCKETS)
1084#define RQ_HISTO(a) HISTO(a, VDEV_RQ_HISTO_BUCKETS)
1085
1086 /* Physical IO histogram */
1087 uint64_t vsx_ind_histo[ZIO_PRIORITY_NUM_QUEUEABLE]
1088 [VDEV_RQ_HISTO_BUCKETS];
193a37cb 1089
7e945072
TH
1090 /* Delegated (aggregated) physical IO histogram */
1091 uint64_t vsx_agg_histo[ZIO_PRIORITY_NUM_QUEUEABLE]
1092 [VDEV_RQ_HISTO_BUCKETS];
193a37cb
TH
1093
1094} vdev_stat_ex_t;
1095
619f0976
GW
1096/*
1097 * Initialize functions.
1098 */
1099typedef enum pool_initialize_func {
1b939560 1100 POOL_INITIALIZE_START,
619f0976
GW
1101 POOL_INITIALIZE_CANCEL,
1102 POOL_INITIALIZE_SUSPEND,
1103 POOL_INITIALIZE_FUNCS
1104} pool_initialize_func_t;
1105
1b939560
BB
1106/*
1107 * TRIM functions.
1108 */
1109typedef enum pool_trim_func {
1110 POOL_TRIM_START,
1111 POOL_TRIM_CANCEL,
1112 POOL_TRIM_SUSPEND,
1113 POOL_TRIM_FUNCS
1114} pool_trim_func_t;
1115
428870ff
BB
1116/*
1117 * DDT statistics. Note: all fields should be 64-bit because this
1118 * is passed between kernel and userland as an nvlist uint64 array.
1119 */
1120typedef struct ddt_object {
4c0883fb 1121 uint64_t ddo_count; /* number of elements in ddt */
428870ff
BB
1122 uint64_t ddo_dspace; /* size of ddt on disk */
1123 uint64_t ddo_mspace; /* size of ddt in-core */
1124} ddt_object_t;
1125
1126typedef struct ddt_stat {
1127 uint64_t dds_blocks; /* blocks */
1128 uint64_t dds_lsize; /* logical size */
1129 uint64_t dds_psize; /* physical size */
1130 uint64_t dds_dsize; /* deflated allocated size */
1131 uint64_t dds_ref_blocks; /* referenced blocks */
1132 uint64_t dds_ref_lsize; /* referenced lsize * refcnt */
1133 uint64_t dds_ref_psize; /* referenced psize * refcnt */
1134 uint64_t dds_ref_dsize; /* referenced dsize * refcnt */
1135} ddt_stat_t;
1136
1137typedef struct ddt_histogram {
1138 ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */
1139} ddt_histogram_t;
1140
34dc7c2f
BB
1141#define ZVOL_DRIVER "zvol"
1142#define ZFS_DRIVER "zfs"
1143#define ZFS_DEV "/dev/zfs"
2bac6814 1144#define ZFS_SHARETAB "/etc/dfs/sharetab"
34dc7c2f 1145
774ee3c7
GM
1146#define ZFS_SUPER_MAGIC 0x2fc12fc1
1147
428870ff 1148/* general zvol path */
60101509
BB
1149#define ZVOL_DIR "/dev"
1150
1151#define ZVOL_MAJOR 230
1152#define ZVOL_MINOR_BITS 4
1153#define ZVOL_MINOR_MASK ((1U << ZVOL_MINOR_BITS) - 1)
1154#define ZVOL_MINORS (1 << 4)
4c0d8e50 1155#define ZVOL_DEV_NAME "zd"
34dc7c2f
BB
1156
1157#define ZVOL_PROP_NAME "name"
428870ff 1158#define ZVOL_DEFAULT_BLOCKSIZE 8192
34dc7c2f 1159
619f0976
GW
1160typedef enum {
1161 VDEV_INITIALIZE_NONE,
1162 VDEV_INITIALIZE_ACTIVE,
1163 VDEV_INITIALIZE_CANCELED,
1164 VDEV_INITIALIZE_SUSPENDED,
1165 VDEV_INITIALIZE_COMPLETE
1166} vdev_initializing_state_t;
1167
1b939560
BB
1168typedef enum {
1169 VDEV_TRIM_NONE,
1170 VDEV_TRIM_ACTIVE,
1171 VDEV_TRIM_CANCELED,
1172 VDEV_TRIM_SUSPENDED,
1173 VDEV_TRIM_COMPLETE,
1174} vdev_trim_state_t;
1175
4c0883fb
AP
1176/*
1177 * nvlist name constants. Facilitate restricting snapshot iteration range for
1178 * the "list next snapshot" ioctl
1179 */
1180#define SNAP_ITER_MIN_TXG "snap_iter_min_txg"
1181#define SNAP_ITER_MAX_TXG "snap_iter_max_txg"
1182
34dc7c2f
BB
1183/*
1184 * /dev/zfs ioctl numbers.
b83a0e2d
DB
1185 *
1186 * These numbers cannot change over time. New ioctl numbers must be appended.
34dc7c2f 1187 */
34dc7c2f 1188typedef enum zfs_ioc {
2e0358cb 1189 /*
96e51d27 1190 * illumos - 81/128 numbers reserved.
2e0358cb 1191 */
6f1ffb06
MA
1192 ZFS_IOC_FIRST = ('Z' << 8),
1193 ZFS_IOC = ZFS_IOC_FIRST,
b83a0e2d
DB
1194 ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST, /* 0x5a00 */
1195 ZFS_IOC_POOL_DESTROY, /* 0x5a01 */
1196 ZFS_IOC_POOL_IMPORT, /* 0x5a02 */
1197 ZFS_IOC_POOL_EXPORT, /* 0x5a03 */
1198 ZFS_IOC_POOL_CONFIGS, /* 0x5a04 */
1199 ZFS_IOC_POOL_STATS, /* 0x5a05 */
1200 ZFS_IOC_POOL_TRYIMPORT, /* 0x5a06 */
1201 ZFS_IOC_POOL_SCAN, /* 0x5a07 */
1202 ZFS_IOC_POOL_FREEZE, /* 0x5a08 */
1203 ZFS_IOC_POOL_UPGRADE, /* 0x5a09 */
1204 ZFS_IOC_POOL_GET_HISTORY, /* 0x5a0a */
1205 ZFS_IOC_VDEV_ADD, /* 0x5a0b */
1206 ZFS_IOC_VDEV_REMOVE, /* 0x5a0c */
1207 ZFS_IOC_VDEV_SET_STATE, /* 0x5a0d */
1208 ZFS_IOC_VDEV_ATTACH, /* 0x5a0e */
1209 ZFS_IOC_VDEV_DETACH, /* 0x5a0f */
1210 ZFS_IOC_VDEV_SETPATH, /* 0x5a10 */
1211 ZFS_IOC_VDEV_SETFRU, /* 0x5a11 */
1212 ZFS_IOC_OBJSET_STATS, /* 0x5a12 */
1213 ZFS_IOC_OBJSET_ZPLPROPS, /* 0x5a13 */
1214 ZFS_IOC_DATASET_LIST_NEXT, /* 0x5a14 */
1215 ZFS_IOC_SNAPSHOT_LIST_NEXT, /* 0x5a15 */
1216 ZFS_IOC_SET_PROP, /* 0x5a16 */
1217 ZFS_IOC_CREATE, /* 0x5a17 */
1218 ZFS_IOC_DESTROY, /* 0x5a18 */
1219 ZFS_IOC_ROLLBACK, /* 0x5a19 */
1220 ZFS_IOC_RENAME, /* 0x5a1a */
1221 ZFS_IOC_RECV, /* 0x5a1b */
1222 ZFS_IOC_SEND, /* 0x5a1c */
1223 ZFS_IOC_INJECT_FAULT, /* 0x5a1d */
1224 ZFS_IOC_CLEAR_FAULT, /* 0x5a1e */
1225 ZFS_IOC_INJECT_LIST_NEXT, /* 0x5a1f */
1226 ZFS_IOC_ERROR_LOG, /* 0x5a20 */
1227 ZFS_IOC_CLEAR, /* 0x5a21 */
1228 ZFS_IOC_PROMOTE, /* 0x5a22 */
1229 ZFS_IOC_SNAPSHOT, /* 0x5a23 */
1230 ZFS_IOC_DSOBJ_TO_DSNAME, /* 0x5a24 */
1231 ZFS_IOC_OBJ_TO_PATH, /* 0x5a25 */
1232 ZFS_IOC_POOL_SET_PROPS, /* 0x5a26 */
1233 ZFS_IOC_POOL_GET_PROPS, /* 0x5a27 */
1234 ZFS_IOC_SET_FSACL, /* 0x5a28 */
1235 ZFS_IOC_GET_FSACL, /* 0x5a29 */
1236 ZFS_IOC_SHARE, /* 0x5a2a */
1237 ZFS_IOC_INHERIT_PROP, /* 0x5a2b */
1238 ZFS_IOC_SMB_ACL, /* 0x5a2c */
1239 ZFS_IOC_USERSPACE_ONE, /* 0x5a2d */
1240 ZFS_IOC_USERSPACE_MANY, /* 0x5a2e */
1241 ZFS_IOC_USERSPACE_UPGRADE, /* 0x5a2f */
1242 ZFS_IOC_HOLD, /* 0x5a30 */
1243 ZFS_IOC_RELEASE, /* 0x5a31 */
1244 ZFS_IOC_GET_HOLDS, /* 0x5a32 */
1245 ZFS_IOC_OBJSET_RECVD_PROPS, /* 0x5a33 */
1246 ZFS_IOC_VDEV_SPLIT, /* 0x5a34 */
1247 ZFS_IOC_NEXT_OBJ, /* 0x5a35 */
1248 ZFS_IOC_DIFF, /* 0x5a36 */
1249 ZFS_IOC_TMP_SNAPSHOT, /* 0x5a37 */
1250 ZFS_IOC_OBJ_TO_STATS, /* 0x5a38 */
1251 ZFS_IOC_SPACE_WRITTEN, /* 0x5a39 */
1252 ZFS_IOC_SPACE_SNAPS, /* 0x5a3a */
1253 ZFS_IOC_DESTROY_SNAPS, /* 0x5a3b */
1254 ZFS_IOC_POOL_REGUID, /* 0x5a3c */
1255 ZFS_IOC_POOL_REOPEN, /* 0x5a3d */
1256 ZFS_IOC_SEND_PROGRESS, /* 0x5a3e */
1257 ZFS_IOC_LOG_HISTORY, /* 0x5a3f */
1258 ZFS_IOC_SEND_NEW, /* 0x5a40 */
1259 ZFS_IOC_SEND_SPACE, /* 0x5a41 */
1260 ZFS_IOC_CLONE, /* 0x5a42 */
1261 ZFS_IOC_BOOKMARK, /* 0x5a43 */
1262 ZFS_IOC_GET_BOOKMARKS, /* 0x5a44 */
1263 ZFS_IOC_DESTROY_BOOKMARKS, /* 0x5a45 */
bf90948d
LB
1264 ZFS_IOC_RECV_NEW, /* 0x5a46 */
1265 ZFS_IOC_POOL_SYNC, /* 0x5a47 */
1266 ZFS_IOC_CHANNEL_PROGRAM, /* 0x5a48 */
b83a0e2d
DB
1267 ZFS_IOC_LOAD_KEY, /* 0x5a49 */
1268 ZFS_IOC_UNLOAD_KEY, /* 0x5a4a */
1269 ZFS_IOC_CHANGE_KEY, /* 0x5a4b */
1270 ZFS_IOC_REMAP, /* 0x5a4c */
1271 ZFS_IOC_POOL_CHECKPOINT, /* 0x5a4d */
1272 ZFS_IOC_POOL_DISCARD_CHECKPOINT, /* 0x5a4e */
619f0976 1273 ZFS_IOC_POOL_INITIALIZE, /* 0x5a4f */
1b939560 1274 ZFS_IOC_POOL_TRIM, /* 0x5a50 */
2e0358cb
BB
1275
1276 /*
1277 * Linux - 3/64 numbers reserved.
1278 */
1279 ZFS_IOC_LINUX = ('Z' << 8) + 0x80,
b83a0e2d
DB
1280 ZFS_IOC_EVENTS_NEXT, /* 0x5a81 */
1281 ZFS_IOC_EVENTS_CLEAR, /* 0x5a82 */
1282 ZFS_IOC_EVENTS_SEEK, /* 0x5a83 */
2e0358cb
BB
1283
1284 /*
1285 * FreeBSD - 1/64 numbers reserved.
1286 */
1287 ZFS_IOC_FREEBSD = ('Z' << 8) + 0xC0,
1288
6f1ffb06 1289 ZFS_IOC_LAST
34dc7c2f
BB
1290} zfs_ioc_t;
1291
4c0d8e50
FN
1292/*
1293 * zvol ioctl to get dataset name
1294 */
eca7b760 1295#define BLKZNAME _IOR(0x12, 125, char[ZFS_MAX_DATASET_NAME_LEN])
4c0d8e50 1296
d2734cce
SD
1297/*
1298 * ZFS-specific error codes used for returning descriptive errors
1299 * to the userland through zfs ioctls.
1300 *
1301 * The enum implicitly includes all the error codes from errno.h.
1302 * New code should use and extend this enum for errors that are
1303 * not described precisely by generic errno codes.
b83a0e2d
DB
1304 *
1305 * These numbers should not change over time. New entries should be appended.
d2734cce
SD
1306 */
1307typedef enum {
1308 ZFS_ERR_CHECKPOINT_EXISTS = 1024,
1309 ZFS_ERR_DISCARDING_CHECKPOINT,
1310 ZFS_ERR_NO_CHECKPOINT,
1311 ZFS_ERR_DEVRM_IN_PROGRESS,
b83a0e2d
DB
1312 ZFS_ERR_VDEV_TOO_BIG,
1313 ZFS_ERR_IOC_CMD_UNAVAIL,
1314 ZFS_ERR_IOC_ARG_UNAVAIL,
1315 ZFS_ERR_IOC_ARG_REQUIRED,
1316 ZFS_ERR_IOC_ARG_BADTYPE,
d8d418ff 1317 ZFS_ERR_WRONG_PARENT,
f00ab3f2
TC
1318 ZFS_ERR_FROM_IVSET_GUID_MISSING,
1319 ZFS_ERR_FROM_IVSET_GUID_MISMATCH,
caf9dd20 1320 ZFS_ERR_SPILL_BLOCK_FLAG_MISSING,
d2734cce
SD
1321} zfs_errno_t;
1322
34dc7c2f
BB
1323/*
1324 * Internal SPA load state. Used by FMA diagnosis engine.
1325 */
1326typedef enum {
428870ff
BB
1327 SPA_LOAD_NONE, /* no load in progress */
1328 SPA_LOAD_OPEN, /* normal open */
1329 SPA_LOAD_IMPORT, /* import in progress */
1330 SPA_LOAD_TRYIMPORT, /* tryimport in progress */
1331 SPA_LOAD_RECOVER, /* recovery requested */
3dfb57a3
DB
1332 SPA_LOAD_ERROR, /* load failed */
1333 SPA_LOAD_CREATE /* creation in progress */
34dc7c2f
BB
1334} spa_load_state_t;
1335
1336/*
1337 * Bookmark name values.
1338 */
1339#define ZPOOL_ERR_LIST "error list"
1340#define ZPOOL_ERR_DATASET "dataset"
1341#define ZPOOL_ERR_OBJECT "object"
1342
1343#define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1)
1344
1345/*
1346 * The following are names used in the nvlist describing
1347 * the pool's history log.
1348 */
1349#define ZPOOL_HIST_RECORD "history record"
1350#define ZPOOL_HIST_TIME "history time"
1351#define ZPOOL_HIST_CMD "history command"
1352#define ZPOOL_HIST_WHO "history who"
1353#define ZPOOL_HIST_ZONE "history zone"
1354#define ZPOOL_HIST_HOST "history hostname"
1355#define ZPOOL_HIST_TXG "history txg"
1356#define ZPOOL_HIST_INT_EVENT "history internal event"
1357#define ZPOOL_HIST_INT_STR "history internal str"
6f1ffb06
MA
1358#define ZPOOL_HIST_INT_NAME "internal_name"
1359#define ZPOOL_HIST_IOCTL "ioctl"
1360#define ZPOOL_HIST_INPUT_NVL "in_nvl"
1361#define ZPOOL_HIST_OUTPUT_NVL "out_nvl"
1362#define ZPOOL_HIST_DSNAME "dsname"
1363#define ZPOOL_HIST_DSID "dsid"
d99a0153 1364#define ZPOOL_HIST_ERRNO "errno"
34dc7c2f 1365
b5256303
TC
1366/*
1367 * Special nvlist name that will not have its args recorded in the pool's
1368 * history log.
1369 */
1370#define ZPOOL_HIDDEN_ARGS "hidden_args"
1371
619f0976
GW
1372/*
1373 * The following are names used when invoking ZFS_IOC_POOL_INITIALIZE.
1374 */
1375#define ZPOOL_INITIALIZE_COMMAND "initialize_command"
1376#define ZPOOL_INITIALIZE_VDEVS "initialize_vdevs"
1377
1b939560
BB
1378/*
1379 * The following are names used when invoking ZFS_IOC_POOL_TRIM.
1380 */
1381#define ZPOOL_TRIM_COMMAND "trim_command"
1382#define ZPOOL_TRIM_VDEVS "trim_vdevs"
1383#define ZPOOL_TRIM_RATE "trim_rate"
1384#define ZPOOL_TRIM_SECURE "trim_secure"
1385
34dc7c2f
BB
1386/*
1387 * Flags for ZFS_IOC_VDEV_SET_STATE
1388 */
1389#define ZFS_ONLINE_CHECKREMOVE 0x1
1390#define ZFS_ONLINE_UNSPARE 0x2
1391#define ZFS_ONLINE_FORCEFAULT 0x4
9babb374 1392#define ZFS_ONLINE_EXPAND 0x8
34dc7c2f
BB
1393#define ZFS_OFFLINE_TEMPORARY 0x1
1394
572e2857
BB
1395/*
1396 * Flags for ZFS_IOC_POOL_IMPORT
1397 */
1398#define ZFS_IMPORT_NORMAL 0x0
1399#define ZFS_IMPORT_VERBATIM 0x1
1400#define ZFS_IMPORT_ANY_HOST 0x2
1401#define ZFS_IMPORT_MISSING_LOG 0x4
1402#define ZFS_IMPORT_ONLY 0x8
26b42f3f 1403#define ZFS_IMPORT_TEMP_NAME 0x10
379ca9cf 1404#define ZFS_IMPORT_SKIP_MMP 0x20
b5256303 1405#define ZFS_IMPORT_LOAD_KEYS 0x40
d2734cce 1406#define ZFS_IMPORT_CHECKPOINT 0x80
572e2857 1407
d99a0153
CW
1408/*
1409 * Channel program argument/return nvlist keys and defaults.
1410 */
1411#define ZCP_ARG_PROGRAM "program"
1412#define ZCP_ARG_ARGLIST "arg"
5b72a38d 1413#define ZCP_ARG_SYNC "sync"
d99a0153
CW
1414#define ZCP_ARG_INSTRLIMIT "instrlimit"
1415#define ZCP_ARG_MEMLIMIT "memlimit"
1416
1417#define ZCP_ARG_CLIARGV "argv"
1418
1419#define ZCP_RET_ERROR "error"
1420#define ZCP_RET_RETURN "return"
1421
1422#define ZCP_DEFAULT_INSTRLIMIT (10 * 1000 * 1000)
1423#define ZCP_MAX_INSTRLIMIT (10 * ZCP_DEFAULT_INSTRLIMIT)
1424#define ZCP_DEFAULT_MEMLIMIT (10 * 1024 * 1024)
1425#define ZCP_MAX_MEMLIMIT (10 * ZCP_DEFAULT_MEMLIMIT)
1426
34dc7c2f
BB
1427/*
1428 * Sysevent payload members. ZFS will generate the following sysevents with the
1429 * given payloads:
1430 *
1431 * ESC_ZFS_RESILVER_START
1432 * ESC_ZFS_RESILVER_END
1433 * ESC_ZFS_POOL_DESTROY
3541dc6d 1434 * ESC_ZFS_POOL_REGUID
34dc7c2f
BB
1435 *
1436 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1437 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1438 *
1439 * ESC_ZFS_VDEV_REMOVE
1440 * ESC_ZFS_VDEV_CLEAR
1441 * ESC_ZFS_VDEV_CHECK
1442 *
1443 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1444 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1445 * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional)
1446 * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64
12fa0466
DE
1447 *
1448 * ESC_ZFS_HISTORY_EVENT
1449 *
1450 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1451 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1452 * ZFS_EV_HIST_TIME DATA_TYPE_UINT64 (optional)
1453 * ZFS_EV_HIST_CMD DATA_TYPE_STRING (optional)
1454 * ZFS_EV_HIST_WHO DATA_TYPE_UINT64 (optional)
1455 * ZFS_EV_HIST_ZONE DATA_TYPE_STRING (optional)
1456 * ZFS_EV_HIST_HOST DATA_TYPE_STRING (optional)
1457 * ZFS_EV_HIST_TXG DATA_TYPE_UINT64 (optional)
1458 * ZFS_EV_HIST_INT_EVENT DATA_TYPE_UINT64 (optional)
1459 * ZFS_EV_HIST_INT_STR DATA_TYPE_STRING (optional)
1460 * ZFS_EV_HIST_INT_NAME DATA_TYPE_STRING (optional)
1461 * ZFS_EV_HIST_IOCTL DATA_TYPE_STRING (optional)
1462 * ZFS_EV_HIST_DSNAME DATA_TYPE_STRING (optional)
1463 * ZFS_EV_HIST_DSID DATA_TYPE_UINT64 (optional)
1464 *
1465 * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the
1466 * history log nvlist. The keynames will be free of any spaces or other
1467 * characters that could be potentially unexpected to consumers of the
1468 * sysevents.
34dc7c2f
BB
1469 */
1470#define ZFS_EV_POOL_NAME "pool_name"
1471#define ZFS_EV_POOL_GUID "pool_guid"
1472#define ZFS_EV_VDEV_PATH "vdev_path"
1473#define ZFS_EV_VDEV_GUID "vdev_guid"
12fa0466
DE
1474#define ZFS_EV_HIST_TIME "history_time"
1475#define ZFS_EV_HIST_CMD "history_command"
1476#define ZFS_EV_HIST_WHO "history_who"
1477#define ZFS_EV_HIST_ZONE "history_zone"
1478#define ZFS_EV_HIST_HOST "history_hostname"
1479#define ZFS_EV_HIST_TXG "history_txg"
1480#define ZFS_EV_HIST_INT_EVENT "history_internal_event"
1481#define ZFS_EV_HIST_INT_STR "history_internal_str"
1482#define ZFS_EV_HIST_INT_NAME "history_internal_name"
1483#define ZFS_EV_HIST_IOCTL "history_ioctl"
1484#define ZFS_EV_HIST_DSNAME "history_dsname"
1485#define ZFS_EV_HIST_DSID "history_dsid"
34dc7c2f 1486
34dc7c2f
BB
1487#ifdef __cplusplus
1488}
1489#endif
1490
1491#endif /* _SYS_FS_ZFS_H */