]> git.proxmox.com Git - mirror_zfs-debian.git/blobdiff - include/sys/fs/zfs.h
Imported Upstream version 0.6.5.8
[mirror_zfs-debian.git] / include / sys / fs / zfs.h
index f72c74fc93e1f1f690c1fb6e2fe1130a85a2476f..57bf55f9365f5a8ce20da4b5549c1d3b85f7d3bb 100644 (file)
@@ -21,9 +21,9 @@
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  */
 
 /* Portions Copyright 2010 Robert Milkowski */
@@ -46,24 +46,36 @@ extern "C" {
  * combined into masks that can be passed to various functions.
  */
 typedef enum {
-       ZFS_TYPE_FILESYSTEM     = 0x1,
-       ZFS_TYPE_SNAPSHOT       = 0x2,
-       ZFS_TYPE_VOLUME         = 0x4,
-       ZFS_TYPE_POOL           = 0x8
+       ZFS_TYPE_FILESYSTEM     = (1 << 0),
+       ZFS_TYPE_SNAPSHOT       = (1 << 1),
+       ZFS_TYPE_VOLUME         = (1 << 2),
+       ZFS_TYPE_POOL           = (1 << 3),
+       ZFS_TYPE_BOOKMARK       = (1 << 4)
 } zfs_type_t;
 
+typedef enum dmu_objset_type {
+       DMU_OST_NONE,
+       DMU_OST_META,
+       DMU_OST_ZFS,
+       DMU_OST_ZVOL,
+       DMU_OST_OTHER,                  /* For testing only! */
+       DMU_OST_ANY,                    /* Be careful! */
+       DMU_OST_NUMTYPES
+} dmu_objset_type_t;
+
 #define        ZFS_TYPE_DATASET        \
        (ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
 
 #define        ZAP_MAXNAMELEN 256
 #define        ZAP_MAXVALUELEN (1024 * 8)
 #define        ZAP_OLDMAXVALUELEN 1024
+#define        ZFS_MAX_DATASET_NAME_LEN 256
 
 /*
  * Dataset properties are identified by these constants and must be added to
  * the end of this list to ensure that external consumers are not affected
  * by the change. If you make any changes to this list, be sure to update
- * the property table in usr/src/common/zfs/zfs_prop.c.
+ * the property table in module/zcommon/zfs_prop.c.
  */
 typedef enum {
        ZFS_PROP_TYPE,
@@ -128,6 +140,22 @@ typedef enum {
        ZFS_PROP_REFRATIO,
        ZFS_PROP_WRITTEN,
        ZFS_PROP_CLONES,
+       ZFS_PROP_LOGICALUSED,
+       ZFS_PROP_LOGICALREFERENCED,
+       ZFS_PROP_INCONSISTENT,          /* not exposed to the user */
+       ZFS_PROP_FILESYSTEM_LIMIT,
+       ZFS_PROP_SNAPSHOT_LIMIT,
+       ZFS_PROP_FILESYSTEM_COUNT,
+       ZFS_PROP_SNAPSHOT_COUNT,
+       ZFS_PROP_SNAPDEV,
+       ZFS_PROP_ACLTYPE,
+       ZFS_PROP_SELINUX_CONTEXT,
+       ZFS_PROP_SELINUX_FSCONTEXT,
+       ZFS_PROP_SELINUX_DEFCONTEXT,
+       ZFS_PROP_SELINUX_ROOTCONTEXT,
+       ZFS_PROP_RELATIME,
+       ZFS_PROP_REDUNDANT_METADATA,
+       ZFS_PROP_OVERLAY,
        ZFS_NUM_PROPS
 } zfs_prop_t;
 
@@ -145,7 +173,7 @@ extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
  * Pool properties are identified by these constants and must be added to the
  * end of this list to ensure that external consumers are not affected
  * by the change. If you make any changes to this list, be sure to update
- * the property table in usr/src/common/zfs/zpool_prop.c.
+ * the property table in module/zcommon/zpool_prop.c.
  */
 typedef enum {
        ZPOOL_PROP_NAME,
@@ -170,6 +198,11 @@ typedef enum {
        ZPOOL_PROP_ASHIFT,
        ZPOOL_PROP_COMMENT,
        ZPOOL_PROP_EXPANDSZ,
+       ZPOOL_PROP_FREEING,
+       ZPOOL_PROP_FRAGMENTATION,
+       ZPOOL_PROP_LEAKED,
+       ZPOOL_PROP_MAXBLOCKSIZE,
+       ZPOOL_PROP_TNAME,
        ZPOOL_NUM_PROPS
 } zpool_prop_t;
 
@@ -234,7 +267,7 @@ boolean_t zfs_prop_written(const char *);
 int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
 int zfs_prop_string_to_index(zfs_prop_t, const char *, uint64_t *);
 uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
-boolean_t zfs_prop_valid_for_type(int, zfs_type_t);
+boolean_t zfs_prop_valid_for_type(int, zfs_type_t, boolean_t);
 
 /*
  * Pool property functions shared between libzfs and kernel.
@@ -244,6 +277,8 @@ const char *zpool_prop_to_name(zpool_prop_t);
 const char *zpool_prop_default_string(zpool_prop_t);
 uint64_t zpool_prop_default_numeric(zpool_prop_t);
 boolean_t zpool_prop_readonly(zpool_prop_t);
+boolean_t zpool_prop_feature(const char *);
+boolean_t zpool_prop_unsupported(const char *);
 int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
 int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
 uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
@@ -325,6 +360,11 @@ typedef enum {
        ZFS_XATTR_SA = 2
 } zfs_xattr_type_t;
 
+typedef enum {
+       ZFS_REDUNDANT_METADATA_ALL,
+       ZFS_REDUNDANT_METADATA_MOST
+} zfs_redundant_metadata_type_t;
+
 /*
  * On-disk version number.
  */
@@ -356,6 +396,7 @@ typedef enum {
 #define        SPA_VERSION_26                  26ULL
 #define        SPA_VERSION_27                  27ULL
 #define        SPA_VERSION_28                  28ULL
+#define        SPA_VERSION_5000                5000ULL
 
 /*
  * When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
@@ -363,8 +404,8 @@ typedef enum {
  * and do the appropriate changes.  Also bump the version number in
  * usr/src/grub/capability.
  */
-#define        SPA_VERSION                     SPA_VERSION_28
-#define        SPA_VERSION_STRING              "28"
+#define        SPA_VERSION                     SPA_VERSION_5000
+#define        SPA_VERSION_STRING              "5000"
 
 /*
  * Symbolic names for the changes that caused a SPA_VERSION switch.
@@ -415,6 +456,12 @@ typedef enum {
 #define        SPA_VERSION_DEADLISTS           SPA_VERSION_26
 #define        SPA_VERSION_FAST_SNAP           SPA_VERSION_27
 #define        SPA_VERSION_MULTI_REPLACE       SPA_VERSION_28
+#define        SPA_VERSION_BEFORE_FEATURES     SPA_VERSION_28
+#define        SPA_VERSION_FEATURES            SPA_VERSION_5000
+
+#define        SPA_VERSION_IS_SUPPORTED(v) \
+       (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
+       ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
 
 /*
  * ZPL version - rev'd whenever an incompatible on-disk format change
@@ -505,13 +552,20 @@ typedef struct zpool_rewind_policy {
 #define        ZPOOL_CONFIG_SPLIT_GUID         "split_guid"
 #define        ZPOOL_CONFIG_SPLIT_LIST         "guid_list"
 #define        ZPOOL_CONFIG_REMOVING           "removing"
-#define        ZPOOL_CONFIG_RESILVERING        "resilvering"
+#define        ZPOOL_CONFIG_RESILVER_TXG       "resilver_txg"
 #define        ZPOOL_CONFIG_COMMENT            "comment"
 #define        ZPOOL_CONFIG_SUSPENDED          "suspended"     /* not stored on disk */
 #define        ZPOOL_CONFIG_TIMESTAMP          "timestamp"     /* not stored on disk */
 #define        ZPOOL_CONFIG_BOOTFS             "bootfs"        /* not stored on disk */
 #define        ZPOOL_CONFIG_MISSING_DEVICES    "missing_vdevs" /* not stored on disk */
 #define        ZPOOL_CONFIG_LOAD_INFO          "load_info"     /* not stored on disk */
+#define        ZPOOL_CONFIG_REWIND_INFO        "rewind_info"   /* not stored on disk */
+#define        ZPOOL_CONFIG_UNSUP_FEAT         "unsup_feat"    /* not stored on disk */
+#define        ZPOOL_CONFIG_ENABLED_FEAT       "enabled_feat"  /* not stored on disk */
+#define        ZPOOL_CONFIG_CAN_RDONLY         "can_rdonly"    /* not stored on disk */
+#define        ZPOOL_CONFIG_FEATURES_FOR_READ  "features_for_read"
+#define        ZPOOL_CONFIG_FEATURE_STATS      "feature_stats" /* not stored on disk */
+#define        ZPOOL_CONFIG_ERRATA             "errata"        /* not stored on disk */
 /*
  * The persistent vdev state is stored as separate values rather than a single
  * 'vdev_state' entry.  This is because a device can be in multiple states, such
@@ -553,6 +607,13 @@ typedef struct zpool_rewind_policy {
  */
 #define        SPA_MINDEVSIZE          (64ULL << 20)
 
+/*
+ * Set if the fragmentation has not yet been calculated. This can happen
+ * because the space maps have not been upgraded or the histogram feature
+ * is not enabled.
+ */
+#define        ZFS_FRAG_INVALID        UINT64_MAX
+
 /*
  * The location of the pool configuration repository, shared between kernel and
  * userland.
@@ -590,6 +651,7 @@ typedef enum vdev_aux {
        VDEV_AUX_BAD_LABEL,     /* the label is OK but invalid          */
        VDEV_AUX_VERSION_NEWER, /* on-disk version is too new           */
        VDEV_AUX_VERSION_OLDER, /* on-disk version is too old           */
+       VDEV_AUX_UNSUP_FEAT,    /* unsupported features                 */
        VDEV_AUX_SPARED,        /* hot spare used in another pool       */
        VDEV_AUX_ERR_EXCEEDED,  /* too many errors                      */
        VDEV_AUX_IO_FAILURE,    /* experienced I/O failure              */
@@ -667,6 +729,17 @@ typedef enum dsl_scan_state {
        DSS_NUM_STATES
 } dsl_scan_state_t;
 
+/*
+ * Errata described by http://zfsonlinux.org/msg/ZFS-8000-ER.  The ordering
+ * of this enum must be maintained to ensure the errata identifiers map to
+ * the correct documentation.  New errata may only be appended to the list
+ * and must contain corresponding documentation at the above link.
+ */
+typedef enum zpool_errata {
+       ZPOOL_ERRATA_NONE,
+       ZPOOL_ERRATA_ZOL_2094_SCRUB,
+       ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY,
+} zpool_errata_t;
 
 /*
  * Vdev statistics.  Note: all fields should be 64-bit because this
@@ -689,6 +762,7 @@ typedef struct vdev_stat {
        uint64_t        vs_self_healed;         /* self-healed bytes    */
        uint64_t        vs_scan_removing;       /* removing?    */
        uint64_t        vs_scan_processed;      /* scan processed bytes */
+       uint64_t        vs_fragmentation;       /* device fragmentation */
 } vdev_stat_t;
 
 /*
@@ -735,10 +809,13 @@ typedef struct ddt_histogram {
 /*
  * /dev/zfs ioctl numbers.
  */
-#define        ZFS_IOC         ('Z' << 8)
-
 typedef enum zfs_ioc {
-       ZFS_IOC_POOL_CREATE = ZFS_IOC,
+       /*
+        * Illumos - 70/128 numbers reserved.
+        */
+       ZFS_IOC_FIRST = ('Z' << 8),
+       ZFS_IOC = ZFS_IOC_FIRST,
+       ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,
        ZFS_IOC_POOL_DESTROY,
        ZFS_IOC_POOL_IMPORT,
        ZFS_IOC_POOL_EXPORT,
@@ -761,8 +838,6 @@ typedef enum zfs_ioc {
        ZFS_IOC_DATASET_LIST_NEXT,
        ZFS_IOC_SNAPSHOT_LIST_NEXT,
        ZFS_IOC_SET_PROP,
-       ZFS_IOC_CREATE_MINOR,
-       ZFS_IOC_REMOVE_MINOR,
        ZFS_IOC_CREATE,
        ZFS_IOC_DESTROY,
        ZFS_IOC_ROLLBACK,
@@ -775,7 +850,6 @@ typedef enum zfs_ioc {
        ZFS_IOC_ERROR_LOG,
        ZFS_IOC_CLEAR,
        ZFS_IOC_PROMOTE,
-       ZFS_IOC_DESTROY_SNAPS_NVL,
        ZFS_IOC_SNAPSHOT,
        ZFS_IOC_DSOBJ_TO_DSNAME,
        ZFS_IOC_OBJ_TO_PATH,
@@ -798,19 +872,40 @@ typedef enum zfs_ioc {
        ZFS_IOC_DIFF,
        ZFS_IOC_TMP_SNAPSHOT,
        ZFS_IOC_OBJ_TO_STATS,
-       ZFS_IOC_EVENTS_NEXT,
-       ZFS_IOC_EVENTS_CLEAR,
-       ZFS_IOC_POOL_REGUID,
        ZFS_IOC_SPACE_WRITTEN,
        ZFS_IOC_SPACE_SNAPS,
+       ZFS_IOC_DESTROY_SNAPS,
+       ZFS_IOC_POOL_REGUID,
        ZFS_IOC_POOL_REOPEN,
        ZFS_IOC_SEND_PROGRESS,
+       ZFS_IOC_LOG_HISTORY,
+       ZFS_IOC_SEND_NEW,
+       ZFS_IOC_SEND_SPACE,
+       ZFS_IOC_CLONE,
+       ZFS_IOC_BOOKMARK,
+       ZFS_IOC_GET_BOOKMARKS,
+       ZFS_IOC_DESTROY_BOOKMARKS,
+
+       /*
+        * Linux - 3/64 numbers reserved.
+        */
+       ZFS_IOC_LINUX = ('Z' << 8) + 0x80,
+       ZFS_IOC_EVENTS_NEXT,
+       ZFS_IOC_EVENTS_CLEAR,
+       ZFS_IOC_EVENTS_SEEK,
+
+       /*
+        * FreeBSD - 1/64 numbers reserved.
+        */
+       ZFS_IOC_FREEBSD = ('Z' << 8) + 0xC0,
+
+       ZFS_IOC_LAST
 } zfs_ioc_t;
 
 /*
  * zvol ioctl to get dataset name
  */
-#define BLKZNAME               _IOR(0x12,125,char[ZFS_MAXNAMELEN])
+#define        BLKZNAME                _IOR(0x12, 125, char[ZFS_MAXNAMELEN])
 
 /*
  * Internal SPA load state.  Used by FMA diagnosis engine.
@@ -846,6 +941,12 @@ typedef enum {
 #define        ZPOOL_HIST_TXG          "history txg"
 #define        ZPOOL_HIST_INT_EVENT    "history internal event"
 #define        ZPOOL_HIST_INT_STR      "history internal str"
+#define        ZPOOL_HIST_INT_NAME     "internal_name"
+#define        ZPOOL_HIST_IOCTL        "ioctl"
+#define        ZPOOL_HIST_INPUT_NVL    "in_nvl"
+#define        ZPOOL_HIST_OUTPUT_NVL   "out_nvl"
+#define        ZPOOL_HIST_DSNAME       "dsname"
+#define        ZPOOL_HIST_DSID         "dsid"
 
 /*
  * Flags for ZFS_IOC_VDEV_SET_STATE
@@ -864,6 +965,7 @@ typedef enum {
 #define        ZFS_IMPORT_ANY_HOST     0x2
 #define        ZFS_IMPORT_MISSING_LOG  0x4
 #define        ZFS_IMPORT_ONLY         0x8
+#define        ZFS_IMPORT_TEMP_NAME    0x10
 
 /*
  * Sysevent payload members.  ZFS will generate the following sysevents with the
@@ -891,56 +993,6 @@ typedef enum {
 #define        ZFS_EV_VDEV_PATH        "vdev_path"
 #define        ZFS_EV_VDEV_GUID        "vdev_guid"
 
-/*
- * Note: This is encoded on-disk, so new events must be added to the
- * end, and unused events can not be removed.  Be sure to edit
- * libzfs_pool.c: hist_event_table[].
- */
-typedef enum history_internal_events {
-       LOG_NO_EVENT = 0,
-       LOG_POOL_CREATE,
-       LOG_POOL_VDEV_ADD,
-       LOG_POOL_REMOVE,
-       LOG_POOL_DESTROY,
-       LOG_POOL_EXPORT,
-       LOG_POOL_IMPORT,
-       LOG_POOL_VDEV_ATTACH,
-       LOG_POOL_VDEV_REPLACE,
-       LOG_POOL_VDEV_DETACH,
-       LOG_POOL_VDEV_ONLINE,
-       LOG_POOL_VDEV_OFFLINE,
-       LOG_POOL_UPGRADE,
-       LOG_POOL_CLEAR,
-       LOG_POOL_SCAN,
-       LOG_POOL_PROPSET,
-       LOG_DS_CREATE,
-       LOG_DS_CLONE,
-       LOG_DS_DESTROY,
-       LOG_DS_DESTROY_BEGIN,
-       LOG_DS_INHERIT,
-       LOG_DS_PROPSET,
-       LOG_DS_QUOTA,
-       LOG_DS_PERM_UPDATE,
-       LOG_DS_PERM_REMOVE,
-       LOG_DS_PERM_WHO_REMOVE,
-       LOG_DS_PROMOTE,
-       LOG_DS_RECEIVE,
-       LOG_DS_RENAME,
-       LOG_DS_RESERVATION,
-       LOG_DS_REPLAY_INC_SYNC,
-       LOG_DS_REPLAY_FULL_SYNC,
-       LOG_DS_ROLLBACK,
-       LOG_DS_SNAPSHOT,
-       LOG_DS_UPGRADE,
-       LOG_DS_REFQUOTA,
-       LOG_DS_REFRESERV,
-       LOG_POOL_SCAN_DONE,
-       LOG_DS_USER_HOLD,
-       LOG_DS_USER_RELEASE,
-       LOG_POOL_SPLIT,
-       LOG_END
-} history_internal_events_t;
-
 #ifdef __cplusplus
 }
 #endif