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