Skip to content

Commit 784d15c

Browse files
Nav Ravindranathbehlendorf
authored andcommitted
OpenZFS 6878 - Add scrub completion info to "zpool history"
Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Approved by: Dan McDonald <danmcd@omniti.com> Authored by: Nav Ravindranath <nav@delphix.com> Ported-by: Chris Dunlop <chris@onthe.net.au> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> OpenZFS-issue: https://www.illumos.org/issues/6878 OpenZFS-commit: openzfs/openzfs@1825bc5 Closes #4787
1 parent 391bba1 commit 784d15c

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

module/zfs/dsl_scan.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ typedef int (scan_cb_t)(dsl_pool_t *, const blkptr_t *,
5656

5757
static scan_cb_t dsl_scan_scrub_cb;
5858
static void dsl_scan_cancel_sync(void *, dmu_tx_t *);
59-
static void dsl_scan_sync_state(dsl_scan_t *, dmu_tx_t *tx);
59+
static void dsl_scan_sync_state(dsl_scan_t *, dmu_tx_t *);
60+
static boolean_t dsl_scan_restarting(dsl_scan_t *, dmu_tx_t *);
6061

6162
int zfs_top_maxinflight = 32; /* maximum I/Os per top-level */
6263
int zfs_resilver_delay = 2; /* number of ticks to delay resilver */
@@ -329,8 +330,15 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu_tx_t *tx)
329330
else
330331
scn->scn_phys.scn_state = DSS_CANCELED;
331332

332-
spa_history_log_internal(spa, "scan done", tx,
333-
"complete=%u", complete);
333+
if (dsl_scan_restarting(scn, tx))
334+
spa_history_log_internal(spa, "scan aborted, restarting", tx,
335+
"errors=%llu", spa_get_errlog_size(spa));
336+
else if (!complete)
337+
spa_history_log_internal(spa, "scan cancelled", tx,
338+
"errors=%llu", spa_get_errlog_size(spa));
339+
else
340+
spa_history_log_internal(spa, "scan done", tx,
341+
"errors=%llu", spa_get_errlog_size(spa));
334342

335343
if (DSL_SCAN_IS_SCRUB_RESILVER(scn)) {
336344
mutex_enter(&spa->spa_scrub_lock);
@@ -1511,8 +1519,7 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
15111519
* that we can restart an old-style scan while the pool is being
15121520
* imported (see dsl_scan_init).
15131521
*/
1514-
if (scn->scn_restart_txg != 0 &&
1515-
scn->scn_restart_txg <= tx->tx_txg) {
1522+
if (dsl_scan_restarting(scn, tx)) {
15161523
pool_scan_func_t func = POOL_SCAN_SCRUB;
15171524
dsl_scan_done(scn, B_FALSE, tx);
15181525
if (vdev_resilver_needed(spa->spa_root_vdev, NULL, NULL))
@@ -1942,6 +1949,13 @@ dsl_scan(dsl_pool_t *dp, pool_scan_func_t func)
19421949
dsl_scan_setup_sync, &func, 0, ZFS_SPACE_CHECK_NONE));
19431950
}
19441951

1952+
static boolean_t
1953+
dsl_scan_restarting(dsl_scan_t *scn, dmu_tx_t *tx)
1954+
{
1955+
return (scn->scn_restart_txg != 0 &&
1956+
scn->scn_restart_txg <= tx->tx_txg);
1957+
}
1958+
19451959
#if defined(_KERNEL) && defined(HAVE_SPL)
19461960
module_param(zfs_top_maxinflight, int, 0644);
19471961
MODULE_PARM_DESC(zfs_top_maxinflight, "Max I/Os per top-level");

0 commit comments

Comments
 (0)