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