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