* ========================================================================== * I/O completion * ========================================================================== */
| 4317 | * ========================================================================== |
| 4318 | */ |
| 4319 | static zio_t * |
| 4320 | zio_ready(zio_t *zio) |
| 4321 | { |
| 4322 | blkptr_t *bp = zio->io_bp; |
| 4323 | zio_t *pio, *pio_next; |
| 4324 | zio_link_t *zl = NULL; |
| 4325 | |
| 4326 | if (zio_wait_for_children(zio, ZIO_CHILD_GANG_BIT | ZIO_CHILD_DDT_BIT, |
| 4327 | ZIO_WAIT_READY)) { |
| 4328 | return (NULL); |
| 4329 | } |
| 4330 | |
| 4331 | if (zio->io_ready) { |
| 4332 | ASSERT(IO_IS_ALLOCATING(zio)); |
| 4333 | ASSERT(bp->blk_birth == zio->io_txg || BP_IS_HOLE(bp) || |
| 4334 | (zio->io_flags & ZIO_FLAG_NOPWRITE)); |
| 4335 | ASSERT(zio->io_children[ZIO_CHILD_GANG][ZIO_WAIT_READY] == 0); |
| 4336 | |
| 4337 | zio->io_ready(zio); |
| 4338 | } |
| 4339 | |
| 4340 | if (bp != NULL && bp != &zio->io_bp_copy) |
| 4341 | zio->io_bp_copy = *bp; |
| 4342 | |
| 4343 | if (zio->io_error != 0) { |
| 4344 | zio->io_pipeline = ZIO_INTERLOCK_PIPELINE; |
| 4345 | |
| 4346 | if (zio->io_flags & ZIO_FLAG_IO_ALLOCATING) { |
| 4347 | ASSERT(IO_IS_ALLOCATING(zio)); |
| 4348 | ASSERT(zio->io_priority == ZIO_PRIORITY_ASYNC_WRITE); |
| 4349 | ASSERT(zio->io_metaslab_class != NULL); |
| 4350 | |
| 4351 | /* |
| 4352 | * We were unable to allocate anything, unreserve and |
| 4353 | * issue the next I/O to allocate. |
| 4354 | */ |
| 4355 | metaslab_class_throttle_unreserve( |
| 4356 | zio->io_metaslab_class, zio->io_prop.zp_copies, |
| 4357 | zio->io_allocator, zio); |
| 4358 | zio_allocate_dispatch(zio->io_spa, zio->io_allocator); |
| 4359 | } |
| 4360 | } |
| 4361 | |
| 4362 | mutex_enter(&zio->io_lock); |
| 4363 | zio->io_state[ZIO_WAIT_READY] = 1; |
| 4364 | pio = zio_walk_parents(zio, &zl); |
| 4365 | mutex_exit(&zio->io_lock); |
| 4366 | |
| 4367 | /* |
| 4368 | * As we notify zio's parents, new parents could be added. |
| 4369 | * New parents go to the head of zio's io_parent_list, however, |
| 4370 | * so we will (correctly) not notify them. The remainder of zio's |
| 4371 | * io_parent_list, from 'pio_next' onward, cannot change because |
| 4372 | * all parents must wait for us to be done before they can be done. |
| 4373 | */ |
| 4374 | for (; pio != NULL; pio = pio_next) { |
| 4375 | pio_next = zio_walk_parents(zio, &zl); |
| 4376 | zio_notify_parent(pio, zio, ZIO_WAIT_READY, NULL); |
nothing calls this directly
no test coverage detected