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