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, 2016 by Delphix. All rights reserved.
25 * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
26 * Copyright (c) 2013, Saso Kiselkov. All rights reserved.
27 * Copyright (c) 2014 Integros [integros.com]
28 * Copyright 2017 Joyent, Inc.
29 * Copyright (c) 2017 Datto Inc.
30 */
31
32 /* Portions Copyright 2010 Robert Milkowski */
33
34 #ifndef _SYS_FS_ZFS_H
35 #define _SYS_FS_ZFS_H
36
37 #include <sys/time.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /*
44 * Types and constants shared between userland and the kernel.
45 */
46
47 /*
48 * Each dataset can be one of the following types. These constants can be
49 * combined into masks that can be passed to various functions.
50 */
51 typedef enum {
52 ZFS_TYPE_FILESYSTEM = (1 << 0),
53 ZFS_TYPE_SNAPSHOT = (1 << 1),
54 ZFS_TYPE_VOLUME = (1 << 2),
55 ZFS_TYPE_POOL = (1 << 3),
56 ZFS_TYPE_BOOKMARK = (1 << 4),
57 ZFS_TYPE_VDEV = (1 << 5),
58 ZFS_TYPE_COS = (1 << 6),
59 ZFS_TYPE_AUTOSNAP = (1 << 7)
60 } zfs_type_t;
61
62 /*
63 * NB: lzc_dataset_type should be updated whenever a new objset type is added,
64 * if it represents a real type of a dataset that can be created from userland.
65 */
66 typedef enum dmu_objset_type {
67 DMU_OST_NONE,
68 DMU_OST_META,
69 DMU_OST_ZFS,
70 DMU_OST_ZVOL,
71 DMU_OST_OTHER, /* For testing only! */
72 DMU_OST_ANY, /* Be careful! */
73 DMU_OST_NUMTYPES
74 } dmu_objset_type_t;
75
76 #define ZFS_TYPE_DATASET \
77 (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME |\
78 ZFS_TYPE_SNAPSHOT | ZFS_TYPE_AUTOSNAP)
79
80 /*
81 * All of these include the terminating NUL byte.
82 */
83 #define ZAP_MAXNAMELEN 256
84 #define ZAP_MAXVALUELEN (1024 * 8)
85 #define ZAP_OLDMAXVALUELEN 1024
86 #define ZFS_MAX_DATASET_NAME_LEN 256
87
88 /*
89 * Dataset properties are identified by these constants and must be added to
90 * the end of this list to ensure that external consumers are not affected
91 * by the change. If you make any changes to this list, be sure to update
92 * the property table in usr/src/common/zfs/zfs_prop.c.
93 */
94 typedef enum {
95 ZFS_PROP_BAD = -1,
96 ZFS_PROP_TYPE = 0,
97 ZFS_PROP_CREATION,
98 ZFS_PROP_USED,
99 ZFS_PROP_AVAILABLE,
100 ZFS_PROP_REFERENCED,
101 ZFS_PROP_COMPRESSRATIO,
102 ZFS_PROP_MOUNTED,
103 ZFS_PROP_ORIGIN,
104 ZFS_PROP_QUOTA,
105 ZFS_PROP_RESERVATION,
106 ZFS_PROP_VOLSIZE,
107 ZFS_PROP_VOLBLOCKSIZE,
108 ZFS_PROP_RECORDSIZE,
109 ZFS_PROP_MOUNTPOINT,
110 ZFS_PROP_SHARENFS,
111 ZFS_PROP_CHECKSUM,
112 ZFS_PROP_COMPRESSION,
113 ZFS_PROP_ATIME,
114 ZFS_PROP_DEVICES,
115 ZFS_PROP_EXEC,
116 ZFS_PROP_SETUID,
117 ZFS_PROP_READONLY,
118 ZFS_PROP_ZONED,
119 ZFS_PROP_SNAPDIR,
120 ZFS_PROP_ACLMODE,
121 ZFS_PROP_ACLINHERIT,
122 ZFS_PROP_CREATETXG, /* not exposed to the user */
123 ZFS_PROP_NAME, /* not exposed to the user */
124 ZFS_PROP_CANMOUNT,
125 ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */
126 ZFS_PROP_XATTR,
127 ZFS_PROP_NUMCLONES, /* not exposed to the user */
128 ZFS_PROP_COPIES,
129 ZFS_PROP_VERSION,
130 ZFS_PROP_UTF8ONLY,
131 ZFS_PROP_NORMALIZE,
132 ZFS_PROP_CASE,
133 ZFS_PROP_VSCAN,
134 ZFS_PROP_NBMAND,
135 ZFS_PROP_SHARESMB,
136 ZFS_PROP_REFQUOTA,
137 ZFS_PROP_REFRESERVATION,
138 ZFS_PROP_GUID,
139 ZFS_PROP_PRIMARYCACHE,
140 ZFS_PROP_SECONDARYCACHE,
141 ZFS_PROP_USEDSNAP,
142 ZFS_PROP_USEDDS,
143 ZFS_PROP_USEDCHILD,
144 ZFS_PROP_USEDREFRESERV,
145 ZFS_PROP_USERACCOUNTING, /* not exposed to the user */
146 ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */
147 ZFS_PROP_DEFER_DESTROY,
148 ZFS_PROP_USERREFS,
149 ZFS_PROP_LOGBIAS,
150 ZFS_PROP_UNIQUE, /* not exposed to the user */
151 ZFS_PROP_OBJSETID, /* not exposed to the user */
152 ZFS_PROP_DEDUP,
153 ZFS_PROP_MLSLABEL,
154 ZFS_PROP_SYNC,
155 ZFS_PROP_REFRATIO,
156 ZFS_PROP_WRITTEN,
157 ZFS_PROP_CLONES,
158 ZFS_PROP_LOGICALUSED,
159 ZFS_PROP_LOGICALREFERENCED,
160 ZFS_PROP_INCONSISTENT, /* not exposed to the user */
161 ZFS_PROP_FILESYSTEM_LIMIT,
162 ZFS_PROP_SNAPSHOT_LIMIT,
163 ZFS_PROP_FILESYSTEM_COUNT,
164 ZFS_PROP_SNAPSHOT_COUNT,
165 ZFS_PROP_REDUNDANT_METADATA,
166 ZFS_PROP_PREV_SNAP,
167 ZFS_PROP_LSTXG,
168 ZFS_PROP_ZPL_META_TO_METADEV,
169 ZFS_PROP_WBC_MODE,
170 ZFS_PROP_RECEIVE_RESUME_TOKEN,
171 ZFS_PROP_SMARTCOMPRESSION,
172 ZFS_PROP_RATE_LIMIT,
173 ZFS_PROP_MODIFIED,
174 ZFS_NUM_PROPS
175 } zfs_prop_t;
176
177 typedef enum {
178 ZFS_PROP_USERUSED,
179 ZFS_PROP_USERQUOTA,
180 ZFS_PROP_GROUPUSED,
181 ZFS_PROP_GROUPQUOTA,
182 ZFS_NUM_USERQUOTA_PROPS
183 } zfs_userquota_prop_t;
184
185 extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
186
187 /*
188 * Pool properties are identified by these constants and must be added to the
189 * end of this list to ensure that external consumers are not affected
190 * by the change. If you make any changes to this list, be sure to update
191 * the property table in usr/src/common/zfs/zpool_prop.c.
192 *
193 * NOTE: When either adding or changing a feature make sure
194 * to update the zfs-tests zpool_get configuration file
195 * at usr/src/test/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg
196 */
197 typedef enum {
198 ZPOOL_PROP_NAME,
199 ZPOOL_PROP_SIZE,
200 ZPOOL_PROP_CAPACITY,
201 ZPOOL_PROP_ALTROOT,
202 ZPOOL_PROP_HEALTH,
203 ZPOOL_PROP_GUID,
204 ZPOOL_PROP_VERSION,
205 ZPOOL_PROP_BOOTFS,
206 ZPOOL_PROP_DELEGATION,
207 ZPOOL_PROP_AUTOREPLACE,
208 ZPOOL_PROP_CACHEFILE,
209 ZPOOL_PROP_FAILUREMODE,
210 ZPOOL_PROP_LISTSNAPS,
211 ZPOOL_PROP_AUTOEXPAND,
212 ZPOOL_PROP_DEDUPDITTO,
213 ZPOOL_PROP_DEDUPRATIO,
214 ZPOOL_PROP_DDTCAPPED,
215 ZPOOL_PROP_FREE,
216 ZPOOL_PROP_ALLOCATED,
217 ZPOOL_PROP_READONLY,
218 ZPOOL_PROP_COMMENT,
219 ZPOOL_PROP_EXPANDSZ,
220 ZPOOL_PROP_FREEING,
221 ZPOOL_PROP_FRAGMENTATION,
222 ZPOOL_PROP_LEAKED,
223 ZPOOL_PROP_MAXBLOCKSIZE,
224 ZPOOL_PROP_ENABLESPECIAL,
225 ZPOOL_PROP_LOWATERMARK,
226 ZPOOL_PROP_HIWATERMARK,
227 ZPOOL_PROP_DEDUPMETA_DITTO,
228 ZPOOL_PROP_DDT_DESEGREGATION,
229 ZPOOL_PROP_META_PLACEMENT,
230 ZPOOL_PROP_DDT_META_TO_METADEV,
231 ZPOOL_PROP_ZFS_META_TO_METADEV,
232 ZPOOL_PROP_DEDUP_BEST_EFFORT,
233 ZPOOL_PROP_DEDUP_LO_BEST_EFFORT,
234 ZPOOL_PROP_DEDUP_HI_BEST_EFFORT,
235 ZPOOL_PROP_FORCETRIM,
236 ZPOOL_PROP_AUTOTRIM,
237 ZPOOL_PROP_SMALL_DATA_TO_METADEV,
238 ZPOOL_PROP_MINWATERMARK,
239 ZPOOL_PROP_SYNC_TO_SPECIAL,
240 ZPOOL_PROP_BOOTSIZE,
241 ZPOOL_PROP_SCRUB_PRIO,
242 ZPOOL_PROP_RESILVER_PRIO,
243 ZPOOL_NUM_PROPS
244 } zpool_prop_t;
245
246 /*
247 * Note: it is important to keep min/max active properties together in the
248 * same order as the corresponding zio_priority_t definitions as this order
249 * is relied upon when processing in loops. See vdev_impl.h for the set of
250 * macros that rely on this dependency.
251 * Also path must be the first entry in the enum as loops use it as a starting
252 * index.
253 */
254 typedef enum vdev_prop {
255 VDEV_PROP_PATH,
256 VDEV_PROP_FRU,
257 /* minactive props for queue classes */
258 VDEV_PROP_READ_MINACTIVE,
259 VDEV_PROP_AREAD_MINACTIVE,
260 VDEV_PROP_WRITE_MINACTIVE,
261 VDEV_PROP_AWRITE_MINACTIVE,
262 VDEV_PROP_RESILVER_MINACTIVE,
263 VDEV_PROP_SCRUB_MINACTIVE,
264 /* maxactive props for queue classes */
265 VDEV_PROP_READ_MAXACTIVE,
266 VDEV_PROP_AREAD_MAXACTIVE,
267 VDEV_PROP_WRITE_MAXACTIVE,
268 VDEV_PROP_AWRITE_MAXACTIVE,
269 VDEV_PROP_RESILVER_MAXACTIVE,
270 VDEV_PROP_SCRUB_MAXACTIVE,
271 VDEV_PROP_PREFERRED_READ,
272 VDEV_PROP_COS,
273 VDEV_PROP_SPAREGROUP,
274 VDEV_PROP_L2ADDDT,
275 VDEV_PROP_GUID,
276 VDEV_NUM_PROPS
277 } vdev_prop_t;
278
279 /*
280 * Note: it is important to keep min/max active properties together in the
281 * same order as the corresponding zio_priority_t definitions as this order
282 * is relied upon when processing in loops. See cos.h for the set of
283 * macros that rely on this dependency.
284 */
285 typedef enum cos_prop {
286 COS_PROP_GUID,
287 /* user-defined cos name */
288 COS_PROP_NAME,
289 /* IO tunables */
290 /* minactive props for queue classes */
291 COS_PROP_READ_MINACTIVE,
292 COS_PROP_AREAD_MINACTIVE,
293 COS_PROP_WRITE_MINACTIVE,
294 COS_PROP_AWRITE_MINACTIVE,
295 COS_PROP_RESILVER_MINACTIVE,
296 COS_PROP_SCRUB_MINACTIVE,
297 /* maxactive props for queue classes */
298 COS_PROP_READ_MAXACTIVE,
299 COS_PROP_AREAD_MAXACTIVE,
300 COS_PROP_WRITE_MAXACTIVE,
301 COS_PROP_AWRITE_MAXACTIVE,
302 COS_PROP_RESILVER_MAXACTIVE,
303 COS_PROP_SCRUB_MAXACTIVE,
304 /* preference for read in mirror configurations */
305 COS_PROP_PREFERRED_READ,
306 COS_NUM_PROPS
307 } cos_prop_t;
308
309 /* Small enough to not hog a whole line of printout in zpool(1M). */
310 #define ZPROP_MAX_COMMENT 32
311
312 #define ZPROP_CONT -2
313 #define ZPROP_INVAL -1
314
315 #define ZPROP_VALUE "value"
316 #define ZPROP_SOURCE "source"
317
318 typedef enum {
319 ZPROP_SRC_NONE = 0x1,
320 ZPROP_SRC_DEFAULT = 0x2,
321 ZPROP_SRC_TEMPORARY = 0x4,
322 ZPROP_SRC_LOCAL = 0x8,
323 ZPROP_SRC_INHERITED = 0x10,
324 ZPROP_SRC_RECEIVED = 0x20
325 } zprop_source_t;
326
327 #define ZPROP_SRC_ALL 0x3f
328
329 #define ZPROP_SOURCE_VAL_RECVD "$recvd"
330 #define ZPROP_N_MORE_ERRORS "N_MORE_ERRORS"
331 /*
332 * Dataset flag implemented as a special entry in the props zap object
333 * indicating that the dataset has received properties on or after
334 * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
335 * just as it did in earlier versions, and thereafter, local properties are
336 * preserved.
337 */
338 #define ZPROP_HAS_RECVD "$hasrecvd"
339
340 typedef enum {
341 ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
342 ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
343 } zprop_errflags_t;
344
345 typedef int (*zprop_func)(int, void *);
346
347 /*
348 * Properties to be set on the root file system of a new pool
349 * are stuffed into their own nvlist, which is then included in
350 * the properties nvlist with the pool properties.
351 */
352 #define ZPOOL_ROOTFS_PROPS "root-props-nvl"
353
354 /*
355 * Length of 'written@' and 'written#'
356 */
357 #define ZFS_WRITTEN_PROP_PREFIX_LEN 8
358
359 /*
360 * Dataset property functions shared between libzfs and kernel.
361 */
362 const char *zfs_prop_default_string(zfs_prop_t);
363 uint64_t zfs_prop_default_numeric(zfs_prop_t);
364 boolean_t zfs_prop_readonly(zfs_prop_t);
365 boolean_t zfs_prop_visible(zfs_prop_t prop);
366 boolean_t zfs_prop_inheritable(zfs_prop_t);
367 boolean_t zfs_prop_setonce(zfs_prop_t);
368 const char *zfs_prop_to_name(zfs_prop_t);
369 zfs_prop_t zfs_name_to_prop(const char *);
370 boolean_t zfs_prop_user(const char *);
371 boolean_t zfs_prop_userquota(const char *);
372 boolean_t zfs_prop_written(const char *);
373 int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
374 int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
375 uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
376 boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
377
378 /*
379 * Pool property functions shared between libzfs and kernel.
380 */
381 zpool_prop_t zpool_name_to_prop(const char *);
382 const char *zpool_prop_to_name(zpool_prop_t);
383 const char *zpool_prop_default_string(zpool_prop_t);
384 uint64_t zpool_prop_default_numeric(zpool_prop_t);
385 boolean_t zpool_prop_readonly(zpool_prop_t);
386 boolean_t zpool_prop_feature(const char *);
387 boolean_t zpool_prop_unsupported(const char *name);
388 int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
389 int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
390 uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
391
392 /*
393 * Vdev property functions shared between libzfs and kernel.
394 */
395 vdev_prop_t vdev_name_to_prop(const char *);
396 const char *vdev_prop_to_name(vdev_prop_t);
397 const char *vdev_prop_default_string(vdev_prop_t);
398 uint64_t vdev_prop_default_numeric(vdev_prop_t);
399 boolean_t vdev_prop_readonly(vdev_prop_t);
400 int vdev_prop_index_to_string(vdev_prop_t, uint64_t, const char **);
401 int vdev_prop_string_to_index(vdev_prop_t, const char *, uint64_t *);
402 uint64_t vdev_prop_random_value(vdev_prop_t, uint64_t seed);
403
404 /*
405 * COS property functions shared between libzfs and kernel.
406 */
407 cos_prop_t cos_name_to_prop(const char *);
408 const char *cos_prop_to_name(cos_prop_t);
409 const char *cos_prop_default_string(cos_prop_t);
410 uint64_t cos_prop_default_numeric(cos_prop_t);
411 boolean_t cos_prop_readonly(cos_prop_t);
412 int cos_prop_index_to_string(cos_prop_t, uint64_t, const char **);
413 int cos_prop_string_to_index(cos_prop_t, const char *, uint64_t *);
414 uint64_t cos_prop_random_value(cos_prop_t, uint64_t seed);
415
416 #define MAXCOSNAMELEN (64)
417 /*
418 * Definitions for the Delegation.
419 */
420 typedef enum {
421 ZFS_DELEG_WHO_UNKNOWN = 0,
422 ZFS_DELEG_USER = 'u',
423 ZFS_DELEG_USER_SETS = 'U',
424 ZFS_DELEG_GROUP = 'g',
425 ZFS_DELEG_GROUP_SETS = 'G',
426 ZFS_DELEG_EVERYONE = 'e',
427 ZFS_DELEG_EVERYONE_SETS = 'E',
428 ZFS_DELEG_CREATE = 'c',
429 ZFS_DELEG_CREATE_SETS = 'C',
430 ZFS_DELEG_NAMED_SET = 's',
431 ZFS_DELEG_NAMED_SET_SETS = 'S'
432 } zfs_deleg_who_type_t;
433
434 typedef enum {
435 ZFS_DELEG_NONE = 0,
436 ZFS_DELEG_PERM_LOCAL = 1,
437 ZFS_DELEG_PERM_DESCENDENT = 2,
438 ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
439 ZFS_DELEG_PERM_CREATE = 4
440 } zfs_deleg_inherit_t;
441
442 #define ZFS_DELEG_PERM_UID "uid"
443 #define ZFS_DELEG_PERM_GID "gid"
444 #define ZFS_DELEG_PERM_GROUPS "groups"
445
446 #define ZFS_MLSLABEL_DEFAULT "none"
447
448 #define ZFS_SMB_ACL_SRC "src"
449 #define ZFS_SMB_ACL_TARGET "target"
450
451 typedef enum {
452 ZFS_CANMOUNT_OFF = 0,
453 ZFS_CANMOUNT_ON = 1,
454 ZFS_CANMOUNT_NOAUTO = 2
455 } zfs_canmount_type_t;
456
457 typedef enum {
458 ZFS_LOGBIAS_LATENCY = 0,
459 ZFS_LOGBIAS_THROUGHPUT = 1
460 } zfs_logbias_op_t;
461
462 typedef enum zfs_share_op {
463 ZFS_SHARE_NFS = 0,
464 ZFS_UNSHARE_NFS = 1,
465 ZFS_SHARE_SMB = 2,
466 ZFS_UNSHARE_SMB = 3
467 } zfs_share_op_t;
468
469 typedef enum zfs_smb_acl_op {
470 ZFS_SMB_ACL_ADD,
471 ZFS_SMB_ACL_REMOVE,
472 ZFS_SMB_ACL_RENAME,
473 ZFS_SMB_ACL_PURGE
474 } zfs_smb_acl_op_t;
475
476 typedef enum zfs_cache_type {
477 ZFS_CACHE_NONE = 0,
478 ZFS_CACHE_METADATA = 1,
479 ZFS_CACHE_ALL = 2,
480 ZFS_CACHE_DATA = 3
481 } zfs_cache_type_t;
482
483 typedef enum {
484 ZFS_SYNC_STANDARD = 0,
485 ZFS_SYNC_ALWAYS = 1,
486 ZFS_SYNC_DISABLED = 2
487 } zfs_sync_type_t;
488
489 typedef enum {
490 ZFS_REDUNDANT_METADATA_ALL,
491 ZFS_REDUNDANT_METADATA_MOST
492 } zfs_redundant_metadata_type_t;
493
494 typedef enum {
495 ZFS_WBC_MODE_OFF,
496 ZFS_WBC_MODE_ON,
497 ZFS_WBC_MODE_OFF_DELAYED
498 } zfs_wbc_mode_t;
499
500 /*
501 * On-disk version number.
502 */
503 #define SPA_VERSION_1 1ULL
504 #define SPA_VERSION_2 2ULL
505 #define SPA_VERSION_3 3ULL
506 #define SPA_VERSION_4 4ULL
507 #define SPA_VERSION_5 5ULL
508 #define SPA_VERSION_6 6ULL
509 #define SPA_VERSION_7 7ULL
510 #define SPA_VERSION_8 8ULL
511 #define SPA_VERSION_9 9ULL
512 #define SPA_VERSION_10 10ULL
513 #define SPA_VERSION_11 11ULL
514 #define SPA_VERSION_12 12ULL
515 #define SPA_VERSION_13 13ULL
516 #define SPA_VERSION_14 14ULL
517 #define SPA_VERSION_15 15ULL
518 #define SPA_VERSION_16 16ULL
519 #define SPA_VERSION_17 17ULL
520 #define SPA_VERSION_18 18ULL
521 #define SPA_VERSION_19 19ULL
522 #define SPA_VERSION_20 20ULL
523 #define SPA_VERSION_21 21ULL
524 #define SPA_VERSION_22 22ULL
525 #define SPA_VERSION_23 23ULL
526 #define SPA_VERSION_24 24ULL
527 #define SPA_VERSION_25 25ULL
528 #define SPA_VERSION_26 26ULL
529 #define SPA_VERSION_27 27ULL
530 #define SPA_VERSION_28 28ULL
531 #define SPA_VERSION_5000 5000ULL
532
533 /*
534 * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
535 * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
536 * and do the appropriate changes. Also bump the version number in
537 * usr/src/grub/capability.
538 */
539 #define SPA_VERSION SPA_VERSION_5000
540 #define SPA_VERSION_STRING "5000"
541
542 /*
543 * Symbolic names for the changes that caused a SPA_VERSION switch.
544 * Used in the code when checking for presence or absence of a feature.
545 * Feel free to define multiple symbolic names for each version if there
546 * were multiple changes to on-disk structures during that version.
547 *
548 * NOTE: When checking the current SPA_VERSION in your code, be sure
549 * to use spa_version() since it reports the version of the
550 * last synced uberblock. Checking the in-flight version can
551 * be dangerous in some cases.
552 */
553 #define SPA_VERSION_INITIAL SPA_VERSION_1
554 #define SPA_VERSION_DITTO_BLOCKS SPA_VERSION_2
555 #define SPA_VERSION_SPARES SPA_VERSION_3
556 #define SPA_VERSION_RAIDZ2 SPA_VERSION_3
557 #define SPA_VERSION_BPOBJ_ACCOUNT SPA_VERSION_3
558 #define SPA_VERSION_RAIDZ_DEFLATE SPA_VERSION_3
559 #define SPA_VERSION_DNODE_BYTES SPA_VERSION_3
560 #define SPA_VERSION_ZPOOL_HISTORY SPA_VERSION_4
561 #define SPA_VERSION_GZIP_COMPRESSION SPA_VERSION_5
562 #define SPA_VERSION_BOOTFS SPA_VERSION_6
563 #define SPA_VERSION_SLOGS SPA_VERSION_7
564 #define SPA_VERSION_DELEGATED_PERMS SPA_VERSION_8
565 #define SPA_VERSION_FUID SPA_VERSION_9
566 #define SPA_VERSION_REFRESERVATION SPA_VERSION_9
567 #define SPA_VERSION_REFQUOTA SPA_VERSION_9
568 #define SPA_VERSION_UNIQUE_ACCURATE SPA_VERSION_9
569 #define SPA_VERSION_L2CACHE SPA_VERSION_10
570 #define SPA_VERSION_NEXT_CLONES SPA_VERSION_11
571 #define SPA_VERSION_ORIGIN SPA_VERSION_11
572 #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11
573 #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12
574 #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13
575 #define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14
576 #define SPA_VERSION_USERSPACE SPA_VERSION_15
577 #define SPA_VERSION_STMF_PROP SPA_VERSION_16
578 #define SPA_VERSION_RAIDZ3 SPA_VERSION_17
579 #define SPA_VERSION_USERREFS SPA_VERSION_18
580 #define SPA_VERSION_HOLES SPA_VERSION_19
581 #define SPA_VERSION_ZLE_COMPRESSION SPA_VERSION_20
582 #define SPA_VERSION_DEDUP SPA_VERSION_21
583 #define SPA_VERSION_RECVD_PROPS SPA_VERSION_22
584 #define SPA_VERSION_SLIM_ZIL SPA_VERSION_23
585 #define SPA_VERSION_SA SPA_VERSION_24
586 #define SPA_VERSION_SCAN SPA_VERSION_25
587 #define SPA_VERSION_DIR_CLONES SPA_VERSION_26
588 #define SPA_VERSION_DEADLISTS SPA_VERSION_26
589 #define SPA_VERSION_FAST_SNAP SPA_VERSION_27
590 #define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28
591 #define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28
592 #define SPA_VERSION_FEATURES SPA_VERSION_5000
593
594 #define SPA_VERSION_IS_SUPPORTED(v) \
595 (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
596 ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
597
598 /*
599 * ZPL version - rev'd whenever an incompatible on-disk format change
600 * occurs. This is independent of SPA/DMU/ZAP versioning. You must
601 * also update the version_table[] and help message in zfs_prop.c.
602 *
603 * When changing, be sure to teach GRUB how to read the new format!
604 * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
605 */
606 #define ZPL_VERSION_1 1ULL
607 #define ZPL_VERSION_2 2ULL
608 #define ZPL_VERSION_3 3ULL
609 #define ZPL_VERSION_4 4ULL
610 #define ZPL_VERSION_5 5ULL
611 #define ZPL_VERSION ZPL_VERSION_5
612 #define ZPL_VERSION_STRING "5"
613
614 #define ZPL_VERSION_INITIAL ZPL_VERSION_1
615 #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2
616 #define ZPL_VERSION_FUID ZPL_VERSION_3
617 #define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3
618 #define ZPL_VERSION_SYSATTR ZPL_VERSION_3
619 #define ZPL_VERSION_USERSPACE ZPL_VERSION_4
620 #define ZPL_VERSION_SA ZPL_VERSION_5
621
622 /* Rewind request information */
623 #define ZPOOL_NO_REWIND 1 /* No policy - default behavior */
624 #define ZPOOL_NEVER_REWIND 2 /* Do not search for best txg or rewind */
625 #define ZPOOL_TRY_REWIND 4 /* Search for best txg, but do not rewind */
626 #define ZPOOL_DO_REWIND 8 /* Rewind to best txg w/in deferred frees */
627 #define ZPOOL_EXTREME_REWIND 16 /* Allow extreme measures to find best txg */
628 #define ZPOOL_REWIND_MASK 28 /* All the possible rewind bits */
629 #define ZPOOL_REWIND_POLICIES 31 /* All the possible policy bits */
630
631 typedef struct zpool_rewind_policy {
632 uint32_t zrp_request; /* rewind behavior requested */
633 uint64_t zrp_maxmeta; /* max acceptable meta-data errors */
634 uint64_t zrp_maxdata; /* max acceptable data errors */
635 uint64_t zrp_txg; /* specific txg to load */
636 } zpool_rewind_policy_t;
637
638 /*
639 * The following are configuration names used in the nvlist describing a pool's
640 * configuration.
641 */
642 #define ZPOOL_CONFIG_VERSION "version"
643 #define ZPOOL_CONFIG_POOL_NAME "name"
644 #define ZPOOL_CONFIG_POOL_STATE "state"
645 #define ZPOOL_CONFIG_POOL_TXG "txg"
646 #define ZPOOL_CONFIG_POOL_GUID "pool_guid"
647 #define ZPOOL_CONFIG_CREATE_TXG "create_txg"
648 #define ZPOOL_CONFIG_TOP_GUID "top_guid"
649 #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
650 #define ZPOOL_CONFIG_TYPE "type"
651 #define ZPOOL_CONFIG_CHILDREN "children"
652 #define ZPOOL_CONFIG_ID "id"
653 #define ZPOOL_CONFIG_GUID "guid"
654 #define ZPOOL_CONFIG_PATH "path"
655 #define ZPOOL_CONFIG_DEVID "devid"
656 #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array"
657 #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift"
658 #define ZPOOL_CONFIG_ASHIFT "ashift"
659 #define ZPOOL_CONFIG_ASIZE "asize"
660 #define ZPOOL_CONFIG_DTL "DTL"
661 #define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */
662 #define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */
663 #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
664 #define ZPOOL_CONFIG_ERRCOUNT "error_count"
665 #define ZPOOL_CONFIG_NOT_PRESENT "not_present"
666 #define ZPOOL_CONFIG_SPARES "spares"
667 #define ZPOOL_CONFIG_IS_SPARE "is_spare"
668 #define ZPOOL_CONFIG_NPARITY "nparity"
669 #define ZPOOL_CONFIG_HOSTID "hostid"
670 #define ZPOOL_CONFIG_HOSTNAME "hostname"
671 #define ZPOOL_CONFIG_LOADED_TIME "initial_load_time"
672 #define ZPOOL_CONFIG_UNSPARE "unspare"
673 #define ZPOOL_CONFIG_PHYS_PATH "phys_path"
674 #define ZPOOL_CONFIG_IS_LOG "is_log"
675 #define ZPOOL_CONFIG_IS_SPECIAL "is_special"
676 #define ZPOOL_CONFIG_L2CACHE "l2cache"
677 #define ZPOOL_CONFIG_L2CACHE_PERSISTENT "l2cache_persistent"
678 #define ZPOOL_CONFIG_HOLE_ARRAY "hole_array"
679 #define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
680 #define ZPOOL_CONFIG_IS_HOLE "is_hole"
681 #define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
682 #define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
683 #define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
684 #define ZPOOL_CONFIG_SPLIT "splitcfg"
685 #define ZPOOL_CONFIG_ORIG_GUID "orig_guid"
686 #define ZPOOL_CONFIG_SPLIT_GUID "split_guid"
687 #define ZPOOL_CONFIG_SPLIT_LIST "guid_list"
688 #define ZPOOL_CONFIG_REMOVING "removing"
689 #define ZPOOL_CONFIG_RESILVERING "resilvering"
690 #define ZPOOL_CONFIG_RESILVER_TXG "resilver_txg"
691 #define ZPOOL_CONFIG_COMMENT "comment"
692 #define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */
693 #define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */
694 #define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */
695 #define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */
696 #define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */
697 #define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */
698 #define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */
699 #define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */
700 #define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */
701 #define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read"
702 #define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */
703 #define ZPOOL_CONFIG_IS_SSD "is_ssd" /* not stored on disk */
704 #define ZPOOL_CONFIG_VDEV_TOP_ZAP "com.delphix:vdev_zap_top"
705 #define ZPOOL_CONFIG_VDEV_LEAF_ZAP "com.delphix:vdev_zap_leaf"
706 #define ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS "com.delphix:has_per_vdev_zaps"
707 /*
708 * The persistent vdev state is stored as separate values rather than a single
709 * 'vdev_state' entry. This is because a device can be in multiple states, such
710 * as offline and degraded.
711 */
712 #define ZPOOL_CONFIG_OFFLINE "offline"
713 #define ZPOOL_CONFIG_FAULTED "faulted"
714 #define ZPOOL_CONFIG_DEGRADED "degraded"
715 #define ZPOOL_CONFIG_REMOVED "removed"
716 #define ZPOOL_CONFIG_FRU "fru"
717 #define ZPOOL_CONFIG_AUX_STATE "aux_state"
718 #define ZPOOL_CONFIG_TRIM_PROG "trim_prog"
719 #define ZPOOL_CONFIG_TRIM_RATE "trim_rate"
720 #define ZPOOL_CONFIG_TRIM_START_TIME "trim_start_time"
721 #define ZPOOL_CONFIG_TRIM_STOP_TIME "trim_stop_time"
722
723 /* Rewind policy parameters */
724 #define ZPOOL_REWIND_POLICY "rewind-policy"
725 #define ZPOOL_REWIND_REQUEST "rewind-request"
726 #define ZPOOL_REWIND_REQUEST_TXG "rewind-request-txg"
727 #define ZPOOL_REWIND_META_THRESH "rewind-meta-thresh"
728 #define ZPOOL_REWIND_DATA_THRESH "rewind-data-thresh"
729
730 /* Rewind data discovered */
731 #define ZPOOL_CONFIG_LOAD_TIME "rewind_txg_ts"
732 #define ZPOOL_CONFIG_LOAD_DATA_ERRORS "verify_data_errors"
733 #define ZPOOL_CONFIG_REWIND_TIME "seconds_of_rewind"
734
735 #define VDEV_TYPE_ROOT "root"
736 #define VDEV_TYPE_MIRROR "mirror"
737 #define VDEV_TYPE_REPLACING "replacing"
738 #define VDEV_TYPE_RAIDZ "raidz"
739 #define VDEV_TYPE_DISK "disk"
740 #define VDEV_TYPE_FILE "file"
741 #define VDEV_TYPE_MISSING "missing"
742 #define VDEV_TYPE_HOLE "hole"
743 #define VDEV_TYPE_SPARE "spare"
744 #define VDEV_TYPE_LOG "log"
745 #define VDEV_TYPE_L2CACHE "l2cache"
746 #define VDEV_TYPE_SPECIAL "special"
747
748 /*
749 * This is needed in userland to report the minimum necessary device size.
750 *
751 * Note that the zfs test suite uses 64MB vdevs.
752 */
753 #define SPA_MINDEVSIZE (64ULL << 20)
754
755 /*
756 * Set if the fragmentation has not yet been calculated. This can happen
757 * because the space maps have not been upgraded or the histogram feature
758 * is not enabled.
759 */
760 #define ZFS_FRAG_INVALID UINT64_MAX
761
762 /*
763 * The location of the pool configuration repository, shared between kernel and
764 * userland.
765 */
766 #define ZPOOL_CACHE "/etc/zfs/zpool.cache"
767
768 /*
769 * vdev states are ordered from least to most healthy.
770 * A vdev that's CANT_OPEN or below is considered unusable.
771 */
772 typedef enum vdev_state {
773 VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */
774 VDEV_STATE_CLOSED, /* Not currently open */
775 VDEV_STATE_OFFLINE, /* Not allowed to open */
776 VDEV_STATE_REMOVED, /* Explicitly removed from system */
777 VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */
778 VDEV_STATE_FAULTED, /* External request to fault device */
779 VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */
780 VDEV_STATE_HEALTHY /* Presumed good */
781 } vdev_state_t;
782
783 #define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY
784
785 /*
786 * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field
787 * of the vdev stats structure uses these constants to distinguish why.
788 */
789 typedef enum vdev_aux {
790 VDEV_AUX_NONE, /* no error */
791 VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */
792 VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */
793 VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */
794 VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */
795 VDEV_AUX_TOO_SMALL, /* vdev size is too small */
796 VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */
797 VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */
798 VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */
799 VDEV_AUX_UNSUP_FEAT, /* unsupported features */
800 VDEV_AUX_SPARED, /* hot spare used in another pool */
801 VDEV_AUX_ERR_EXCEEDED, /* too many errors */
802 VDEV_AUX_IO_FAILURE, /* experienced I/O failure */
803 VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */
804 VDEV_AUX_EXTERNAL, /* external diagnosis */
805 VDEV_AUX_SPLIT_POOL /* vdev was split off into another pool */
806 } vdev_aux_t;
807
808 /*
809 * pool state. The following states are written to disk as part of the normal
810 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
811 * states are software abstractions used at various levels to communicate
812 * pool state.
813 */
814 typedef enum pool_state {
815 POOL_STATE_ACTIVE = 0, /* In active use */
816 POOL_STATE_EXPORTED, /* Explicitly exported */
817 POOL_STATE_DESTROYED, /* Explicitly destroyed */
818 POOL_STATE_SPARE, /* Reserved for hot spare use */
819 POOL_STATE_L2CACHE, /* Level 2 ARC device */
820 POOL_STATE_UNINITIALIZED, /* Internal spa_t state */
821 POOL_STATE_UNAVAIL, /* Internal libzfs state */
822 POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */
823 } pool_state_t;
824
825 /*
826 * Scan Functions.
827 */
828 typedef enum pool_scan_func {
829 POOL_SCAN_NONE,
830 POOL_SCAN_SCRUB,
831 POOL_SCAN_RESILVER,
832 POOL_SCAN_MOS,
833 POOL_SCAN_META,
834 POOL_SCAN_FUNCS
835 } pool_scan_func_t;
836
837 /*
838 * TRIM command configuration info.
839 */
840 typedef struct trim_cmd_info_s {
841 uint64_t tci_start; /* B_TRUE = start; B_FALSE = stop */
842 uint64_t tci_rate; /* requested TRIM rate in bytes/sec */
843 } trim_cmd_info_t;
844
845 /*
846 * Used to control scrub pause and resume.
847 */
848 typedef enum pool_scrub_cmd {
849 POOL_SCRUB_NORMAL = 0,
850 POOL_SCRUB_PAUSE,
851 POOL_SCRUB_FLAGS_END
852 } pool_scrub_cmd_t;
853
854 /*
855 * ZIO types. Needed to interpret vdev statistics below.
856 */
857 typedef enum zio_type {
858 ZIO_TYPE_NULL = 0,
859 ZIO_TYPE_READ,
860 ZIO_TYPE_WRITE,
861 ZIO_TYPE_FREE,
862 ZIO_TYPE_CLAIM,
863 ZIO_TYPE_IOCTL,
864 ZIO_TYPES
865 } zio_type_t;
866
867 /*
868 * Pool statistics. Note: all fields should be 64-bit because this
869 * is passed between kernel and userland as an nvlist uint64 array.
870 */
871 typedef struct pool_scan_stat {
872 /* values stored on disk */
873 uint64_t pss_func; /* pool_scan_func_t */
874 uint64_t pss_state; /* dsl_scan_state_t */
875 uint64_t pss_start_time; /* scan start time */
876 uint64_t pss_end_time; /* scan end time */
877 uint64_t pss_to_examine; /* total bytes to scan */
878 uint64_t pss_examined; /* total bytes located by scanner */
879 uint64_t pss_issued; /* total bytes checked by scanner */
880 uint64_t pss_to_process; /* total bytes to process */
881 uint64_t pss_processed; /* total processed bytes */
882 uint64_t pss_errors; /* scan errors */
883
884 /* values not stored on disk */
885 uint64_t pss_pass_exam; /* examined bytes per scan pass */
886 uint64_t pss_pass_work; /* issued bytes per scan pass */
887 uint64_t pss_pass_start; /* start time of a scan pass */
888 uint64_t pss_pass_scrub_pause; /* pause time of a scurb pass */
889 /* cumulative time scrub spent paused, needed for rate calculation */
890 uint64_t pss_pass_scrub_spent_paused;
891 } pool_scan_stat_t;
892
893 typedef enum dsl_scan_state {
894 DSS_NONE,
895 DSS_SCANNING,
896 DSS_FINISHED,
897 DSS_CANCELED,
898 DSS_FINISHING,
899 DSS_NUM_STATES
900 } dsl_scan_state_t;
901
902
903 /*
904 * Vdev statistics. Note: all fields should be 64-bit because this
905 * is passed between kernel and userland as an nvlist uint64 array.
906 */
907 typedef struct vdev_stat {
908 hrtime_t vs_timestamp; /* time since vdev load */
909 uint64_t vs_state; /* vdev state */
910 uint64_t vs_aux; /* see vdev_aux_t */
911 uint64_t vs_alloc; /* space allocated */
912 uint64_t vs_space; /* total capacity */
913 uint64_t vs_dspace; /* deflated capacity */
914 uint64_t vs_rsize; /* replaceable dev size */
915 uint64_t vs_esize; /* expandable dev size */
916 uint64_t vs_ops[ZIO_TYPES]; /* operation count */
917 uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */
918 uint64_t vs_read_errors; /* read errors */
919 uint64_t vs_write_errors; /* write errors */
920 uint64_t vs_checksum_errors; /* checksum errors */
921 uint64_t vs_self_healed; /* self-healed bytes */
922 uint64_t vs_scan_removing; /* removing? */
923 uint64_t vs_scan_processed; /* scan processed bytes */
924 uint64_t vs_fragmentation; /* device fragmentation */
925 hrtime_t vs_latency[ZIO_TYPES]; /* moving average of latency */
926 hrtime_t vs_iotime[ZIO_TYPES]; /* time spent doing i/o */
927 } vdev_stat_t;
928
929 /*
930 * DDT statistics. Note: all fields should be 64-bit because this
931 * is passed between kernel and userland as an nvlist uint64 array.
932 */
933 typedef struct ddt_object {
934 uint64_t ddo_count; /* number of elments in ddt */
935 uint64_t ddo_dspace; /* size of ddt on disk */
936 uint64_t ddo_mspace; /* size of ddt in-core */
937 } ddt_object_t;
938
939 typedef struct ddt_stat {
940 uint64_t dds_blocks; /* blocks */
941 uint64_t dds_lsize; /* logical size */
942 uint64_t dds_psize; /* physical size */
943 uint64_t dds_dsize; /* deflated allocated size */
944 uint64_t dds_ref_blocks; /* referenced blocks */
945 uint64_t dds_ref_lsize; /* referenced lsize * refcnt */
946 uint64_t dds_ref_psize; /* referenced psize * refcnt */
947 uint64_t dds_ref_dsize; /* referenced dsize * refcnt */
948 } ddt_stat_t;
949
950 typedef struct ddt_histogram {
951 ddt_stat_t ddh_stat[64]; /* power-of-two histogram buckets */
952 } ddt_histogram_t;
953
954 #define ZVOL_DRIVER "zvol"
955 #define ZFS_DRIVER "zfs"
956 #define ZFS_DEV "/dev/zfs"
957 #define ZFS_DISK_ROOT "/dev/dsk"
958 #define ZFS_DISK_ROOTD ZFS_DISK_ROOT "/"
959 #define ZFS_RDISK_ROOT "/dev/rdsk"
960 #define ZFS_RDISK_ROOTD ZFS_RDISK_ROOT "/"
961
962 /* general zvol path */
963 #define ZVOL_DIR "/dev/zvol"
964 /* expansion */
965 #define ZVOL_PSEUDO_DEV "/devices/pseudo/zfs@0:"
966 /* for dump and swap */
967 #define ZVOL_FULL_DEV_DIR ZVOL_DIR "/dsk/"
968 #define ZVOL_FULL_RDEV_DIR ZVOL_DIR "/rdsk/"
969
970 #define ZVOL_PROP_NAME "name"
971 #define ZVOL_DEFAULT_BLOCKSIZE 8192
972
973 /*
974 * /dev/zfs ioctl numbers.
975 */
976 typedef enum zfs_ioc {
977 ZFS_IOC_FIRST = ('Z' << 8),
978 ZFS_IOC = ZFS_IOC_FIRST,
979 ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,
980 ZFS_IOC_POOL_DESTROY,
981 ZFS_IOC_POOL_IMPORT,
982 ZFS_IOC_POOL_EXPORT,
983 ZFS_IOC_POOL_CONFIGS,
984 ZFS_IOC_POOL_STATS,
985 ZFS_IOC_POOL_TRYIMPORT,
986 ZFS_IOC_POOL_SCAN,
987 ZFS_IOC_POOL_FREEZE,
988 ZFS_IOC_POOL_UPGRADE,
989 ZFS_IOC_POOL_GET_HISTORY,
990 ZFS_IOC_VDEV_ADD,
991 ZFS_IOC_VDEV_REMOVE,
992 ZFS_IOC_VDEV_SET_STATE,
993 ZFS_IOC_VDEV_ATTACH,
994 ZFS_IOC_VDEV_DETACH,
995 ZFS_IOC_VDEV_SETL2ADDDT,
996 ZFS_IOC_VDEV_SETPATH,
997 ZFS_IOC_VDEV_SETFRU,
998 ZFS_IOC_OBJSET_STATS,
999 ZFS_IOC_OBJSET_ZPLPROPS,
1000 ZFS_IOC_DATASET_LIST_NEXT,
1001 ZFS_IOC_SNAPSHOT_LIST_NEXT,
1002 ZFS_IOC_SET_PROP,
1003 ZFS_IOC_CREATE,
1004 ZFS_IOC_DESTROY,
1005 ZFS_IOC_ROLLBACK,
1006 ZFS_IOC_RENAME,
1007 ZFS_IOC_RECV,
1008 ZFS_IOC_SEND,
1009 ZFS_IOC_INJECT_FAULT,
1010 ZFS_IOC_CLEAR_FAULT,
1011 ZFS_IOC_INJECT_LIST_NEXT,
1012 ZFS_IOC_ERROR_LOG,
1013 ZFS_IOC_CLEAR,
1014 ZFS_IOC_PROMOTE,
1015 ZFS_IOC_SNAPSHOT,
1016 ZFS_IOC_DSOBJ_TO_DSNAME,
1017 ZFS_IOC_OBJ_TO_PATH,
1018 ZFS_IOC_POOL_SET_PROPS,
1019 ZFS_IOC_POOL_GET_PROPS,
1020 ZFS_IOC_SET_FSACL,
1021 ZFS_IOC_GET_FSACL,
1022 ZFS_IOC_SHARE,
1023 ZFS_IOC_INHERIT_PROP,
1024 ZFS_IOC_SMB_ACL,
1025 ZFS_IOC_USERSPACE_ONE,
1026 ZFS_IOC_USERSPACE_MANY,
1027 ZFS_IOC_USERSPACE_UPGRADE,
1028 ZFS_IOC_HOLD,
1029 ZFS_IOC_RELEASE,
1030 ZFS_IOC_GET_HOLDS,
1031 ZFS_IOC_OBJSET_RECVD_PROPS,
1032 ZFS_IOC_VDEV_SPLIT,
1033 ZFS_IOC_NEXT_OBJ,
1034 ZFS_IOC_DIFF,
1035 ZFS_IOC_TMP_SNAPSHOT,
1036 ZFS_IOC_OBJ_TO_STATS,
1037 ZFS_IOC_SPACE_WRITTEN,
1038 ZFS_IOC_SPACE_SNAPS,
1039 ZFS_IOC_DESTROY_SNAPS,
1040 ZFS_IOC_POOL_REGUID,
1041 ZFS_IOC_POOL_REOPEN,
1042 ZFS_IOC_SEND_PROGRESS,
1043 ZFS_IOC_LOG_HISTORY,
1044 ZFS_IOC_SEND_NEW,
1045 ZFS_IOC_SEND_SPACE,
1046 ZFS_IOC_CLONE,
1047 ZFS_IOC_BOOKMARK,
1048 ZFS_IOC_GET_BOOKMARKS,
1049 ZFS_IOC_DESTROY_BOOKMARKS,
1050 ZFS_IOC_VDEV_SET_PROPS,
1051 ZFS_IOC_VDEV_GET_PROPS,
1052 ZFS_IOC_COS_ALLOC,
1053 ZFS_IOC_COS_FREE,
1054 ZFS_IOC_COS_LIST,
1055 ZFS_IOC_COS_SET_PROPS,
1056 ZFS_IOC_COS_GET_PROPS,
1057 ZFS_IOC_POOL_CONFIGS_NVL,
1058 ZFS_IOC_POOL_STATS_NVL,
1059 ZFS_IOC_OBJSET_STATS_NVL,
1060 ZFS_IOC_DATASET_LIST_NEXT_NVL,
1061 ZFS_IOC_SNAPSHOT_LIST_NEXT_NVL,
1062 ZFS_IOC_POOL_GET_PROPS_NVL,
1063 ZFS_IOC_CHECK_KRRP,
1064 ZFS_IOC_BULK_LIST,
1065 ZFS_IOC_POOL_TRIM,
1066 ZFS_IOC_CHANNEL_PROGRAM,
1067 ZFS_IOC_SET_PROPS_MDS,
1068 ZFS_IOC_LAST
1069 } zfs_ioc_t;
1070
1071 /*
1072 * Internal SPA load state. Used by FMA diagnosis engine.
1073 */
1074 typedef enum {
1075 SPA_LOAD_NONE, /* no load in progress */
1076 SPA_LOAD_OPEN, /* normal open */
1077 SPA_LOAD_IMPORT, /* import in progress */
1078 SPA_LOAD_TRYIMPORT, /* tryimport in progress */
1079 SPA_LOAD_RECOVER, /* recovery requested */
1080 SPA_LOAD_ERROR, /* load failed */
1081 SPA_LOAD_CREATE /* creation in progress */
1082 } spa_load_state_t;
1083
1084 /*
1085 * Bookmark name values.
1086 */
1087 #define ZPOOL_ERR_LIST "error list"
1088 #define ZPOOL_ERR_DATASET "dataset"
1089 #define ZPOOL_ERR_OBJECT "object"
1090
1091 #define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1)
1092
1093 /*
1094 * The following are names used in the nvlist describing
1095 * the pool's history log.
1096 */
1097 #define ZPOOL_HIST_RECORD "history record"
1098 #define ZPOOL_HIST_TIME "history time"
1099 #define ZPOOL_HIST_CMD "history command"
1100 #define ZPOOL_HIST_WHO "history who"
1101 #define ZPOOL_HIST_ZONE "history zone"
1102 #define ZPOOL_HIST_HOST "history hostname"
1103 #define ZPOOL_HIST_TXG "history txg"
1104 #define ZPOOL_HIST_INT_EVENT "history internal event"
1105 #define ZPOOL_HIST_INT_STR "history internal str"
1106 #define ZPOOL_HIST_INT_NAME "internal_name"
1107 #define ZPOOL_HIST_IOCTL "ioctl"
1108 #define ZPOOL_HIST_INPUT_NVL "in_nvl"
1109 #define ZPOOL_HIST_OUTPUT_NVL "out_nvl"
1110 #define ZPOOL_HIST_DSNAME "dsname"
1111 #define ZPOOL_HIST_DSID "dsid"
1112 #define ZPOOL_HIST_ERRNO "errno"
1113
1114 /*
1115 * Flags for ZFS_IOC_VDEV_SET_STATE
1116 */
1117 #define ZFS_ONLINE_CHECKREMOVE 0x1
1118 #define ZFS_ONLINE_UNSPARE 0x2
1119 #define ZFS_ONLINE_FORCEFAULT 0x4
1120 #define ZFS_ONLINE_EXPAND 0x8
1121 #define ZFS_OFFLINE_TEMPORARY 0x1
1122
1123 /*
1124 * Flags for ZFS_IOC_POOL_IMPORT
1125 */
1126 #define ZFS_IMPORT_NORMAL 0x0
1127 #define ZFS_IMPORT_VERBATIM 0x1
1128 #define ZFS_IMPORT_ANY_HOST 0x2
1129 #define ZFS_IMPORT_MISSING_LOG 0x4
1130 #define ZFS_IMPORT_ONLY 0x8
1131
1132 /*
1133 * Channel program argument/return nvlist keys and defaults.
1134 */
1135 #define ZCP_ARG_PROGRAM "program"
1136 #define ZCP_ARG_ARGLIST "arg"
1137 #define ZCP_ARG_SYNC "sync"
1138 #define ZCP_ARG_INSTRLIMIT "instrlimit"
1139 #define ZCP_ARG_MEMLIMIT "memlimit"
1140
1141 #define ZCP_ARG_CLIARGV "argv"
1142
1143 #define ZCP_RET_ERROR "error"
1144 #define ZCP_RET_RETURN "return"
1145
1146 #define ZCP_DEFAULT_INSTRLIMIT (10 * 1000 * 1000)
1147 #define ZCP_MAX_INSTRLIMIT (10 * ZCP_DEFAULT_INSTRLIMIT)
1148 #define ZCP_DEFAULT_MEMLIMIT (10 * 1024 * 1024)
1149 #define ZCP_MAX_MEMLIMIT (10 * ZCP_DEFAULT_MEMLIMIT)
1150
1151 /*
1152 * Sysevent payload members. ZFS will generate the following sysevents with the
1153 * given payloads:
1154 *
1155 * ESC_ZFS_RESILVER_START
1156 * ESC_ZFS_RESILVER_END
1157 * ESC_ZFS_POOL_DESTROY
1158 * ESC_ZFS_POOL_REGUID
1159 *
1160 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1161 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1162 *
1163 * ESC_ZFS_VDEV_REMOVE
1164 * ESC_ZFS_VDEV_CLEAR
1165 * ESC_ZFS_VDEV_CHECK
1166 *
1167 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1168 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1169 * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional)
1170 * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64
1171 *
1172 * ESC_ZFS_HISTORY_EVENT
1173 *
1174 * ZFS_EV_POOL_NAME DATA_TYPE_STRING
1175 * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
1176 * ZFS_EV_HIST_TIME DATA_TYPE_UINT64 (optional)
1177 * ZFS_EV_HIST_CMD DATA_TYPE_STRING (optional)
1178 * ZFS_EV_HIST_WHO DATA_TYPE_UINT64 (optional)
1179 * ZFS_EV_HIST_ZONE DATA_TYPE_STRING (optional)
1180 * ZFS_EV_HIST_HOST DATA_TYPE_STRING (optional)
1181 * ZFS_EV_HIST_TXG DATA_TYPE_UINT64 (optional)
1182 * ZFS_EV_HIST_INT_EVENT DATA_TYPE_UINT64 (optional)
1183 * ZFS_EV_HIST_INT_STR DATA_TYPE_STRING (optional)
1184 * ZFS_EV_HIST_INT_NAME DATA_TYPE_STRING (optional)
1185 * ZFS_EV_HIST_IOCTL DATA_TYPE_STRING (optional)
1186 * ZFS_EV_HIST_DSNAME DATA_TYPE_STRING (optional)
1187 * ZFS_EV_HIST_DSID DATA_TYPE_UINT64 (optional)
1188 *
1189 * The ZFS_EV_HIST_* members will correspond to the ZPOOL_HIST_* members in the
1190 * history log nvlist. The keynames will be free of any spaces or other
1191 * characters that could be potentially unexpected to consumers of the
1192 * sysevents.
1193 */
1194 #define ZFS_EV_POOL_NAME "pool_name"
1195 #define ZFS_EV_POOL_GUID "pool_guid"
1196 #define ZFS_EV_VDEV_PATH "vdev_path"
1197 #define ZFS_EV_VDEV_GUID "vdev_guid"
1198 #define ZFS_EV_HIST_TIME "history_time"
1199 #define ZFS_EV_HIST_CMD "history_command"
1200 #define ZFS_EV_HIST_WHO "history_who"
1201 #define ZFS_EV_HIST_ZONE "history_zone"
1202 #define ZFS_EV_HIST_HOST "history_hostname"
1203 #define ZFS_EV_HIST_TXG "history_txg"
1204 #define ZFS_EV_HIST_INT_EVENT "history_internal_event"
1205 #define ZFS_EV_HIST_INT_STR "history_internal_str"
1206 #define ZFS_EV_HIST_INT_NAME "history_internal_name"
1207 #define ZFS_EV_HIST_IOCTL "history_ioctl"
1208 #define ZFS_EV_HIST_DSNAME "history_dsname"
1209 #define ZFS_EV_HIST_DSID "history_dsid"
1210
1211 #ifdef __cplusplus
1212 }
1213 #endif
1214
1215 #endif /* _SYS_FS_ZFS_H */