* Create a child I/O to do some work for us. */
| 1414 | * Create a child I/O to do some work for us. |
| 1415 | */ |
| 1416 | zio_t * |
| 1417 | zio_vdev_child_io(zio_t *pio, blkptr_t *bp, vdev_t *vd, uint64_t offset, |
| 1418 | abd_t *data, uint64_t size, int type, zio_priority_t priority, |
| 1419 | enum zio_flag flags, zio_done_func_t *done, void *private) |
| 1420 | { |
| 1421 | enum zio_stage pipeline = ZIO_VDEV_CHILD_PIPELINE; |
| 1422 | zio_t *zio; |
| 1423 | |
| 1424 | /* |
| 1425 | * vdev child I/Os do not propagate their error to the parent. |
| 1426 | * Therefore, for correct operation the caller *must* check for |
| 1427 | * and handle the error in the child i/o's done callback. |
| 1428 | * The only exceptions are i/os that we don't care about |
| 1429 | * (OPTIONAL or REPAIR). |
| 1430 | */ |
| 1431 | ASSERT((flags & ZIO_FLAG_OPTIONAL) || (flags & ZIO_FLAG_IO_REPAIR) || |
| 1432 | done != NULL); |
| 1433 | |
| 1434 | if (type == ZIO_TYPE_READ && bp != NULL) { |
| 1435 | /* |
| 1436 | * If we have the bp, then the child should perform the |
| 1437 | * checksum and the parent need not. This pushes error |
| 1438 | * detection as close to the leaves as possible and |
| 1439 | * eliminates redundant checksums in the interior nodes. |
| 1440 | */ |
| 1441 | pipeline |= ZIO_STAGE_CHECKSUM_VERIFY; |
| 1442 | pio->io_pipeline &= ~ZIO_STAGE_CHECKSUM_VERIFY; |
| 1443 | } |
| 1444 | |
| 1445 | if (vd->vdev_ops->vdev_op_leaf) { |
| 1446 | ASSERT0(vd->vdev_children); |
| 1447 | offset += VDEV_LABEL_START_SIZE; |
| 1448 | } |
| 1449 | |
| 1450 | flags |= ZIO_VDEV_CHILD_FLAGS(pio); |
| 1451 | |
| 1452 | /* |
| 1453 | * If we've decided to do a repair, the write is not speculative -- |
| 1454 | * even if the original read was. |
| 1455 | */ |
| 1456 | if (flags & ZIO_FLAG_IO_REPAIR) |
| 1457 | flags &= ~ZIO_FLAG_SPECULATIVE; |
| 1458 | |
| 1459 | /* |
| 1460 | * If we're creating a child I/O that is not associated with a |
| 1461 | * top-level vdev, then the child zio is not an allocating I/O. |
| 1462 | * If this is a retried I/O then we ignore it since we will |
| 1463 | * have already processed the original allocating I/O. |
| 1464 | */ |
| 1465 | if (flags & ZIO_FLAG_IO_ALLOCATING && |
| 1466 | (vd != vd->vdev_top || (flags & ZIO_FLAG_IO_RETRY))) { |
| 1467 | ASSERT(pio->io_metaslab_class != NULL); |
| 1468 | ASSERT(pio->io_metaslab_class->mc_alloc_throttle_enabled); |
| 1469 | ASSERT(type == ZIO_TYPE_WRITE); |
| 1470 | ASSERT(priority == ZIO_PRIORITY_ASYNC_WRITE); |
| 1471 | ASSERT(!(flags & ZIO_FLAG_IO_REPAIR)); |
| 1472 | ASSERT(!(pio->io_flags & ZIO_FLAG_IO_REWRITE) || |
| 1473 | pio->io_child_type == ZIO_CHILD_GANG); |
no test coverage detected