* Determine whether the specified vdev can be offlined/detached/removed * without losing data. */
| 3160 | * without losing data. |
| 3161 | */ |
| 3162 | boolean_t |
| 3163 | vdev_dtl_required(vdev_t *vd) |
| 3164 | { |
| 3165 | spa_t *spa = vd->vdev_spa; |
| 3166 | vdev_t *tvd = vd->vdev_top; |
| 3167 | uint8_t cant_read = vd->vdev_cant_read; |
| 3168 | boolean_t required; |
| 3169 | |
| 3170 | ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL); |
| 3171 | |
| 3172 | if (vd == spa->spa_root_vdev || vd == tvd) |
| 3173 | return (B_TRUE); |
| 3174 | |
| 3175 | /* |
| 3176 | * Temporarily mark the device as unreadable, and then determine |
| 3177 | * whether this results in any DTL outages in the top-level vdev. |
| 3178 | * If not, we can safely offline/detach/remove the device. |
| 3179 | */ |
| 3180 | vd->vdev_cant_read = B_TRUE; |
| 3181 | vdev_dtl_reassess(tvd, 0, 0, B_FALSE, B_FALSE); |
| 3182 | required = !vdev_dtl_empty(tvd, DTL_OUTAGE); |
| 3183 | vd->vdev_cant_read = cant_read; |
| 3184 | vdev_dtl_reassess(tvd, 0, 0, B_FALSE, B_FALSE); |
| 3185 | |
| 3186 | if (!required && zio_injection_enabled) { |
| 3187 | required = !!zio_handle_device_injection(vd, NULL, |
| 3188 | SET_ERROR(ECHILD)); |
| 3189 | } |
| 3190 | |
| 3191 | return (required); |
| 3192 | } |
| 3193 | |
| 3194 | /* |
| 3195 | * Determine if resilver is needed, and if so the txg range. |
no test coverage detected