* ========================================================================== * Initiate I/O, either sync or async * ========================================================================== */
| 2209 | * ========================================================================== |
| 2210 | */ |
| 2211 | int |
| 2212 | zio_wait(zio_t *zio) |
| 2213 | { |
| 2214 | /* |
| 2215 | * Some routines, like zio_free_sync(), may return a NULL zio |
| 2216 | * to avoid the performance overhead of creating and then destroying |
| 2217 | * an unneeded zio. For the callers' simplicity, we accept a NULL |
| 2218 | * zio and ignore it. |
| 2219 | */ |
| 2220 | if (zio == NULL) |
| 2221 | return (0); |
| 2222 | |
| 2223 | long timeout = MSEC_TO_TICK(zfs_deadman_ziotime_ms); |
| 2224 | int error; |
| 2225 | |
| 2226 | ASSERT3S(zio->io_stage, ==, ZIO_STAGE_OPEN); |
| 2227 | ASSERT3P(zio->io_executor, ==, NULL); |
| 2228 | |
| 2229 | zio->io_waiter = curthread; |
| 2230 | ASSERT0(zio->io_queued_timestamp); |
| 2231 | zio->io_queued_timestamp = gethrtime(); |
| 2232 | |
| 2233 | __zio_execute(zio); |
| 2234 | |
| 2235 | mutex_enter(&zio->io_lock); |
| 2236 | while (zio->io_executor != NULL) { |
| 2237 | error = cv_timedwait_io(&zio->io_cv, &zio->io_lock, |
| 2238 | ddi_get_lbolt() + timeout); |
| 2239 | |
| 2240 | if (zfs_deadman_enabled && error == -1 && |
| 2241 | gethrtime() - zio->io_queued_timestamp > |
| 2242 | spa_deadman_ziotime(zio->io_spa)) { |
| 2243 | mutex_exit(&zio->io_lock); |
| 2244 | timeout = MSEC_TO_TICK(zfs_deadman_checktime_ms); |
| 2245 | zio_deadman(zio, FTAG); |
| 2246 | mutex_enter(&zio->io_lock); |
| 2247 | } |
| 2248 | } |
| 2249 | mutex_exit(&zio->io_lock); |
| 2250 | |
| 2251 | error = zio->io_error; |
| 2252 | zio_destroy(zio); |
| 2253 | |
| 2254 | return (error); |
| 2255 | } |
| 2256 | |
| 2257 | void |
| 2258 | zio_nowait(zio_t *zio) |
no test coverage detected