From 1a4629c03d003332bf3b2fb42528c601d856ed1e Mon Sep 17 00:00:00 2001 From: mav Date: Sun, 20 Mar 2016 23:51:56 +0000 Subject: [PATCH] MFC r294799: MFV r294798: 6292 exporting a pool while an async destroy is running can leave entries in the deferred tree Reviewed by: Paul Dagnelie Reviewed by: Matthew Ahrens Reviewed by: Andriy Gapon Reviewed by: Fabian Keil Approved by: Gordon Ross illumos/illumos-gate@a443cc80c742af740aa82130db840f02b4389365 git-svn-id: svn://svn.freebsd.org/base/stable/10@297094 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- .../opensolaris/uts/common/fs/zfs/dsl_scan.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c index 3c6a29bfb..7e5a18169 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c @@ -1449,11 +1449,24 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx) dsl_scan_setup_sync(&func, tx); } + /* + * Only process scans in sync pass 1. + */ + if (spa_sync_pass(dp->dp_spa) > 1) + return; + + /* + * If the spa is shutting down, then stop scanning. This will + * ensure that the scan does not dirty any new data during the + * shutdown phase. + */ + if (spa_shutting_down(spa)) + return; + /* * If the scan is inactive due to a stalled async destroy, try again. */ - if ((!scn->scn_async_stalled && !dsl_scan_active(scn)) || - spa_sync_pass(dp->dp_spa) > 1) + if (!scn->scn_async_stalled && !dsl_scan_active(scn)) return; scn->scn_visited_this_txg = 0; -- 2.45.0