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