* Determine if resilver is needed, and if so the txg range. */
| 3195 | * Determine if resilver is needed, and if so the txg range. |
| 3196 | */ |
| 3197 | boolean_t |
| 3198 | vdev_resilver_needed(vdev_t *vd, uint64_t *minp, uint64_t *maxp) |
| 3199 | { |
| 3200 | boolean_t needed = B_FALSE; |
| 3201 | uint64_t thismin = UINT64_MAX; |
| 3202 | uint64_t thismax = 0; |
| 3203 | |
| 3204 | if (vd->vdev_children == 0) { |
| 3205 | mutex_enter(&vd->vdev_dtl_lock); |
| 3206 | if (!range_tree_is_empty(vd->vdev_dtl[DTL_MISSING]) && |
| 3207 | vdev_writeable(vd)) { |
| 3208 | |
| 3209 | thismin = vdev_dtl_min(vd); |
| 3210 | thismax = vdev_dtl_max(vd); |
| 3211 | needed = B_TRUE; |
| 3212 | } |
| 3213 | mutex_exit(&vd->vdev_dtl_lock); |
| 3214 | } else { |
| 3215 | for (int c = 0; c < vd->vdev_children; c++) { |
| 3216 | vdev_t *cvd = vd->vdev_child[c]; |
| 3217 | uint64_t cmin, cmax; |
| 3218 | |
| 3219 | if (vdev_resilver_needed(cvd, &cmin, &cmax)) { |
| 3220 | thismin = MIN(thismin, cmin); |
| 3221 | thismax = MAX(thismax, cmax); |
| 3222 | needed = B_TRUE; |
| 3223 | } |
| 3224 | } |
| 3225 | } |
| 3226 | |
| 3227 | if (needed && minp) { |
| 3228 | *minp = thismin; |
| 3229 | *maxp = thismax; |
| 3230 | } |
| 3231 | return (needed); |
| 3232 | } |
| 3233 | |
| 3234 | /* |
| 3235 | * Gets the checkpoint space map object from the vdev's ZAP. On success sm_obj |