From 600a1dc54cadded39ce56cb5a0fa99737abdbbe9 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 8 Apr 2021 14:33:15 -0700 Subject: [PATCH] Use dsl_scan_setup_check() to setup a scrub When a rebuild completes it will automatically schedule a follow up scrub to verify all of the block checksums. Before setting up the scrub execute the counterpart dsl_scan_setup_check() function to confirm the scrub can be started. Prior to this change we'd only check vdev_rebuild_active() which isn't as comprehensive, and using the check function keeps all of this logic in one place. Reviewed-by: Mark Maybee Signed-off-by: Brian Behlendorf Closes #11849 --- include/sys/dsl_scan.h | 1 + module/zfs/dsl_scan.c | 2 +- module/zfs/vdev_rebuild.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/sys/dsl_scan.h b/include/sys/dsl_scan.h index 19c3dd599b10..fb1f1d65bad4 100644 --- a/include/sys/dsl_scan.h +++ b/include/sys/dsl_scan.h @@ -163,6 +163,7 @@ typedef struct dsl_scan_io_queue dsl_scan_io_queue_t; void scan_init(void); void scan_fini(void); int dsl_scan_init(struct dsl_pool *dp, uint64_t txg); +int dsl_scan_setup_check(void *, dmu_tx_t *); void dsl_scan_setup_sync(void *, dmu_tx_t *); void dsl_scan_fini(struct dsl_pool *dp); void dsl_scan_sync(struct dsl_pool *, dmu_tx_t *); diff --git a/module/zfs/dsl_scan.c b/module/zfs/dsl_scan.c index a54cd6ca800e..cc1cbcdb9778 100644 --- a/module/zfs/dsl_scan.c +++ b/module/zfs/dsl_scan.c @@ -701,7 +701,7 @@ dsl_scan_sync_state(dsl_scan_t *scn, dmu_tx_t *tx, state_sync_type_t sync_type) } /* ARGSUSED */ -static int +int dsl_scan_setup_check(void *arg, dmu_tx_t *tx) { dsl_scan_t *scn = dmu_tx_pool(tx)->dp_scan; diff --git a/module/zfs/vdev_rebuild.c b/module/zfs/vdev_rebuild.c index aa79642aaae5..4d7de0c6c44c 100644 --- a/module/zfs/vdev_rebuild.c +++ b/module/zfs/vdev_rebuild.c @@ -331,9 +331,9 @@ vdev_rebuild_complete_sync(void *arg, dmu_tx_t *tx) * While we're in syncing context take the opportunity to * setup the scrub when there are no more active rebuilds. */ - if (!vdev_rebuild_active(spa->spa_root_vdev) && + pool_scan_func_t func = POOL_SCAN_SCRUB; + if (dsl_scan_setup_check(&func, tx) == 0 && zfs_rebuild_scrub_enabled) { - pool_scan_func_t func = POOL_SCAN_SCRUB; dsl_scan_setup_sync(&func, tx); }