]> git.proxmox.com Git - mirror_zfs.git/blobdiff - include/sys/fs/zfs.h
OpenZFS 9102 - zfs should be able to initialize storage devices
[mirror_zfs.git] / include / sys / fs / zfs.h
index 76e61eb0762084c328eef5c4ffab92429b9054b7..945853739b7cb70954f36bd1cc5657a2dcacaf70 100644 (file)
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2013, 2017 Joyent, Inc. All rights reserved.
  * Copyright (c) 2014 Integros [integros.com]
  * Copyright (c) 2017 Datto Inc.
+ * Copyright (c) 2017, Intel Corporation.
  */
 
 /* Portions Copyright 2010 Robert Milkowski */
@@ -145,7 +146,7 @@ typedef enum {
        ZFS_PROP_USERREFS,
        ZFS_PROP_LOGBIAS,
        ZFS_PROP_UNIQUE,                /* not exposed to the user */
-       ZFS_PROP_OBJSETID,              /* not exposed to the user */
+       ZFS_PROP_OBJSETID,
        ZFS_PROP_DEDUP,
        ZFS_PROP_MLSLABEL,
        ZFS_PROP_SYNC,
@@ -181,6 +182,7 @@ typedef enum {
        ZFS_PROP_KEY_GUID,
        ZFS_PROP_KEYSTATUS,
        ZFS_PROP_REMAPTXG,              /* not exposed to the user */
+       ZFS_PROP_SPECIAL_SMALL_BLOCKS,
        ZFS_NUM_PROPS
 } zfs_prop_t;
 
@@ -240,6 +242,7 @@ typedef enum {
        ZPOOL_PROP_MAXDNODESIZE,
        ZPOOL_PROP_MULTIHOST,
        ZPOOL_PROP_CHECKPOINT,
+       ZPOOL_PROP_LOAD_GUID,
        ZPOOL_NUM_PROPS
 } zpool_prop_t;
 
@@ -662,6 +665,9 @@ typedef struct zpool_load_policy {
 #define        ZPOOL_CONFIG_VDEV_ASYNC_AGG_W_HISTO     "vdev_async_agg_w_histo"
 #define        ZPOOL_CONFIG_VDEV_AGG_SCRUB_HISTO       "vdev_agg_scrub_histo"
 
+/* Number of slow IOs */
+#define        ZPOOL_CONFIG_VDEV_SLOW_IOS              "vdev_slow_ios"
+
 /* vdev enclosure sysfs path */
 #define        ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH        "vdev_enc_sysfs_path"
 
@@ -707,11 +713,14 @@ typedef struct zpool_load_policy {
 #define        ZPOOL_CONFIG_VDEV_TOP_ZAP       "com.delphix:vdev_zap_top"
 #define        ZPOOL_CONFIG_VDEV_LEAF_ZAP      "com.delphix:vdev_zap_leaf"
 #define        ZPOOL_CONFIG_HAS_PER_VDEV_ZAPS  "com.delphix:has_per_vdev_zaps"
+#define        ZPOOL_CONFIG_RESILVER_DEFER     "com.datto:resilver_defer"
 #define        ZPOOL_CONFIG_CACHEFILE          "cachefile"     /* not stored on disk */
 #define        ZPOOL_CONFIG_MMP_STATE          "mmp_state"     /* not stored on disk */
 #define        ZPOOL_CONFIG_MMP_TXG            "mmp_txg"       /* not stored on disk */
 #define        ZPOOL_CONFIG_MMP_HOSTNAME       "mmp_hostname"  /* not stored on disk */
 #define        ZPOOL_CONFIG_MMP_HOSTID         "mmp_hostid"    /* not stored on disk */
+#define        ZPOOL_CONFIG_ALLOCATION_BIAS    "alloc_bias"    /* not stored on disk */
+#define        ZPOOL_CONFIG_EXPANSION_TIME     "expansion_time"        /* not stored */
 
 /*
  * The persistent vdev state is stored as separate values rather than a single
@@ -758,6 +767,21 @@ typedef struct zpool_load_policy {
 #define        VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \
        "com.delphix:pool_checkpoint_sm"
 
+#define        VDEV_TOP_ZAP_ALLOCATION_BIAS \
+       "org.zfsonlinux:allocation_bias"
+
+/* vdev metaslab allocation bias */
+#define        VDEV_ALLOC_BIAS_LOG             "log"
+#define        VDEV_ALLOC_BIAS_SPECIAL         "special"
+#define        VDEV_ALLOC_BIAS_DEDUP           "dedup"
+
+#define        VDEV_LEAF_ZAP_INITIALIZE_LAST_OFFSET    \
+       "com.delphix:next_offset_to_initialize"
+#define        VDEV_LEAF_ZAP_INITIALIZE_STATE  \
+       "com.delphix:vdev_initialize_state"
+#define        VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME    \
+       "com.delphix:vdev_initialize_action_time"
+
 /*
  * This is needed in userland to report the minimum necessary device size.
  */
@@ -971,11 +995,18 @@ typedef struct vdev_stat {
        uint64_t        vs_read_errors;         /* read errors          */
        uint64_t        vs_write_errors;        /* write errors         */
        uint64_t        vs_checksum_errors;     /* checksum errors      */
+       uint64_t        vs_initialize_errors;   /* initializing errors  */
        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 */
+       uint64_t        vs_initialize_bytes_done; /* bytes initialized */
+       uint64_t        vs_initialize_bytes_est; /* total bytes to initialize */
+       uint64_t        vs_initialize_state;    /* vdev_initialzing_state_t */
+       uint64_t        vs_initialize_action_time; /* time_t */
        uint64_t        vs_checkpoint_space;    /* checkpoint-consumed space */
+       uint64_t        vs_resilver_deferred;   /* resilver deferred    */
+       uint64_t        vs_slow_ios;            /* slow IOs */
 } vdev_stat_t;
 
 /*
@@ -1004,7 +1035,6 @@ typedef struct vdev_stat_ex {
 #define        VDEV_L_HISTO_BUCKETS 37         /* Latency histo buckets */
 #define        VDEV_RQ_HISTO_BUCKETS 25        /* Request size histo buckets */
 
-
        /* Amount of time in ZIO queue (ns) */
        uint64_t vsx_queue_histo[ZIO_PRIORITY_NUM_QUEUEABLE]
            [VDEV_L_HISTO_BUCKETS];
@@ -1031,6 +1061,16 @@ typedef struct vdev_stat_ex {
 
 } vdev_stat_ex_t;
 
+/*
+ * Initialize functions.
+ */
+typedef enum pool_initialize_func {
+       POOL_INITIALIZE_DO,
+       POOL_INITIALIZE_CANCEL,
+       POOL_INITIALIZE_SUSPEND,
+       POOL_INITIALIZE_FUNCS
+} pool_initialize_func_t;
+
 /*
  * DDT statistics.  Note: all fields should be 64-bit because this
  * is passed between kernel and userland as an nvlist uint64 array.
@@ -1075,8 +1115,18 @@ typedef struct ddt_histogram {
 #define        ZVOL_PROP_NAME          "name"
 #define        ZVOL_DEFAULT_BLOCKSIZE  8192
 
+typedef enum {
+       VDEV_INITIALIZE_NONE,
+       VDEV_INITIALIZE_ACTIVE,
+       VDEV_INITIALIZE_CANCELED,
+       VDEV_INITIALIZE_SUSPENDED,
+       VDEV_INITIALIZE_COMPLETE
+} vdev_initializing_state_t;
+
 /*
  * /dev/zfs ioctl numbers.
+ *
+ * These numbers cannot change over time. New ioctl numbers must be appended.
  */
 typedef enum zfs_ioc {
        /*
@@ -1084,93 +1134,94 @@ typedef enum zfs_ioc {
         */
        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,
-       ZFS_IOC_POOL_CONFIGS,
-       ZFS_IOC_POOL_STATS,
-       ZFS_IOC_POOL_TRYIMPORT,
-       ZFS_IOC_POOL_SCAN,
-       ZFS_IOC_POOL_FREEZE,
-       ZFS_IOC_POOL_UPGRADE,
-       ZFS_IOC_POOL_GET_HISTORY,
-       ZFS_IOC_VDEV_ADD,
-       ZFS_IOC_VDEV_REMOVE,
-       ZFS_IOC_VDEV_SET_STATE,
-       ZFS_IOC_VDEV_ATTACH,
-       ZFS_IOC_VDEV_DETACH,
-       ZFS_IOC_VDEV_SETPATH,
-       ZFS_IOC_VDEV_SETFRU,
-       ZFS_IOC_OBJSET_STATS,
-       ZFS_IOC_OBJSET_ZPLPROPS,
-       ZFS_IOC_DATASET_LIST_NEXT,
-       ZFS_IOC_SNAPSHOT_LIST_NEXT,
-       ZFS_IOC_SET_PROP,
-       ZFS_IOC_CREATE,
-       ZFS_IOC_DESTROY,
-       ZFS_IOC_ROLLBACK,
-       ZFS_IOC_RENAME,
-       ZFS_IOC_RECV,
-       ZFS_IOC_SEND,
-       ZFS_IOC_INJECT_FAULT,
-       ZFS_IOC_CLEAR_FAULT,
-       ZFS_IOC_INJECT_LIST_NEXT,
-       ZFS_IOC_ERROR_LOG,
-       ZFS_IOC_CLEAR,
-       ZFS_IOC_PROMOTE,
-       ZFS_IOC_SNAPSHOT,
-       ZFS_IOC_DSOBJ_TO_DSNAME,
-       ZFS_IOC_OBJ_TO_PATH,
-       ZFS_IOC_POOL_SET_PROPS,
-       ZFS_IOC_POOL_GET_PROPS,
-       ZFS_IOC_SET_FSACL,
-       ZFS_IOC_GET_FSACL,
-       ZFS_IOC_SHARE,
-       ZFS_IOC_INHERIT_PROP,
-       ZFS_IOC_SMB_ACL,
-       ZFS_IOC_USERSPACE_ONE,
-       ZFS_IOC_USERSPACE_MANY,
-       ZFS_IOC_USERSPACE_UPGRADE,
-       ZFS_IOC_HOLD,
-       ZFS_IOC_RELEASE,
-       ZFS_IOC_GET_HOLDS,
-       ZFS_IOC_OBJSET_RECVD_PROPS,
-       ZFS_IOC_VDEV_SPLIT,
-       ZFS_IOC_NEXT_OBJ,
-       ZFS_IOC_DIFF,
-       ZFS_IOC_TMP_SNAPSHOT,
-       ZFS_IOC_OBJ_TO_STATS,
-       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,
-       ZFS_IOC_CHANNEL_PROGRAM,
-       ZFS_IOC_RECV_NEW,
-       ZFS_IOC_POOL_SYNC,
-       ZFS_IOC_LOAD_KEY,
-       ZFS_IOC_UNLOAD_KEY,
-       ZFS_IOC_CHANGE_KEY,
-       ZFS_IOC_REMAP,
-       ZFS_IOC_POOL_CHECKPOINT,
-       ZFS_IOC_POOL_DISCARD_CHECKPOINT,
+       ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,    /* 0x5a00 */
+       ZFS_IOC_POOL_DESTROY,                   /* 0x5a01 */
+       ZFS_IOC_POOL_IMPORT,                    /* 0x5a02 */
+       ZFS_IOC_POOL_EXPORT,                    /* 0x5a03 */
+       ZFS_IOC_POOL_CONFIGS,                   /* 0x5a04 */
+       ZFS_IOC_POOL_STATS,                     /* 0x5a05 */
+       ZFS_IOC_POOL_TRYIMPORT,                 /* 0x5a06 */
+       ZFS_IOC_POOL_SCAN,                      /* 0x5a07 */
+       ZFS_IOC_POOL_FREEZE,                    /* 0x5a08 */
+       ZFS_IOC_POOL_UPGRADE,                   /* 0x5a09 */
+       ZFS_IOC_POOL_GET_HISTORY,               /* 0x5a0a */
+       ZFS_IOC_VDEV_ADD,                       /* 0x5a0b */
+       ZFS_IOC_VDEV_REMOVE,                    /* 0x5a0c */
+       ZFS_IOC_VDEV_SET_STATE,                 /* 0x5a0d */
+       ZFS_IOC_VDEV_ATTACH,                    /* 0x5a0e */
+       ZFS_IOC_VDEV_DETACH,                    /* 0x5a0f */
+       ZFS_IOC_VDEV_SETPATH,                   /* 0x5a10 */
+       ZFS_IOC_VDEV_SETFRU,                    /* 0x5a11 */
+       ZFS_IOC_OBJSET_STATS,                   /* 0x5a12 */
+       ZFS_IOC_OBJSET_ZPLPROPS,                /* 0x5a13 */
+       ZFS_IOC_DATASET_LIST_NEXT,              /* 0x5a14 */
+       ZFS_IOC_SNAPSHOT_LIST_NEXT,             /* 0x5a15 */
+       ZFS_IOC_SET_PROP,                       /* 0x5a16 */
+       ZFS_IOC_CREATE,                         /* 0x5a17 */
+       ZFS_IOC_DESTROY,                        /* 0x5a18 */
+       ZFS_IOC_ROLLBACK,                       /* 0x5a19 */
+       ZFS_IOC_RENAME,                         /* 0x5a1a */
+       ZFS_IOC_RECV,                           /* 0x5a1b */
+       ZFS_IOC_SEND,                           /* 0x5a1c */
+       ZFS_IOC_INJECT_FAULT,                   /* 0x5a1d */
+       ZFS_IOC_CLEAR_FAULT,                    /* 0x5a1e */
+       ZFS_IOC_INJECT_LIST_NEXT,               /* 0x5a1f */
+       ZFS_IOC_ERROR_LOG,                      /* 0x5a20 */
+       ZFS_IOC_CLEAR,                          /* 0x5a21 */
+       ZFS_IOC_PROMOTE,                        /* 0x5a22 */
+       ZFS_IOC_SNAPSHOT,                       /* 0x5a23 */
+       ZFS_IOC_DSOBJ_TO_DSNAME,                /* 0x5a24 */
+       ZFS_IOC_OBJ_TO_PATH,                    /* 0x5a25 */
+       ZFS_IOC_POOL_SET_PROPS,                 /* 0x5a26 */
+       ZFS_IOC_POOL_GET_PROPS,                 /* 0x5a27 */
+       ZFS_IOC_SET_FSACL,                      /* 0x5a28 */
+       ZFS_IOC_GET_FSACL,                      /* 0x5a29 */
+       ZFS_IOC_SHARE,                          /* 0x5a2a */
+       ZFS_IOC_INHERIT_PROP,                   /* 0x5a2b */
+       ZFS_IOC_SMB_ACL,                        /* 0x5a2c */
+       ZFS_IOC_USERSPACE_ONE,                  /* 0x5a2d */
+       ZFS_IOC_USERSPACE_MANY,                 /* 0x5a2e */
+       ZFS_IOC_USERSPACE_UPGRADE,              /* 0x5a2f */
+       ZFS_IOC_HOLD,                           /* 0x5a30 */
+       ZFS_IOC_RELEASE,                        /* 0x5a31 */
+       ZFS_IOC_GET_HOLDS,                      /* 0x5a32 */
+       ZFS_IOC_OBJSET_RECVD_PROPS,             /* 0x5a33 */
+       ZFS_IOC_VDEV_SPLIT,                     /* 0x5a34 */
+       ZFS_IOC_NEXT_OBJ,                       /* 0x5a35 */
+       ZFS_IOC_DIFF,                           /* 0x5a36 */
+       ZFS_IOC_TMP_SNAPSHOT,                   /* 0x5a37 */
+       ZFS_IOC_OBJ_TO_STATS,                   /* 0x5a38 */
+       ZFS_IOC_SPACE_WRITTEN,                  /* 0x5a39 */
+       ZFS_IOC_SPACE_SNAPS,                    /* 0x5a3a */
+       ZFS_IOC_DESTROY_SNAPS,                  /* 0x5a3b */
+       ZFS_IOC_POOL_REGUID,                    /* 0x5a3c */
+       ZFS_IOC_POOL_REOPEN,                    /* 0x5a3d */
+       ZFS_IOC_SEND_PROGRESS,                  /* 0x5a3e */
+       ZFS_IOC_LOG_HISTORY,                    /* 0x5a3f */
+       ZFS_IOC_SEND_NEW,                       /* 0x5a40 */
+       ZFS_IOC_SEND_SPACE,                     /* 0x5a41 */
+       ZFS_IOC_CLONE,                          /* 0x5a42 */
+       ZFS_IOC_BOOKMARK,                       /* 0x5a43 */
+       ZFS_IOC_GET_BOOKMARKS,                  /* 0x5a44 */
+       ZFS_IOC_DESTROY_BOOKMARKS,              /* 0x5a45 */
+       ZFS_IOC_CHANNEL_PROGRAM,                /* 0x5a46 */
+       ZFS_IOC_RECV_NEW,                       /* 0x5a47 */
+       ZFS_IOC_POOL_SYNC,                      /* 0x5a48 */
+       ZFS_IOC_LOAD_KEY,                       /* 0x5a49 */
+       ZFS_IOC_UNLOAD_KEY,                     /* 0x5a4a */
+       ZFS_IOC_CHANGE_KEY,                     /* 0x5a4b */
+       ZFS_IOC_REMAP,                          /* 0x5a4c */
+       ZFS_IOC_POOL_CHECKPOINT,                /* 0x5a4d */
+       ZFS_IOC_POOL_DISCARD_CHECKPOINT,        /* 0x5a4e */
+       ZFS_IOC_POOL_INITIALIZE,                /* 0x5a4f */
 
        /*
         * Linux - 3/64 numbers reserved.
         */
        ZFS_IOC_LINUX = ('Z' << 8) + 0x80,
-       ZFS_IOC_EVENTS_NEXT,
-       ZFS_IOC_EVENTS_CLEAR,
-       ZFS_IOC_EVENTS_SEEK,
+       ZFS_IOC_EVENTS_NEXT,                    /* 0x5a81 */
+       ZFS_IOC_EVENTS_CLEAR,                   /* 0x5a82 */
+       ZFS_IOC_EVENTS_SEEK,                    /* 0x5a83 */
 
        /*
         * FreeBSD - 1/64 numbers reserved.
@@ -1192,13 +1243,19 @@ typedef enum zfs_ioc {
  * The enum implicitly includes all the error codes from errno.h.
  * New code should use and extend this enum for errors that are
  * not described precisely by generic errno codes.
+ *
+ * These numbers should not change over time. New entries should be appended.
  */
 typedef enum {
        ZFS_ERR_CHECKPOINT_EXISTS = 1024,
        ZFS_ERR_DISCARDING_CHECKPOINT,
        ZFS_ERR_NO_CHECKPOINT,
        ZFS_ERR_DEVRM_IN_PROGRESS,
-       ZFS_ERR_VDEV_TOO_BIG
+       ZFS_ERR_VDEV_TOO_BIG,
+       ZFS_ERR_IOC_CMD_UNAVAIL,
+       ZFS_ERR_IOC_ARG_UNAVAIL,
+       ZFS_ERR_IOC_ARG_REQUIRED,
+       ZFS_ERR_IOC_ARG_BADTYPE,
 } zfs_errno_t;
 
 /*
@@ -1250,6 +1307,12 @@ typedef enum {
  */
 #define        ZPOOL_HIDDEN_ARGS       "hidden_args"
 
+/*
+ * The following are names used when invoking ZFS_IOC_POOL_INITIALIZE.
+ */
+#define        ZPOOL_INITIALIZE_COMMAND        "initialize_command"
+#define        ZPOOL_INITIALIZE_VDEVS          "initialize_vdevs"
+
 /*
  * Flags for ZFS_IOC_VDEV_SET_STATE
  */