* Close a virtual device. */
| 2347 | * Close a virtual device. |
| 2348 | */ |
| 2349 | void |
| 2350 | vdev_close(vdev_t *vd) |
| 2351 | { |
| 2352 | vdev_t *pvd = vd->vdev_parent; |
| 2353 | spa_t *spa __maybe_unused = vd->vdev_spa; |
| 2354 | |
| 2355 | ASSERT(vd != NULL); |
| 2356 | ASSERT(vd->vdev_open_thread == curthread || |
| 2357 | spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL); |
| 2358 | |
| 2359 | /* |
| 2360 | * If our parent is reopening, then we are as well, unless we are |
| 2361 | * going offline. |
| 2362 | */ |
| 2363 | if (pvd != NULL && pvd->vdev_reopening) |
| 2364 | vd->vdev_reopening = (pvd->vdev_reopening && !vd->vdev_offline); |
| 2365 | |
| 2366 | vd->vdev_ops->vdev_op_close(vd); |
| 2367 | |
| 2368 | vdev_cache_purge(vd); |
| 2369 | |
| 2370 | /* |
| 2371 | * We record the previous state before we close it, so that if we are |
| 2372 | * doing a reopen(), we don't generate FMA ereports if we notice that |
| 2373 | * it's still faulted. |
| 2374 | */ |
| 2375 | vd->vdev_prevstate = vd->vdev_state; |
| 2376 | |
| 2377 | if (vd->vdev_offline) |
| 2378 | vd->vdev_state = VDEV_STATE_OFFLINE; |
| 2379 | else |
| 2380 | vd->vdev_state = VDEV_STATE_CLOSED; |
| 2381 | vd->vdev_stat.vs_aux = VDEV_AUX_NONE; |
| 2382 | } |
| 2383 | |
| 2384 | void |
| 2385 | vdev_hold(vdev_t *vd) |
no test coverage detected