| 714 | } |
| 715 | |
| 716 | void |
| 717 | dsl_scan_setup_sync(void *arg, dmu_tx_t *tx) |
| 718 | { |
| 719 | dsl_scan_t *scn = dmu_tx_pool(tx)->dp_scan; |
| 720 | pool_scan_func_t *funcp = arg; |
| 721 | dmu_object_type_t ot = 0; |
| 722 | dsl_pool_t *dp = scn->scn_dp; |
| 723 | spa_t *spa = dp->dp_spa; |
| 724 | |
| 725 | ASSERT(!dsl_scan_is_running(scn)); |
| 726 | ASSERT(*funcp > POOL_SCAN_NONE && *funcp < POOL_SCAN_FUNCS); |
| 727 | bzero(&scn->scn_phys, sizeof (scn->scn_phys)); |
| 728 | scn->scn_phys.scn_func = *funcp; |
| 729 | scn->scn_phys.scn_state = DSS_SCANNING; |
| 730 | scn->scn_phys.scn_min_txg = 0; |
| 731 | scn->scn_phys.scn_max_txg = tx->tx_txg; |
| 732 | scn->scn_phys.scn_ddt_class_max = DDT_CLASSES - 1; /* the entire DDT */ |
| 733 | scn->scn_phys.scn_start_time = gethrestime_sec(); |
| 734 | scn->scn_phys.scn_errors = 0; |
| 735 | scn->scn_phys.scn_to_examine = spa->spa_root_vdev->vdev_stat.vs_alloc; |
| 736 | scn->scn_issued_before_pass = 0; |
| 737 | scn->scn_restart_txg = 0; |
| 738 | scn->scn_done_txg = 0; |
| 739 | scn->scn_last_checkpoint = 0; |
| 740 | scn->scn_checkpointing = B_FALSE; |
| 741 | spa_scan_stat_init(spa); |
| 742 | |
| 743 | if (DSL_SCAN_IS_SCRUB_RESILVER(scn)) { |
| 744 | scn->scn_phys.scn_ddt_class_max = zfs_scrub_ddt_class_max; |
| 745 | |
| 746 | /* rewrite all disk labels */ |
| 747 | vdev_config_dirty(spa->spa_root_vdev); |
| 748 | |
| 749 | if (vdev_resilver_needed(spa->spa_root_vdev, |
| 750 | &scn->scn_phys.scn_min_txg, &scn->scn_phys.scn_max_txg)) { |
| 751 | nvlist_t *aux = fnvlist_alloc(); |
| 752 | fnvlist_add_string(aux, ZFS_EV_RESILVER_TYPE, |
| 753 | "healing"); |
| 754 | spa_event_notify(spa, NULL, aux, |
| 755 | ESC_ZFS_RESILVER_START); |
| 756 | nvlist_free(aux); |
| 757 | } else { |
| 758 | spa_event_notify(spa, NULL, NULL, ESC_ZFS_SCRUB_START); |
| 759 | } |
| 760 | |
| 761 | spa->spa_scrub_started = B_TRUE; |
| 762 | /* |
| 763 | * If this is an incremental scrub, limit the DDT scrub phase |
| 764 | * to just the auto-ditto class (for correctness); the rest |
| 765 | * of the scrub should go faster using top-down pruning. |
| 766 | */ |
| 767 | if (scn->scn_phys.scn_min_txg > TXG_INITIAL) |
| 768 | scn->scn_phys.scn_ddt_class_max = DDT_CLASS_DITTO; |
| 769 | |
| 770 | /* |
| 771 | * When starting a resilver clear any existing rebuild state. |
| 772 | * This is required to prevent stale rebuild status from |
| 773 | * being reported when a rebuild is run, then a resilver and |
no test coverage detected