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