]> git.proxmox.com Git - mirror_zfs.git/blobdiff - include/sys/fs/zfs.h
Replace ZPROP_INVAL with ZPROP_USERPROP where it means a user property
[mirror_zfs.git] / include / sys / fs / zfs.h
index 1bfd7a485abe410e928069cb9b25954fd7f13039..f013e6b2060327deb6be82762bc315f08646e940 100644 (file)
  * Copyright (c) 2014 Integros [integros.com]
  * Copyright (c) 2017, Intel Corporation.
  * Copyright (c) 2019 Datto Inc.
+ * Portions Copyright 2010 Robert Milkowski
+ * Copyright (c) 2021, Colm Buckley <colm@tuatha.org>
  */
 
-/* Portions Copyright 2010 Robert Milkowski */
-
 #ifndef        _SYS_FS_ZFS_H
-#define        _SYS_FS_ZFS_H
+#define        _SYS_FS_ZFS_H extern __attribute__((visibility("default")))
 
 #include <sys/time.h>
 #include <sys/zio_priority.h>
@@ -50,11 +50,13 @@ extern "C" {
  * combined into masks that can be passed to various functions.
  */
 typedef enum {
+       ZFS_TYPE_INVALID        = 0,
        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_BOOKMARK       = (1 << 4),
+       ZFS_TYPE_VDEV           = (1 << 5),
 } zfs_type_t;
 
 /*
@@ -91,6 +93,7 @@ typedef enum dmu_objset_type {
 typedef enum {
        ZPROP_CONT = -2,
        ZPROP_INVAL = -1,
+       ZPROP_USERPROP = ZPROP_INVAL,
        ZFS_PROP_TYPE = 0,
        ZFS_PROP_CREATION,
        ZFS_PROP_USED,
@@ -205,7 +208,8 @@ typedef enum {
        ZFS_NUM_USERQUOTA_PROPS
 } zfs_userquota_prop_t;
 
-extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
+_SYS_FS_ZFS_H const char *const zfs_userquota_prop_prefixes[
+    ZFS_NUM_USERQUOTA_PROPS];
 
 /*
  * Pool properties are identified by these constants and must be added to the
@@ -246,11 +250,13 @@ typedef enum {
        ZPOOL_PROP_CHECKPOINT,
        ZPOOL_PROP_LOAD_GUID,
        ZPOOL_PROP_AUTOTRIM,
+       ZPOOL_PROP_COMPATIBILITY,
        ZPOOL_NUM_PROPS
 } zpool_prop_t;
 
-/* Small enough to not hog a whole line of printout in zpool(1M). */
+/* Small enough to not hog a whole line of printout in zpool(8). */
 #define        ZPROP_MAX_COMMENT       32
+#define        ZPROP_BOOLEAN_NA        2
 
 #define        ZPROP_VALUE             "value"
 #define        ZPROP_SOURCE            "source"
@@ -297,41 +303,113 @@ typedef int (*zprop_func)(int, void *);
  */
 #define        ZFS_WRITTEN_PROP_PREFIX_LEN     8
 
+/*
+ * VDEV 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.
+ */
+typedef enum {
+       VDEV_PROP_INVAL = -1,
+       VDEV_PROP_USERPROP = VDEV_PROP_INVAL,
+       VDEV_PROP_NAME,
+       VDEV_PROP_CAPACITY,
+       VDEV_PROP_STATE,
+       VDEV_PROP_GUID,
+       VDEV_PROP_ASIZE,
+       VDEV_PROP_PSIZE,
+       VDEV_PROP_ASHIFT,
+       VDEV_PROP_SIZE,
+       VDEV_PROP_FREE,
+       VDEV_PROP_ALLOCATED,
+       VDEV_PROP_COMMENT,
+       VDEV_PROP_EXPANDSZ,
+       VDEV_PROP_FRAGMENTATION,
+       VDEV_PROP_BOOTSIZE,
+       VDEV_PROP_PARITY,
+       VDEV_PROP_PATH,
+       VDEV_PROP_DEVID,
+       VDEV_PROP_PHYS_PATH,
+       VDEV_PROP_ENC_PATH,
+       VDEV_PROP_FRU,
+       VDEV_PROP_PARENT,
+       VDEV_PROP_CHILDREN,
+       VDEV_PROP_NUMCHILDREN,
+       VDEV_PROP_READ_ERRORS,
+       VDEV_PROP_WRITE_ERRORS,
+       VDEV_PROP_CHECKSUM_ERRORS,
+       VDEV_PROP_INITIALIZE_ERRORS,
+       VDEV_PROP_OPS_NULL,
+       VDEV_PROP_OPS_READ,
+       VDEV_PROP_OPS_WRITE,
+       VDEV_PROP_OPS_FREE,
+       VDEV_PROP_OPS_CLAIM,
+       VDEV_PROP_OPS_TRIM,
+       VDEV_PROP_BYTES_NULL,
+       VDEV_PROP_BYTES_READ,
+       VDEV_PROP_BYTES_WRITE,
+       VDEV_PROP_BYTES_FREE,
+       VDEV_PROP_BYTES_CLAIM,
+       VDEV_PROP_BYTES_TRIM,
+       VDEV_PROP_REMOVING,
+       VDEV_PROP_ALLOCATING,
+       VDEV_NUM_PROPS
+} vdev_prop_t;
+
 /*
  * Dataset property functions shared between libzfs and kernel.
  */
-const char *zfs_prop_default_string(zfs_prop_t);
-uint64_t zfs_prop_default_numeric(zfs_prop_t);
-boolean_t zfs_prop_readonly(zfs_prop_t);
-boolean_t zfs_prop_visible(zfs_prop_t prop);
-boolean_t zfs_prop_inheritable(zfs_prop_t);
-boolean_t zfs_prop_setonce(zfs_prop_t);
-boolean_t zfs_prop_encryption_key_param(zfs_prop_t);
-boolean_t zfs_prop_valid_keylocation(const char *, boolean_t);
-const char *zfs_prop_to_name(zfs_prop_t);
-zfs_prop_t zfs_name_to_prop(const char *);
-boolean_t zfs_prop_user(const char *);
-boolean_t zfs_prop_userquota(const char *);
-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);
+_SYS_FS_ZFS_H const char *zfs_prop_default_string(zfs_prop_t);
+_SYS_FS_ZFS_H uint64_t zfs_prop_default_numeric(zfs_prop_t);
+_SYS_FS_ZFS_H boolean_t zfs_prop_readonly(zfs_prop_t);
+_SYS_FS_ZFS_H boolean_t zfs_prop_visible(zfs_prop_t prop);
+_SYS_FS_ZFS_H boolean_t zfs_prop_inheritable(zfs_prop_t);
+_SYS_FS_ZFS_H boolean_t zfs_prop_setonce(zfs_prop_t);
+_SYS_FS_ZFS_H boolean_t zfs_prop_encryption_key_param(zfs_prop_t);
+_SYS_FS_ZFS_H boolean_t zfs_prop_valid_keylocation(const char *, boolean_t);
+_SYS_FS_ZFS_H const char *zfs_prop_to_name(zfs_prop_t);
+_SYS_FS_ZFS_H zfs_prop_t zfs_name_to_prop(const char *);
+_SYS_FS_ZFS_H boolean_t zfs_prop_user(const char *);
+_SYS_FS_ZFS_H boolean_t zfs_prop_userquota(const char *);
+_SYS_FS_ZFS_H boolean_t zfs_prop_written(const char *);
+_SYS_FS_ZFS_H int zfs_prop_index_to_string(zfs_prop_t, uint64_t, const char **);
+_SYS_FS_ZFS_H int zfs_prop_string_to_index(zfs_prop_t, const char *,
+    uint64_t *);
+_SYS_FS_ZFS_H uint64_t zfs_prop_random_value(zfs_prop_t, uint64_t seed);
+_SYS_FS_ZFS_H boolean_t zfs_prop_valid_for_type(int, zfs_type_t, boolean_t);
 
 /*
  * Pool property functions shared between libzfs and kernel.
  */
-zpool_prop_t zpool_name_to_prop(const char *);
-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_setonce(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);
+_SYS_FS_ZFS_H zpool_prop_t zpool_name_to_prop(const char *);
+_SYS_FS_ZFS_H const char *zpool_prop_to_name(zpool_prop_t);
+_SYS_FS_ZFS_H const char *zpool_prop_default_string(zpool_prop_t);
+_SYS_FS_ZFS_H uint64_t zpool_prop_default_numeric(zpool_prop_t);
+_SYS_FS_ZFS_H boolean_t zpool_prop_readonly(zpool_prop_t);
+_SYS_FS_ZFS_H boolean_t zpool_prop_setonce(zpool_prop_t);
+_SYS_FS_ZFS_H boolean_t zpool_prop_feature(const char *);
+_SYS_FS_ZFS_H boolean_t zpool_prop_unsupported(const char *);
+_SYS_FS_ZFS_H int zpool_prop_index_to_string(zpool_prop_t, uint64_t,
+    const char **);
+_SYS_FS_ZFS_H int zpool_prop_string_to_index(zpool_prop_t, const char *,
+    uint64_t *);
+_SYS_FS_ZFS_H uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
+
+/*
+ * VDEV property functions shared between libzfs and kernel.
+ */
+_SYS_FS_ZFS_H vdev_prop_t vdev_name_to_prop(const char *);
+_SYS_FS_ZFS_H boolean_t vdev_prop_user(const char *name);
+_SYS_FS_ZFS_H const char *vdev_prop_to_name(vdev_prop_t);
+_SYS_FS_ZFS_H const char *vdev_prop_default_string(vdev_prop_t);
+_SYS_FS_ZFS_H uint64_t vdev_prop_default_numeric(vdev_prop_t);
+_SYS_FS_ZFS_H boolean_t vdev_prop_readonly(vdev_prop_t prop);
+_SYS_FS_ZFS_H int vdev_prop_index_to_string(vdev_prop_t, uint64_t,
+    const char **);
+_SYS_FS_ZFS_H int vdev_prop_string_to_index(vdev_prop_t, const char *,
+    uint64_t *);
+_SYS_FS_ZFS_H boolean_t zpool_prop_vdev(const char *name);
+_SYS_FS_ZFS_H uint64_t vdev_prop_random_value(vdev_prop_t prop, uint64_t seed);
 
 /*
  * Definitions for the Delegation.
@@ -617,6 +695,7 @@ typedef struct zpool_load_policy {
 #define        ZPOOL_CONFIG_PREV_INDIRECT_VDEV "com.delphix:prev_indirect_vdev"
 #define        ZPOOL_CONFIG_PATH               "path"
 #define        ZPOOL_CONFIG_DEVID              "devid"
+#define        ZPOOL_CONFIG_SPARE_ID           "spareid"
 #define        ZPOOL_CONFIG_METASLAB_ARRAY     "metaslab_array"
 #define        ZPOOL_CONFIG_METASLAB_SHIFT     "metaslab_shift"
 #define        ZPOOL_CONFIG_ASHIFT             "ashift"
@@ -638,6 +717,7 @@ typedef struct zpool_load_policy {
 #define        ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE  "vdev_async_w_active_queue"
 #define        ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE    "vdev_async_scrub_active_queue"
 #define        ZPOOL_CONFIG_VDEV_TRIM_ACTIVE_QUEUE     "vdev_async_trim_active_queue"
+#define        ZPOOL_CONFIG_VDEV_REBUILD_ACTIVE_QUEUE  "vdev_rebuild_active_queue"
 
 /* Queue sizes */
 #define        ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE     "vdev_sync_r_pend_queue"
@@ -646,6 +726,7 @@ typedef struct zpool_load_policy {
 #define        ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE    "vdev_async_w_pend_queue"
 #define        ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE      "vdev_async_scrub_pend_queue"
 #define        ZPOOL_CONFIG_VDEV_TRIM_PEND_QUEUE       "vdev_async_trim_pend_queue"
+#define        ZPOOL_CONFIG_VDEV_REBUILD_PEND_QUEUE    "vdev_rebuild_pend_queue"
 
 /* Latency read/write histogram stats */
 #define        ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO       "vdev_tot_r_lat_histo"
@@ -658,6 +739,7 @@ typedef struct zpool_load_policy {
 #define        ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO     "vdev_async_w_lat_histo"
 #define        ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO       "vdev_scrub_histo"
 #define        ZPOOL_CONFIG_VDEV_TRIM_LAT_HISTO        "vdev_trim_histo"
+#define        ZPOOL_CONFIG_VDEV_REBUILD_LAT_HISTO     "vdev_rebuild_histo"
 
 /* Request size histograms */
 #define        ZPOOL_CONFIG_VDEV_SYNC_IND_R_HISTO      "vdev_sync_ind_r_histo"
@@ -666,12 +748,14 @@ typedef struct zpool_load_policy {
 #define        ZPOOL_CONFIG_VDEV_ASYNC_IND_W_HISTO     "vdev_async_ind_w_histo"
 #define        ZPOOL_CONFIG_VDEV_IND_SCRUB_HISTO       "vdev_ind_scrub_histo"
 #define        ZPOOL_CONFIG_VDEV_IND_TRIM_HISTO        "vdev_ind_trim_histo"
+#define        ZPOOL_CONFIG_VDEV_IND_REBUILD_HISTO     "vdev_ind_rebuild_histo"
 #define        ZPOOL_CONFIG_VDEV_SYNC_AGG_R_HISTO      "vdev_sync_agg_r_histo"
 #define        ZPOOL_CONFIG_VDEV_SYNC_AGG_W_HISTO      "vdev_sync_agg_w_histo"
 #define        ZPOOL_CONFIG_VDEV_ASYNC_AGG_R_HISTO     "vdev_async_agg_r_histo"
 #define        ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO     "vdev_async_agg_w_histo"
 #define        ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO       "vdev_agg_scrub_histo"
 #define        ZPOOL_CONFIG_VDEV_AGG_TRIM_HISTO        "vdev_agg_trim_histo"
+#define        ZPOOL_CONFIG_VDEV_AGG_REBUILD_HISTO     "vdev_agg_rebuild_histo"
 
 /* Number of slow IOs */
 #define        ZPOOL_CONFIG_VDEV_SLOW_IOS              "vdev_slow_ios"
@@ -702,6 +786,7 @@ typedef struct zpool_load_policy {
 #define        ZPOOL_CONFIG_ORIG_GUID          "orig_guid"
 #define        ZPOOL_CONFIG_SPLIT_GUID         "split_guid"
 #define        ZPOOL_CONFIG_SPLIT_LIST         "guid_list"
+#define        ZPOOL_CONFIG_NONALLOCATING      "non_allocating"
 #define        ZPOOL_CONFIG_REMOVING           "removing"
 #define        ZPOOL_CONFIG_RESILVER_TXG       "resilver_txg"
 #define        ZPOOL_CONFIG_REBUILD_TXG        "rebuild_txg"
@@ -732,6 +817,7 @@ typedef struct zpool_load_policy {
 #define        ZPOOL_CONFIG_ALLOCATION_BIAS    "alloc_bias"    /* not stored on disk */
 #define        ZPOOL_CONFIG_EXPANSION_TIME     "expansion_time"        /* not stored */
 #define        ZPOOL_CONFIG_REBUILD_STATS      "org.openzfs:rebuild_stats"
+#define        ZPOOL_CONFIG_COMPATIBILITY      "compatibility"
 
 /*
  * The persistent vdev state is stored as separate values rather than a single
@@ -754,13 +840,21 @@ typedef struct zpool_load_policy {
 
 /* Rewind data discovered */
 #define        ZPOOL_CONFIG_LOAD_TIME          "rewind_txg_ts"
+#define        ZPOOL_CONFIG_LOAD_META_ERRORS   "verify_meta_errors"
 #define        ZPOOL_CONFIG_LOAD_DATA_ERRORS   "verify_data_errors"
 #define        ZPOOL_CONFIG_REWIND_TIME        "seconds_of_rewind"
 
+/* dRAID configuration */
+#define        ZPOOL_CONFIG_DRAID_NDATA        "draid_ndata"
+#define        ZPOOL_CONFIG_DRAID_NSPARES      "draid_nspares"
+#define        ZPOOL_CONFIG_DRAID_NGROUPS      "draid_ngroups"
+
 #define        VDEV_TYPE_ROOT                  "root"
 #define        VDEV_TYPE_MIRROR                "mirror"
 #define        VDEV_TYPE_REPLACING             "replacing"
 #define        VDEV_TYPE_RAIDZ                 "raidz"
+#define        VDEV_TYPE_DRAID                 "draid"
+#define        VDEV_TYPE_DRAID_SPARE           "dspare"
 #define        VDEV_TYPE_DISK                  "disk"
 #define        VDEV_TYPE_FILE                  "file"
 #define        VDEV_TYPE_MISSING               "missing"
@@ -770,6 +864,12 @@ typedef struct zpool_load_policy {
 #define        VDEV_TYPE_L2CACHE               "l2cache"
 #define        VDEV_TYPE_INDIRECT              "indirect"
 
+#define        VDEV_RAIDZ_MAXPARITY            3
+
+#define        VDEV_DRAID_MAXPARITY            3
+#define        VDEV_DRAID_MIN_CHILDREN         2
+#define        VDEV_DRAID_MAX_CHILDREN         UINT8_MAX
+
 /* VDEV_TOP_ZAP_* are used in top-level vdev ZAP objects. */
 #define        VDEV_TOP_ZAP_INDIRECT_OBSOLETE_SM \
        "com.delphix:indirect_obsolete_sm"
@@ -829,7 +929,20 @@ typedef struct zpool_load_policy {
  * The location of the pool configuration repository, shared between kernel and
  * userland.
  */
+#define        ZPOOL_CACHE_BOOT        "/boot/zfs/zpool.cache"
 #define        ZPOOL_CACHE             "/etc/zfs/zpool.cache"
+/*
+ * Settings for zpool compatibility features files
+ */
+#define        ZPOOL_SYSCONF_COMPAT_D  SYSCONFDIR "/zfs/compatibility.d"
+#define        ZPOOL_DATA_COMPAT_D     PKGDATADIR "/compatibility.d"
+#define        ZPOOL_COMPAT_MAXSIZE    16384
+
+/*
+ * Hard-wired compatibility settings
+ */
+#define        ZPOOL_COMPAT_LEGACY     "legacy"
+#define        ZPOOL_COMPAT_OFF        "off"
 
 /*
  * vdev states are ordered from least to most healthy.
@@ -873,6 +986,7 @@ typedef enum vdev_aux {
        VDEV_AUX_EXTERNAL_PERSIST,      /* persistent forced fault      */
        VDEV_AUX_ACTIVE,        /* vdev active on a different host      */
        VDEV_AUX_CHILDREN_OFFLINE, /* all children are offline          */
+       VDEV_AUX_ASHIFT_TOO_BIG, /* vdev's min block size is too large   */
 } vdev_aux_t;
 
 /*
@@ -1012,10 +1126,10 @@ typedef struct vdev_rebuild_stat {
 } vdev_rebuild_stat_t;
 
 /*
- * Errata described by https://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.
+ * Errata described by https://openzfs.github.io/openzfs-docs/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,
@@ -1068,8 +1182,17 @@ typedef struct vdev_stat {
        uint64_t        vs_trim_state;          /* vdev_trim_state_t */
        uint64_t        vs_trim_action_time;    /* time_t */
        uint64_t        vs_rebuild_processed;   /* bytes rebuilt */
+       uint64_t        vs_configured_ashift;   /* TLV vdev_ashift */
+       uint64_t        vs_logical_ashift;      /* vdev_logical_ashift  */
+       uint64_t        vs_physical_ashift;     /* vdev_physical_ashift */
+       uint64_t        vs_noalloc;             /* allocations halted?  */
+       uint64_t        vs_pspace;              /* physical capacity */
 } vdev_stat_t;
 
+#define        VDEV_STAT_VALID(field, uint64_t_field_count) \
+((uint64_t_field_count * sizeof (uint64_t)) >=  \
+       (offsetof(vdev_stat_t, field) + sizeof (((vdev_stat_t *)NULL)->field)))
+
 /*
  * Extended stats
  *
@@ -1170,10 +1293,13 @@ typedef struct ddt_histogram {
 #define        ZVOL_DRIVER     "zvol"
 #define        ZFS_DRIVER      "zfs"
 #define        ZFS_DEV         "/dev/zfs"
-#define        ZFS_SHARETAB    "/etc/dfs/sharetab"
+#define        ZFS_DEVDIR      "/dev"
 
 #define        ZFS_SUPER_MAGIC 0x2fc12fc1
 
+/* general zvol path */
+#define        ZVOL_DIR                "/dev/zvol/"
+
 #define        ZVOL_MAJOR              230
 #define        ZVOL_MINOR_BITS         4
 #define        ZVOL_MINOR_MASK         ((1U << ZVOL_MINOR_BITS) - 1)
@@ -1181,7 +1307,7 @@ typedef struct ddt_histogram {
 #define        ZVOL_DEV_NAME           "zd"
 
 #define        ZVOL_PROP_NAME          "name"
-#define        ZVOL_DEFAULT_BLOCKSIZE  8192
+#define        ZVOL_DEFAULT_BLOCKSIZE  16384
 
 typedef enum {
        VDEV_INITIALIZE_NONE,
@@ -1313,6 +1439,8 @@ typedef enum zfs_ioc {
        ZFS_IOC_GET_BOOKMARK_PROPS,             /* 0x5a52 */
        ZFS_IOC_WAIT,                           /* 0x5a53 */
        ZFS_IOC_WAIT_FS,                        /* 0x5a54 */
+       ZFS_IOC_VDEV_GET_PROPS,                 /* 0x5a55 */
+       ZFS_IOC_VDEV_SET_PROPS,                 /* 0x5a56 */
 
        /*
         * Per-platform (Optional) - 8/128 numbers reserved.
@@ -1323,9 +1451,11 @@ typedef enum zfs_ioc {
        ZFS_IOC_EVENTS_SEEK,                    /* 0x83 (Linux) */
        ZFS_IOC_NEXTBOOT,                       /* 0x84 (FreeBSD) */
        ZFS_IOC_JAIL,                           /* 0x85 (FreeBSD) */
+       ZFS_IOC_USERNS_ATTACH = ZFS_IOC_JAIL,   /* 0x85 (Linux) */
        ZFS_IOC_UNJAIL,                         /* 0x86 (FreeBSD) */
-       ZFS_IOC_SET_BOOTENV,                    /* 0x87 (Linux) */
-       ZFS_IOC_GET_BOOTENV,                    /* 0x88 (Linux) */
+       ZFS_IOC_USERNS_DETACH = ZFS_IOC_UNJAIL, /* 0x86 (Linux) */
+       ZFS_IOC_SET_BOOTENV,                    /* 0x87 */
+       ZFS_IOC_GET_BOOTENV,                    /* 0x88 */
        ZFS_IOC_LAST
 } zfs_ioc_t;
 
@@ -1334,6 +1464,41 @@ typedef enum zfs_ioc {
  */
 #define        BLKZNAME                _IOR(0x12, 125, char[ZFS_MAX_DATASET_NAME_LEN])
 
+#ifdef __linux__
+
+/*
+ * IOCTLs to update and retrieve additional file level attributes on
+ * Linux.
+ */
+#define        ZFS_IOC_GETDOSFLAGS     _IOR(0x83, 1, uint64_t)
+#define        ZFS_IOC_SETDOSFLAGS     _IOW(0x83, 2, uint64_t)
+
+/*
+ * Additional file level attributes, that are stored
+ * in the upper half of z_pflags
+ */
+#define        ZFS_READONLY            0x0000000100000000ull
+#define        ZFS_HIDDEN              0x0000000200000000ull
+#define        ZFS_SYSTEM              0x0000000400000000ull
+#define        ZFS_ARCHIVE             0x0000000800000000ull
+#define        ZFS_IMMUTABLE           0x0000001000000000ull
+#define        ZFS_NOUNLINK            0x0000002000000000ull
+#define        ZFS_APPENDONLY          0x0000004000000000ull
+#define        ZFS_NODUMP              0x0000008000000000ull
+#define        ZFS_OPAQUE              0x0000010000000000ull
+#define        ZFS_AV_QUARANTINED      0x0000020000000000ull
+#define        ZFS_AV_MODIFIED         0x0000040000000000ull
+#define        ZFS_REPARSE             0x0000080000000000ull
+#define        ZFS_OFFLINE             0x0000100000000000ull
+#define        ZFS_SPARSE              0x0000200000000000ull
+
+#define        ZFS_DOS_FL_USER_VISIBLE (ZFS_IMMUTABLE | ZFS_APPENDONLY | \
+           ZFS_NOUNLINK | ZFS_ARCHIVE | ZFS_NODUMP | ZFS_SYSTEM | \
+           ZFS_HIDDEN | ZFS_READONLY | ZFS_REPARSE | ZFS_OFFLINE | \
+           ZFS_SPARSE)
+
+#endif
+
 /*
  * ZFS-specific error codes used for returning descriptive errors
  * to the userland through zfs ioctls.
@@ -1367,6 +1532,9 @@ typedef enum {
        ZFS_ERR_STREAM_LARGE_BLOCK_MISMATCH,
        ZFS_ERR_RESILVER_IN_PROGRESS,
        ZFS_ERR_REBUILD_IN_PROGRESS,
+       ZFS_ERR_BADPROP,
+       ZFS_ERR_VDEV_NOTSUP,
+       ZFS_ERR_NOT_USER_NAMESPACE,
 } zfs_errno_t;
 
 /*
@@ -1425,9 +1593,11 @@ typedef enum {
 #define        ZPOOL_HIST_IOCTL        "ioctl"
 #define        ZPOOL_HIST_INPUT_NVL    "in_nvl"
 #define        ZPOOL_HIST_OUTPUT_NVL   "out_nvl"
+#define        ZPOOL_HIST_OUTPUT_SIZE  "out_size"
 #define        ZPOOL_HIST_DSNAME       "dsname"
 #define        ZPOOL_HIST_DSID         "dsid"
 #define        ZPOOL_HIST_ERRNO        "errno"
+#define        ZPOOL_HIST_ELAPSED_NS   "elapsed_ns"
 
 /*
  * Special nvlist name that will not have its args recorded in the pool's
@@ -1456,6 +1626,18 @@ typedef enum {
 #define        ZPOOL_WAIT_TAG                  "wait_tag"
 #define        ZPOOL_WAIT_WAITED               "wait_waited"
 
+/*
+ * The following are names used when invoking ZFS_IOC_VDEV_GET_PROP.
+ */
+#define        ZPOOL_VDEV_PROPS_GET_VDEV       "vdevprops_get_vdev"
+#define        ZPOOL_VDEV_PROPS_GET_PROPS      "vdevprops_get_props"
+
+/*
+ * The following are names used when invoking ZFS_IOC_VDEV_SET_PROP.
+ */
+#define        ZPOOL_VDEV_PROPS_SET_VDEV       "vdevprops_set_vdev"
+#define        ZPOOL_VDEV_PROPS_SET_PROPS      "vdevprops_set_props"
+
 /*
  * The following are names used when invoking ZFS_IOC_WAIT_FS.
  */
@@ -1569,6 +1751,73 @@ typedef enum {
 #define        ZFS_EV_HIST_DSID        "history_dsid"
 #define        ZFS_EV_RESILVER_TYPE    "resilver_type"
 
+/*
+ * We currently support block sizes from 512 bytes to 16MB.
+ * The benefits of larger blocks, and thus larger IO, need to be weighed
+ * against the cost of COWing a giant block to modify one byte, and the
+ * large latency of reading or writing a large block.
+ *
+ * Note that although blocks up to 16MB are supported, the recordsize
+ * property can not be set larger than zfs_max_recordsize (default 1MB).
+ * See the comment near zfs_max_recordsize in dsl_dataset.c for details.
+ *
+ * Note that although the LSIZE field of the blkptr_t can store sizes up
+ * to 32MB, the dnode's dn_datablkszsec can only store sizes up to
+ * 32MB - 512 bytes.  Therefore, we limit SPA_MAXBLOCKSIZE to 16MB.
+ */
+#define        SPA_MINBLOCKSHIFT       9
+#define        SPA_OLD_MAXBLOCKSHIFT   17
+#define        SPA_MAXBLOCKSHIFT       24
+#define        SPA_MINBLOCKSIZE        (1ULL << SPA_MINBLOCKSHIFT)
+#define        SPA_OLD_MAXBLOCKSIZE    (1ULL << SPA_OLD_MAXBLOCKSHIFT)
+#define        SPA_MAXBLOCKSIZE        (1ULL << SPA_MAXBLOCKSHIFT)
+
+/* supported encryption algorithms */
+enum zio_encrypt {
+       ZIO_CRYPT_INHERIT = 0,
+       ZIO_CRYPT_ON,
+       ZIO_CRYPT_OFF,
+       ZIO_CRYPT_AES_128_CCM,
+       ZIO_CRYPT_AES_192_CCM,
+       ZIO_CRYPT_AES_256_CCM,
+       ZIO_CRYPT_AES_128_GCM,
+       ZIO_CRYPT_AES_192_GCM,
+       ZIO_CRYPT_AES_256_GCM,
+       ZIO_CRYPT_FUNCTIONS
+};
+
+#define        ZIO_CRYPT_ON_VALUE      ZIO_CRYPT_AES_256_GCM
+#define        ZIO_CRYPT_DEFAULT       ZIO_CRYPT_OFF
+
+/*
+ * xattr namespace prefixes.  These are forbidden in xattr names.
+ *
+ * For cross-platform compatibility, xattrs in the user namespace should not be
+ * prefixed with the namespace name, but for backwards compatibility with older
+ * ZFS on Linux versions we do prefix the namespace.
+ */
+#define        ZFS_XA_NS_FREEBSD_PREFIX                "freebsd:"
+#define        ZFS_XA_NS_FREEBSD_PREFIX_LEN            strlen("freebsd:")
+#define        ZFS_XA_NS_LINUX_SECURITY_PREFIX         "security."
+#define        ZFS_XA_NS_LINUX_SECURITY_PREFIX_LEN     strlen("security.")
+#define        ZFS_XA_NS_LINUX_SYSTEM_PREFIX           "system."
+#define        ZFS_XA_NS_LINUX_SYSTEM_PREFIX_LEN       strlen("system.")
+#define        ZFS_XA_NS_LINUX_TRUSTED_PREFIX          "trusted."
+#define        ZFS_XA_NS_LINUX_TRUSTED_PREFIX_LEN      strlen("trusted.")
+#define        ZFS_XA_NS_LINUX_USER_PREFIX             "user."
+#define        ZFS_XA_NS_LINUX_USER_PREFIX_LEN         strlen("user.")
+
+#define        ZFS_XA_NS_PREFIX_MATCH(ns, name) \
+       (strncmp(name, ZFS_XA_NS_##ns##_PREFIX, \
+       ZFS_XA_NS_##ns##_PREFIX_LEN) == 0)
+
+#define        ZFS_XA_NS_PREFIX_FORBIDDEN(name) \
+       (ZFS_XA_NS_PREFIX_MATCH(FREEBSD, name) || \
+           ZFS_XA_NS_PREFIX_MATCH(LINUX_SECURITY, name) || \
+           ZFS_XA_NS_PREFIX_MATCH(LINUX_SYSTEM, name) || \
+           ZFS_XA_NS_PREFIX_MATCH(LINUX_TRUSTED, name) || \
+           ZFS_XA_NS_PREFIX_MATCH(LINUX_USER, name))
+
 #ifdef __cplusplus
 }
 #endif