zfs.h revision 8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfb
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
441d80aa4f613b6298fc8bd3151f4be02dbf84fclling * Common Development and Distribution License (the "License").
441d80aa4f613b6298fc8bd3151f4be02dbf84fclling * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
743a77ed89085d3c232c4a2f65ab4e19576839e2Alan Wright * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Use is subject to license terms.
fa9e4066f08beec538e775443c5be79dd423fcabahrensextern "C" {
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Types and constants shared between userland and the kernel.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Each dataset can be one of the following types. These constants can be
fa9e4066f08beec538e775443c5be79dd423fcabahrens * combined into masks that can be passed to various functions.
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum {
fa9e4066f08beec538e775443c5be79dd423fcabahrens (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
990b4856d0eaada6f8140335733a1b1771ed2746lling * Dataset properties are identified by these constants and must be added to
990b4856d0eaada6f8140335733a1b1771ed2746lling * the end of this list to ensure that external consumers are not affected
990b4856d0eaada6f8140335733a1b1771ed2746lling * by the change. If you make any changes to this list, be sure to update
66e2aacc02a4625d105fb249ad16c27e79604ff2gw * the property table in usr/src/common/zfs/zfs_prop.c.
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum {
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrens ZFS_PROP_USERACCOUNTING, /* not exposed to the user */
478ed9ada0b6efe1318150a700986aa47e6a926dEric Taylor ZFS_PROP_STMF_SHAREINFO, /* not exposed to the user */
1d7132005da8d75994a6ad204e6ec05ef5ffaa4bEric Schrock ZFS_PROP_OBJSETID, /* not exposed to the user */
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrenstypedef enum {
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrensextern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
990b4856d0eaada6f8140335733a1b1771ed2746lling * Pool properties are identified by these constants and must be added to the
b87f3af36bb994656da117319f5129ddfd05ed21perrin * end of this list to ensure that external consumers are not affected
990b4856d0eaada6f8140335733a1b1771ed2746lling * by the change. If you make any changes to this list, be sure to update
990b4856d0eaada6f8140335733a1b1771ed2746lling * the property table in usr/src/common/zfs/zpool_prop.c.
990b4856d0eaada6f8140335733a1b1771ed2746llingtypedef enum {
b1b8ab34de515a5e83206da22c3d7e563241b021llingtypedef enum {
990b4856d0eaada6f8140335733a1b1771ed2746llingtypedef int (*zprop_func)(int, void *);
0a48a24e663a04e34e2ed4e55390ad96f178dbeatimh * Properties to be set on the root file system of a new pool
0a48a24e663a04e34e2ed4e55390ad96f178dbeatimh * are stuffed into their own nvlist, which is then included in
0a48a24e663a04e34e2ed4e55390ad96f178dbeatimh * the properties nvlist with the pool properties.
990b4856d0eaada6f8140335733a1b1771ed2746lling * Dataset property functions shared between libzfs and kernel.
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrensboolean_t zfs_prop_userquota(const char *name);
990b4856d0eaada6f8140335733a1b1771ed2746llingint zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
990b4856d0eaada6f8140335733a1b1771ed2746llingint zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
990b4856d0eaada6f8140335733a1b1771ed2746lling * Pool property functions shared between libzfs and kernel.
990b4856d0eaada6f8140335733a1b1771ed2746llingint zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
990b4856d0eaada6f8140335733a1b1771ed2746llingint zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
990b4856d0eaada6f8140335733a1b1771ed2746lling * Definitions for the Delegation.
ecd6cf800b63704be73fb264c3f5b6e0dafc068dmarkstypedef enum {
ecd6cf800b63704be73fb264c3f5b6e0dafc068dmarkstypedef enum {
a227b7f4f323ad89c40a86c430a5e891504a8e8bhstypedef enum {
e09fa4dacfb671e707d50a55ae9b5cc191e1b8cbNeil Perrintypedef enum {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef enum zfs_share_op {
3baa08fc5b6bea08a475b0cfe3ad161d74c5864bektypedef enum zfs_cache_type {
99653d4ee642c6528e88224f12409a5f23060994eschrock * On-disk version number.
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
478ed9ada0b6efe1318150a700986aa47e6a926dEric Taylor * format change. Go to usr/src/grub/grub-0.97/stage2/{zfs-include/, fsys_zfs*},
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrens * and do the appropriate changes. Also bump the version number in
e7437265dc2a4920c197ed4337665539d358b22cahrens * Symbolic names for the changes that caused a SPA_VERSION switch.
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * Used in the code when checking for presence or absence of a feature.
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * Feel free to define multiple symbolic names for each version if there
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * were multiple changes to on-disk structures during that version.
e7437265dc2a4920c197ed4337665539d358b22cahrens * NOTE: When checking the current SPA_VERSION in your code, be sure
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * to use spa_version() since it reports the version of the
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * last synced uberblock. Checking the in-flight version can
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * be dangerous in some cases.
74e7dc986c89efca1f2e4451c7a572e05e4a6e4fMatthew Ahrens#define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13
d0f3f37e7f24f68fdbd85386c60e576883622762Mark Shellenbaum#define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14
e7437265dc2a4920c197ed4337665539d358b22cahrens * ZPL version - rev'd whenever an incompatible on-disk format change
e7437265dc2a4920c197ed4337665539d358b22cahrens * occurs. This is independent of SPA/DMU/ZAP versioning. You must
e7437265dc2a4920c197ed4337665539d358b22cahrens * also update the version_table[] and help message in zfs_prop.c.
e7437265dc2a4920c197ed4337665539d358b22cahrens * When changing, be sure to teach GRUB how to read the new format!
478ed9ada0b6efe1318150a700986aa47e6a926dEric Taylor * See usr/src/grub/grub-0.97/stage2/{zfs-include/,fsys_zfs*}
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The following are configuration names used in the nvlist describing a pool's
fa9e4066f08beec538e775443c5be79dd423fcabahrens * configuration.
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson#define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick#define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw#define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */
e7cbe64f7a72dae5cb44f100db60ca88f3313c65gw#define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * The persistent vdev state is stored as separate values rather than a single
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * 'vdev_state' entry. This is because a device can be in multiple states, such
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * as offline and degraded.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * This is needed in userland to report the minimum necessary device size.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The location of the pool configuration repository, shared between kernel and
fa9e4066f08beec538e775443c5be79dd423fcabahrens * userland.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * vdev states are ordered from least to most healthy.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * A vdev that's CANT_OPEN or below is considered unusable.
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum vdev_state {
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock VDEV_STATE_REMOVED, /* Explicitly removed from system */
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock VDEV_STATE_FAULTED, /* External request to fault device */
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */
fa9e4066f08beec538e775443c5be79dd423fcabahrens * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field
fa9e4066f08beec538e775443c5be79dd423fcabahrens * of the vdev stats structure uses these constants to distinguish why.
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum vdev_aux {
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_AUX_OPEN_FAILED, /* ldi_open_*() or vn_open() failed */
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_AUX_CORRUPT_DATA, /* bad label or disk contents */
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_AUX_NO_REPLICAS, /* insufficient number of replicas */
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_AUX_BAD_GUID_SUM, /* vdev guid sum doesn't match */
eaca9bbd5f5d1e4e554da4c7108e8a03c8c33481eschrock VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */
eaca9bbd5f5d1e4e554da4c7108e8a03c8c33481eschrock VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */
99653d4ee642c6528e88224f12409a5f23060994eschrock VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock VDEV_AUX_SPARED, /* hot spare used in another pool */
46a2abf27af40eda17a3f97e79eda1aef4e3c3c8eschrock * pool state. The following states are written to disk as part of the normal
fa94a07fd0519b8abfd871ad8fe60e6bebe1e2bbbrendan * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
fa94a07fd0519b8abfd871ad8fe60e6bebe1e2bbbrendan * states are software abstractions used at various levels to communicate
fa94a07fd0519b8abfd871ad8fe60e6bebe1e2bbbrendan * pool state.
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum pool_state {
46a2abf27af40eda17a3f97e79eda1aef4e3c3c8eschrock POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Scrub types.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * ZIO types. Needed to interpret vdev statistics below.
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum zio_type {
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Vdev statistics. Note: all fields should be 64-bit because this
fa9e4066f08beec538e775443c5be79dd423fcabahrens * is passed between kernel and userland as an nvlist uint64 array.
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef struct vdev_stat {
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_scrub_examined; /* bytes examined; top */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_scrub_repaired; /* bytes repaired; leaf */
681d9761e8516a7dc5ab6589e2dfe717777e1123Eric Taylor/* general zvol path */
681d9761e8516a7dc5ab6589e2dfe717777e1123Eric Taylor/* expansion */
573ca77e53dd31dcaebef023e7eb41969e6896c1George Wilson#define ZVOL_PSEUDO_DEV "/devices/pseudo/zfs@0:"
681d9761e8516a7dc5ab6589e2dfe717777e1123Eric Taylor/* for dump and swap */
fa9e4066f08beec538e775443c5be79dd423fcabahrens * /dev/zfs ioctl numbers.
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum zfs_ioc {
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Internal SPA load state. Used by FMA diagnosis engine.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrocktypedef enum {
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock * Bookmark name values.
06eeb2ad640ce72d394ac521094bed7681044408ek * The following are names used in the nvlist describing
06eeb2ad640ce72d394ac521094bed7681044408ek * the pool's history log.
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * Flags for ZFS_IOC_VDEV_SET_STATE
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * Sysevent payload members. ZFS will generate the following sysevents with the
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * given payloads:
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ESC_ZFS_RESILVER_START
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ESC_ZFS_RESILVER_END
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ESC_ZFS_POOL_DESTROY
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ESC_ZFS_VDEV_REMOVE
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ESC_ZFS_VDEV_CLEAR
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ESC_ZFS_VDEV_CHECK
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ZFS_EV_POOL_NAME DATA_TYPE_STRING
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ZFS_EV_POOL_GUID DATA_TYPE_UINT64
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ZFS_EV_VDEV_PATH DATA_TYPE_STRING (optional)
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * ZFS_EV_VDEV_GUID DATA_TYPE_UINT64
088f389458728c464569a5506b58070254fa4f7dahrens * Note: This is encoded on-disk, so new events must be added to the
088f389458728c464569a5506b58070254fa4f7dahrens * end, and unused events can not be removed. Be sure to edit
8f18d1fadf6a0c20fac9ff7259a5368faa3c3bfbGeorge Wilson * libzfs_pool.c: hist_event_table[].
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif /* _SYS_FS_ZFS_H */