Skip to content

Commit

Permalink
OpenZFS 6878 - Add scrub completion info to "zpool history"
Browse files Browse the repository at this point in the history
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: Dan Kimmel <[email protected]>
Approved by: Dan McDonald <[email protected]>
Authored by: Nav Ravindranath <[email protected]>
Ported-by: Chris Dunlop <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>

OpenZFS-issue: https://www.illumos.org/issues/6878
OpenZFS-commit: openzfs/openzfs@1825bc5
Closes openzfs#4787
  • Loading branch information
Nav Ravindranath authored and RageLtMan committed Jun 25, 2016
1 parent 7625607 commit 769bd14
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions module/zfs/dsl_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ typedef int (scan_cb_t)(dsl_pool_t *, const blkptr_t *,

static scan_cb_t dsl_scan_scrub_cb;
static void dsl_scan_cancel_sync(void *, dmu_tx_t *);
static void dsl_scan_sync_state(dsl_scan_t *, dmu_tx_t *tx);
static void dsl_scan_sync_state(dsl_scan_t *, dmu_tx_t *);
static boolean_t dsl_scan_restarting(dsl_scan_t *, dmu_tx_t *);

int zfs_top_maxinflight = 32; /* maximum I/Os per top-level */
int zfs_resilver_delay = 2; /* number of ticks to delay resilver */
Expand Down Expand Up @@ -331,8 +332,15 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu_tx_t *tx)
else
scn->scn_phys.scn_state = DSS_CANCELED;

spa_history_log_internal(spa, "scan done", tx,
"complete=%u", complete);
if (dsl_scan_restarting(scn, tx))
spa_history_log_internal(spa, "scan aborted, restarting", tx,
"errors=%llu", spa_get_errlog_size(spa));
else if (!complete)
spa_history_log_internal(spa, "scan cancelled", tx,
"errors=%llu", spa_get_errlog_size(spa));
else
spa_history_log_internal(spa, "scan done", tx,
"errors=%llu", spa_get_errlog_size(spa));

if (DSL_SCAN_IS_SCRUB_RESILVER(scn)) {
mutex_enter(&spa->spa_scrub_lock);
Expand Down Expand Up @@ -1517,8 +1525,7 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
* that we can restart an old-style scan while the pool is being
* imported (see dsl_scan_init).
*/
if (scn->scn_restart_txg != 0 &&
scn->scn_restart_txg <= tx->tx_txg) {
if (dsl_scan_restarting(scn, tx)) {
pool_scan_func_t func = POOL_SCAN_SCRUB;
dsl_scan_done(scn, B_FALSE, tx);
if (vdev_resilver_needed(spa->spa_root_vdev, NULL, NULL))
Expand Down Expand Up @@ -1953,6 +1960,13 @@ dsl_scan(dsl_pool_t *dp, pool_scan_func_t func)
dsl_scan_setup_sync, &func, 0, ZFS_SPACE_CHECK_NONE));
}

static boolean_t
dsl_scan_restarting(dsl_scan_t *scn, dmu_tx_t *tx)
{
return (scn->scn_restart_txg != 0 &&
scn->scn_restart_txg <= tx->tx_txg);
}

#if defined(_KERNEL) && defined(HAVE_SPL)
module_param(zfs_top_maxinflight, int, 0644);
MODULE_PARM_DESC(zfs_top_maxinflight, "Max I/Os per top-level");
Expand Down

0 comments on commit 769bd14

Please sign in to comment.