* Reopen all interior vdevs and any unopened leaves. We don't actually * reopen leaf vdevs which had previously been opened as they might deadlock * on the spa_config_lock. Instead we only obtain the leaf's physical size. * If the leaf has never been opened then open it, as usual. */
| 2415 | * If the leaf has never been opened then open it, as usual. |
| 2416 | */ |
| 2417 | void |
| 2418 | vdev_reopen(vdev_t *vd) |
| 2419 | { |
| 2420 | spa_t *spa = vd->vdev_spa; |
| 2421 | |
| 2422 | ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL); |
| 2423 | |
| 2424 | /* set the reopening flag unless we're taking the vdev offline */ |
| 2425 | vd->vdev_reopening = !vd->vdev_offline; |
| 2426 | vdev_close(vd); |
| 2427 | (void) vdev_open(vd); |
| 2428 | |
| 2429 | /* |
| 2430 | * Call vdev_validate() here to make sure we have the same device. |
| 2431 | * Otherwise, a device with an invalid label could be successfully |
| 2432 | * opened in response to vdev_reopen(). |
| 2433 | */ |
| 2434 | if (vd->vdev_aux) { |
| 2435 | (void) vdev_validate_aux(vd); |
| 2436 | if (vdev_readable(vd) && vdev_writeable(vd) && |
| 2437 | vd->vdev_aux == &spa->spa_l2cache) { |
| 2438 | /* |
| 2439 | * In case the vdev is present we should evict all ARC |
| 2440 | * buffers and pointers to log blocks and reclaim their |
| 2441 | * space before restoring its contents to L2ARC. |
| 2442 | */ |
| 2443 | if (l2arc_vdev_present(vd)) { |
| 2444 | l2arc_rebuild_vdev(vd, B_TRUE); |
| 2445 | } else { |
| 2446 | l2arc_add_vdev(spa, vd); |
| 2447 | } |
| 2448 | spa_async_request(spa, SPA_ASYNC_L2CACHE_REBUILD); |
| 2449 | spa_async_request(spa, SPA_ASYNC_L2CACHE_TRIM); |
| 2450 | } |
| 2451 | } else { |
| 2452 | (void) vdev_validate(vd); |
| 2453 | } |
| 2454 | |
| 2455 | /* |
| 2456 | * Reassess parent vdev's health. |
| 2457 | */ |
| 2458 | vdev_propagate_state(vd); |
| 2459 | } |
| 2460 | |
| 2461 | int |
| 2462 | vdev_create(vdev_t *vd, uint64_t txg, boolean_t isreplacing) |