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 <mark.maybee@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #11849
This commit is contained in:
Brian Behlendorf 2021-04-08 14:33:15 -07:00
parent a35cadcf14
commit f17d146ca6
3 changed files with 4 additions and 3 deletions

View File

@ -163,6 +163,7 @@ typedef struct dsl_scan_io_queue dsl_scan_io_queue_t;
void scan_init(void); void scan_init(void);
void scan_fini(void); void scan_fini(void);
int dsl_scan_init(struct dsl_pool *dp, uint64_t txg); 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_setup_sync(void *, dmu_tx_t *);
void dsl_scan_fini(struct dsl_pool *dp); void dsl_scan_fini(struct dsl_pool *dp);
void dsl_scan_sync(struct dsl_pool *, dmu_tx_t *); void dsl_scan_sync(struct dsl_pool *, dmu_tx_t *);

View File

@ -701,7 +701,7 @@ dsl_scan_sync_state(dsl_scan_t *scn, dmu_tx_t *tx, state_sync_type_t sync_type)
} }
/* ARGSUSED */ /* ARGSUSED */
static int int
dsl_scan_setup_check(void *arg, dmu_tx_t *tx) dsl_scan_setup_check(void *arg, dmu_tx_t *tx)
{ {
dsl_scan_t *scn = dmu_tx_pool(tx)->dp_scan; dsl_scan_t *scn = dmu_tx_pool(tx)->dp_scan;

View File

@ -331,9 +331,9 @@ vdev_rebuild_complete_sync(void *arg, dmu_tx_t *tx)
* While we're in syncing context take the opportunity to * While we're in syncing context take the opportunity to
* setup the scrub when there are no more active rebuilds. * 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) { zfs_rebuild_scrub_enabled) {
pool_scan_func_t func = POOL_SCAN_SCRUB;
dsl_scan_setup_sync(&func, tx); dsl_scan_setup_sync(&func, tx);
} }