1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Matthew Ahrens <mahrens@delphix.com>
3 Date: Thu, 2 Aug 2018 15:51:45 -0700
4 Subject: [PATCH] Reduce taskq and context-switch cost of zio pipe
6 When doing a read from disk, ZFS creates 3 ZIO's: a zio_null(), the
7 logical zio_read(), and then a physical zio. Currently, each of these
8 results in a separate taskq_dispatch(zio_execute).
10 On high-read-iops workloads, this causes a significant performance
11 impact. By processing all 3 ZIO's in a single taskq entry, we reduce the
12 overhead on taskq locking and context switching. We accomplish this by
13 allowing zio_done() to return a "next zio to execute" to zio_execute().
15 This results in a ~12% performance increase for random reads, from
16 96,000 iops to 108,000 iops (with recordsize=8k, on SSD's).
18 Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
19 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
20 Reviewed by: George Wilson <george.wilson@delphix.com>
21 Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
22 External-issue: DLPX-59292
25 include/sys/zio.h | 4 +-
26 module/zfs/zio.c | 252 +++++++++++++++++++++++++++++-------------------------
27 2 files changed, 139 insertions(+), 117 deletions(-)
29 diff --git a/include/sys/zio.h b/include/sys/zio.h
30 index 4b0eecc2..3618912c 100644
31 --- a/include/sys/zio.h
32 +++ b/include/sys/zio.h
33 @@ -237,7 +237,7 @@ enum zio_child {
34 #define ZIO_CHILD_DDT_BIT ZIO_CHILD_BIT(ZIO_CHILD_DDT)
35 #define ZIO_CHILD_LOGICAL_BIT ZIO_CHILD_BIT(ZIO_CHILD_LOGICAL)
36 #define ZIO_CHILD_ALL_BITS \
37 - (ZIO_CHILD_VDEV_BIT | ZIO_CHILD_GANG_BIT | \
38 + (ZIO_CHILD_VDEV_BIT | ZIO_CHILD_GANG_BIT | \
39 ZIO_CHILD_DDT_BIT | ZIO_CHILD_LOGICAL_BIT)
42 @@ -375,7 +375,7 @@ typedef struct zio_transform {
43 struct zio_transform *zt_next;
46 -typedef int zio_pipe_stage_t(zio_t *zio);
47 +typedef zio_t *zio_pipe_stage_t(zio_t *zio);
50 * The io_reexecute flags are distinct from io_flags because the child must
51 diff --git a/module/zfs/zio.c b/module/zfs/zio.c
52 index 9a465e1b..dd0dfcdb 100644
53 --- a/module/zfs/zio.c
54 +++ b/module/zfs/zio.c
55 @@ -75,9 +75,6 @@ uint64_t zio_buf_cache_frees[SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT];
57 int zio_delay_max = ZIO_DELAY_MAX;
59 -#define ZIO_PIPELINE_CONTINUE 0x100
60 -#define ZIO_PIPELINE_STOP 0x101
62 #define BP_SPANB(indblkshift, level) \
63 (((uint64_t)1) << ((level) * ((indblkshift) - SPA_BLKPTRSHIFT)))
64 #define COMPARE_META_LEVEL 0x80000000ul
65 @@ -516,7 +513,8 @@ zio_wait_for_children(zio_t *zio, uint8_t childbits, enum zio_wait_type wait)
67 __attribute__((always_inline))
69 -zio_notify_parent(zio_t *pio, zio_t *zio, enum zio_wait_type wait)
70 +zio_notify_parent(zio_t *pio, zio_t *zio, enum zio_wait_type wait,
71 + zio_t **next_to_executep)
73 uint64_t *countp = &pio->io_children[zio->io_child_type][wait];
74 int *errorp = &pio->io_child_error[zio->io_child_type];
75 @@ -535,13 +533,33 @@ zio_notify_parent(zio_t *pio, zio_t *zio, enum zio_wait_type wait)
78 mutex_exit(&pio->io_lock);
81 - * Dispatch the parent zio in its own taskq so that
82 - * the child can continue to make progress. This also
83 - * prevents overflowing the stack when we have deeply nested
84 - * parent-child relationships.
85 + * If we can tell the caller to execute this parent next, do
86 + * so. Otherwise dispatch the parent zio as its own task.
88 + * Having the caller execute the parent when possible reduces
89 + * locking on the zio taskq's, reduces context switch
90 + * overhead, and has no recursion penalty. Note that one
91 + * read from disk typically causes at least 3 zio's: a
92 + * zio_null(), the logical zio_read(), and then a physical
93 + * zio. When the physical ZIO completes, we are able to call
94 + * zio_done() on all 3 of these zio's from one invocation of
95 + * zio_execute() by returning the parent back to
96 + * zio_execute(). Since the parent isn't executed until this
97 + * thread returns back to zio_execute(), the caller should do
100 + * In other cases, dispatching the parent prevents
101 + * overflowing the stack when we have deeply nested
102 + * parent-child relationships, as we do with the "mega zio"
103 + * of writes for spa_sync(), and the chain of ZIL blocks.
105 - zio_taskq_dispatch(pio, type, B_FALSE);
106 + if (next_to_executep != NULL && *next_to_executep == NULL) {
107 + *next_to_executep = pio;
109 + zio_taskq_dispatch(pio, type, B_FALSE);
112 mutex_exit(&pio->io_lock);
114 @@ -1187,7 +1205,7 @@ zio_shrink(zio_t *zio, uint64_t size)
115 * ==========================================================================
120 zio_read_bp_init(zio_t *zio)
122 blkptr_t *bp = zio->io_bp;
123 @@ -1221,15 +1239,15 @@ zio_read_bp_init(zio_t *zio)
124 if (BP_GET_DEDUP(bp) && zio->io_child_type == ZIO_CHILD_LOGICAL)
125 zio->io_pipeline = ZIO_DDT_READ_PIPELINE;
127 - return (ZIO_PIPELINE_CONTINUE);
133 zio_write_bp_init(zio_t *zio)
136 if (!IO_IS_ALLOCATING(zio))
137 - return (ZIO_PIPELINE_CONTINUE);
140 ASSERT(zio->io_child_type != ZIO_CHILD_DDT);
142 @@ -1244,7 +1262,7 @@ zio_write_bp_init(zio_t *zio)
143 zio->io_pipeline = ZIO_INTERLOCK_PIPELINE;
145 if (BP_IS_EMBEDDED(bp))
146 - return (ZIO_PIPELINE_CONTINUE);
150 * If we've been overridden and nopwrite is set then
151 @@ -1255,13 +1273,13 @@ zio_write_bp_init(zio_t *zio)
152 ASSERT(!zp->zp_dedup);
153 ASSERT3U(BP_GET_CHECKSUM(bp), ==, zp->zp_checksum);
154 zio->io_flags |= ZIO_FLAG_NOPWRITE;
155 - return (ZIO_PIPELINE_CONTINUE);
159 ASSERT(!zp->zp_nopwrite);
161 if (BP_IS_HOLE(bp) || !zp->zp_dedup)
162 - return (ZIO_PIPELINE_CONTINUE);
165 ASSERT((zio_checksum_table[zp->zp_checksum].ci_flags &
166 ZCHECKSUM_FLAG_DEDUP) || zp->zp_dedup_verify);
167 @@ -1269,7 +1287,7 @@ zio_write_bp_init(zio_t *zio)
168 if (BP_GET_CHECKSUM(bp) == zp->zp_checksum) {
170 zio->io_pipeline |= ZIO_STAGE_DDT_WRITE;
171 - return (ZIO_PIPELINE_CONTINUE);
176 @@ -1281,10 +1299,10 @@ zio_write_bp_init(zio_t *zio)
177 zio->io_pipeline = zio->io_orig_pipeline;
180 - return (ZIO_PIPELINE_CONTINUE);
186 zio_write_compress(zio_t *zio)
188 spa_t *spa = zio->io_spa;
189 @@ -1303,11 +1321,11 @@ zio_write_compress(zio_t *zio)
191 if (zio_wait_for_children(zio, ZIO_CHILD_LOGICAL_BIT |
192 ZIO_CHILD_GANG_BIT, ZIO_WAIT_READY)) {
193 - return (ZIO_PIPELINE_STOP);
197 if (!IO_IS_ALLOCATING(zio))
198 - return (ZIO_PIPELINE_CONTINUE);
201 if (zio->io_children_ready != NULL) {
203 @@ -1366,7 +1384,7 @@ zio_write_compress(zio_t *zio)
204 zio->io_pipeline = ZIO_INTERLOCK_PIPELINE;
205 ASSERT(spa_feature_is_active(spa,
206 SPA_FEATURE_EMBEDDED_DATA));
207 - return (ZIO_PIPELINE_CONTINUE);
211 * Round up compressed size up to the ashift
212 @@ -1459,10 +1477,10 @@ zio_write_compress(zio_t *zio)
213 zio->io_pipeline |= ZIO_STAGE_NOP_WRITE;
216 - return (ZIO_PIPELINE_CONTINUE);
222 zio_free_bp_init(zio_t *zio)
224 blkptr_t *bp = zio->io_bp;
225 @@ -1472,7 +1490,9 @@ zio_free_bp_init(zio_t *zio)
226 zio->io_pipeline = ZIO_DDT_FREE_PIPELINE;
229 - return (ZIO_PIPELINE_CONTINUE);
230 + ASSERT3P(zio->io_bp, ==, &zio->io_bp_copy);
236 @@ -1541,12 +1561,12 @@ zio_taskq_member(zio_t *zio, zio_taskq_type_t q)
242 zio_issue_async(zio_t *zio)
244 zio_taskq_dispatch(zio, ZIO_TASKQ_ISSUE, B_FALSE);
246 - return (ZIO_PIPELINE_STOP);
251 @@ -1687,14 +1707,13 @@ __attribute__((always_inline))
253 __zio_execute(zio_t *zio)
255 - zio->io_executor = curthread;
257 ASSERT3U(zio->io_queued_timestamp, >, 0);
259 while (zio->io_stage < ZIO_STAGE_DONE) {
260 enum zio_stage pipeline = zio->io_pipeline;
261 enum zio_stage stage = zio->io_stage;
264 + zio->io_executor = curthread;
266 ASSERT(!MUTEX_HELD(&zio->io_lock));
268 @@ -1736,12 +1755,16 @@ __zio_execute(zio_t *zio)
270 zio->io_stage = stage;
271 zio->io_pipeline_trace |= zio->io_stage;
272 - rv = zio_pipeline[highbit64(stage) - 1](zio);
274 - if (rv == ZIO_PIPELINE_STOP)
277 + * The zio pipeline stage returns the next zio to execute
278 + * (typically the same as this one), or NULL if we should
281 + zio = zio_pipeline[highbit64(stage) - 1](zio);
283 - ASSERT(rv == ZIO_PIPELINE_CONTINUE);
289 @@ -2215,7 +2238,7 @@ zio_gang_tree_issue(zio_t *pio, zio_gang_node_t *gn, blkptr_t *bp, abd_t *data,
295 zio_gang_assemble(zio_t *zio)
297 blkptr_t *bp = zio->io_bp;
298 @@ -2227,16 +2250,16 @@ zio_gang_assemble(zio_t *zio)
300 zio_gang_tree_assemble(zio, bp, &zio->io_gang_tree);
302 - return (ZIO_PIPELINE_CONTINUE);
308 zio_gang_issue(zio_t *zio)
310 blkptr_t *bp = zio->io_bp;
312 if (zio_wait_for_children(zio, ZIO_CHILD_GANG_BIT, ZIO_WAIT_DONE)) {
313 - return (ZIO_PIPELINE_STOP);
317 ASSERT(BP_IS_GANG(bp) && zio->io_gang_leader == zio);
318 @@ -2250,7 +2273,7 @@ zio_gang_issue(zio_t *zio)
320 zio->io_pipeline = ZIO_INTERLOCK_PIPELINE;
322 - return (ZIO_PIPELINE_CONTINUE);
327 @@ -2290,7 +2313,7 @@ zio_write_gang_done(zio_t *zio)
328 abd_put(zio->io_abd);
333 zio_write_gang_block(zio_t *pio)
335 spa_t *spa = pio->io_spa;
336 @@ -2349,7 +2372,7 @@ zio_write_gang_block(zio_t *pio)
339 pio->io_error = error;
340 - return (ZIO_PIPELINE_CONTINUE);
345 @@ -2423,7 +2446,7 @@ zio_write_gang_block(zio_t *pio)
349 - return (ZIO_PIPELINE_CONTINUE);
354 @@ -2444,7 +2467,7 @@ zio_write_gang_block(zio_t *pio)
355 * used for nopwrite, assuming that the salt and the checksums
356 * themselves remain secret.
360 zio_nop_write(zio_t *zio)
362 blkptr_t *bp = zio->io_bp;
363 @@ -2471,7 +2494,7 @@ zio_nop_write(zio_t *zio)
364 BP_GET_COMPRESS(bp) != BP_GET_COMPRESS(bp_orig) ||
365 BP_GET_DEDUP(bp) != BP_GET_DEDUP(bp_orig) ||
366 zp->zp_copies != BP_GET_NDVAS(bp_orig))
367 - return (ZIO_PIPELINE_CONTINUE);
371 * If the checksums match then reset the pipeline so that we
372 @@ -2491,7 +2514,7 @@ zio_nop_write(zio_t *zio)
373 zio->io_flags |= ZIO_FLAG_NOPWRITE;
376 - return (ZIO_PIPELINE_CONTINUE);
381 @@ -2519,7 +2542,7 @@ zio_ddt_child_read_done(zio_t *zio)
382 mutex_exit(&pio->io_lock);
387 zio_ddt_read_start(zio_t *zio)
389 blkptr_t *bp = zio->io_bp;
390 @@ -2540,7 +2563,7 @@ zio_ddt_read_start(zio_t *zio)
393 if (ddp_self == NULL)
394 - return (ZIO_PIPELINE_CONTINUE);
397 for (p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
398 if (ddp->ddp_phys_birth == 0 || ddp == ddp_self)
399 @@ -2553,23 +2576,23 @@ zio_ddt_read_start(zio_t *zio)
400 zio->io_priority, ZIO_DDT_CHILD_FLAGS(zio) |
401 ZIO_FLAG_DONT_PROPAGATE, &zio->io_bookmark));
403 - return (ZIO_PIPELINE_CONTINUE);
407 zio_nowait(zio_read(zio, zio->io_spa, bp,
408 zio->io_abd, zio->io_size, NULL, NULL, zio->io_priority,
409 ZIO_DDT_CHILD_FLAGS(zio), &zio->io_bookmark));
411 - return (ZIO_PIPELINE_CONTINUE);
417 zio_ddt_read_done(zio_t *zio)
419 blkptr_t *bp = zio->io_bp;
421 if (zio_wait_for_children(zio, ZIO_CHILD_DDT_BIT, ZIO_WAIT_DONE)) {
422 - return (ZIO_PIPELINE_STOP);
426 ASSERT(BP_GET_DEDUP(bp));
427 @@ -2581,12 +2604,12 @@ zio_ddt_read_done(zio_t *zio)
428 ddt_entry_t *dde = zio->io_vsd;
430 ASSERT(spa_load_state(zio->io_spa) != SPA_LOAD_NONE);
431 - return (ZIO_PIPELINE_CONTINUE);
435 zio->io_stage = ZIO_STAGE_DDT_READ_START >> 1;
436 zio_taskq_dispatch(zio, ZIO_TASKQ_ISSUE, B_FALSE);
437 - return (ZIO_PIPELINE_STOP);
440 if (dde->dde_repair_abd != NULL) {
441 abd_copy(zio->io_abd, dde->dde_repair_abd,
442 @@ -2599,7 +2622,7 @@ zio_ddt_read_done(zio_t *zio)
444 ASSERT(zio->io_vsd == NULL);
446 - return (ZIO_PIPELINE_CONTINUE);
451 @@ -2780,7 +2803,7 @@ zio_ddt_ditto_write_done(zio_t *zio)
457 zio_ddt_write(zio_t *zio)
459 spa_t *spa = zio->io_spa;
460 @@ -2822,7 +2845,7 @@ zio_ddt_write(zio_t *zio)
462 zio->io_pipeline = ZIO_WRITE_PIPELINE;
464 - return (ZIO_PIPELINE_CONTINUE);
468 ditto_copies = ddt_ditto_copies_needed(ddt, dde, ddp);
469 @@ -2848,7 +2871,7 @@ zio_ddt_write(zio_t *zio)
470 zio->io_bp_override = NULL;
473 - return (ZIO_PIPELINE_CONTINUE);
477 dio = zio_write(zio, spa, txg, bp, zio->io_orig_abd,
478 @@ -2890,12 +2913,12 @@ zio_ddt_write(zio_t *zio)
482 - return (ZIO_PIPELINE_CONTINUE);
486 ddt_entry_t *freedde; /* for debugging */
490 zio_ddt_free(zio_t *zio)
492 spa_t *spa = zio->io_spa;
493 @@ -2916,7 +2939,7 @@ zio_ddt_free(zio_t *zio)
497 - return (ZIO_PIPELINE_CONTINUE);
502 @@ -2953,7 +2976,7 @@ zio_io_to_allocate(spa_t *spa)
508 zio_dva_throttle(zio_t *zio)
510 spa_t *spa = zio->io_spa;
511 @@ -2963,7 +2986,7 @@ zio_dva_throttle(zio_t *zio)
512 !spa_normal_class(zio->io_spa)->mc_alloc_throttle_enabled ||
513 zio->io_child_type == ZIO_CHILD_GANG ||
514 zio->io_flags & ZIO_FLAG_NODATA) {
515 - return (ZIO_PIPELINE_CONTINUE);
519 ASSERT(zio->io_child_type > ZIO_CHILD_GANG);
520 @@ -2979,22 +3002,7 @@ zio_dva_throttle(zio_t *zio)
521 nio = zio_io_to_allocate(zio->io_spa);
522 mutex_exit(&spa->spa_alloc_lock);
525 - return (ZIO_PIPELINE_CONTINUE);
528 - ASSERT(nio->io_stage == ZIO_STAGE_DVA_THROTTLE);
530 - * We are passing control to a new zio so make sure that
531 - * it is processed by a different thread. We do this to
532 - * avoid stack overflows that can occur when parents are
533 - * throttled and children are making progress. We allow
534 - * it to go to the head of the taskq since it's already
537 - zio_taskq_dispatch(nio, ZIO_TASKQ_ISSUE, B_TRUE);
539 - return (ZIO_PIPELINE_STOP);
544 @@ -3013,7 +3021,7 @@ zio_allocate_dispatch(spa_t *spa)
545 zio_taskq_dispatch(zio, ZIO_TASKQ_ISSUE, B_TRUE);
550 zio_dva_allocate(zio_t *zio)
552 spa_t *spa = zio->io_spa;
553 @@ -3054,18 +3062,18 @@ zio_dva_allocate(zio_t *zio)
554 zio->io_error = error;
557 - return (ZIO_PIPELINE_CONTINUE);
563 zio_dva_free(zio_t *zio)
565 metaslab_free(zio->io_spa, zio->io_bp, zio->io_txg, B_FALSE);
567 - return (ZIO_PIPELINE_CONTINUE);
573 zio_dva_claim(zio_t *zio)
576 @@ -3074,7 +3082,7 @@ zio_dva_claim(zio_t *zio)
578 zio->io_error = error;
580 - return (ZIO_PIPELINE_CONTINUE);
585 @@ -3172,7 +3180,7 @@ zio_free_zil(spa_t *spa, uint64_t txg, blkptr_t *bp)
586 * force the underlying vdev layers to call either zio_execute() or
587 * zio_interrupt() to ensure that the pipeline continues with the correct I/O.
591 zio_vdev_io_start(zio_t *zio)
593 vdev_t *vd = zio->io_vd;
594 @@ -3192,7 +3200,7 @@ zio_vdev_io_start(zio_t *zio)
595 * The mirror_ops handle multiple DVAs in a single BP.
597 vdev_mirror_ops.vdev_op_io_start(zio);
598 - return (ZIO_PIPELINE_STOP);
602 ASSERT3P(zio->io_logical, !=, zio);
603 @@ -3269,31 +3277,31 @@ zio_vdev_io_start(zio_t *zio)
604 !vdev_dtl_contains(vd, DTL_PARTIAL, zio->io_txg, 1)) {
605 ASSERT(zio->io_type == ZIO_TYPE_WRITE);
606 zio_vdev_io_bypass(zio);
607 - return (ZIO_PIPELINE_CONTINUE);
611 if (vd->vdev_ops->vdev_op_leaf &&
612 (zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE)) {
614 if (zio->io_type == ZIO_TYPE_READ && vdev_cache_read(zio))
615 - return (ZIO_PIPELINE_CONTINUE);
618 if ((zio = vdev_queue_io(zio)) == NULL)
619 - return (ZIO_PIPELINE_STOP);
622 if (!vdev_accessible(vd, zio)) {
623 zio->io_error = SET_ERROR(ENXIO);
625 - return (ZIO_PIPELINE_STOP);
628 zio->io_delay = gethrtime();
631 vd->vdev_ops->vdev_op_io_start(zio);
632 - return (ZIO_PIPELINE_STOP);
638 zio_vdev_io_done(zio_t *zio)
640 vdev_t *vd = zio->io_vd;
641 @@ -3301,7 +3309,7 @@ zio_vdev_io_done(zio_t *zio)
642 boolean_t unexpected_error = B_FALSE;
644 if (zio_wait_for_children(zio, ZIO_CHILD_VDEV_BIT, ZIO_WAIT_DONE)) {
645 - return (ZIO_PIPELINE_STOP);
649 ASSERT(zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE);
650 @@ -3337,7 +3345,7 @@ zio_vdev_io_done(zio_t *zio)
651 if (unexpected_error)
652 VERIFY(vdev_probe(vd, zio) == NULL);
654 - return (ZIO_PIPELINE_CONTINUE);
659 @@ -3366,13 +3374,13 @@ zio_vsd_default_cksum_report(zio_t *zio, zio_cksum_report_t *zcr, void *ignored)
660 zcr->zcr_free = zio_abd_free;
665 zio_vdev_io_assess(zio_t *zio)
667 vdev_t *vd = zio->io_vd;
669 if (zio_wait_for_children(zio, ZIO_CHILD_VDEV_BIT, ZIO_WAIT_DONE)) {
670 - return (ZIO_PIPELINE_STOP);
674 if (vd == NULL && !(zio->io_flags & ZIO_FLAG_CONFIG_WRITER))
675 @@ -3402,7 +3410,7 @@ zio_vdev_io_assess(zio_t *zio)
676 zio->io_stage = ZIO_STAGE_VDEV_IO_START >> 1;
677 zio_taskq_dispatch(zio, ZIO_TASKQ_ISSUE,
678 zio_requeue_io_start_cut_in_line);
679 - return (ZIO_PIPELINE_STOP);
684 @@ -3442,7 +3450,7 @@ zio_vdev_io_assess(zio_t *zio)
685 zio->io_physdone(zio->io_logical);
688 - return (ZIO_PIPELINE_CONTINUE);
693 @@ -3477,7 +3485,7 @@ zio_vdev_io_bypass(zio_t *zio)
694 * Generate and verify checksums
695 * ==========================================================================
699 zio_checksum_generate(zio_t *zio)
701 blkptr_t *bp = zio->io_bp;
702 @@ -3491,7 +3499,7 @@ zio_checksum_generate(zio_t *zio)
703 checksum = zio->io_prop.zp_checksum;
705 if (checksum == ZIO_CHECKSUM_OFF)
706 - return (ZIO_PIPELINE_CONTINUE);
709 ASSERT(checksum == ZIO_CHECKSUM_LABEL);
711 @@ -3505,10 +3513,10 @@ zio_checksum_generate(zio_t *zio)
713 zio_checksum_compute(zio, checksum, zio->io_abd, zio->io_size);
715 - return (ZIO_PIPELINE_CONTINUE);
721 zio_checksum_verify(zio_t *zio)
723 zio_bad_cksum_t info;
724 @@ -3523,7 +3531,7 @@ zio_checksum_verify(zio_t *zio)
725 * We're either verifying a label checksum, or nothing at all.
727 if (zio->io_prop.zp_checksum == ZIO_CHECKSUM_OFF)
728 - return (ZIO_PIPELINE_CONTINUE);
731 ASSERT(zio->io_prop.zp_checksum == ZIO_CHECKSUM_LABEL);
733 @@ -3538,7 +3546,7 @@ zio_checksum_verify(zio_t *zio)
737 - return (ZIO_PIPELINE_CONTINUE);
742 @@ -3581,7 +3589,7 @@ zio_worst_error(int e1, int e2)
744 * ==========================================================================
748 zio_ready(zio_t *zio)
750 blkptr_t *bp = zio->io_bp;
751 @@ -3590,7 +3598,7 @@ zio_ready(zio_t *zio)
753 if (zio_wait_for_children(zio, ZIO_CHILD_GANG_BIT | ZIO_CHILD_DDT_BIT,
755 - return (ZIO_PIPELINE_STOP);
760 @@ -3636,7 +3644,7 @@ zio_ready(zio_t *zio)
762 for (; pio != NULL; pio = pio_next) {
763 pio_next = zio_walk_parents(zio, &zl);
764 - zio_notify_parent(pio, zio, ZIO_WAIT_READY);
765 + zio_notify_parent(pio, zio, ZIO_WAIT_READY, NULL);
768 if (zio->io_flags & ZIO_FLAG_NODATA) {
769 @@ -3652,7 +3660,7 @@ zio_ready(zio_t *zio)
770 zio->io_spa->spa_syncing_txg == zio->io_txg)
771 zio_handle_ignored_writes(zio);
773 - return (ZIO_PIPELINE_CONTINUE);
778 @@ -3716,7 +3724,7 @@ zio_dva_throttle_done(zio_t *zio)
779 zio_allocate_dispatch(zio->io_spa);
787 @@ -3733,7 +3741,7 @@ zio_done(zio_t *zio)
788 * wait for them and then repeat this pipeline stage.
790 if (zio_wait_for_children(zio, ZIO_CHILD_ALL_BITS, ZIO_WAIT_DONE)) {
791 - return (ZIO_PIPELINE_STOP);
796 @@ -3957,7 +3965,12 @@ zio_done(zio_t *zio)
797 if ((pio->io_flags & ZIO_FLAG_GODFATHER) &&
798 (zio->io_reexecute & ZIO_REEXECUTE_SUSPEND)) {
799 zio_remove_child(pio, zio, remove_zl);
800 - zio_notify_parent(pio, zio, ZIO_WAIT_DONE);
802 + * This is a rare code path, so we don't
803 + * bother with "next_to_execute".
805 + zio_notify_parent(pio, zio, ZIO_WAIT_DONE,
810 @@ -3969,7 +3982,11 @@ zio_done(zio_t *zio)
812 ASSERT(!(zio->io_flags & ZIO_FLAG_GODFATHER));
813 zio->io_flags |= ZIO_FLAG_DONT_PROPAGATE;
814 - zio_notify_parent(pio, zio, ZIO_WAIT_DONE);
816 + * This is a rare code path, so we don't bother with
817 + * "next_to_execute".
819 + zio_notify_parent(pio, zio, ZIO_WAIT_DONE, NULL);
820 } else if (zio->io_reexecute & ZIO_REEXECUTE_SUSPEND) {
822 * We'd fail again if we reexecuted now, so suspend
823 @@ -3987,7 +4004,7 @@ zio_done(zio_t *zio)
824 (task_func_t *)zio_reexecute, zio, 0,
827 - return (ZIO_PIPELINE_STOP);
831 ASSERT(zio->io_child_count == 0);
832 @@ -4023,12 +4040,17 @@ zio_done(zio_t *zio)
833 zio->io_state[ZIO_WAIT_DONE] = 1;
834 mutex_exit(&zio->io_lock);
837 + * We are done executing this zio. We may want to execute a parent
838 + * next. See the comment in zio_notify_parent().
840 + zio_t *next_to_execute = NULL;
842 for (pio = zio_walk_parents(zio, &zl); pio != NULL; pio = pio_next) {
843 zio_link_t *remove_zl = zl;
844 pio_next = zio_walk_parents(zio, &zl);
845 zio_remove_child(pio, zio, remove_zl);
846 - zio_notify_parent(pio, zio, ZIO_WAIT_DONE);
847 + zio_notify_parent(pio, zio, ZIO_WAIT_DONE, &next_to_execute);
850 if (zio->io_waiter != NULL) {
851 @@ -4040,7 +4062,7 @@ zio_done(zio_t *zio)
855 - return (ZIO_PIPELINE_STOP);
856 + return (next_to_execute);