Skip to content

Commit 101edf7

Browse files
amotintonyhutter
authored andcommitted
Fix race between resilver wait and offline/detach
We should not clear scn_state and notify waiters until we call vdev_dtl_reassess(), otherwise following offline/detach request may fail with "no valid replicas". Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. (cherry picked from commit f86d9af)
1 parent a2593c1 commit 101edf7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

module/zfs/dsl_scan.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,10 +1132,6 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu_tx_t *tx)
11321132
}
11331133
}
11341134

1135-
scn->scn_phys.scn_state = complete ? DSS_FINISHED : DSS_CANCELED;
1136-
1137-
spa_notify_waiters(spa);
1138-
11391135
if (dsl_scan_restarting(scn, tx)) {
11401136
spa_history_log_internal(spa, "scan aborted, restarting", tx,
11411137
"errors=%llu", (u_longlong_t)spa_approx_errlog_size(spa));
@@ -1194,6 +1190,9 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu_tx_t *tx)
11941190
* Don't clear flag until after vdev_dtl_reassess to ensure that
11951191
* DTL_MISSING will get updated when possible.
11961192
*/
1193+
scn->scn_phys.scn_state = complete ? DSS_FINISHED :
1194+
DSS_CANCELED;
1195+
scn->scn_phys.scn_end_time = gethrestime_sec();
11971196
spa->spa_scrub_started = B_FALSE;
11981197

11991198
/*
@@ -1223,9 +1222,13 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu_tx_t *tx)
12231222
/* Clear recent error events (i.e. duplicate events tracking) */
12241223
if (complete)
12251224
zfs_ereport_clear(spa, NULL);
1225+
} else {
1226+
scn->scn_phys.scn_state = complete ? DSS_FINISHED :
1227+
DSS_CANCELED;
1228+
scn->scn_phys.scn_end_time = gethrestime_sec();
12261229
}
12271230

1228-
scn->scn_phys.scn_end_time = gethrestime_sec();
1231+
spa_notify_waiters(spa);
12291232

12301233
if (spa->spa_errata == ZPOOL_ERRATA_ZOL_2094_SCRUB)
12311234
spa->spa_errata = 0;

0 commit comments

Comments
 (0)