]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
Merge ZFS feature flags support and related bugfixes:
[FreeBSD/stable/8.git] / sys / cddl / contrib / opensolaris / uts / common / 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) 2012 by Delphix. All rights reserved.
25  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
26  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
27  * Copyright (c) 2012, Martin Matuska <mm@FreeBSD.org>. All rights reserved.
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/types.h>
36 #include <sys/ioccom.h>
37 #include <sys/time.h>
38
39 #ifdef  __cplusplus
40 extern "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  */
51 typedef enum {
52         ZFS_TYPE_FILESYSTEM     = 0x1,
53         ZFS_TYPE_SNAPSHOT       = 0x2,
54         ZFS_TYPE_VOLUME         = 0x4,
55         ZFS_TYPE_POOL           = 0x8
56 } zfs_type_t;
57
58 #define ZFS_TYPE_DATASET        \
59         (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
60
61 #define ZAP_MAXNAMELEN 256
62 #define ZAP_MAXVALUELEN (1024 * 8)
63 #define ZAP_OLDMAXVALUELEN 1024
64
65 /*
66  * Dataset properties are identified by these constants and must be added to
67  * the end of this list to ensure that external consumers are not affected
68  * by the change. If you make any changes to this list, be sure to update
69  * the property table in usr/src/common/zfs/zfs_prop.c.
70  */
71 typedef enum {
72         ZFS_PROP_TYPE,
73         ZFS_PROP_CREATION,
74         ZFS_PROP_USED,
75         ZFS_PROP_AVAILABLE,
76         ZFS_PROP_REFERENCED,
77         ZFS_PROP_COMPRESSRATIO,
78         ZFS_PROP_MOUNTED,
79         ZFS_PROP_ORIGIN,
80         ZFS_PROP_QUOTA,
81         ZFS_PROP_RESERVATION,
82         ZFS_PROP_VOLSIZE,
83         ZFS_PROP_VOLBLOCKSIZE,
84         ZFS_PROP_RECORDSIZE,
85         ZFS_PROP_MOUNTPOINT,
86         ZFS_PROP_SHARENFS,
87         ZFS_PROP_CHECKSUM,
88         ZFS_PROP_COMPRESSION,
89         ZFS_PROP_ATIME,
90         ZFS_PROP_DEVICES,
91         ZFS_PROP_EXEC,
92         ZFS_PROP_SETUID,
93         ZFS_PROP_READONLY,
94         ZFS_PROP_ZONED,
95         ZFS_PROP_SNAPDIR,
96         ZFS_PROP_ACLMODE,
97         ZFS_PROP_ACLINHERIT,
98         ZFS_PROP_CREATETXG,             /* not exposed to the user */
99         ZFS_PROP_NAME,                  /* not exposed to the user */
100         ZFS_PROP_CANMOUNT,
101         ZFS_PROP_ISCSIOPTIONS,          /* not exposed to the user */
102         ZFS_PROP_XATTR,
103         ZFS_PROP_NUMCLONES,             /* not exposed to the user */
104         ZFS_PROP_COPIES,
105         ZFS_PROP_VERSION,
106         ZFS_PROP_UTF8ONLY,
107         ZFS_PROP_NORMALIZE,
108         ZFS_PROP_CASE,
109         ZFS_PROP_VSCAN,
110         ZFS_PROP_NBMAND,
111         ZFS_PROP_SHARESMB,
112         ZFS_PROP_REFQUOTA,
113         ZFS_PROP_REFRESERVATION,
114         ZFS_PROP_GUID,
115         ZFS_PROP_PRIMARYCACHE,
116         ZFS_PROP_SECONDARYCACHE,
117         ZFS_PROP_USEDSNAP,
118         ZFS_PROP_USEDDS,
119         ZFS_PROP_USEDCHILD,
120         ZFS_PROP_USEDREFRESERV,
121         ZFS_PROP_USERACCOUNTING,        /* not exposed to the user */
122         ZFS_PROP_STMF_SHAREINFO,        /* not exposed to the user */
123         ZFS_PROP_DEFER_DESTROY,
124         ZFS_PROP_USERREFS,
125         ZFS_PROP_LOGBIAS,
126         ZFS_PROP_UNIQUE,                /* not exposed to the user */
127         ZFS_PROP_OBJSETID,              /* not exposed to the user */
128         ZFS_PROP_DEDUP,
129         ZFS_PROP_MLSLABEL,
130         ZFS_PROP_SYNC,
131         ZFS_PROP_REFRATIO,
132         ZFS_PROP_WRITTEN,
133         ZFS_PROP_CLONES,
134         ZFS_NUM_PROPS
135 } zfs_prop_t;
136
137 typedef enum {
138         ZFS_PROP_USERUSED,
139         ZFS_PROP_USERQUOTA,
140         ZFS_PROP_GROUPUSED,
141         ZFS_PROP_GROUPQUOTA,
142         ZFS_NUM_USERQUOTA_PROPS
143 } zfs_userquota_prop_t;
144
145 extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
146
147 /*
148  * Pool properties are identified by these constants and must be added to the
149  * end of this list to ensure that external consumers are not affected
150  * by the change. If you make any changes to this list, be sure to update
151  * the property table in usr/src/common/zfs/zpool_prop.c.
152  */
153 typedef enum {
154         ZPOOL_PROP_NAME,
155         ZPOOL_PROP_SIZE,
156         ZPOOL_PROP_CAPACITY,
157         ZPOOL_PROP_ALTROOT,
158         ZPOOL_PROP_HEALTH,
159         ZPOOL_PROP_GUID,
160         ZPOOL_PROP_VERSION,
161         ZPOOL_PROP_BOOTFS,
162         ZPOOL_PROP_DELEGATION,
163         ZPOOL_PROP_AUTOREPLACE,
164         ZPOOL_PROP_CACHEFILE,
165         ZPOOL_PROP_FAILUREMODE,
166         ZPOOL_PROP_LISTSNAPS,
167         ZPOOL_PROP_AUTOEXPAND,
168         ZPOOL_PROP_DEDUPDITTO,
169         ZPOOL_PROP_DEDUPRATIO,
170         ZPOOL_PROP_FREE,
171         ZPOOL_PROP_ALLOCATED,
172         ZPOOL_PROP_READONLY,
173         ZPOOL_PROP_COMMENT,
174         ZPOOL_PROP_EXPANDSZ,
175         ZPOOL_PROP_FREEING,
176         ZPOOL_NUM_PROPS
177 } zpool_prop_t;
178
179 /* Small enough to not hog a whole line of printout in zpool(1M). */
180 #define ZPROP_MAX_COMMENT       32
181
182 #define ZPROP_CONT              -2
183 #define ZPROP_INVAL             -1
184
185 #define ZPROP_VALUE             "value"
186 #define ZPROP_SOURCE            "source"
187
188 typedef enum {
189         ZPROP_SRC_NONE = 0x1,
190         ZPROP_SRC_DEFAULT = 0x2,
191         ZPROP_SRC_TEMPORARY = 0x4,
192         ZPROP_SRC_LOCAL = 0x8,
193         ZPROP_SRC_INHERITED = 0x10,
194         ZPROP_SRC_RECEIVED = 0x20
195 } zprop_source_t;
196
197 #define ZPROP_SRC_ALL   0x3f
198
199 #define ZPROP_SOURCE_VAL_RECVD  "$recvd"
200 #define ZPROP_N_MORE_ERRORS     "N_MORE_ERRORS"
201 /*
202  * Dataset flag implemented as a special entry in the props zap object
203  * indicating that the dataset has received properties on or after
204  * SPA_VERSION_RECVD_PROPS. The first such receive blows away local properties
205  * just as it did in earlier versions, and thereafter, local properties are
206  * preserved.
207  */
208 #define ZPROP_HAS_RECVD         "$hasrecvd"
209
210 typedef enum {
211         ZPROP_ERR_NOCLEAR = 0x1, /* failure to clear existing props */
212         ZPROP_ERR_NORESTORE = 0x2 /* failure to restore props on error */
213 } zprop_errflags_t;
214
215 typedef int (*zprop_func)(int, void *);
216
217 /*
218  * Properties to be set on the root file system of a new pool
219  * are stuffed into their own nvlist, which is then included in
220  * the properties nvlist with the pool properties.
221  */
222 #define ZPOOL_ROOTFS_PROPS      "root-props-nvl"
223
224 /*
225  * Dataset property functions shared between libzfs and kernel.
226  */
227 const char *zfs_prop_default_string(zfs_prop_t);
228 uint64_t zfs_prop_default_numeric(zfs_prop_t);
229 boolean_t zfs_prop_readonly(zfs_prop_t);
230 boolean_t zfs_prop_inheritable(zfs_prop_t);
231 boolean_t zfs_prop_setonce(zfs_prop_t);
232 const char *zfs_prop_to_name(zfs_prop_t);
233 zfs_prop_t zfs_name_to_prop(const char *);
234 boolean_t zfs_prop_user(const char *);
235 boolean_t zfs_prop_userquota(const char *);
236 int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
237 int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
238 uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
239 boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
240
241 /*
242  * Pool property functions shared between libzfs and kernel.
243  */
244 zpool_prop_t zpool_name_to_prop(const char *);
245 const char *zpool_prop_to_name(zpool_prop_t);
246 const char *zpool_prop_default_string(zpool_prop_t);
247 uint64_t zpool_prop_default_numeric(zpool_prop_t);
248 boolean_t zpool_prop_readonly(zpool_prop_t);
249 boolean_t zpool_prop_feature(const char *);
250 boolean_t zpool_prop_unsupported(const char *name);
251 int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
252 int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
253 uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
254
255 /*
256  * Definitions for the Delegation.
257  */
258 typedef enum {
259         ZFS_DELEG_WHO_UNKNOWN = 0,
260         ZFS_DELEG_USER = 'u',
261         ZFS_DELEG_USER_SETS = 'U',
262         ZFS_DELEG_GROUP = 'g',
263         ZFS_DELEG_GROUP_SETS = 'G',
264         ZFS_DELEG_EVERYONE = 'e',
265         ZFS_DELEG_EVERYONE_SETS = 'E',
266         ZFS_DELEG_CREATE = 'c',
267         ZFS_DELEG_CREATE_SETS = 'C',
268         ZFS_DELEG_NAMED_SET = 's',
269         ZFS_DELEG_NAMED_SET_SETS = 'S'
270 } zfs_deleg_who_type_t;
271
272 typedef enum {
273         ZFS_DELEG_NONE = 0,
274         ZFS_DELEG_PERM_LOCAL = 1,
275         ZFS_DELEG_PERM_DESCENDENT = 2,
276         ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
277         ZFS_DELEG_PERM_CREATE = 4
278 } zfs_deleg_inherit_t;
279
280 #define ZFS_DELEG_PERM_UID      "uid"
281 #define ZFS_DELEG_PERM_GID      "gid"
282 #define ZFS_DELEG_PERM_GROUPS   "groups"
283
284 #define ZFS_MLSLABEL_DEFAULT    "none"
285
286 #define ZFS_SMB_ACL_SRC         "src"
287 #define ZFS_SMB_ACL_TARGET      "target"
288
289 typedef enum {
290         ZFS_CANMOUNT_OFF = 0,
291         ZFS_CANMOUNT_ON = 1,
292         ZFS_CANMOUNT_NOAUTO = 2
293 } zfs_canmount_type_t;
294
295 typedef enum {
296         ZFS_LOGBIAS_LATENCY = 0,
297         ZFS_LOGBIAS_THROUGHPUT = 1
298 } zfs_logbias_op_t;
299
300 typedef enum zfs_share_op {
301         ZFS_SHARE_NFS = 0,
302         ZFS_UNSHARE_NFS = 1,
303         ZFS_SHARE_SMB = 2,
304         ZFS_UNSHARE_SMB = 3
305 } zfs_share_op_t;
306
307 typedef enum zfs_smb_acl_op {
308         ZFS_SMB_ACL_ADD,
309         ZFS_SMB_ACL_REMOVE,
310         ZFS_SMB_ACL_RENAME,
311         ZFS_SMB_ACL_PURGE
312 } zfs_smb_acl_op_t;
313
314 typedef enum zfs_cache_type {
315         ZFS_CACHE_NONE = 0,
316         ZFS_CACHE_METADATA = 1,
317         ZFS_CACHE_ALL = 2
318 } zfs_cache_type_t;
319
320 typedef enum {
321         ZFS_SYNC_STANDARD = 0,
322         ZFS_SYNC_ALWAYS = 1,
323         ZFS_SYNC_DISABLED = 2
324 } zfs_sync_type_t;
325
326
327 /*
328  * On-disk version number.
329  */
330 #define SPA_VERSION_1                   1ULL
331 #define SPA_VERSION_2                   2ULL
332 #define SPA_VERSION_3                   3ULL
333 #define SPA_VERSION_4                   4ULL
334 #define SPA_VERSION_5                   5ULL
335 #define SPA_VERSION_6                   6ULL
336 #define SPA_VERSION_7                   7ULL
337 #define SPA_VERSION_8                   8ULL
338 #define SPA_VERSION_9                   9ULL
339 #define SPA_VERSION_10                  10ULL
340 #define SPA_VERSION_11                  11ULL
341 #define SPA_VERSION_12                  12ULL
342 #define SPA_VERSION_13                  13ULL
343 #define SPA_VERSION_14                  14ULL
344 #define SPA_VERSION_15                  15ULL
345 #define SPA_VERSION_16                  16ULL
346 #define SPA_VERSION_17                  17ULL
347 #define SPA_VERSION_18                  18ULL
348 #define SPA_VERSION_19                  19ULL
349 #define SPA_VERSION_20                  20ULL
350 #define SPA_VERSION_21                  21ULL
351 #define SPA_VERSION_22                  22ULL
352 #define SPA_VERSION_23                  23ULL
353 #define SPA_VERSION_24                  24ULL
354 #define SPA_VERSION_25                  25ULL
355 #define SPA_VERSION_26                  26ULL
356 #define SPA_VERSION_27                  27ULL
357 #define SPA_VERSION_28                  28ULL
358 #define SPA_VERSION_5000                5000ULL
359
360 /*
361  * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
362  * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
363  * and do the appropriate changes.  Also bump the version number in
364  * usr/src/grub/capability.
365  */
366 #define SPA_VERSION                     SPA_VERSION_5000
367 #define SPA_VERSION_STRING              "5000"
368
369 /*
370  * Symbolic names for the changes that caused a SPA_VERSION switch.
371  * Used in the code when checking for presence or absence of a feature.
372  * Feel free to define multiple symbolic names for each version if there
373  * were multiple changes to on-disk structures during that version.
374  *
375  * NOTE: When checking the current SPA_VERSION in your code, be sure
376  *       to use spa_version() since it reports the version of the
377  *       last synced uberblock.  Checking the in-flight version can
378  *       be dangerous in some cases.
379  */
380 #define SPA_VERSION_INITIAL             SPA_VERSION_1
381 #define SPA_VERSION_DITTO_BLOCKS        SPA_VERSION_2
382 #define SPA_VERSION_SPARES              SPA_VERSION_3
383 #define SPA_VERSION_RAIDZ2              SPA_VERSION_3
384 #define SPA_VERSION_BPOBJ_ACCOUNT       SPA_VERSION_3
385 #define SPA_VERSION_RAIDZ_DEFLATE       SPA_VERSION_3
386 #define SPA_VERSION_DNODE_BYTES         SPA_VERSION_3
387 #define SPA_VERSION_ZPOOL_HISTORY       SPA_VERSION_4
388 #define SPA_VERSION_GZIP_COMPRESSION    SPA_VERSION_5
389 #define SPA_VERSION_BOOTFS              SPA_VERSION_6
390 #define SPA_VERSION_SLOGS               SPA_VERSION_7
391 #define SPA_VERSION_DELEGATED_PERMS     SPA_VERSION_8
392 #define SPA_VERSION_FUID                SPA_VERSION_9
393 #define SPA_VERSION_REFRESERVATION      SPA_VERSION_9
394 #define SPA_VERSION_REFQUOTA            SPA_VERSION_9
395 #define SPA_VERSION_UNIQUE_ACCURATE     SPA_VERSION_9
396 #define SPA_VERSION_L2CACHE             SPA_VERSION_10
397 #define SPA_VERSION_NEXT_CLONES         SPA_VERSION_11
398 #define SPA_VERSION_ORIGIN              SPA_VERSION_11
399 #define SPA_VERSION_DSL_SCRUB           SPA_VERSION_11
400 #define SPA_VERSION_SNAP_PROPS          SPA_VERSION_12
401 #define SPA_VERSION_USED_BREAKDOWN      SPA_VERSION_13
402 #define SPA_VERSION_PASSTHROUGH_X       SPA_VERSION_14
403 #define SPA_VERSION_USERSPACE           SPA_VERSION_15
404 #define SPA_VERSION_STMF_PROP           SPA_VERSION_16
405 #define SPA_VERSION_RAIDZ3              SPA_VERSION_17
406 #define SPA_VERSION_USERREFS            SPA_VERSION_18
407 #define SPA_VERSION_HOLES               SPA_VERSION_19
408 #define SPA_VERSION_ZLE_COMPRESSION     SPA_VERSION_20
409 #define SPA_VERSION_DEDUP               SPA_VERSION_21
410 #define SPA_VERSION_RECVD_PROPS         SPA_VERSION_22
411 #define SPA_VERSION_SLIM_ZIL            SPA_VERSION_23
412 #define SPA_VERSION_SA                  SPA_VERSION_24
413 #define SPA_VERSION_SCAN                SPA_VERSION_25
414 #define SPA_VERSION_DIR_CLONES          SPA_VERSION_26
415 #define SPA_VERSION_DEADLISTS           SPA_VERSION_26
416 #define SPA_VERSION_FAST_SNAP           SPA_VERSION_27
417 #define SPA_VERSION_MULTI_REPLACE       SPA_VERSION_28
418 #define SPA_VERSION_BEFORE_FEATURES     SPA_VERSION_28
419 #define SPA_VERSION_FEATURES            SPA_VERSION_5000
420
421 #define SPA_VERSION_IS_SUPPORTED(v) \
422         (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
423         ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
424
425 /*
426  * ZPL version - rev'd whenever an incompatible on-disk format change
427  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
428  * also update the version_table[] and help message in zfs_prop.c.
429  *
430  * When changing, be sure to teach GRUB how to read the new format!
431  * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
432  */
433 #define ZPL_VERSION_1                   1ULL
434 #define ZPL_VERSION_2                   2ULL
435 #define ZPL_VERSION_3                   3ULL
436 #define ZPL_VERSION_4                   4ULL
437 #define ZPL_VERSION_5                   5ULL
438 #define ZPL_VERSION                     ZPL_VERSION_5
439 #define ZPL_VERSION_STRING              "5"
440
441 #define ZPL_VERSION_INITIAL             ZPL_VERSION_1
442 #define ZPL_VERSION_DIRENT_TYPE         ZPL_VERSION_2
443 #define ZPL_VERSION_FUID                ZPL_VERSION_3
444 #define ZPL_VERSION_NORMALIZATION       ZPL_VERSION_3
445 #define ZPL_VERSION_SYSATTR             ZPL_VERSION_3
446 #define ZPL_VERSION_USERSPACE           ZPL_VERSION_4
447 #define ZPL_VERSION_SA                  ZPL_VERSION_5
448
449 /* Rewind request information */
450 #define ZPOOL_NO_REWIND         1  /* No policy - default behavior */
451 #define ZPOOL_NEVER_REWIND      2  /* Do not search for best txg or rewind */
452 #define ZPOOL_TRY_REWIND        4  /* Search for best txg, but do not rewind */
453 #define ZPOOL_DO_REWIND         8  /* Rewind to best txg w/in deferred frees */
454 #define ZPOOL_EXTREME_REWIND    16 /* Allow extreme measures to find best txg */
455 #define ZPOOL_REWIND_MASK       28 /* All the possible rewind bits */
456 #define ZPOOL_REWIND_POLICIES   31 /* All the possible policy bits */
457
458 typedef struct zpool_rewind_policy {
459         uint32_t        zrp_request;    /* rewind behavior requested */
460         uint64_t        zrp_maxmeta;    /* max acceptable meta-data errors */
461         uint64_t        zrp_maxdata;    /* max acceptable data errors */
462         uint64_t        zrp_txg;        /* specific txg to load */
463 } zpool_rewind_policy_t;
464
465 /*
466  * The following are configuration names used in the nvlist describing a pool's
467  * configuration.
468  */
469 #define ZPOOL_CONFIG_VERSION            "version"
470 #define ZPOOL_CONFIG_POOL_NAME          "name"
471 #define ZPOOL_CONFIG_POOL_STATE         "state"
472 #define ZPOOL_CONFIG_POOL_TXG           "txg"
473 #define ZPOOL_CONFIG_POOL_GUID          "pool_guid"
474 #define ZPOOL_CONFIG_CREATE_TXG         "create_txg"
475 #define ZPOOL_CONFIG_TOP_GUID           "top_guid"
476 #define ZPOOL_CONFIG_VDEV_TREE          "vdev_tree"
477 #define ZPOOL_CONFIG_TYPE               "type"
478 #define ZPOOL_CONFIG_CHILDREN           "children"
479 #define ZPOOL_CONFIG_ID                 "id"
480 #define ZPOOL_CONFIG_GUID               "guid"
481 #define ZPOOL_CONFIG_PATH               "path"
482 #define ZPOOL_CONFIG_DEVID              "devid"
483 #define ZPOOL_CONFIG_METASLAB_ARRAY     "metaslab_array"
484 #define ZPOOL_CONFIG_METASLAB_SHIFT     "metaslab_shift"
485 #define ZPOOL_CONFIG_ASHIFT             "ashift"
486 #define ZPOOL_CONFIG_ASIZE              "asize"
487 #define ZPOOL_CONFIG_DTL                "DTL"
488 #define ZPOOL_CONFIG_SCAN_STATS         "scan_stats"    /* not stored on disk */
489 #define ZPOOL_CONFIG_VDEV_STATS         "vdev_stats"    /* not stored on disk */
490 #define ZPOOL_CONFIG_WHOLE_DISK         "whole_disk"
491 #define ZPOOL_CONFIG_ERRCOUNT           "error_count"
492 #define ZPOOL_CONFIG_NOT_PRESENT        "not_present"
493 #define ZPOOL_CONFIG_SPARES             "spares"
494 #define ZPOOL_CONFIG_IS_SPARE           "is_spare"
495 #define ZPOOL_CONFIG_NPARITY            "nparity"
496 #define ZPOOL_CONFIG_HOSTID             "hostid"
497 #define ZPOOL_CONFIG_HOSTNAME           "hostname"
498 #define ZPOOL_CONFIG_LOADED_TIME        "initial_load_time"
499 #define ZPOOL_CONFIG_UNSPARE            "unspare"
500 #define ZPOOL_CONFIG_PHYS_PATH          "phys_path"
501 #define ZPOOL_CONFIG_IS_LOG             "is_log"
502 #define ZPOOL_CONFIG_L2CACHE            "l2cache"
503 #define ZPOOL_CONFIG_HOLE_ARRAY         "hole_array"
504 #define ZPOOL_CONFIG_VDEV_CHILDREN      "vdev_children"
505 #define ZPOOL_CONFIG_IS_HOLE            "is_hole"
506 #define ZPOOL_CONFIG_DDT_HISTOGRAM      "ddt_histogram"
507 #define ZPOOL_CONFIG_DDT_OBJ_STATS      "ddt_object_stats"
508 #define ZPOOL_CONFIG_DDT_STATS          "ddt_stats"
509 #define ZPOOL_CONFIG_SPLIT              "splitcfg"
510 #define ZPOOL_CONFIG_ORIG_GUID          "orig_guid"
511 #define ZPOOL_CONFIG_SPLIT_GUID         "split_guid"
512 #define ZPOOL_CONFIG_SPLIT_LIST         "guid_list"
513 #define ZPOOL_CONFIG_REMOVING           "removing"
514 #define ZPOOL_CONFIG_RESILVERING        "resilvering"
515 #define ZPOOL_CONFIG_COMMENT            "comment"
516 #define ZPOOL_CONFIG_SUSPENDED          "suspended"     /* not stored on disk */
517 #define ZPOOL_CONFIG_TIMESTAMP          "timestamp"     /* not stored on disk */
518 #define ZPOOL_CONFIG_BOOTFS             "bootfs"        /* not stored on disk */
519 #define ZPOOL_CONFIG_MISSING_DEVICES    "missing_vdevs" /* not stored on disk */
520 #define ZPOOL_CONFIG_LOAD_INFO          "load_info"     /* not stored on disk */
521 #define ZPOOL_CONFIG_REWIND_INFO        "rewind_info"   /* not stored on disk */
522 #define ZPOOL_CONFIG_UNSUP_FEAT         "unsup_feat"    /* not stored on disk */
523 #define ZPOOL_CONFIG_ENABLED_FEAT       "enabled_feat"  /* not stored on disk */
524 #define ZPOOL_CONFIG_CAN_RDONLY         "can_rdonly"    /* not stored on disk */
525 #define ZPOOL_CONFIG_FEATURES_FOR_READ  "features_for_read"
526 #define ZPOOL_CONFIG_FEATURE_STATS      "feature_stats" /* not stored on disk */
527 /*
528  * The persistent vdev state is stored as separate values rather than a single
529  * 'vdev_state' entry.  This is because a device can be in multiple states, such
530  * as offline and degraded.
531  */
532 #define ZPOOL_CONFIG_OFFLINE            "offline"
533 #define ZPOOL_CONFIG_FAULTED            "faulted"
534 #define ZPOOL_CONFIG_DEGRADED           "degraded"
535 #define ZPOOL_CONFIG_REMOVED            "removed"
536 #define ZPOOL_CONFIG_FRU                "fru"
537 #define ZPOOL_CONFIG_AUX_STATE          "aux_state"
538
539 /* Rewind policy parameters */
540 #define ZPOOL_REWIND_POLICY             "rewind-policy"
541 #define ZPOOL_REWIND_REQUEST            "rewind-request"
542 #define ZPOOL_REWIND_REQUEST_TXG        "rewind-request-txg"
543 #define ZPOOL_REWIND_META_THRESH        "rewind-meta-thresh"
544 #define ZPOOL_REWIND_DATA_THRESH        "rewind-data-thresh"
545
546 /* Rewind data discovered */
547 #define ZPOOL_CONFIG_LOAD_TIME          "rewind_txg_ts"
548 #define ZPOOL_CONFIG_LOAD_DATA_ERRORS   "verify_data_errors"
549 #define ZPOOL_CONFIG_REWIND_TIME        "seconds_of_rewind"
550
551 #define VDEV_TYPE_ROOT                  "root"
552 #define VDEV_TYPE_MIRROR                "mirror"
553 #define VDEV_TYPE_REPLACING             "replacing"
554 #define VDEV_TYPE_RAIDZ                 "raidz"
555 #define VDEV_TYPE_DISK                  "disk"
556 #define VDEV_TYPE_FILE                  "file"
557 #define VDEV_TYPE_MISSING               "missing"
558 #define VDEV_TYPE_HOLE                  "hole"
559 #define VDEV_TYPE_SPARE                 "spare"
560 #define VDEV_TYPE_LOG                   "log"
561 #define VDEV_TYPE_L2CACHE               "l2cache"
562
563 /*
564  * This is needed in userland to report the minimum necessary device size.
565  */
566 #define SPA_MINDEVSIZE          (64ULL << 20)
567
568 /*
569  * The location of the pool configuration repository, shared between kernel and
570  * userland.
571  */
572 #define ZPOOL_CACHE             "/boot/zfs/zpool.cache"
573
574 /*
575  * vdev states are ordered from least to most healthy.
576  * A vdev that's CANT_OPEN or below is considered unusable.
577  */
578 typedef enum vdev_state {
579         VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev                   */
580         VDEV_STATE_CLOSED,      /* Not currently open                   */
581         VDEV_STATE_OFFLINE,     /* Not allowed to open                  */
582         VDEV_STATE_REMOVED,     /* Explicitly removed from system       */
583         VDEV_STATE_CANT_OPEN,   /* Tried to open, but failed            */
584         VDEV_STATE_FAULTED,     /* External request to fault device     */
585         VDEV_STATE_DEGRADED,    /* Replicated vdev with unhealthy kids  */
586         VDEV_STATE_HEALTHY      /* Presumed good                        */
587 } vdev_state_t;
588
589 #define VDEV_STATE_ONLINE       VDEV_STATE_HEALTHY
590
591 /*
592  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
593  * of the vdev stats structure uses these constants to distinguish why.
594  */
595 typedef enum vdev_aux {
596         VDEV_AUX_NONE,          /* no error                             */
597         VDEV_AUX_OPEN_FAILED,   /* ldi_open_*() or vn_open() failed     */
598         VDEV_AUX_CORRUPT_DATA,  /* bad label or disk contents           */
599         VDEV_AUX_NO_REPLICAS,   /* insufficient number of replicas      */
600         VDEV_AUX_BAD_GUID_SUM,  /* vdev guid sum doesn't match          */
601         VDEV_AUX_TOO_SMALL,     /* vdev size is too small               */
602         VDEV_AUX_BAD_LABEL,     /* the label is OK but invalid          */
603         VDEV_AUX_VERSION_NEWER, /* on-disk version is too new           */
604         VDEV_AUX_VERSION_OLDER, /* on-disk version is too old           */
605         VDEV_AUX_UNSUP_FEAT,    /* unsupported features                 */
606         VDEV_AUX_SPARED,        /* hot spare used in another pool       */
607         VDEV_AUX_ERR_EXCEEDED,  /* too many errors                      */
608         VDEV_AUX_IO_FAILURE,    /* experienced I/O failure              */
609         VDEV_AUX_BAD_LOG,       /* cannot read log chain(s)             */
610         VDEV_AUX_EXTERNAL,      /* external diagnosis                   */
611         VDEV_AUX_SPLIT_POOL     /* vdev was split off into another pool */
612 } vdev_aux_t;
613
614 /*
615  * pool state.  The following states are written to disk as part of the normal
616  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
617  * states are software abstractions used at various levels to communicate
618  * pool state.
619  */
620 typedef enum pool_state {
621         POOL_STATE_ACTIVE = 0,          /* In active use                */
622         POOL_STATE_EXPORTED,            /* Explicitly exported          */
623         POOL_STATE_DESTROYED,           /* Explicitly destroyed         */
624         POOL_STATE_SPARE,               /* Reserved for hot spare use   */
625         POOL_STATE_L2CACHE,             /* Level 2 ARC device           */
626         POOL_STATE_UNINITIALIZED,       /* Internal spa_t state         */
627         POOL_STATE_UNAVAIL,             /* Internal libzfs state        */
628         POOL_STATE_POTENTIALLY_ACTIVE   /* Internal libzfs state        */
629 } pool_state_t;
630
631 /*
632  * Scan Functions.
633  */
634 typedef enum pool_scan_func {
635         POOL_SCAN_NONE,
636         POOL_SCAN_SCRUB,
637         POOL_SCAN_RESILVER,
638         POOL_SCAN_FUNCS
639 } pool_scan_func_t;
640
641 /*
642  * ZIO types.  Needed to interpret vdev statistics below.
643  */
644 typedef enum zio_type {
645         ZIO_TYPE_NULL = 0,
646         ZIO_TYPE_READ,
647         ZIO_TYPE_WRITE,
648         ZIO_TYPE_FREE,
649         ZIO_TYPE_CLAIM,
650         ZIO_TYPE_IOCTL,
651         ZIO_TYPES
652 } zio_type_t;
653
654 /*
655  * Pool statistics.  Note: all fields should be 64-bit because this
656  * is passed between kernel and userland as an nvlist uint64 array.
657  */
658 typedef struct pool_scan_stat {
659         /* values stored on disk */
660         uint64_t        pss_func;       /* pool_scan_func_t */
661         uint64_t        pss_state;      /* dsl_scan_state_t */
662         uint64_t        pss_start_time; /* scan start time */
663         uint64_t        pss_end_time;   /* scan end time */
664         uint64_t        pss_to_examine; /* total bytes to scan */
665         uint64_t        pss_examined;   /* total examined bytes */
666         uint64_t        pss_to_process; /* total bytes to process */
667         uint64_t        pss_processed;  /* total processed bytes */
668         uint64_t        pss_errors;     /* scan errors  */
669
670         /* values not stored on disk */
671         uint64_t        pss_pass_exam;  /* examined bytes per scan pass */
672         uint64_t        pss_pass_start; /* start time of a scan pass */
673 } pool_scan_stat_t;
674
675 typedef enum dsl_scan_state {
676         DSS_NONE,
677         DSS_SCANNING,
678         DSS_FINISHED,
679         DSS_CANCELED,
680         DSS_NUM_STATES
681 } dsl_scan_state_t;
682
683
684 /*
685  * Vdev statistics.  Note: all fields should be 64-bit because this
686  * is passed between kernel and userland as an nvlist uint64 array.
687  */
688 typedef struct vdev_stat {
689         hrtime_t        vs_timestamp;           /* time since vdev load */
690         uint64_t        vs_state;               /* vdev state           */
691         uint64_t        vs_aux;                 /* see vdev_aux_t       */
692         uint64_t        vs_alloc;               /* space allocated      */
693         uint64_t        vs_space;               /* total capacity       */
694         uint64_t        vs_dspace;              /* deflated capacity    */
695         uint64_t        vs_rsize;               /* replaceable dev size */
696         uint64_t        vs_esize;               /* expandable dev size */
697         uint64_t        vs_ops[ZIO_TYPES];      /* operation count      */
698         uint64_t        vs_bytes[ZIO_TYPES];    /* bytes read/written   */
699         uint64_t        vs_read_errors;         /* read errors          */
700         uint64_t        vs_write_errors;        /* write errors         */
701         uint64_t        vs_checksum_errors;     /* checksum errors      */
702         uint64_t        vs_self_healed;         /* self-healed bytes    */
703         uint64_t        vs_scan_removing;       /* removing?    */
704         uint64_t        vs_scan_processed;      /* scan processed bytes */
705 } vdev_stat_t;
706
707 /*
708  * DDT statistics.  Note: all fields should be 64-bit because this
709  * is passed between kernel and userland as an nvlist uint64 array.
710  */
711 typedef struct ddt_object {
712         uint64_t        ddo_count;      /* number of elments in ddt     */
713         uint64_t        ddo_dspace;     /* size of ddt on disk          */
714         uint64_t        ddo_mspace;     /* size of ddt in-core          */
715 } ddt_object_t;
716
717 typedef struct ddt_stat {
718         uint64_t        dds_blocks;     /* blocks                       */
719         uint64_t        dds_lsize;      /* logical size                 */
720         uint64_t        dds_psize;      /* physical size                */
721         uint64_t        dds_dsize;      /* deflated allocated size      */
722         uint64_t        dds_ref_blocks; /* referenced blocks            */
723         uint64_t        dds_ref_lsize;  /* referenced lsize * refcnt    */
724         uint64_t        dds_ref_psize;  /* referenced psize * refcnt    */
725         uint64_t        dds_ref_dsize;  /* referenced dsize * refcnt    */
726 } ddt_stat_t;
727
728 typedef struct ddt_histogram {
729         ddt_stat_t      ddh_stat[64];   /* power-of-two histogram buckets */
730 } ddt_histogram_t;
731
732 #define ZVOL_DRIVER     "zvol"
733 #define ZFS_DRIVER      "zfs"
734 #define ZFS_DEV_NAME    "zfs"
735 #define ZFS_DEV         "/dev/" ZFS_DEV_NAME
736
737 /* general zvol path */
738 #define ZVOL_DIR                "/dev/zvol"
739 /* expansion */
740 #define ZVOL_PSEUDO_DEV         "/devices/pseudo/zfs@0:"
741 /* for dump and swap */
742 #define ZVOL_FULL_DEV_DIR       ZVOL_DIR "/dsk/"
743 #define ZVOL_FULL_RDEV_DIR      ZVOL_DIR "/rdsk/"
744
745 #define ZVOL_PROP_NAME          "name"
746 #define ZVOL_DEFAULT_BLOCKSIZE  8192
747
748 /*
749  * /dev/zfs ioctl numbers.
750  */
751 typedef unsigned long   zfs_ioc_t;
752
753 #define ZFS_IOC(ioreq)  ((ioreq) & 0xff)
754
755 #define ZFS_IOC_POOL_CREATE             _IOWR('Z', 0, struct zfs_cmd)
756 #define ZFS_IOC_POOL_DESTROY            _IOWR('Z', 1, struct zfs_cmd)
757 #define ZFS_IOC_POOL_IMPORT             _IOWR('Z', 2, struct zfs_cmd)
758 #define ZFS_IOC_POOL_EXPORT             _IOWR('Z', 3, struct zfs_cmd)
759 #define ZFS_IOC_POOL_CONFIGS            _IOWR('Z', 4, struct zfs_cmd)
760 #define ZFS_IOC_POOL_STATS              _IOWR('Z', 5, struct zfs_cmd)
761 #define ZFS_IOC_POOL_TRYIMPORT          _IOWR('Z', 6, struct zfs_cmd)
762 #define ZFS_IOC_POOL_SCAN               _IOWR('Z', 7, struct zfs_cmd)
763 #define ZFS_IOC_POOL_FREEZE             _IOWR('Z', 8, struct zfs_cmd)
764 #define ZFS_IOC_POOL_UPGRADE            _IOWR('Z', 9, struct zfs_cmd)
765 #define ZFS_IOC_POOL_GET_HISTORY        _IOWR('Z', 10, struct zfs_cmd)
766 #define ZFS_IOC_VDEV_ADD                _IOWR('Z', 11, struct zfs_cmd)
767 #define ZFS_IOC_VDEV_REMOVE             _IOWR('Z', 12, struct zfs_cmd)
768 #define ZFS_IOC_VDEV_SET_STATE          _IOWR('Z', 13, struct zfs_cmd)
769 #define ZFS_IOC_VDEV_ATTACH             _IOWR('Z', 14, struct zfs_cmd)
770 #define ZFS_IOC_VDEV_DETACH             _IOWR('Z', 15, struct zfs_cmd)
771 #define ZFS_IOC_VDEV_SETPATH            _IOWR('Z', 16, struct zfs_cmd)
772 #define ZFS_IOC_VDEV_SETFRU             _IOWR('Z', 17, struct zfs_cmd)
773 #define ZFS_IOC_OBJSET_STATS            _IOWR('Z', 18, struct zfs_cmd)
774 #define ZFS_IOC_OBJSET_ZPLPROPS         _IOWR('Z', 19, struct zfs_cmd)
775 #define ZFS_IOC_DATASET_LIST_NEXT       _IOWR('Z', 20, struct zfs_cmd)
776 #define ZFS_IOC_SNAPSHOT_LIST_NEXT      _IOWR('Z', 21, struct zfs_cmd)
777 #define ZFS_IOC_SET_PROP                _IOWR('Z', 22, struct zfs_cmd)
778 #define ZFS_IOC_CREATE                  _IOWR('Z', 23, struct zfs_cmd)
779 #define ZFS_IOC_DESTROY                 _IOWR('Z', 24, struct zfs_cmd)
780 #define ZFS_IOC_ROLLBACK                _IOWR('Z', 25, struct zfs_cmd)
781 #define ZFS_IOC_RENAME                  _IOWR('Z', 26, struct zfs_cmd)
782 #define ZFS_IOC_RECV                    _IOWR('Z', 27, struct zfs_cmd)
783 #define ZFS_IOC_SEND                    _IOWR('Z', 28, struct zfs_cmd)
784 #define ZFS_IOC_INJECT_FAULT            _IOWR('Z', 29, struct zfs_cmd)
785 #define ZFS_IOC_CLEAR_FAULT             _IOWR('Z', 30, struct zfs_cmd)
786 #define ZFS_IOC_INJECT_LIST_NEXT        _IOWR('Z', 31, struct zfs_cmd)
787 #define ZFS_IOC_ERROR_LOG               _IOWR('Z', 32, struct zfs_cmd)
788 #define ZFS_IOC_CLEAR                   _IOWR('Z', 33, struct zfs_cmd)
789 #define ZFS_IOC_PROMOTE                 _IOWR('Z', 34, struct zfs_cmd)
790 #define ZFS_IOC_DESTROY_SNAPS_NVL       _IOWR('Z', 35, struct zfs_cmd)
791 #define ZFS_IOC_SNAPSHOT                _IOWR('Z', 36, struct zfs_cmd)
792 #define ZFS_IOC_DSOBJ_TO_DSNAME         _IOWR('Z', 37, struct zfs_cmd)
793 #define ZFS_IOC_OBJ_TO_PATH             _IOWR('Z', 38, struct zfs_cmd)
794 #define ZFS_IOC_POOL_SET_PROPS          _IOWR('Z', 39, struct zfs_cmd)
795 #define ZFS_IOC_POOL_GET_PROPS          _IOWR('Z', 40, struct zfs_cmd)
796 #define ZFS_IOC_SET_FSACL               _IOWR('Z', 41, struct zfs_cmd)
797 #define ZFS_IOC_GET_FSACL               _IOWR('Z', 42, struct zfs_cmd)
798 #define ZFS_IOC_SHARE                   _IOWR('Z', 43, struct zfs_cmd)
799 #define ZFS_IOC_INHERIT_PROP            _IOWR('Z', 44, struct zfs_cmd)
800 #define ZFS_IOC_SMB_ACL                 _IOWR('Z', 45, struct zfs_cmd)
801 #define ZFS_IOC_USERSPACE_ONE           _IOWR('Z', 46, struct zfs_cmd)
802 #define ZFS_IOC_USERSPACE_MANY          _IOWR('Z', 47, struct zfs_cmd)
803 #define ZFS_IOC_USERSPACE_UPGRADE       _IOWR('Z', 48, struct zfs_cmd)
804 #define ZFS_IOC_HOLD                    _IOWR('Z', 49, struct zfs_cmd)
805 #define ZFS_IOC_RELEASE                 _IOWR('Z', 50, struct zfs_cmd)
806 #define ZFS_IOC_GET_HOLDS               _IOWR('Z', 51, struct zfs_cmd)
807 #define ZFS_IOC_OBJSET_RECVD_PROPS      _IOWR('Z', 52, struct zfs_cmd)
808 #define ZFS_IOC_VDEV_SPLIT              _IOWR('Z', 53, struct zfs_cmd)
809 #define ZFS_IOC_NEXT_OBJ                _IOWR('Z', 54, struct zfs_cmd)
810 #define ZFS_IOC_DIFF                    _IOWR('Z', 55, struct zfs_cmd)
811 #define ZFS_IOC_TMP_SNAPSHOT            _IOWR('Z', 56, struct zfs_cmd)
812 #define ZFS_IOC_OBJ_TO_STATS            _IOWR('Z', 57, struct zfs_cmd)
813 #define ZFS_IOC_JAIL                    _IOWR('Z', 58, struct zfs_cmd)
814 #define ZFS_IOC_UNJAIL                  _IOWR('Z', 59, struct zfs_cmd)
815 #define ZFS_IOC_POOL_REGUID             _IOWR('Z', 60, struct zfs_cmd)
816 #define ZFS_IOC_SPACE_WRITTEN           _IOWR('Z', 61, struct zfs_cmd)
817 #define ZFS_IOC_SPACE_SNAPS             _IOWR('Z', 62, struct zfs_cmd)
818 #define ZFS_IOC_SEND_PROGRESS           _IOWR('Z', 63, struct zfs_cmd)
819 #define ZFS_IOC_POOL_REOPEN             _IOWR('Z', 64, struct zfs_cmd)
820
821 /*
822  * Internal SPA load state.  Used by FMA diagnosis engine.
823  */
824 typedef enum {
825         SPA_LOAD_NONE,          /* no load in progress  */
826         SPA_LOAD_OPEN,          /* normal open          */
827         SPA_LOAD_IMPORT,        /* import in progress   */
828         SPA_LOAD_TRYIMPORT,     /* tryimport in progress */
829         SPA_LOAD_RECOVER,       /* recovery requested   */
830         SPA_LOAD_ERROR          /* load failed          */
831 } spa_load_state_t;
832
833 /*
834  * Bookmark name values.
835  */
836 #define ZPOOL_ERR_LIST          "error list"
837 #define ZPOOL_ERR_DATASET       "dataset"
838 #define ZPOOL_ERR_OBJECT        "object"
839
840 #define HIS_MAX_RECORD_LEN      (MAXPATHLEN + MAXPATHLEN + 1)
841
842 /*
843  * The following are names used in the nvlist describing
844  * the pool's history log.
845  */
846 #define ZPOOL_HIST_RECORD       "history record"
847 #define ZPOOL_HIST_TIME         "history time"
848 #define ZPOOL_HIST_CMD          "history command"
849 #define ZPOOL_HIST_WHO          "history who"
850 #define ZPOOL_HIST_ZONE         "history zone"
851 #define ZPOOL_HIST_HOST         "history hostname"
852 #define ZPOOL_HIST_TXG          "history txg"
853 #define ZPOOL_HIST_INT_EVENT    "history internal event"
854 #define ZPOOL_HIST_INT_STR      "history internal str"
855
856 /*
857  * Flags for ZFS_IOC_VDEV_SET_STATE
858  */
859 #define ZFS_ONLINE_CHECKREMOVE  0x1
860 #define ZFS_ONLINE_UNSPARE      0x2
861 #define ZFS_ONLINE_FORCEFAULT   0x4
862 #define ZFS_ONLINE_EXPAND       0x8
863 #define ZFS_OFFLINE_TEMPORARY   0x1
864
865 /*
866  * Flags for ZFS_IOC_POOL_IMPORT
867  */
868 #define ZFS_IMPORT_NORMAL       0x0
869 #define ZFS_IMPORT_VERBATIM     0x1
870 #define ZFS_IMPORT_ANY_HOST     0x2
871 #define ZFS_IMPORT_MISSING_LOG  0x4
872 #define ZFS_IMPORT_ONLY         0x8
873
874 /*
875  * Sysevent payload members.  ZFS will generate the following sysevents with the
876  * given payloads:
877  *
878  *      ESC_ZFS_RESILVER_START
879  *      ESC_ZFS_RESILVER_END
880  *      ESC_ZFS_POOL_DESTROY
881  *      ESC_ZFS_POOL_REGUID
882  *
883  *              ZFS_EV_POOL_NAME        DATA_TYPE_STRING
884  *              ZFS_EV_POOL_GUID        DATA_TYPE_UINT64
885  *
886  *      ESC_ZFS_VDEV_REMOVE
887  *      ESC_ZFS_VDEV_CLEAR
888  *      ESC_ZFS_VDEV_CHECK
889  *
890  *              ZFS_EV_POOL_NAME        DATA_TYPE_STRING
891  *              ZFS_EV_POOL_GUID        DATA_TYPE_UINT64
892  *              ZFS_EV_VDEV_PATH        DATA_TYPE_STRING        (optional)
893  *              ZFS_EV_VDEV_GUID        DATA_TYPE_UINT64
894  */
895 #define ZFS_EV_POOL_NAME        "pool_name"
896 #define ZFS_EV_POOL_GUID        "pool_guid"
897 #define ZFS_EV_VDEV_PATH        "vdev_path"
898 #define ZFS_EV_VDEV_GUID        "vdev_guid"
899
900 /*
901  * Note: This is encoded on-disk, so new events must be added to the
902  * end, and unused events can not be removed.  Be sure to edit
903  * libzfs_pool.c: hist_event_table[].
904  */
905 typedef enum history_internal_events {
906         LOG_NO_EVENT = 0,
907         LOG_POOL_CREATE,
908         LOG_POOL_VDEV_ADD,
909         LOG_POOL_REMOVE,
910         LOG_POOL_DESTROY,
911         LOG_POOL_EXPORT,
912         LOG_POOL_IMPORT,
913         LOG_POOL_VDEV_ATTACH,
914         LOG_POOL_VDEV_REPLACE,
915         LOG_POOL_VDEV_DETACH,
916         LOG_POOL_VDEV_ONLINE,
917         LOG_POOL_VDEV_OFFLINE,
918         LOG_POOL_UPGRADE,
919         LOG_POOL_CLEAR,
920         LOG_POOL_SCAN,
921         LOG_POOL_PROPSET,
922         LOG_DS_CREATE,
923         LOG_DS_CLONE,
924         LOG_DS_DESTROY,
925         LOG_DS_DESTROY_BEGIN,
926         LOG_DS_INHERIT,
927         LOG_DS_PROPSET,
928         LOG_DS_QUOTA,
929         LOG_DS_PERM_UPDATE,
930         LOG_DS_PERM_REMOVE,
931         LOG_DS_PERM_WHO_REMOVE,
932         LOG_DS_PROMOTE,
933         LOG_DS_RECEIVE,
934         LOG_DS_RENAME,
935         LOG_DS_RESERVATION,
936         LOG_DS_REPLAY_INC_SYNC,
937         LOG_DS_REPLAY_FULL_SYNC,
938         LOG_DS_ROLLBACK,
939         LOG_DS_SNAPSHOT,
940         LOG_DS_UPGRADE,
941         LOG_DS_REFQUOTA,
942         LOG_DS_REFRESERV,
943         LOG_POOL_SCAN_DONE,
944         LOG_DS_USER_HOLD,
945         LOG_DS_USER_RELEASE,
946         LOG_POOL_SPLIT,
947         LOG_END
948 } history_internal_events_t;
949
950 #ifdef  __cplusplus
951 }
952 #endif
953
954 #endif  /* _SYS_FS_ZFS_H */