]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
MFC r209962, r211970-r211972, r212050, r212605, r212611
[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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25
26 #ifndef _SYS_FS_ZFS_H
27 #define _SYS_FS_ZFS_H
28
29 #include <sys/types.h>
30 #include <sys/ioccom.h>
31 #include <sys/time.h>
32
33 #ifdef  __cplusplus
34 extern "C" {
35 #endif
36
37 /*
38  * Types and constants shared between userland and the kernel.
39  */
40
41 /*
42  * Each dataset can be one of the following types.  These constants can be
43  * combined into masks that can be passed to various functions.
44  */
45 typedef enum {
46         ZFS_TYPE_FILESYSTEM     = 0x1,
47         ZFS_TYPE_SNAPSHOT       = 0x2,
48         ZFS_TYPE_VOLUME         = 0x4,
49         ZFS_TYPE_POOL           = 0x8
50 } zfs_type_t;
51
52 #define ZFS_TYPE_DATASET        \
53         (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
54
55 /*
56  * Dataset properties are identified by these constants and must be added to
57  * the end of this list to ensure that external consumers are not affected
58  * by the change. If you make any changes to this list, be sure to update
59  * the property table in usr/src/common/zfs/zfs_prop.c.
60  */
61 typedef enum {
62         ZFS_PROP_TYPE,
63         ZFS_PROP_CREATION,
64         ZFS_PROP_USED,
65         ZFS_PROP_AVAILABLE,
66         ZFS_PROP_REFERENCED,
67         ZFS_PROP_COMPRESSRATIO,
68         ZFS_PROP_MOUNTED,
69         ZFS_PROP_ORIGIN,
70         ZFS_PROP_QUOTA,
71         ZFS_PROP_RESERVATION,
72         ZFS_PROP_VOLSIZE,
73         ZFS_PROP_VOLBLOCKSIZE,
74         ZFS_PROP_RECORDSIZE,
75         ZFS_PROP_MOUNTPOINT,
76         ZFS_PROP_SHARENFS,
77         ZFS_PROP_CHECKSUM,
78         ZFS_PROP_COMPRESSION,
79         ZFS_PROP_ATIME,
80         ZFS_PROP_DEVICES,
81         ZFS_PROP_EXEC,
82         ZFS_PROP_SETUID,
83         ZFS_PROP_READONLY,
84         ZFS_PROP_ZONED,
85         ZFS_PROP_SNAPDIR,
86         ZFS_PROP_ACLMODE,
87         ZFS_PROP_ACLINHERIT,
88         ZFS_PROP_CREATETXG,             /* not exposed to the user */
89         ZFS_PROP_NAME,                  /* not exposed to the user */
90         ZFS_PROP_CANMOUNT,
91         ZFS_PROP_SHAREISCSI,
92         ZFS_PROP_ISCSIOPTIONS,          /* not exposed to the user */
93         ZFS_PROP_XATTR,
94         ZFS_PROP_NUMCLONES,             /* not exposed to the user */
95         ZFS_PROP_COPIES,
96         ZFS_PROP_VERSION,
97         ZFS_PROP_UTF8ONLY,
98         ZFS_PROP_NORMALIZE,
99         ZFS_PROP_CASE,
100         ZFS_PROP_VSCAN,
101         ZFS_PROP_NBMAND,
102         ZFS_PROP_SHARESMB,
103         ZFS_PROP_REFQUOTA,
104         ZFS_PROP_REFRESERVATION,
105         ZFS_PROP_GUID,
106         ZFS_PROP_PRIMARYCACHE,
107         ZFS_PROP_SECONDARYCACHE,
108         ZFS_PROP_USEDSNAP,
109         ZFS_PROP_USEDDS,
110         ZFS_PROP_USEDCHILD,
111         ZFS_PROP_USEDREFRESERV,
112         ZFS_PROP_USERACCOUNTING,        /* not exposed to the user */
113         ZFS_NUM_PROPS
114 } zfs_prop_t;
115
116 typedef enum {
117         ZFS_PROP_USERUSED,
118         ZFS_PROP_USERQUOTA,
119         ZFS_PROP_GROUPUSED,
120         ZFS_PROP_GROUPQUOTA,
121         ZFS_NUM_USERQUOTA_PROPS
122 } zfs_userquota_prop_t;
123
124 extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
125
126 /*
127  * Pool properties are identified by these constants and must be added to the
128  * end of this list to ensure that external consumers are not affected
129  * by the change. If you make any changes to this list, be sure to update
130  * the property table in usr/src/common/zfs/zpool_prop.c.
131  */
132 typedef enum {
133         ZPOOL_PROP_NAME,
134         ZPOOL_PROP_SIZE,
135         ZPOOL_PROP_USED,
136         ZPOOL_PROP_AVAILABLE,
137         ZPOOL_PROP_CAPACITY,
138         ZPOOL_PROP_ALTROOT,
139         ZPOOL_PROP_HEALTH,
140         ZPOOL_PROP_GUID,
141         ZPOOL_PROP_VERSION,
142         ZPOOL_PROP_BOOTFS,
143         ZPOOL_PROP_DELEGATION,
144         ZPOOL_PROP_AUTOREPLACE,
145         ZPOOL_PROP_CACHEFILE,
146         ZPOOL_PROP_FAILUREMODE,
147         ZPOOL_PROP_LISTSNAPS,
148         ZPOOL_NUM_PROPS
149 } zpool_prop_t;
150
151 #define ZPROP_CONT              -2
152 #define ZPROP_INVAL             -1
153
154 #define ZPROP_VALUE             "value"
155 #define ZPROP_SOURCE            "source"
156
157 typedef enum {
158         ZPROP_SRC_NONE = 0x1,
159         ZPROP_SRC_DEFAULT = 0x2,
160         ZPROP_SRC_TEMPORARY = 0x4,
161         ZPROP_SRC_LOCAL = 0x8,
162         ZPROP_SRC_INHERITED = 0x10
163 } zprop_source_t;
164
165 #define ZPROP_SRC_ALL   0x1f
166
167 typedef int (*zprop_func)(int, void *);
168
169 /*
170  * Properties to be set on the root file system of a new pool
171  * are stuffed into their own nvlist, which is then included in
172  * the properties nvlist with the pool properties.
173  */
174 #define ZPOOL_ROOTFS_PROPS      "root-props-nvl"
175
176 /*
177  * Dataset property functions shared between libzfs and kernel.
178  */
179 const char *zfs_prop_default_string(zfs_prop_t);
180 uint64_t zfs_prop_default_numeric(zfs_prop_t);
181 boolean_t zfs_prop_readonly(zfs_prop_t);
182 boolean_t zfs_prop_inheritable(zfs_prop_t);
183 boolean_t zfs_prop_setonce(zfs_prop_t);
184 const char *zfs_prop_to_name(zfs_prop_t);
185 zfs_prop_t zfs_name_to_prop(const char *);
186 boolean_t zfs_prop_user(const char *);
187 boolean_t zfs_prop_userquota(const char *name);
188 int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
189 int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
190 boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
191
192 /*
193  * Pool property functions shared between libzfs and kernel.
194  */
195 zpool_prop_t zpool_name_to_prop(const char *);
196 const char *zpool_prop_to_name(zpool_prop_t);
197 const char *zpool_prop_default_string(zpool_prop_t);
198 uint64_t zpool_prop_default_numeric(zpool_prop_t);
199 boolean_t zpool_prop_readonly(zpool_prop_t);
200 int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
201 int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
202
203 /*
204  * Definitions for the Delegation.
205  */
206 typedef enum {
207         ZFS_DELEG_WHO_UNKNOWN = 0,
208         ZFS_DELEG_USER = 'u',
209         ZFS_DELEG_USER_SETS = 'U',
210         ZFS_DELEG_GROUP = 'g',
211         ZFS_DELEG_GROUP_SETS = 'G',
212         ZFS_DELEG_EVERYONE = 'e',
213         ZFS_DELEG_EVERYONE_SETS = 'E',
214         ZFS_DELEG_CREATE = 'c',
215         ZFS_DELEG_CREATE_SETS = 'C',
216         ZFS_DELEG_NAMED_SET = 's',
217         ZFS_DELEG_NAMED_SET_SETS = 'S'
218 } zfs_deleg_who_type_t;
219
220 typedef enum {
221         ZFS_DELEG_NONE = 0,
222         ZFS_DELEG_PERM_LOCAL = 1,
223         ZFS_DELEG_PERM_DESCENDENT = 2,
224         ZFS_DELEG_PERM_LOCALDESCENDENT = 3,
225         ZFS_DELEG_PERM_CREATE = 4
226 } zfs_deleg_inherit_t;
227
228 #define ZFS_DELEG_PERM_UID      "uid"
229 #define ZFS_DELEG_PERM_GID      "gid"
230 #define ZFS_DELEG_PERM_GROUPS   "groups"
231
232 #define ZFS_SMB_ACL_SRC         "src"
233 #define ZFS_SMB_ACL_TARGET      "target"
234
235 typedef enum {
236         ZFS_CANMOUNT_OFF = 0,
237         ZFS_CANMOUNT_ON = 1,
238         ZFS_CANMOUNT_NOAUTO = 2
239 } zfs_canmount_type_t;
240
241 typedef enum zfs_share_op {
242         ZFS_SHARE_NFS = 0,
243         ZFS_UNSHARE_NFS = 1,
244         ZFS_SHARE_SMB = 2,
245         ZFS_UNSHARE_SMB = 3
246 } zfs_share_op_t;
247
248 typedef enum zfs_smb_acl_op {
249         ZFS_SMB_ACL_ADD,
250         ZFS_SMB_ACL_REMOVE,
251         ZFS_SMB_ACL_RENAME,
252         ZFS_SMB_ACL_PURGE
253 } zfs_smb_acl_op_t;
254
255 typedef enum zfs_cache_type {
256         ZFS_CACHE_NONE = 0,
257         ZFS_CACHE_METADATA = 1,
258         ZFS_CACHE_ALL = 2
259 } zfs_cache_type_t;
260
261
262 /*
263  * On-disk version number.
264  */
265 #define SPA_VERSION_1                   1ULL
266 #define SPA_VERSION_2                   2ULL
267 #define SPA_VERSION_3                   3ULL
268 #define SPA_VERSION_4                   4ULL
269 #define SPA_VERSION_5                   5ULL
270 #define SPA_VERSION_6                   6ULL
271 #define SPA_VERSION_7                   7ULL
272 #define SPA_VERSION_8                   8ULL
273 #define SPA_VERSION_9                   9ULL
274 #define SPA_VERSION_10                  10ULL
275 #define SPA_VERSION_11                  11ULL
276 #define SPA_VERSION_12                  12ULL
277 #define SPA_VERSION_13                  13ULL
278 #define SPA_VERSION_14                  14ULL
279 #define SPA_VERSION_15                  15ULL
280 /*
281  * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
282  * format change. Go to usr/src/grub/grub-0.95/stage2/{zfs-include/, fsys_zfs*},
283  * and do the appropriate changes.  Also bump the version number in
284  * usr/src/grub/capability.
285  */
286 #define SPA_VERSION                     SPA_VERSION_15
287 #define SPA_VERSION_STRING              "15"
288
289 /*
290  * Symbolic names for the changes that caused a SPA_VERSION switch.
291  * Used in the code when checking for presence or absence of a feature.
292  * Feel free to define multiple symbolic names for each version if there
293  * were multiple changes to on-disk structures during that version.
294  *
295  * NOTE: When checking the current SPA_VERSION in your code, be sure
296  *       to use spa_version() since it reports the version of the
297  *       last synced uberblock.  Checking the in-flight version can
298  *       be dangerous in some cases.
299  */
300 #define SPA_VERSION_INITIAL             SPA_VERSION_1
301 #define SPA_VERSION_DITTO_BLOCKS        SPA_VERSION_2
302 #define SPA_VERSION_SPARES              SPA_VERSION_3
303 #define SPA_VERSION_RAID6               SPA_VERSION_3
304 #define SPA_VERSION_BPLIST_ACCOUNT      SPA_VERSION_3
305 #define SPA_VERSION_RAIDZ_DEFLATE       SPA_VERSION_3
306 #define SPA_VERSION_DNODE_BYTES         SPA_VERSION_3
307 #define SPA_VERSION_ZPOOL_HISTORY       SPA_VERSION_4
308 #define SPA_VERSION_GZIP_COMPRESSION    SPA_VERSION_5
309 #define SPA_VERSION_BOOTFS              SPA_VERSION_6
310 #define SPA_VERSION_SLOGS               SPA_VERSION_7
311 #define SPA_VERSION_DELEGATED_PERMS     SPA_VERSION_8
312 #define SPA_VERSION_FUID                SPA_VERSION_9
313 #define SPA_VERSION_REFRESERVATION      SPA_VERSION_9
314 #define SPA_VERSION_REFQUOTA            SPA_VERSION_9
315 #define SPA_VERSION_UNIQUE_ACCURATE     SPA_VERSION_9
316 #define SPA_VERSION_L2CACHE             SPA_VERSION_10
317 #define SPA_VERSION_NEXT_CLONES         SPA_VERSION_11
318 #define SPA_VERSION_ORIGIN              SPA_VERSION_11
319 #define SPA_VERSION_DSL_SCRUB           SPA_VERSION_11
320 #define SPA_VERSION_SNAP_PROPS          SPA_VERSION_12
321 #define SPA_VERSION_USED_BREAKDOWN      SPA_VERSION_13
322 #define SPA_VERSION_PASSTHROUGH_X       SPA_VERSION_14
323 #define SPA_VERSION_USERSPACE           SPA_VERSION_15
324
325 /*
326  * ZPL version - rev'd whenever an incompatible on-disk format change
327  * occurs.  This is independent of SPA/DMU/ZAP versioning.  You must
328  * also update the version_table[] and help message in zfs_prop.c.
329  *
330  * When changing, be sure to teach GRUB how to read the new format!
331  * See usr/src/grub/grub-0.95/stage2/{zfs-include/,fsys_zfs*}
332  */
333 #define ZPL_VERSION_1                   1ULL
334 #define ZPL_VERSION_2                   2ULL
335 #define ZPL_VERSION_3                   3ULL
336 #define ZPL_VERSION_4                   4ULL
337 #define ZPL_VERSION                     ZPL_VERSION_4
338 #define ZPL_VERSION_STRING              "4"
339
340 #define ZPL_VERSION_INITIAL             ZPL_VERSION_1
341 #define ZPL_VERSION_DIRENT_TYPE         ZPL_VERSION_2
342 #define ZPL_VERSION_FUID                ZPL_VERSION_3
343 #define ZPL_VERSION_NORMALIZATION       ZPL_VERSION_3
344 #define ZPL_VERSION_SYSATTR             ZPL_VERSION_3
345 #define ZPL_VERSION_USERSPACE           ZPL_VERSION_4
346
347 /*
348  * The following are configuration names used in the nvlist describing a pool's
349  * configuration.
350  */
351 #define ZPOOL_CONFIG_VERSION            "version"
352 #define ZPOOL_CONFIG_POOL_NAME          "name"
353 #define ZPOOL_CONFIG_POOL_STATE         "state"
354 #define ZPOOL_CONFIG_POOL_TXG           "txg"
355 #define ZPOOL_CONFIG_POOL_GUID          "pool_guid"
356 #define ZPOOL_CONFIG_CREATE_TXG         "create_txg"
357 #define ZPOOL_CONFIG_TOP_GUID           "top_guid"
358 #define ZPOOL_CONFIG_VDEV_TREE          "vdev_tree"
359 #define ZPOOL_CONFIG_TYPE               "type"
360 #define ZPOOL_CONFIG_CHILDREN           "children"
361 #define ZPOOL_CONFIG_ID                 "id"
362 #define ZPOOL_CONFIG_GUID               "guid"
363 #define ZPOOL_CONFIG_PATH               "path"
364 #define ZPOOL_CONFIG_DEVID              "devid"
365 #define ZPOOL_CONFIG_METASLAB_ARRAY     "metaslab_array"
366 #define ZPOOL_CONFIG_METASLAB_SHIFT     "metaslab_shift"
367 #define ZPOOL_CONFIG_ASHIFT             "ashift"
368 #define ZPOOL_CONFIG_ASIZE              "asize"
369 #define ZPOOL_CONFIG_DTL                "DTL"
370 #define ZPOOL_CONFIG_STATS              "stats"
371 #define ZPOOL_CONFIG_WHOLE_DISK         "whole_disk"
372 #define ZPOOL_CONFIG_ERRCOUNT           "error_count"
373 #define ZPOOL_CONFIG_NOT_PRESENT        "not_present"
374 #define ZPOOL_CONFIG_SPARES             "spares"
375 #define ZPOOL_CONFIG_IS_SPARE           "is_spare"
376 #define ZPOOL_CONFIG_NPARITY            "nparity"
377 #define ZPOOL_CONFIG_HOSTID             "hostid"
378 #define ZPOOL_CONFIG_HOSTNAME           "hostname"
379 #define ZPOOL_CONFIG_UNSPARE            "unspare"
380 #define ZPOOL_CONFIG_PHYS_PATH          "phys_path"
381 #define ZPOOL_CONFIG_IS_LOG             "is_log"
382 #define ZPOOL_CONFIG_L2CACHE            "l2cache"
383 #define ZPOOL_CONFIG_SUSPENDED          "suspended"     /* not stored on disk */
384 #define ZPOOL_CONFIG_TIMESTAMP          "timestamp"     /* not stored on disk */
385 #define ZPOOL_CONFIG_BOOTFS             "bootfs"        /* not stored on disk */
386 /*
387  * The persistent vdev state is stored as separate values rather than a single
388  * 'vdev_state' entry.  This is because a device can be in multiple states, such
389  * as offline and degraded.
390  */
391 #define ZPOOL_CONFIG_OFFLINE            "offline"
392 #define ZPOOL_CONFIG_FAULTED            "faulted"
393 #define ZPOOL_CONFIG_DEGRADED           "degraded"
394 #define ZPOOL_CONFIG_REMOVED            "removed"
395 #define ZPOOL_CONFIG_FRU                "fru"
396
397 #define VDEV_TYPE_ROOT                  "root"
398 #define VDEV_TYPE_MIRROR                "mirror"
399 #define VDEV_TYPE_REPLACING             "replacing"
400 #define VDEV_TYPE_RAIDZ                 "raidz"
401 #define VDEV_TYPE_DISK                  "disk"
402 #define VDEV_TYPE_FILE                  "file"
403 #define VDEV_TYPE_MISSING               "missing"
404 #define VDEV_TYPE_SPARE                 "spare"
405 #define VDEV_TYPE_LOG                   "log"
406 #define VDEV_TYPE_L2CACHE               "l2cache"
407
408 /*
409  * This is needed in userland to report the minimum necessary device size.
410  */
411 #define SPA_MINDEVSIZE          (64ULL << 20)
412
413 /*
414  * The location of the pool configuration repository, shared between kernel and
415  * userland.
416  */
417 #define ZPOOL_CACHE             "/boot/zfs/zpool.cache"
418
419 /*
420  * vdev states are ordered from least to most healthy.
421  * A vdev that's CANT_OPEN or below is considered unusable.
422  */
423 typedef enum vdev_state {
424         VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev                   */
425         VDEV_STATE_CLOSED,      /* Not currently open                   */
426         VDEV_STATE_OFFLINE,     /* Not allowed to open                  */
427         VDEV_STATE_REMOVED,     /* Explicitly removed from system       */
428         VDEV_STATE_CANT_OPEN,   /* Tried to open, but failed            */
429         VDEV_STATE_FAULTED,     /* External request to fault device     */
430         VDEV_STATE_DEGRADED,    /* Replicated vdev with unhealthy kids  */
431         VDEV_STATE_HEALTHY      /* Presumed good                        */
432 } vdev_state_t;
433
434 #define VDEV_STATE_ONLINE       VDEV_STATE_HEALTHY
435
436 /*
437  * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
438  * of the vdev stats structure uses these constants to distinguish why.
439  */
440 typedef enum vdev_aux {
441         VDEV_AUX_NONE,          /* no error                             */
442         VDEV_AUX_OPEN_FAILED,   /* ldi_open_*() or vn_open() failed     */
443         VDEV_AUX_CORRUPT_DATA,  /* bad label or disk contents           */
444         VDEV_AUX_NO_REPLICAS,   /* insufficient number of replicas      */
445         VDEV_AUX_BAD_GUID_SUM,  /* vdev guid sum doesn't match          */
446         VDEV_AUX_TOO_SMALL,     /* vdev size is too small               */
447         VDEV_AUX_BAD_LABEL,     /* the label is OK but invalid          */
448         VDEV_AUX_VERSION_NEWER, /* on-disk version is too new           */
449         VDEV_AUX_VERSION_OLDER, /* on-disk version is too old           */
450         VDEV_AUX_SPARED,        /* hot spare used in another pool       */
451         VDEV_AUX_ERR_EXCEEDED,  /* too many errors                      */
452         VDEV_AUX_IO_FAILURE,    /* experienced I/O failure              */
453         VDEV_AUX_BAD_LOG        /* cannot read log chain(s)             */
454 } vdev_aux_t;
455
456 /*
457  * pool state.  The following states are written to disk as part of the normal
458  * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
459  * states are software abstractions used at various levels to communicate
460  * pool state.
461  */
462 typedef enum pool_state {
463         POOL_STATE_ACTIVE = 0,          /* In active use                */
464         POOL_STATE_EXPORTED,            /* Explicitly exported          */
465         POOL_STATE_DESTROYED,           /* Explicitly destroyed         */
466         POOL_STATE_SPARE,               /* Reserved for hot spare use   */
467         POOL_STATE_L2CACHE,             /* Level 2 ARC device           */
468         POOL_STATE_UNINITIALIZED,       /* Internal spa_t state         */
469         POOL_STATE_UNAVAIL,             /* Internal libzfs state        */
470         POOL_STATE_POTENTIALLY_ACTIVE   /* Internal libzfs state        */
471 } pool_state_t;
472
473 /*
474  * Scrub types.
475  */
476 typedef enum pool_scrub_type {
477         POOL_SCRUB_NONE,
478         POOL_SCRUB_RESILVER,
479         POOL_SCRUB_EVERYTHING,
480         POOL_SCRUB_TYPES
481 } pool_scrub_type_t;
482
483 /*
484  * ZIO types.  Needed to interpret vdev statistics below.
485  */
486 typedef enum zio_type {
487         ZIO_TYPE_NULL = 0,
488         ZIO_TYPE_READ,
489         ZIO_TYPE_WRITE,
490         ZIO_TYPE_FREE,
491         ZIO_TYPE_CLAIM,
492         ZIO_TYPE_IOCTL,
493         ZIO_TYPES
494 } zio_type_t;
495
496 /*
497  * Vdev statistics.  Note: all fields should be 64-bit because this
498  * is passed between kernel and userland as an nvlist uint64 array.
499  */
500 typedef struct vdev_stat {
501         hrtime_t        vs_timestamp;           /* time since vdev load */
502         uint64_t        vs_state;               /* vdev state           */
503         uint64_t        vs_aux;                 /* see vdev_aux_t       */
504         uint64_t        vs_alloc;               /* space allocated      */
505         uint64_t        vs_space;               /* total capacity       */
506         uint64_t        vs_dspace;              /* deflated capacity    */
507         uint64_t        vs_rsize;               /* replaceable dev size */
508         uint64_t        vs_ops[ZIO_TYPES];      /* operation count      */
509         uint64_t        vs_bytes[ZIO_TYPES];    /* bytes read/written   */
510         uint64_t        vs_read_errors;         /* read errors          */
511         uint64_t        vs_write_errors;        /* write errors         */
512         uint64_t        vs_checksum_errors;     /* checksum errors      */
513         uint64_t        vs_self_healed;         /* self-healed bytes    */
514         uint64_t        vs_scrub_type;          /* pool_scrub_type_t    */
515         uint64_t        vs_scrub_complete;      /* completed?           */
516         uint64_t        vs_scrub_examined;      /* bytes examined; top  */
517         uint64_t        vs_scrub_repaired;      /* bytes repaired; leaf */
518         uint64_t        vs_scrub_errors;        /* errors during scrub  */
519         uint64_t        vs_scrub_start;         /* UTC scrub start time */
520         uint64_t        vs_scrub_end;           /* UTC scrub end time   */
521 } vdev_stat_t;
522
523 #define ZVOL_DRIVER     "zvol"
524 #define ZFS_DRIVER      "zfs"
525 #define ZFS_DEV_NAME    "zfs"
526 #define ZFS_DEV         "/dev/" ZFS_DEV_NAME
527
528 /*
529  * zvol paths.  Irritatingly, the devfsadm interfaces want all these
530  * paths without the /dev prefix, but for some things, we want the
531  * /dev prefix.  Below are the names without /dev.
532  */
533 #define ZVOL_DEV_DIR    "zvol"
534
535 /*
536  * And here are the things we need with /dev, etc. in front of them.
537  */
538 #define ZVOL_PSEUDO_DEV         "/devices/pseudo/zvol@0:"
539 #define ZVOL_FULL_DEV_DIR       "/dev/" ZVOL_DEV_DIR "/"
540
541 #define ZVOL_PROP_NAME          "name"
542
543 /*
544  * /dev/zfs ioctl numbers.
545  */
546 typedef unsigned long   zfs_ioc_t;
547
548 #define ZFS_IOC(ioreq)  ((ioreq) & 0xff)
549
550 #define ZFS_IOC_POOL_CREATE             _IOWR('Z', 0, struct zfs_cmd)
551 #define ZFS_IOC_POOL_DESTROY            _IOWR('Z', 1, struct zfs_cmd)
552 #define ZFS_IOC_POOL_IMPORT             _IOWR('Z', 2, struct zfs_cmd)
553 #define ZFS_IOC_POOL_EXPORT             _IOWR('Z', 3, struct zfs_cmd)
554 #define ZFS_IOC_POOL_CONFIGS            _IOWR('Z', 4, struct zfs_cmd)
555 #define ZFS_IOC_POOL_STATS              _IOWR('Z', 5, struct zfs_cmd)
556 #define ZFS_IOC_POOL_TRYIMPORT          _IOWR('Z', 6, struct zfs_cmd)
557 #define ZFS_IOC_POOL_SCRUB              _IOWR('Z', 7, struct zfs_cmd)
558 #define ZFS_IOC_POOL_FREEZE             _IOWR('Z', 8, struct zfs_cmd)
559 #define ZFS_IOC_POOL_UPGRADE            _IOWR('Z', 9, struct zfs_cmd)
560 #define ZFS_IOC_POOL_GET_HISTORY        _IOWR('Z', 10, struct zfs_cmd)
561 #define ZFS_IOC_VDEV_ADD                _IOWR('Z', 11, struct zfs_cmd)
562 #define ZFS_IOC_VDEV_REMOVE             _IOWR('Z', 12, struct zfs_cmd)
563 #define ZFS_IOC_VDEV_SET_STATE          _IOWR('Z', 13, struct zfs_cmd)
564 #define ZFS_IOC_VDEV_ATTACH             _IOWR('Z', 14, struct zfs_cmd)
565 #define ZFS_IOC_VDEV_DETACH             _IOWR('Z', 15, struct zfs_cmd)
566 #define ZFS_IOC_VDEV_SETPATH            _IOWR('Z', 16, struct zfs_cmd)
567 #define ZFS_IOC_OBJSET_STATS            _IOWR('Z', 17, struct zfs_cmd)
568 #define ZFS_IOC_OBJSET_ZPLPROPS         _IOWR('Z', 18, struct zfs_cmd)
569 #define ZFS_IOC_DATASET_LIST_NEXT       _IOWR('Z', 19, struct zfs_cmd)
570 #define ZFS_IOC_SNAPSHOT_LIST_NEXT      _IOWR('Z', 20, struct zfs_cmd)
571 #define ZFS_IOC_SET_PROP                _IOWR('Z', 21, struct zfs_cmd)
572 #define ZFS_IOC_CREATE_MINOR            _IOWR('Z', 22, struct zfs_cmd)
573 #define ZFS_IOC_REMOVE_MINOR            _IOWR('Z', 23, struct zfs_cmd)
574 #define ZFS_IOC_CREATE                  _IOWR('Z', 24, struct zfs_cmd)
575 #define ZFS_IOC_DESTROY                 _IOWR('Z', 25, struct zfs_cmd)
576 #define ZFS_IOC_ROLLBACK                _IOWR('Z', 26, struct zfs_cmd)
577 #define ZFS_IOC_RENAME                  _IOWR('Z', 27, struct zfs_cmd)
578 #define ZFS_IOC_RECV                    _IOWR('Z', 28, struct zfs_cmd)
579 #define ZFS_IOC_SEND                    _IOWR('Z', 29, struct zfs_cmd)
580 #define ZFS_IOC_INJECT_FAULT            _IOWR('Z', 30, struct zfs_cmd)
581 #define ZFS_IOC_CLEAR_FAULT             _IOWR('Z', 31, struct zfs_cmd)
582 #define ZFS_IOC_INJECT_LIST_NEXT        _IOWR('Z', 32, struct zfs_cmd)
583 #define ZFS_IOC_ERROR_LOG               _IOWR('Z', 33, struct zfs_cmd)
584 #define ZFS_IOC_CLEAR                   _IOWR('Z', 34, struct zfs_cmd)
585 #define ZFS_IOC_PROMOTE                 _IOWR('Z', 35, struct zfs_cmd)
586 #define ZFS_IOC_DESTROY_SNAPS           _IOWR('Z', 36, struct zfs_cmd)
587 #define ZFS_IOC_SNAPSHOT                _IOWR('Z', 37, struct zfs_cmd)
588 #define ZFS_IOC_DSOBJ_TO_DSNAME         _IOWR('Z', 38, struct zfs_cmd)
589 #define ZFS_IOC_OBJ_TO_PATH             _IOWR('Z', 39, struct zfs_cmd)
590 #define ZFS_IOC_POOL_SET_PROPS          _IOWR('Z', 40, struct zfs_cmd)
591 #define ZFS_IOC_POOL_GET_PROPS          _IOWR('Z', 41, struct zfs_cmd)
592 #define ZFS_IOC_SET_FSACL               _IOWR('Z', 42, struct zfs_cmd)
593 #define ZFS_IOC_GET_FSACL               _IOWR('Z', 43, struct zfs_cmd)
594 #define ZFS_IOC_ISCSI_PERM_CHECK        _IOWR('Z', 44, struct zfs_cmd)
595 #define ZFS_IOC_SHARE                   _IOWR('Z', 45, struct zfs_cmd)
596 #define ZFS_IOC_INHERIT_PROP            _IOWR('Z', 46, struct zfs_cmd)
597 #define ZFS_IOC_JAIL                    _IOWR('Z', 47, struct zfs_cmd)
598 #define ZFS_IOC_UNJAIL                  _IOWR('Z', 48, struct zfs_cmd)
599 #define ZFS_IOC_SMB_ACL                 _IOWR('Z', 49, struct zfs_cmd)
600 #define ZFS_IOC_USERSPACE_ONE           _IOWR('Z', 50, struct zfs_cmd)
601 #define ZFS_IOC_USERSPACE_MANY          _IOWR('Z', 51, struct zfs_cmd)
602 #define ZFS_IOC_USERSPACE_UPGRADE       _IOWR('Z', 52, struct zfs_cmd)
603 #define ZFS_IOC_SETFRU                  _IOWR('Z', 53, struct zfs_cmd)
604
605 /*
606  * Internal SPA load state.  Used by FMA diagnosis engine.
607  */
608 typedef enum {
609         SPA_LOAD_NONE,          /* no load in progress */
610         SPA_LOAD_OPEN,          /* normal open */
611         SPA_LOAD_IMPORT,        /* import in progress */
612         SPA_LOAD_TRYIMPORT      /* tryimport in progress */
613 } spa_load_state_t;
614
615 /*
616  * Bookmark name values.
617  */
618 #define ZPOOL_ERR_LIST          "error list"
619 #define ZPOOL_ERR_DATASET       "dataset"
620 #define ZPOOL_ERR_OBJECT        "object"
621
622 #define HIS_MAX_RECORD_LEN      (MAXPATHLEN + MAXPATHLEN + 1)
623
624 /*
625  * The following are names used in the nvlist describing
626  * the pool's history log.
627  */
628 #define ZPOOL_HIST_RECORD       "history record"
629 #define ZPOOL_HIST_TIME         "history time"
630 #define ZPOOL_HIST_CMD          "history command"
631 #define ZPOOL_HIST_WHO          "history who"
632 #define ZPOOL_HIST_ZONE         "history zone"
633 #define ZPOOL_HIST_HOST         "history hostname"
634 #define ZPOOL_HIST_TXG          "history txg"
635 #define ZPOOL_HIST_INT_EVENT    "history internal event"
636 #define ZPOOL_HIST_INT_STR      "history internal str"
637
638 /*
639  * Flags for ZFS_IOC_VDEV_SET_STATE
640  */
641 #define ZFS_ONLINE_CHECKREMOVE  0x1
642 #define ZFS_ONLINE_UNSPARE      0x2
643 #define ZFS_ONLINE_FORCEFAULT   0x4
644 #define ZFS_OFFLINE_TEMPORARY   0x1
645
646 /*
647  * Sysevent payload members.  ZFS will generate the following sysevents with the
648  * given payloads:
649  *
650  *      ESC_ZFS_RESILVER_START
651  *      ESC_ZFS_RESILVER_END
652  *      ESC_ZFS_POOL_DESTROY
653  *
654  *              ZFS_EV_POOL_NAME        DATA_TYPE_STRING
655  *              ZFS_EV_POOL_GUID        DATA_TYPE_UINT64
656  *
657  *      ESC_ZFS_VDEV_REMOVE
658  *      ESC_ZFS_VDEV_CLEAR
659  *      ESC_ZFS_VDEV_CHECK
660  *
661  *              ZFS_EV_POOL_NAME        DATA_TYPE_STRING
662  *              ZFS_EV_POOL_GUID        DATA_TYPE_UINT64
663  *              ZFS_EV_VDEV_PATH        DATA_TYPE_STRING        (optional)
664  *              ZFS_EV_VDEV_GUID        DATA_TYPE_UINT64
665  */
666 #define ZFS_EV_POOL_NAME        "pool_name"
667 #define ZFS_EV_POOL_GUID        "pool_guid"
668 #define ZFS_EV_VDEV_PATH        "vdev_path"
669 #define ZFS_EV_VDEV_GUID        "vdev_guid"
670
671 /*
672  * Note: This is encoded on-disk, so new events must be added to the
673  * end, and unused events can not be removed.  Be sure to edit
674  * zpool_main.c: hist_event_table[].
675  */
676 typedef enum history_internal_events {
677         LOG_NO_EVENT = 0,
678         LOG_POOL_CREATE,
679         LOG_POOL_VDEV_ADD,
680         LOG_POOL_REMOVE,
681         LOG_POOL_DESTROY,
682         LOG_POOL_EXPORT,
683         LOG_POOL_IMPORT,
684         LOG_POOL_VDEV_ATTACH,
685         LOG_POOL_VDEV_REPLACE,
686         LOG_POOL_VDEV_DETACH,
687         LOG_POOL_VDEV_ONLINE,
688         LOG_POOL_VDEV_OFFLINE,
689         LOG_POOL_UPGRADE,
690         LOG_POOL_CLEAR,
691         LOG_POOL_SCRUB,
692         LOG_POOL_PROPSET,
693         LOG_DS_CREATE,
694         LOG_DS_CLONE,
695         LOG_DS_DESTROY,
696         LOG_DS_DESTROY_BEGIN,
697         LOG_DS_INHERIT,
698         LOG_DS_PROPSET,
699         LOG_DS_QUOTA,
700         LOG_DS_PERM_UPDATE,
701         LOG_DS_PERM_REMOVE,
702         LOG_DS_PERM_WHO_REMOVE,
703         LOG_DS_PROMOTE,
704         LOG_DS_RECEIVE,
705         LOG_DS_RENAME,
706         LOG_DS_RESERVATION,
707         LOG_DS_REPLAY_INC_SYNC,
708         LOG_DS_REPLAY_FULL_SYNC,
709         LOG_DS_ROLLBACK,
710         LOG_DS_SNAPSHOT,
711         LOG_DS_UPGRADE,
712         LOG_DS_REFQUOTA,
713         LOG_DS_REFRESERV,
714         LOG_POOL_SCRUB_DONE,
715         LOG_END
716 } history_internal_events_t;
717
718 #ifdef  __cplusplus
719 }
720 #endif
721
722 #endif  /* _SYS_FS_ZFS_H */