summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sys/spa_impl.h1
-rw-r--r--module/zfs/dmu_traverse.c3
-rw-r--r--module/zfs/spa.c13
3 files changed, 16 insertions, 1 deletions
diff --git a/include/sys/spa_impl.h b/include/sys/spa_impl.h
index af1d6aef0..77625d4b0 100644
--- a/include/sys/spa_impl.h
+++ b/include/sys/spa_impl.h
@@ -280,6 +280,7 @@ struct spa {
spa_keystore_t spa_keystore; /* loaded crypto keys */
hrtime_t spa_ccw_fail_time; /* Conf cache write fail time */
taskq_t *spa_zvol_taskq; /* Taskq for minor management */
+ taskq_t *spa_prefetch_taskq; /* Taskq for prefetch threads */
uint64_t spa_multihost; /* multihost aware (mmp) */
mmp_thread_t spa_mmp; /* multihost mmp thread */
diff --git a/module/zfs/dmu_traverse.c b/module/zfs/dmu_traverse.c
index 5407e4817..cffcd2d00 100644
--- a/module/zfs/dmu_traverse.c
+++ b/module/zfs/dmu_traverse.c
@@ -31,6 +31,7 @@
#include <sys/dsl_pool.h>
#include <sys/dnode.h>
#include <sys/spa.h>
+#include <sys/spa_impl.h>
#include <sys/zio.h>
#include <sys/dmu_impl.h>
#include <sys/sa.h>
@@ -661,7 +662,7 @@ traverse_impl(spa_t *spa, dsl_dataset_t *ds, uint64_t objset, blkptr_t *rootbp,
}
if (!(flags & TRAVERSE_PREFETCH_DATA) ||
- taskq_dispatch(system_taskq, traverse_prefetch_thread,
+ taskq_dispatch(spa->spa_prefetch_taskq, traverse_prefetch_thread,
td, TQ_NOQUEUE) == TASKQID_INVALID)
pd->pd_exited = B_TRUE;
diff --git a/module/zfs/spa.c b/module/zfs/spa.c
index 1e9e7b013..4b6196cc3 100644
--- a/module/zfs/spa.c
+++ b/module/zfs/spa.c
@@ -1187,6 +1187,14 @@ spa_activate(spa_t *spa, int mode)
1, INT_MAX, 0);
/*
+ * Taskq dedicated to prefetcher threads: this is used to prevent the
+ * pool traverse code from monopolizing the global (and limited)
+ * system_taskq by inappropriately scheduling long running tasks on it.
+ */
+ spa->spa_prefetch_taskq = taskq_create("z_prefetch", boot_ncpus,
+ defclsyspri, 1, INT_MAX, TASKQ_DYNAMIC);
+
+ /*
* The taskq to upgrade datasets in this pool. Currently used by
* feature SPA_FEATURE_USEROBJ_ACCOUNTING/SPA_FEATURE_PROJECT_QUOTA.
*/
@@ -1213,6 +1221,11 @@ spa_deactivate(spa_t *spa)
spa->spa_zvol_taskq = NULL;
}
+ if (spa->spa_prefetch_taskq) {
+ taskq_destroy(spa->spa_prefetch_taskq);
+ spa->spa_prefetch_taskq = NULL;
+ }
+
if (spa->spa_upgrade_taskq) {
taskq_destroy(spa->spa_upgrade_taskq);
spa->spa_upgrade_taskq = NULL;