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