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