]> git.proxmox.com Git - mirror_zfs.git/blobdiff - include/sys/spa_impl.h
fix: Uber block label not always found for aux vdevs
[mirror_zfs.git] / include / sys / spa_impl.h
index 69de75fb6d3f87d12f8268441d7b13cdf81a7e8c..0cd0c4720fbefa00277c9815a17367e992997740 100644 (file)
@@ -6,7 +6,7 @@
  * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
+ * or https://opensource.org/licenses/CDDL-1.0.
  * See the License for the specific language governing permissions
  * and limitations under the License.
  *
@@ -25,8 +25,8 @@
  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
  * Copyright 2013 Saso Kiselkov. All rights reserved.
  * Copyright (c) 2016 Actifio, Inc. All rights reserved.
- * Copyright (c) 2017 Datto Inc.
  * Copyright (c) 2017, Intel Corporation.
+ * Copyright (c) 2019 Datto Inc.
  */
 
 #ifndef _SYS_SPA_IMPL_H
@@ -38,6 +38,7 @@
 #include <sys/vdev.h>
 #include <sys/vdev_rebuild.h>
 #include <sys/vdev_removal.h>
+#include <sys/vdev_raidz.h>
 #include <sys/metaslab.h>
 #include <sys/dmu.h>
 #include <sys/dsl_pool.h>
 extern "C" {
 #endif
 
+typedef struct spa_alloc {
+       kmutex_t        spaa_lock;
+       avl_tree_t      spaa_tree;
+} ____cacheline_aligned spa_alloc_t;
+
 typedef struct spa_error_entry {
        zbookmark_phys_t        se_bookmark;
        char                    *se_name;
        avl_node_t              se_avl;
+       zbookmark_err_phys_t    se_zep;         /* not accounted in avl_find */
 } spa_error_entry_t;
 
 typedef struct spa_history_phys {
@@ -141,9 +148,9 @@ typedef struct spa_config_lock {
        kmutex_t        scl_lock;
        kthread_t       *scl_writer;
        int             scl_write_wanted;
+       int             scl_count;
        kcondvar_t      scl_cv;
-       zfs_refcount_t  scl_count;
-} spa_config_lock_t;
+} ____cacheline_aligned spa_config_lock_t;
 
 typedef struct spa_config_dirent {
        list_node_t     scd_link;
@@ -182,6 +189,12 @@ typedef struct spa_taskqs {
        taskq_t **stqs_taskq;
 } spa_taskqs_t;
 
+/* one for each thread in the spa sync taskq */
+typedef struct spa_syncthread_info {
+       kthread_t       *sti_thread;
+       taskq_t         *sti_wr_iss_tq;         /* assigned wr_iss taskq */
+} spa_syncthread_info_t;
+
 typedef enum spa_all_vdev_zap_action {
        AVZ_ACTION_NONE = 0,
        AVZ_ACTION_DESTROY,     /* Destroy all per-vdev ZAPs and the AVZ. */
@@ -210,7 +223,7 @@ struct spa {
        nvlist_t        *spa_config_splitting;  /* config for splitting */
        nvlist_t        *spa_load_info;         /* info and errors from load */
        uint64_t        spa_config_txg;         /* txg of last config change */
-       int             spa_sync_pass;          /* iterate-to-convergence */
+       uint32_t        spa_sync_pass;          /* iterate-to-convergence */
        pool_state_t    spa_state;              /* pool state */
        int             spa_inject_ref;         /* injection references */
        uint8_t         spa_sync_on;            /* sync threads are running */
@@ -226,6 +239,7 @@ struct spa {
        boolean_t       spa_is_exporting;       /* true while exporting pool */
        metaslab_class_t *spa_normal_class;     /* normal data class */
        metaslab_class_t *spa_log_class;        /* intent log data class */
+       metaslab_class_t *spa_embedded_log_class; /* log on normal vdevs */
        metaslab_class_t *spa_special_class;    /* special allocation class */
        metaslab_class_t *spa_dedup_class;      /* dedup allocation class */
        uint64_t        spa_first_txg;          /* first txg after spa_open() */
@@ -240,25 +254,31 @@ struct spa {
        kcondvar_t      spa_evicting_os_cv;     /* Objset Eviction Completion */
        txg_list_t      spa_vdev_txg_list;      /* per-txg dirty vdev list */
        vdev_t          *spa_root_vdev;         /* top-level vdev container */
-       int             spa_min_ashift;         /* of vdevs in normal class */
-       int             spa_max_ashift;         /* of vdevs in normal class */
+       uint64_t        spa_min_ashift;         /* of vdevs in normal class */
+       uint64_t        spa_max_ashift;         /* of vdevs in normal class */
+       uint64_t        spa_min_alloc;          /* of vdevs in normal class */
+       uint64_t        spa_gcd_alloc;          /* of vdevs in normal class */
        uint64_t        spa_config_guid;        /* config pool guid */
        uint64_t        spa_load_guid;          /* spa_load initialized guid */
        uint64_t        spa_last_synced_guid;   /* last synced guid */
        list_t          spa_config_dirty_list;  /* vdevs with dirty config */
        list_t          spa_state_dirty_list;   /* vdevs with dirty state */
        /*
-        * spa_alloc_locks and spa_alloc_trees are arrays, whose lengths are
-        * stored in spa_alloc_count. There is one tree and one lock for each
-        * allocator, to help improve allocation performance in write-heavy
-        * workloads.
+        * spa_allocs is an array, whose lengths is stored in spa_alloc_count.
+        * There is one tree and one lock for each allocator, to help improve
+        * allocation performance in write-heavy workloads.
         */
-       kmutex_t        *spa_alloc_locks;
-       avl_tree_t      *spa_alloc_trees;
+       spa_alloc_t     *spa_allocs;
        int             spa_alloc_count;
+       int             spa_active_allocator;   /* selectable allocator */
+
+       /* per-allocator sync thread taskqs */
+       taskq_t         *spa_sync_tq;
+       spa_syncthread_info_t *spa_syncthreads;
 
        spa_aux_vdev_t  spa_spares;             /* hot spares */
        spa_aux_vdev_t  spa_l2cache;            /* L2ARC cache devices */
+       boolean_t       spa_aux_sync_uber;      /* need to sync aux uber */
        nvlist_t        *spa_label_features;    /* Features for reading MOS */
        uint64_t        spa_config_object;      /* MOS object for pool config */
        uint64_t        spa_config_generation;  /* config generation number */
@@ -289,6 +309,10 @@ struct spa {
        uint64_t        spa_scan_pass_exam;     /* examined bytes per pass */
        uint64_t        spa_scan_pass_issued;   /* issued bytes per pass */
 
+       /* error scrub pause time in milliseconds */
+       uint64_t        spa_scan_pass_errorscrub_pause;
+       /* total error scrub paused time in milliseconds */
+       uint64_t        spa_scan_pass_errorscrub_spent_paused;
        /*
         * We are in the middle of a resilver, and another resilver
         * is needed once this one completes. This is set iff any
@@ -303,6 +327,7 @@ struct spa {
        uint64_t        spa_missing_tvds;       /* unopenable tvds on load */
        uint64_t        spa_missing_tvds_allowed; /* allow loading spa? */
 
+       uint64_t        spa_nonallocating_dspace;
        spa_removing_phys_t spa_removing_phys;
        spa_vdev_removal_t *spa_vdev_removal;
 
@@ -310,6 +335,9 @@ struct spa {
        spa_condensing_indirect_t       *spa_condensing_indirect;
        zthr_t          *spa_condense_zthr;     /* zthr doing condense. */
 
+       vdev_raidz_expand_t     *spa_raidz_expand;
+       zthr_t          *spa_raidz_expand_zthr;
+
        uint64_t        spa_checkpoint_txg;     /* the txg of the checkpoint */
        spa_checkpoint_info_t spa_checkpoint_info; /* checkpoint accounting */
        zthr_t          *spa_checkpoint_discard_zthr;
@@ -343,6 +371,7 @@ struct spa {
        kmutex_t        spa_errlist_lock;       /* error list/ereport lock */
        avl_tree_t      spa_errlist_last;       /* last error list */
        avl_tree_t      spa_errlist_scrub;      /* scrub error list */
+       avl_tree_t      spa_errlist_healed;     /* list of healed blocks */
        uint64_t        spa_deflate;            /* should we deflate? */
        uint64_t        spa_history;            /* history object */
        kmutex_t        spa_history_lock;       /* history lock */
@@ -365,6 +394,7 @@ struct spa {
        boolean_t       spa_is_root;            /* pool is root */
        int             spa_minref;             /* num refs when first opened */
        spa_mode_t      spa_mode;               /* SPA_MODE_{READ|WRITE} */
+       boolean_t       spa_read_spacemaps;     /* spacemaps available if ro */
        spa_log_state_t spa_log_state;          /* log state */
        uint64_t        spa_autoexpand;         /* lun expansion on/off */
        ddt_t           *spa_ddt[ZIO_CHECKSUM_FUNCTIONS]; /* in-core DDTs */
@@ -372,12 +402,13 @@ struct spa {
        uint64_t        spa_dedup_dspace;       /* Cache get_dedup_dspace() */
        uint64_t        spa_dedup_checksum;     /* default dedup checksum */
        uint64_t        spa_dspace;             /* dspace in normal class */
+       struct brt      *spa_brt;               /* in-core BRT */
        kmutex_t        spa_vdev_top_lock;      /* dueling offline/remove */
        kmutex_t        spa_proc_lock;          /* protects spa_proc* */
        kcondvar_t      spa_proc_cv;            /* spa_proc_state transitions */
        spa_proc_state_t spa_proc_state;        /* see definition */
        proc_t          *spa_proc;              /* "zpool-poolname" process */
-       uint64_t        spa_did;                /* if procp != p0, did of t1 */
+       uintptr_t       spa_did;                /* if procp != p0, did of t1 */
        boolean_t       spa_autoreplace;        /* autoreplace set in open */
        int             spa_vdev_locks;         /* locks grabbed */
        uint64_t        spa_creation_version;   /* version at pool creation */
@@ -408,7 +439,9 @@ struct spa {
 
        hrtime_t        spa_ccw_fail_time;      /* Conf cache write fail time */
        taskq_t         *spa_zvol_taskq;        /* Taskq for minor management */
+       taskq_t         *spa_metaslab_taskq;    /* Taskq for metaslab preload */
        taskq_t         *spa_prefetch_taskq;    /* Taskq for prefetch threads */
+       taskq_t         *spa_upgrade_taskq;     /* Taskq for upgrade jobs */
        uint64_t        spa_multihost;          /* multihost aware (mmp) */
        mmp_thread_t    spa_mmp;                /* multihost mmp thread */
        list_t          spa_leaf_list;          /* list of leaf vdevs */
@@ -422,6 +455,8 @@ struct spa {
        int             spa_waiters;            /* number of waiting threads */
        boolean_t       spa_waiters_cancel;     /* waiters should return */
 
+       char            *spa_compatibility;     /* compatibility file(s) */
+
        /*
         * spa_refcount & spa_config_lock must be the last elements
         * because zfs_refcount_t changes size based on compilation options.
@@ -430,15 +465,13 @@ struct spa {
         */
        spa_config_lock_t spa_config_lock[SCL_LOCKS]; /* config changes */
        zfs_refcount_t  spa_refcount;           /* number of opens */
-
-       taskq_t         *spa_upgrade_taskq;     /* taskq for upgrade jobs */
 };
 
 extern char *spa_config_path;
-extern char *zfs_deadman_failmode;
-extern int spa_slop_shift;
+extern const char *zfs_deadman_failmode;
+extern uint_t spa_slop_shift;
 extern void spa_taskq_dispatch_ent(spa_t *spa, zio_type_t t, zio_taskq_type_t q,
-    task_func_t *func, void *arg, uint_t flags, taskq_ent_t *ent);
+    task_func_t *func, void *arg, uint_t flags, taskq_ent_t *ent, zio_t *zio);
 extern void spa_taskq_dispatch_sync(spa_t *, zio_type_t t, zio_taskq_type_t q,
     task_func_t *func, void *arg, uint_t flags);
 extern void spa_load_spares(spa_t *spa);
@@ -450,6 +483,8 @@ extern int param_set_deadman_failmode_common(const char *val);
 extern void spa_set_deadman_synctime(hrtime_t ns);
 extern void spa_set_deadman_ziotime(hrtime_t ns);
 extern const char *spa_history_zone(void);
+extern const char *zfs_active_allocator;
+extern int param_set_active_allocator_common(const char *val);
 
 #ifdef __cplusplus
 }