zfs.h revision c9431fa1e59a88c2f0abf611f25b97af964449e5
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
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 *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * or http://www.opensolaris.org/os/licensing.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
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 *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
39c23413b8df94a95f67b34cfd4a4dfc3fd0b48deschrock * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Use is subject to license terms.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifndef _SYS_FS_ZFS_H
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define _SYS_FS_ZFS_H
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#pragma ident "%Z%%M% %I% %E% SMI"
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/types.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifdef __cplusplus
fa9e4066f08beec538e775443c5be79dd423fcabahrensextern "C" {
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Types and constants shared between userland and the kernel.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
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.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum {
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_TYPE_FILESYSTEM = 0x1,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_TYPE_SNAPSHOT = 0x2,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_TYPE_VOLUME = 0x4
fa9e4066f08beec538e775443c5be79dd423fcabahrens} zfs_type_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZFS_TYPE_ANY \
fa9e4066f08beec538e775443c5be79dd423fcabahrens (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
66e2aacc02a4625d105fb249ad16c27e79604ff2gw * Properties are identified by these constants and must be added to the
66e2aacc02a4625d105fb249ad16c27e79604ff2gw * end of this list to ensure that external conumsers are not affected
66e2aacc02a4625d105fb249ad16c27e79604ff2gw * by the change. The property list also determines how 'zfs get' will
66e2aacc02a4625d105fb249ad16c27e79604ff2gw * display them. If you make any changes to this list, be sure to update
66e2aacc02a4625d105fb249ad16c27e79604ff2gw * the property table in usr/src/common/zfs/zfs_prop.c.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum {
66e2aacc02a4625d105fb249ad16c27e79604ff2gw ZFS_PROP_CONT = -2,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_INVAL = -1,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_TYPE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_CREATION,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_USED,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_AVAILABLE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_REFERENCED,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_COMPRESSRATIO,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_MOUNTED,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_ORIGIN,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_QUOTA,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_RESERVATION,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_VOLSIZE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_VOLBLOCKSIZE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_RECORDSIZE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_MOUNTPOINT,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_SHARENFS,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_CHECKSUM,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_COMPRESSION,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_ATIME,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_DEVICES,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_EXEC,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_SETUID,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_READONLY,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_ZONED,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_SNAPDIR,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_ACLMODE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_PROP_ACLINHERIT,
66e2aacc02a4625d105fb249ad16c27e79604ff2gw ZFS_PROP_CREATETXG, /* not exposed to the user */
66e2aacc02a4625d105fb249ad16c27e79604ff2gw ZFS_PROP_NAME, /* not exposed to the user */
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock ZFS_PROP_CANMOUNT,
66e2aacc02a4625d105fb249ad16c27e79604ff2gw ZFS_PROP_SHAREISCSI,
66e2aacc02a4625d105fb249ad16c27e79604ff2gw ZFS_PROP_ISCSIOPTIONS, /* not exposed to the user */
7b55fa8ea6046becb3b72f8886a503979c322084ck ZFS_PROP_XATTR,
d0ad202d2eff2cc0c70ee550686a703ddda7106cahrens ZFS_PROP_NUMCLONES, /* not exposed to the user */
d0ad202d2eff2cc0c70ee550686a703ddda7106cahrens ZFS_PROP_COPIES
fa9e4066f08beec538e775443c5be79dd423fcabahrens} zfs_prop_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
7f7322febbcfe774b7270abc3b191c094bfcc517eschrock#define ZFS_PROP_VALUE "value"
7f7322febbcfe774b7270abc3b191c094bfcc517eschrock#define ZFS_PROP_SOURCE "source"
7f7322febbcfe774b7270abc3b191c094bfcc517eschrock
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The following functions are shared between libzfs and the kernel.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrenszfs_prop_t zfs_name_to_prop(const char *);
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrockboolean_t zfs_prop_user(const char *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensint zfs_prop_readonly(zfs_prop_t);
7f7322febbcfe774b7270abc3b191c094bfcc517eschrockconst char *zfs_prop_default_string(zfs_prop_t);
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrockconst char *zfs_prop_to_name(zfs_prop_t);
fa9e4066f08beec538e775443c5be79dd423fcabahrensuint64_t zfs_prop_default_numeric(zfs_prop_t);
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrockint zfs_prop_inheritable(zfs_prop_t);
acd76fe5a01cfab51c34c67df884b68562a97f3feschrockint zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
acd76fe5a01cfab51c34c67df884b68562a97f3feschrockint zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
99653d4ee642c6528e88224f12409a5f23060994eschrock
66e2aacc02a4625d105fb249ad16c27e79604ff2gw/*
66e2aacc02a4625d105fb249ad16c27e79604ff2gw * Property Iterator
66e2aacc02a4625d105fb249ad16c27e79604ff2gw */
66e2aacc02a4625d105fb249ad16c27e79604ff2gwtypedef zfs_prop_t (*zfs_prop_f)(zfs_prop_t, void *);
66e2aacc02a4625d105fb249ad16c27e79604ff2gwextern zfs_prop_t zfs_prop_iter(zfs_prop_f, void *, boolean_t);
66e2aacc02a4625d105fb249ad16c27e79604ff2gw
eaca9bbd5f5d1e4e554da4c7108e8a03c8c33481eschrock/*
99653d4ee642c6528e88224f12409a5f23060994eschrock * On-disk version number.
eaca9bbd5f5d1e4e554da4c7108e8a03c8c33481eschrock */
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm#define ZFS_VERSION_1 1ULL
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm#define ZFS_VERSION_2 2ULL
99653d4ee642c6528e88224f12409a5f23060994eschrock#define ZFS_VERSION_3 3ULL
d7306b64c847d897abb9ece8624fca9cf28d358fek#define ZFS_VERSION_4 4ULL
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl#define ZFS_VERSION_5 5ULL
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl#define ZFS_VERSION ZFS_VERSION_5
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl#define ZFS_VERSION_STRING "5"
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm/*
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * Symbolic names for the changes that caused a ZFS_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.
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm *
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * NOTE: When checking the current ZFS_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.
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm */
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm#define ZFS_VERSION_INITIAL ZFS_VERSION_1
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm#define ZFS_VERSION_DITTO_BLOCKS ZFS_VERSION_2
99653d4ee642c6528e88224f12409a5f23060994eschrock#define ZFS_VERSION_SPARES ZFS_VERSION_3
99653d4ee642c6528e88224f12409a5f23060994eschrock#define ZFS_VERSION_RAID6 ZFS_VERSION_3
99653d4ee642c6528e88224f12409a5f23060994eschrock#define ZFS_VERSION_BPLIST_ACCOUNT ZFS_VERSION_3
99653d4ee642c6528e88224f12409a5f23060994eschrock#define ZFS_VERSION_RAIDZ_DEFLATE ZFS_VERSION_3
99653d4ee642c6528e88224f12409a5f23060994eschrock#define ZFS_VERSION_DNODE_BYTES ZFS_VERSION_3
d7306b64c847d897abb9ece8624fca9cf28d358fek#define ZFS_VERSION_ZPOOL_HISTORY ZFS_VERSION_4
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl#define ZFS_VERSION_GZIP_COMPRESSION ZFS_VERSION_5
eaca9bbd5f5d1e4e554da4c7108e8a03c8c33481eschrock
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The following are configuration names used in the nvlist describing a pool's
fa9e4066f08beec538e775443c5be79dd423fcabahrens * configuration.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_VERSION "version"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_POOL_NAME "name"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_POOL_STATE "state"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_POOL_TXG "txg"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_POOL_GUID "pool_guid"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_CREATE_TXG "create_txg"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_TOP_GUID "top_guid"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_TYPE "type"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_CHILDREN "children"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_ID "id"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_GUID "guid"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_PATH "path"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_DEVID "devid"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_ASHIFT "ashift"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_ASIZE "asize"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_DTL "DTL"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CONFIG_STATS "stats"
afefbcddfd8caf5f3b2da510d9439471ab225040eschrock#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
441d80aa4f613b6298fc8bd3151f4be02dbf84fclling#define ZPOOL_CONFIG_OFFLINE "offline"
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock#define ZPOOL_CONFIG_ERRCOUNT "error_count"
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock#define ZPOOL_CONFIG_NOT_PRESENT "not_present"
99653d4ee642c6528e88224f12409a5f23060994eschrock#define ZPOOL_CONFIG_SPARES "spares"
99653d4ee642c6528e88224f12409a5f23060994eschrock#define ZPOOL_CONFIG_IS_SPARE "is_spare"
99653d4ee642c6528e88224f12409a5f23060994eschrock#define ZPOOL_CONFIG_NPARITY "nparity"
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define VDEV_TYPE_ROOT "root"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define VDEV_TYPE_MIRROR "mirror"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define VDEV_TYPE_REPLACING "replacing"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define VDEV_TYPE_RAIDZ "raidz"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define VDEV_TYPE_DISK "disk"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define VDEV_TYPE_FILE "file"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define VDEV_TYPE_MISSING "missing"
99653d4ee642c6528e88224f12409a5f23060994eschrock#define VDEV_TYPE_SPARE "spare"
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * This is needed in userland to report the minimum necessary device size.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define SPA_MINDEVSIZE (64ULL << 20)
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The location of the pool configuration repository, shared between kernel and
fa9e4066f08beec538e775443c5be79dd423fcabahrens * userland.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CACHE_DIR "/etc/zfs"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CACHE_FILE "zpool.cache"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CACHE_TMP ".zpool.cache"
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZPOOL_CACHE ZPOOL_CACHE_DIR "/" ZPOOL_CACHE_FILE
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * vdev states are ordered from least to most healthy.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * A vdev that's CANT_OPEN or below is considered unusable.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum vdev_state {
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_STATE_CLOSED, /* Not currently open */
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_STATE_OFFLINE, /* Not allowed to open */
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_STATE_HEALTHY /* Presumed good */
fa9e4066f08beec538e775443c5be79dd423fcabahrens} vdev_state_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
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.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum vdev_aux {
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_AUX_NONE, /* no error */
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 */
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_AUX_TOO_SMALL, /* vdev size is too small */
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 */
99653d4ee642c6528e88224f12409a5f23060994eschrock VDEV_AUX_SPARED /* hot spare used in another pool */
fa9e4066f08beec538e775443c5be79dd423fcabahrens} vdev_aux_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
46a2abf27af40eda17a3f97e79eda1aef4e3c3c8eschrock * pool state. The following states are written to disk as part of the normal
99653d4ee642c6528e88224f12409a5f23060994eschrock * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE. The remaining states are
46a2abf27af40eda17a3f97e79eda1aef4e3c3c8eschrock * software abstractions used at various levels to communicate pool state.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum pool_state {
fa9e4066f08beec538e775443c5be79dd423fcabahrens POOL_STATE_ACTIVE = 0, /* In active use */
fa9e4066f08beec538e775443c5be79dd423fcabahrens POOL_STATE_EXPORTED, /* Explicitly exported */
fa9e4066f08beec538e775443c5be79dd423fcabahrens POOL_STATE_DESTROYED, /* Explicitly destroyed */
99653d4ee642c6528e88224f12409a5f23060994eschrock POOL_STATE_SPARE, /* Reserved for hot spare use */
fa9e4066f08beec538e775443c5be79dd423fcabahrens POOL_STATE_UNINITIALIZED, /* Internal spa_t state */
46a2abf27af40eda17a3f97e79eda1aef4e3c3c8eschrock POOL_STATE_UNAVAIL, /* Internal libzfs state */
46a2abf27af40eda17a3f97e79eda1aef4e3c3c8eschrock POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */
fa9e4066f08beec538e775443c5be79dd423fcabahrens} pool_state_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Scrub types.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum pool_scrub_type {
fa9e4066f08beec538e775443c5be79dd423fcabahrens POOL_SCRUB_NONE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens POOL_SCRUB_RESILVER,
fa9e4066f08beec538e775443c5be79dd423fcabahrens POOL_SCRUB_EVERYTHING,
fa9e4066f08beec538e775443c5be79dd423fcabahrens POOL_SCRUB_TYPES
fa9e4066f08beec538e775443c5be79dd423fcabahrens} pool_scrub_type_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * ZIO types. Needed to interpret vdev statistics below.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum zio_type {
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_TYPE_NULL = 0,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_TYPE_READ,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_TYPE_WRITE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_TYPE_FREE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_TYPE_CLAIM,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_TYPE_IOCTL,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZIO_TYPES
fa9e4066f08beec538e775443c5be79dd423fcabahrens} zio_type_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Vdev statistics. Note: all fields should be 64-bit because this
fa9e4066f08beec538e775443c5be79dd423fcabahrens * is passed between kernel and userland as an nvlist uint64 array.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef struct vdev_stat {
fa9e4066f08beec538e775443c5be79dd423fcabahrens hrtime_t vs_timestamp; /* time since vdev load */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_state; /* vdev state */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_aux; /* see vdev_aux_t */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_alloc; /* space allocated */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_space; /* total capacity */
99653d4ee642c6528e88224f12409a5f23060994eschrock uint64_t vs_dspace; /* deflated capacity */
2a79c5fee1dab68e30266ba4356cf60b871aabcflling uint64_t vs_rsize; /* replaceable dev size */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_ops[ZIO_TYPES]; /* operation count */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_read_errors; /* read errors */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_write_errors; /* write errors */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_checksum_errors; /* checksum errors */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_self_healed; /* self-healed bytes */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_scrub_type; /* pool_scrub_type_t */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_scrub_complete; /* completed? */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_scrub_examined; /* bytes examined; top */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_scrub_repaired; /* bytes repaired; leaf */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_scrub_errors; /* errors during scrub */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_scrub_start; /* UTC scrub start time */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vs_scrub_end; /* UTC scrub end time */
fa9e4066f08beec538e775443c5be79dd423fcabahrens} vdev_stat_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZFS_DRIVER "zfs"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZFS_DEV "/dev/zfs"
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zvol paths. Irritatingly, the devfsadm interfaces want all these
fa9e4066f08beec538e775443c5be79dd423fcabahrens * paths without the /dev prefix, but for some things, we want the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * /dev prefix. Below are the names without /dev.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZVOL_DEV_DIR "zvol/dsk"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZVOL_RDEV_DIR "zvol/rdsk"
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * And here are the things we need with /dev, etc. in front of them.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZVOL_PSEUDO_DEV "/devices/pseudo/zvol@0:"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZVOL_FULL_DEV_DIR "/dev/" ZVOL_DEV_DIR
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZVOL_PROP_NAME "name"
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * /dev/zfs ioctl numbers.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZFS_IOC ('Z' << 8)
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef enum zfs_ioc {
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_POOL_CREATE = ZFS_IOC,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_POOL_DESTROY,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_POOL_IMPORT,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_POOL_EXPORT,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_POOL_CONFIGS,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_POOL_STATS,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_POOL_TRYIMPORT,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_POOL_SCRUB,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_POOL_FREEZE,
eaca9bbd5f5d1e4e554da4c7108e8a03c8c33481eschrock ZFS_IOC_POOL_UPGRADE,
06eeb2ad640ce72d394ac521094bed7681044408ek ZFS_IOC_POOL_GET_HISTORY,
06eeb2ad640ce72d394ac521094bed7681044408ek ZFS_IOC_POOL_LOG_HISTORY,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_VDEV_ADD,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_VDEV_REMOVE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_VDEV_ONLINE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_VDEV_OFFLINE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_VDEV_ATTACH,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_VDEV_DETACH,
c67d9675bbc8392fe45f3a7dfbda1ad4daa1eb07eschrock ZFS_IOC_VDEV_SETPATH,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_OBJSET_STATS,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_DATASET_LIST_NEXT,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_SNAPSHOT_LIST_NEXT,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_SET_PROP,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_CREATE_MINOR,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_REMOVE_MINOR,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_CREATE,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_DESTROY,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_ROLLBACK,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_RENAME,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFS_IOC_RECVBACKUP,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock ZFS_IOC_SENDBACKUP,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock ZFS_IOC_INJECT_FAULT,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock ZFS_IOC_CLEAR_FAULT,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock ZFS_IOC_INJECT_LIST_NEXT,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock ZFS_IOC_ERROR_LOG,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock ZFS_IOC_CLEAR,
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens ZFS_IOC_PROMOTE,
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens ZFS_IOC_DESTROY_SNAPS,
55434c770c89aa1b84474f2559a106803511aba0ek ZFS_IOC_SNAPSHOT,
55434c770c89aa1b84474f2559a106803511aba0ek ZFS_IOC_DSOBJ_TO_DSNAME,
55434c770c89aa1b84474f2559a106803511aba0ek ZFS_IOC_OBJ_TO_PATH
fa9e4066f08beec538e775443c5be79dd423fcabahrens} zfs_ioc_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock/*
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Internal SPA load state. Used by FMA diagnosis engine.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock */
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrocktypedef enum {
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock SPA_LOAD_NONE, /* no load in progress */
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock SPA_LOAD_OPEN, /* normal open */
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock SPA_LOAD_IMPORT, /* import in progress */
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock SPA_LOAD_TRYIMPORT /* tryimport in progress */
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock} spa_load_state_t;
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock/*
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock * Bookmark name values.
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock */
55434c770c89aa1b84474f2559a106803511aba0ek#define ZPOOL_ERR_LIST "error list"
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock#define ZPOOL_ERR_DATASET "dataset"
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock#define ZPOOL_ERR_OBJECT "object"
e9dbad6f263d5570ed7ff5443ec5b958af8c24d7eschrock
06eeb2ad640ce72d394ac521094bed7681044408ek#define HIS_MAX_RECORD_LEN (MAXPATHLEN + MAXPATHLEN + 1)
06eeb2ad640ce72d394ac521094bed7681044408ek
06eeb2ad640ce72d394ac521094bed7681044408ek/*
06eeb2ad640ce72d394ac521094bed7681044408ek * The following are names used in the nvlist describing
06eeb2ad640ce72d394ac521094bed7681044408ek * the pool's history log.
06eeb2ad640ce72d394ac521094bed7681044408ek */
06eeb2ad640ce72d394ac521094bed7681044408ek#define ZPOOL_HIST_RECORD "history record"
06eeb2ad640ce72d394ac521094bed7681044408ek#define ZPOOL_HIST_TIME "history time"
06eeb2ad640ce72d394ac521094bed7681044408ek#define ZPOOL_HIST_CMD "history command"
06eeb2ad640ce72d394ac521094bed7681044408ek
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifdef __cplusplus
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif /* _SYS_FS_ZFS_H */