* Determine if a resilvering vdev should remove any DTL entries from * its range. If the vdev was resilvering for the entire duration of the * scan then it should excise that range from its DTLs. Otherwise, this * vdev is considered partially resilvered and should leave its DTL * entries intact. The comment in vdev_dtl_reassess() describes how we * excise the DTLs. */
| 2745 | * excise the DTLs. |
| 2746 | */ |
| 2747 | static boolean_t |
| 2748 | vdev_dtl_should_excise(vdev_t *vd, boolean_t rebuild_done) |
| 2749 | { |
| 2750 | ASSERT0(vd->vdev_children); |
| 2751 | |
| 2752 | if (vd->vdev_state < VDEV_STATE_DEGRADED) |
| 2753 | return (B_FALSE); |
| 2754 | |
| 2755 | if (vd->vdev_resilver_deferred) |
| 2756 | return (B_FALSE); |
| 2757 | |
| 2758 | if (range_tree_is_empty(vd->vdev_dtl[DTL_MISSING])) |
| 2759 | return (B_TRUE); |
| 2760 | |
| 2761 | if (rebuild_done) { |
| 2762 | vdev_rebuild_t *vr = &vd->vdev_top->vdev_rebuild_config; |
| 2763 | vdev_rebuild_phys_t *vrp = &vr->vr_rebuild_phys; |
| 2764 | |
| 2765 | /* Rebuild not initiated by attach */ |
| 2766 | if (vd->vdev_rebuild_txg == 0) |
| 2767 | return (B_TRUE); |
| 2768 | |
| 2769 | /* |
| 2770 | * When a rebuild completes without error then all missing data |
| 2771 | * up to the rebuild max txg has been reconstructed and the DTL |
| 2772 | * is eligible for excision. |
| 2773 | */ |
| 2774 | if (vrp->vrp_rebuild_state == VDEV_REBUILD_COMPLETE && |
| 2775 | vdev_dtl_max(vd) <= vrp->vrp_max_txg) { |
| 2776 | ASSERT3U(vrp->vrp_min_txg, <=, vdev_dtl_min(vd)); |
| 2777 | ASSERT3U(vrp->vrp_min_txg, <, vd->vdev_rebuild_txg); |
| 2778 | ASSERT3U(vd->vdev_rebuild_txg, <=, vrp->vrp_max_txg); |
| 2779 | return (B_TRUE); |
| 2780 | } |
| 2781 | } else { |
| 2782 | dsl_scan_t *scn = vd->vdev_spa->spa_dsl_pool->dp_scan; |
| 2783 | dsl_scan_phys_t *scnp __maybe_unused = &scn->scn_phys; |
| 2784 | |
| 2785 | /* Resilver not initiated by attach */ |
| 2786 | if (vd->vdev_resilver_txg == 0) |
| 2787 | return (B_TRUE); |
| 2788 | |
| 2789 | /* |
| 2790 | * When a resilver is initiated the scan will assign the |
| 2791 | * scn_max_txg value to the highest txg value that exists |
| 2792 | * in all DTLs. If this device's max DTL is not part of this |
| 2793 | * scan (i.e. it is not in the range (scn_min_txg, scn_max_txg] |
| 2794 | * then it is not eligible for excision. |
| 2795 | */ |
| 2796 | if (vdev_dtl_max(vd) <= scn->scn_phys.scn_max_txg) { |
| 2797 | ASSERT3U(scnp->scn_min_txg, <=, vdev_dtl_min(vd)); |
| 2798 | ASSERT3U(scnp->scn_min_txg, <, vd->vdev_resilver_txg); |
| 2799 | ASSERT3U(vd->vdev_resilver_txg, <=, scnp->scn_max_txg); |
| 2800 | return (B_TRUE); |
| 2801 | } |
| 2802 | } |
| 2803 | |
| 2804 | return (B_FALSE); |
no test coverage detected