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