From 6af7ba417eb429413f9f24cd2704a302d766d9b4 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 27 Feb 2019 10:49:22 -0800 Subject: Fix overly broad spa config lock The spa_txg_history_init_io() and spa_txg_history_fini_io() were mistakenly taking SCL_ALL when only SCL_CONFIG is required to access the vdev stats. This could result in a deadlock which was observed when running ztest. Reviewed-by: Olaf Faaland Reviewed-by: Tim Chase Signed-off-by: Brian Behlendorf Closes #8445 --- module/zfs/spa_stats.c | 8 ++++---- module/zfs/vdev.c | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'module/zfs') diff --git a/module/zfs/spa_stats.c b/module/zfs/spa_stats.c index c02ef86b5..e01d2d198 100644 --- a/module/zfs/spa_stats.c +++ b/module/zfs/spa_stats.c @@ -414,9 +414,9 @@ spa_txg_history_init_io(spa_t *spa, uint64_t txg, dsl_pool_t *dp) ts = kmem_alloc(sizeof (txg_stat_t), KM_SLEEP); - spa_config_enter(spa, SCL_ALL, FTAG, RW_READER); + spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER); vdev_get_stats(spa->spa_root_vdev, &ts->vs1); - spa_config_exit(spa, SCL_ALL, FTAG); + spa_config_exit(spa, SCL_CONFIG, FTAG); ts->txg = txg; ts->ndirty = dp->dp_dirty_pertxg[txg & TXG_MASK]; @@ -437,9 +437,9 @@ spa_txg_history_fini_io(spa_t *spa, txg_stat_t *ts) return; } - spa_config_enter(spa, SCL_ALL, FTAG, RW_READER); + spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER); vdev_get_stats(spa->spa_root_vdev, &ts->vs2); - spa_config_exit(spa, SCL_ALL, FTAG); + spa_config_exit(spa, SCL_CONFIG, FTAG); spa_txg_history_set(spa, ts->txg, TXG_STATE_SYNCED, gethrtime()); spa_txg_history_set_io(spa, ts->txg, diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index a803833ba..1332c720f 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -3892,7 +3892,6 @@ vdev_get_stats_ex(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx) vs->vs_resilver_deferred = vd->vdev_resilver_deferred; } - ASSERT(spa_config_held(vd->vdev_spa, SCL_ALL, RW_READER) != 0); vdev_get_stats_ex_impl(vd, vs, vsx); mutex_exit(&vd->vdev_stat_lock); } -- cgit v1.2.3