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
23 Requires-spl: spl-0.7-release
26 (cherry-picked from behlendorf/issue-7736 496657ab3bcfeb638b1786e1759980ccfcacb08e)
27 Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
29 include/sys/zio.h | 4 +-
30 module/zfs/zio.c | 250 +++++++++++++++++++++++++++++-------------------------
31 2 files changed, 137 insertions(+), 117 deletions(-)
33 diff --git a/include/sys/zio.h b/include/sys/zio.h
34 index 4b0eecc2..3618912c 100644
35 --- a/include/sys/zio.h
36 +++ b/include/sys/zio.h
37 @@ -237,7 +237,7 @@ enum zio_child {
38 #define ZIO_CHILD_DDT_BIT ZIO_CHILD_BIT(ZIO_CHILD_DDT)
39 #define ZIO_CHILD_LOGICAL_BIT ZIO_CHILD_BIT(ZIO_CHILD_LOGICAL)
40 #define ZIO_CHILD_ALL_BITS \
41 - (ZIO_CHILD_VDEV_BIT | ZIO_CHILD_GANG_BIT | \
42 + (ZIO_CHILD_VDEV_BIT | ZIO_CHILD_GANG_BIT | \
43 ZIO_CHILD_DDT_BIT | ZIO_CHILD_LOGICAL_BIT)
46 @@ -375,7 +375,7 @@ typedef struct zio_transform {
47 struct zio_transform *zt_next;
50 -typedef int zio_pipe_stage_t(zio_t *zio);
51 +typedef zio_t *zio_pipe_stage_t(zio_t *zio);
54 * The io_reexecute flags are distinct from io_flags because the child must
55 diff --git a/module/zfs/zio.c b/module/zfs/zio.c
56 index 9a465e1b..b08b4747 100644
57 --- a/module/zfs/zio.c
58 +++ b/module/zfs/zio.c
59 @@ -75,9 +75,6 @@ uint64_t zio_buf_cache_frees[SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT];
61 int zio_delay_max = ZIO_DELAY_MAX;
63 -#define ZIO_PIPELINE_CONTINUE 0x100
64 -#define ZIO_PIPELINE_STOP 0x101
66 #define BP_SPANB(indblkshift, level) \
67 (((uint64_t)1) << ((level) * ((indblkshift) - SPA_BLKPTRSHIFT)))
68 #define COMPARE_META_LEVEL 0x80000000ul
69 @@ -516,7 +513,8 @@ zio_wait_for_children(zio_t *zio, uint8_t childbits, enum zio_wait_type wait)
71 __attribute__((always_inline))
73 -zio_notify_parent(zio_t *pio, zio_t *zio, enum zio_wait_type wait)
74 +zio_notify_parent(zio_t *pio, zio_t *zio, enum zio_wait_type wait,
75 + zio_t **next_to_executep)
77 uint64_t *countp = &pio->io_children[zio->io_child_type][wait];
78 int *errorp = &pio->io_child_error[zio->io_child_type];
79 @@ -535,13 +533,33 @@ zio_notify_parent(zio_t *pio, zio_t *zio, enum zio_wait_type wait)
82 mutex_exit(&pio->io_lock);
85 - * Dispatch the parent zio in its own taskq so that
86 - * the child can continue to make progress. This also
87 - * prevents overflowing the stack when we have deeply nested
88 - * parent-child relationships.
89 + * If we can tell the caller to execute this parent next, do
90 + * so. Otherwise dispatch the parent zio as its own task.
92 + * Having the caller execute the parent when possible reduces
93 + * locking on the zio taskq's, reduces context switch
94 + * overhead, and has no recursion penalty. Note that one
95 + * read from disk typically causes at least 3 zio's: a
96 + * zio_null(), the logical zio_read(), and then a physical
97 + * zio. When the physical ZIO completes, we are able to call
98 + * zio_done() on all 3 of these zio's from one invocation of
99 + * zio_execute() by returning the parent back to
100 + * zio_execute(). Since the parent isn't executed until this
101 + * thread returns back to zio_execute(), the caller should do
104 + * In other cases, dispatching the parent prevents
105 + * overflowing the stack when we have deeply nested
106 + * parent-child relationships, as we do with the "mega zio"
107 + * of writes for spa_sync(), and the chain of ZIL blocks.
109 - zio_taskq_dispatch(pio, type, B_FALSE);
110 + if (next_to_executep != NULL && *next_to_executep == NULL) {
111 + *next_to_executep = pio;
113 + zio_taskq_dispatch(pio, type, B_FALSE);
116 mutex_exit(&pio->io_lock);
118 @@ -1187,7 +1205,7 @@ zio_shrink(zio_t *zio, uint64_t size)
119 * ==========================================================================
124 zio_read_bp_init(zio_t *zio)
126 blkptr_t *bp = zio->io_bp;
127 @@ -1221,15 +1239,15 @@ zio_read_bp_init(zio_t *zio)
128 if (BP_GET_DEDUP(bp) && zio->io_child_type == ZIO_CHILD_LOGICAL)
129 zio->io_pipeline = ZIO_DDT_READ_PIPELINE;
131 - return (ZIO_PIPELINE_CONTINUE);
137 zio_write_bp_init(zio_t *zio)
140 if (!IO_IS_ALLOCATING(zio))
141 - return (ZIO_PIPELINE_CONTINUE);
144 ASSERT(zio->io_child_type != ZIO_CHILD_DDT);
146 @@ -1244,7 +1262,7 @@ zio_write_bp_init(zio_t *zio)
147 zio->io_pipeline = ZIO_INTERLOCK_PIPELINE;
149 if (BP_IS_EMBEDDED(bp))
150 - return (ZIO_PIPELINE_CONTINUE);
154 * If we've been overridden and nopwrite is set then
155 @@ -1255,13 +1273,13 @@ zio_write_bp_init(zio_t *zio)
156 ASSERT(!zp->zp_dedup);
157 ASSERT3U(BP_GET_CHECKSUM(bp), ==, zp->zp_checksum);
158 zio->io_flags |= ZIO_FLAG_NOPWRITE;
159 - return (ZIO_PIPELINE_CONTINUE);
163 ASSERT(!zp->zp_nopwrite);
165 if (BP_IS_HOLE(bp) || !zp->zp_dedup)
166 - return (ZIO_PIPELINE_CONTINUE);
169 ASSERT((zio_checksum_table[zp->zp_checksum].ci_flags &
170 ZCHECKSUM_FLAG_DEDUP) || zp->zp_dedup_verify);
171 @@ -1269,7 +1287,7 @@ zio_write_bp_init(zio_t *zio)
172 if (BP_GET_CHECKSUM(bp) == zp->zp_checksum) {
174 zio->io_pipeline |= ZIO_STAGE_DDT_WRITE;
175 - return (ZIO_PIPELINE_CONTINUE);
180 @@ -1281,10 +1299,10 @@ zio_write_bp_init(zio_t *zio)
181 zio->io_pipeline = zio->io_orig_pipeline;
184 - return (ZIO_PIPELINE_CONTINUE);
190 zio_write_compress(zio_t *zio)
192 spa_t *spa = zio->io_spa;
193 @@ -1303,11 +1321,11 @@ zio_write_compress(zio_t *zio)
195 if (zio_wait_for_children(zio, ZIO_CHILD_LOGICAL_BIT |
196 ZIO_CHILD_GANG_BIT, ZIO_WAIT_READY)) {
197 - return (ZIO_PIPELINE_STOP);
201 if (!IO_IS_ALLOCATING(zio))
202 - return (ZIO_PIPELINE_CONTINUE);
205 if (zio->io_children_ready != NULL) {
207 @@ -1366,7 +1384,7 @@ zio_write_compress(zio_t *zio)
208 zio->io_pipeline = ZIO_INTERLOCK_PIPELINE;
209 ASSERT(spa_feature_is_active(spa,
210 SPA_FEATURE_EMBEDDED_DATA));
211 - return (ZIO_PIPELINE_CONTINUE);
215 * Round up compressed size up to the ashift
216 @@ -1459,10 +1477,10 @@ zio_write_compress(zio_t *zio)
217 zio->io_pipeline |= ZIO_STAGE_NOP_WRITE;
220 - return (ZIO_PIPELINE_CONTINUE);
226 zio_free_bp_init(zio_t *zio)
228 blkptr_t *bp = zio->io_bp;
229 @@ -1472,7 +1490,7 @@ zio_free_bp_init(zio_t *zio)
230 zio->io_pipeline = ZIO_DDT_FREE_PIPELINE;
233 - return (ZIO_PIPELINE_CONTINUE);
238 @@ -1541,12 +1559,12 @@ zio_taskq_member(zio_t *zio, zio_taskq_type_t q)
244 zio_issue_async(zio_t *zio)
246 zio_taskq_dispatch(zio, ZIO_TASKQ_ISSUE, B_FALSE);
248 - return (ZIO_PIPELINE_STOP);
253 @@ -1687,14 +1705,13 @@ __attribute__((always_inline))
255 __zio_execute(zio_t *zio)
257 - zio->io_executor = curthread;
259 ASSERT3U(zio->io_queued_timestamp, >, 0);
261 while (zio->io_stage < ZIO_STAGE_DONE) {
262 enum zio_stage pipeline = zio->io_pipeline;
263 enum zio_stage stage = zio->io_stage;
266 + zio->io_executor = curthread;
268 ASSERT(!MUTEX_HELD(&zio->io_lock));
270 @@ -1736,12 +1753,16 @@ __zio_execute(zio_t *zio)
272 zio->io_stage = stage;
273 zio->io_pipeline_trace |= zio->io_stage;
274 - rv = zio_pipeline[highbit64(stage) - 1](zio);
276 - if (rv == ZIO_PIPELINE_STOP)
279 + * The zio pipeline stage returns the next zio to execute
280 + * (typically the same as this one), or NULL if we should
283 + zio = zio_pipeline[highbit64(stage) - 1](zio);
285 - ASSERT(rv == ZIO_PIPELINE_CONTINUE);
291 @@ -2215,7 +2236,7 @@ zio_gang_tree_issue(zio_t *pio, zio_gang_node_t *gn, blkptr_t *bp, abd_t *data,
297 zio_gang_assemble(zio_t *zio)
299 blkptr_t *bp = zio->io_bp;
300 @@ -2227,16 +2248,16 @@ zio_gang_assemble(zio_t *zio)
302 zio_gang_tree_assemble(zio, bp, &zio->io_gang_tree);
304 - return (ZIO_PIPELINE_CONTINUE);
310 zio_gang_issue(zio_t *zio)
312 blkptr_t *bp = zio->io_bp;
314 if (zio_wait_for_children(zio, ZIO_CHILD_GANG_BIT, ZIO_WAIT_DONE)) {
315 - return (ZIO_PIPELINE_STOP);
319 ASSERT(BP_IS_GANG(bp) && zio->io_gang_leader == zio);
320 @@ -2250,7 +2271,7 @@ zio_gang_issue(zio_t *zio)
322 zio->io_pipeline = ZIO_INTERLOCK_PIPELINE;
324 - return (ZIO_PIPELINE_CONTINUE);
329 @@ -2290,7 +2311,7 @@ zio_write_gang_done(zio_t *zio)
330 abd_put(zio->io_abd);
335 zio_write_gang_block(zio_t *pio)
337 spa_t *spa = pio->io_spa;
338 @@ -2349,7 +2370,7 @@ zio_write_gang_block(zio_t *pio)
341 pio->io_error = error;
342 - return (ZIO_PIPELINE_CONTINUE);
347 @@ -2423,7 +2444,7 @@ zio_write_gang_block(zio_t *pio)
351 - return (ZIO_PIPELINE_CONTINUE);
356 @@ -2444,7 +2465,7 @@ zio_write_gang_block(zio_t *pio)
357 * used for nopwrite, assuming that the salt and the checksums
358 * themselves remain secret.
362 zio_nop_write(zio_t *zio)
364 blkptr_t *bp = zio->io_bp;
365 @@ -2471,7 +2492,7 @@ zio_nop_write(zio_t *zio)
366 BP_GET_COMPRESS(bp) != BP_GET_COMPRESS(bp_orig) ||
367 BP_GET_DEDUP(bp) != BP_GET_DEDUP(bp_orig) ||
368 zp->zp_copies != BP_GET_NDVAS(bp_orig))
369 - return (ZIO_PIPELINE_CONTINUE);
373 * If the checksums match then reset the pipeline so that we
374 @@ -2491,7 +2512,7 @@ zio_nop_write(zio_t *zio)
375 zio->io_flags |= ZIO_FLAG_NOPWRITE;
378 - return (ZIO_PIPELINE_CONTINUE);
383 @@ -2519,7 +2540,7 @@ zio_ddt_child_read_done(zio_t *zio)
384 mutex_exit(&pio->io_lock);
389 zio_ddt_read_start(zio_t *zio)
391 blkptr_t *bp = zio->io_bp;
392 @@ -2540,7 +2561,7 @@ zio_ddt_read_start(zio_t *zio)
395 if (ddp_self == NULL)
396 - return (ZIO_PIPELINE_CONTINUE);
399 for (p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
400 if (ddp->ddp_phys_birth == 0 || ddp == ddp_self)
401 @@ -2553,23 +2574,23 @@ zio_ddt_read_start(zio_t *zio)
402 zio->io_priority, ZIO_DDT_CHILD_FLAGS(zio) |
403 ZIO_FLAG_DONT_PROPAGATE, &zio->io_bookmark));
405 - return (ZIO_PIPELINE_CONTINUE);
409 zio_nowait(zio_read(zio, zio->io_spa, bp,
410 zio->io_abd, zio->io_size, NULL, NULL, zio->io_priority,
411 ZIO_DDT_CHILD_FLAGS(zio), &zio->io_bookmark));
413 - return (ZIO_PIPELINE_CONTINUE);
419 zio_ddt_read_done(zio_t *zio)
421 blkptr_t *bp = zio->io_bp;
423 if (zio_wait_for_children(zio, ZIO_CHILD_DDT_BIT, ZIO_WAIT_DONE)) {
424 - return (ZIO_PIPELINE_STOP);
428 ASSERT(BP_GET_DEDUP(bp));
429 @@ -2581,12 +2602,12 @@ zio_ddt_read_done(zio_t *zio)
430 ddt_entry_t *dde = zio->io_vsd;
432 ASSERT(spa_load_state(zio->io_spa) != SPA_LOAD_NONE);
433 - return (ZIO_PIPELINE_CONTINUE);
437 zio->io_stage = ZIO_STAGE_DDT_READ_START >> 1;
438 zio_taskq_dispatch(zio, ZIO_TASKQ_ISSUE, B_FALSE);
439 - return (ZIO_PIPELINE_STOP);
442 if (dde->dde_repair_abd != NULL) {
443 abd_copy(zio->io_abd, dde->dde_repair_abd,
444 @@ -2599,7 +2620,7 @@ zio_ddt_read_done(zio_t *zio)
446 ASSERT(zio->io_vsd == NULL);
448 - return (ZIO_PIPELINE_CONTINUE);
453 @@ -2780,7 +2801,7 @@ zio_ddt_ditto_write_done(zio_t *zio)
459 zio_ddt_write(zio_t *zio)
461 spa_t *spa = zio->io_spa;
462 @@ -2822,7 +2843,7 @@ zio_ddt_write(zio_t *zio)
464 zio->io_pipeline = ZIO_WRITE_PIPELINE;
466 - return (ZIO_PIPELINE_CONTINUE);
470 ditto_copies = ddt_ditto_copies_needed(ddt, dde, ddp);
471 @@ -2848,7 +2869,7 @@ zio_ddt_write(zio_t *zio)
472 zio->io_bp_override = NULL;
475 - return (ZIO_PIPELINE_CONTINUE);
479 dio = zio_write(zio, spa, txg, bp, zio->io_orig_abd,
480 @@ -2890,12 +2911,12 @@ zio_ddt_write(zio_t *zio)
484 - return (ZIO_PIPELINE_CONTINUE);
488 ddt_entry_t *freedde; /* for debugging */
492 zio_ddt_free(zio_t *zio)
494 spa_t *spa = zio->io_spa;
495 @@ -2916,7 +2937,7 @@ zio_ddt_free(zio_t *zio)
499 - return (ZIO_PIPELINE_CONTINUE);
504 @@ -2953,7 +2974,7 @@ zio_io_to_allocate(spa_t *spa)
510 zio_dva_throttle(zio_t *zio)
512 spa_t *spa = zio->io_spa;
513 @@ -2963,7 +2984,7 @@ zio_dva_throttle(zio_t *zio)
514 !spa_normal_class(zio->io_spa)->mc_alloc_throttle_enabled ||
515 zio->io_child_type == ZIO_CHILD_GANG ||
516 zio->io_flags & ZIO_FLAG_NODATA) {
517 - return (ZIO_PIPELINE_CONTINUE);
521 ASSERT(zio->io_child_type > ZIO_CHILD_GANG);
522 @@ -2979,22 +3000,7 @@ zio_dva_throttle(zio_t *zio)
523 nio = zio_io_to_allocate(zio->io_spa);
524 mutex_exit(&spa->spa_alloc_lock);
527 - return (ZIO_PIPELINE_CONTINUE);
530 - ASSERT(nio->io_stage == ZIO_STAGE_DVA_THROTTLE);
532 - * We are passing control to a new zio so make sure that
533 - * it is processed by a different thread. We do this to
534 - * avoid stack overflows that can occur when parents are
535 - * throttled and children are making progress. We allow
536 - * it to go to the head of the taskq since it's already
539 - zio_taskq_dispatch(nio, ZIO_TASKQ_ISSUE, B_TRUE);
541 - return (ZIO_PIPELINE_STOP);
546 @@ -3013,7 +3019,7 @@ zio_allocate_dispatch(spa_t *spa)
547 zio_taskq_dispatch(zio, ZIO_TASKQ_ISSUE, B_TRUE);
552 zio_dva_allocate(zio_t *zio)
554 spa_t *spa = zio->io_spa;
555 @@ -3054,18 +3060,18 @@ zio_dva_allocate(zio_t *zio)
556 zio->io_error = error;
559 - return (ZIO_PIPELINE_CONTINUE);
565 zio_dva_free(zio_t *zio)
567 metaslab_free(zio->io_spa, zio->io_bp, zio->io_txg, B_FALSE);
569 - return (ZIO_PIPELINE_CONTINUE);
575 zio_dva_claim(zio_t *zio)
578 @@ -3074,7 +3080,7 @@ zio_dva_claim(zio_t *zio)
580 zio->io_error = error;
582 - return (ZIO_PIPELINE_CONTINUE);
587 @@ -3172,7 +3178,7 @@ zio_free_zil(spa_t *spa, uint64_t txg, blkptr_t *bp)
588 * force the underlying vdev layers to call either zio_execute() or
589 * zio_interrupt() to ensure that the pipeline continues with the correct I/O.
593 zio_vdev_io_start(zio_t *zio)
595 vdev_t *vd = zio->io_vd;
596 @@ -3192,7 +3198,7 @@ zio_vdev_io_start(zio_t *zio)
597 * The mirror_ops handle multiple DVAs in a single BP.
599 vdev_mirror_ops.vdev_op_io_start(zio);
600 - return (ZIO_PIPELINE_STOP);
604 ASSERT3P(zio->io_logical, !=, zio);
605 @@ -3269,31 +3275,31 @@ zio_vdev_io_start(zio_t *zio)
606 !vdev_dtl_contains(vd, DTL_PARTIAL, zio->io_txg, 1)) {
607 ASSERT(zio->io_type == ZIO_TYPE_WRITE);
608 zio_vdev_io_bypass(zio);
609 - return (ZIO_PIPELINE_CONTINUE);
613 if (vd->vdev_ops->vdev_op_leaf &&
614 (zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE)) {
616 if (zio->io_type == ZIO_TYPE_READ && vdev_cache_read(zio))
617 - return (ZIO_PIPELINE_CONTINUE);
620 if ((zio = vdev_queue_io(zio)) == NULL)
621 - return (ZIO_PIPELINE_STOP);
624 if (!vdev_accessible(vd, zio)) {
625 zio->io_error = SET_ERROR(ENXIO);
627 - return (ZIO_PIPELINE_STOP);
630 zio->io_delay = gethrtime();
633 vd->vdev_ops->vdev_op_io_start(zio);
634 - return (ZIO_PIPELINE_STOP);
640 zio_vdev_io_done(zio_t *zio)
642 vdev_t *vd = zio->io_vd;
643 @@ -3301,7 +3307,7 @@ zio_vdev_io_done(zio_t *zio)
644 boolean_t unexpected_error = B_FALSE;
646 if (zio_wait_for_children(zio, ZIO_CHILD_VDEV_BIT, ZIO_WAIT_DONE)) {
647 - return (ZIO_PIPELINE_STOP);
651 ASSERT(zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE);
652 @@ -3337,7 +3343,7 @@ zio_vdev_io_done(zio_t *zio)
653 if (unexpected_error)
654 VERIFY(vdev_probe(vd, zio) == NULL);
656 - return (ZIO_PIPELINE_CONTINUE);
661 @@ -3366,13 +3372,13 @@ zio_vsd_default_cksum_report(zio_t *zio, zio_cksum_report_t *zcr, void *ignored)
662 zcr->zcr_free = zio_abd_free;
667 zio_vdev_io_assess(zio_t *zio)
669 vdev_t *vd = zio->io_vd;
671 if (zio_wait_for_children(zio, ZIO_CHILD_VDEV_BIT, ZIO_WAIT_DONE)) {
672 - return (ZIO_PIPELINE_STOP);
676 if (vd == NULL && !(zio->io_flags & ZIO_FLAG_CONFIG_WRITER))
677 @@ -3402,7 +3408,7 @@ zio_vdev_io_assess(zio_t *zio)
678 zio->io_stage = ZIO_STAGE_VDEV_IO_START >> 1;
679 zio_taskq_dispatch(zio, ZIO_TASKQ_ISSUE,
680 zio_requeue_io_start_cut_in_line);
681 - return (ZIO_PIPELINE_STOP);
686 @@ -3442,7 +3448,7 @@ zio_vdev_io_assess(zio_t *zio)
687 zio->io_physdone(zio->io_logical);
690 - return (ZIO_PIPELINE_CONTINUE);
695 @@ -3477,7 +3483,7 @@ zio_vdev_io_bypass(zio_t *zio)
696 * Generate and verify checksums
697 * ==========================================================================
701 zio_checksum_generate(zio_t *zio)
703 blkptr_t *bp = zio->io_bp;
704 @@ -3491,7 +3497,7 @@ zio_checksum_generate(zio_t *zio)
705 checksum = zio->io_prop.zp_checksum;
707 if (checksum == ZIO_CHECKSUM_OFF)
708 - return (ZIO_PIPELINE_CONTINUE);
711 ASSERT(checksum == ZIO_CHECKSUM_LABEL);
713 @@ -3505,10 +3511,10 @@ zio_checksum_generate(zio_t *zio)
715 zio_checksum_compute(zio, checksum, zio->io_abd, zio->io_size);
717 - return (ZIO_PIPELINE_CONTINUE);
723 zio_checksum_verify(zio_t *zio)
725 zio_bad_cksum_t info;
726 @@ -3523,7 +3529,7 @@ zio_checksum_verify(zio_t *zio)
727 * We're either verifying a label checksum, or nothing at all.
729 if (zio->io_prop.zp_checksum == ZIO_CHECKSUM_OFF)
730 - return (ZIO_PIPELINE_CONTINUE);
733 ASSERT(zio->io_prop.zp_checksum == ZIO_CHECKSUM_LABEL);
735 @@ -3538,7 +3544,7 @@ zio_checksum_verify(zio_t *zio)
739 - return (ZIO_PIPELINE_CONTINUE);
744 @@ -3581,7 +3587,7 @@ zio_worst_error(int e1, int e2)
746 * ==========================================================================
750 zio_ready(zio_t *zio)
752 blkptr_t *bp = zio->io_bp;
753 @@ -3590,7 +3596,7 @@ zio_ready(zio_t *zio)
755 if (zio_wait_for_children(zio, ZIO_CHILD_GANG_BIT | ZIO_CHILD_DDT_BIT,
757 - return (ZIO_PIPELINE_STOP);
762 @@ -3636,7 +3642,7 @@ zio_ready(zio_t *zio)
764 for (; pio != NULL; pio = pio_next) {
765 pio_next = zio_walk_parents(zio, &zl);
766 - zio_notify_parent(pio, zio, ZIO_WAIT_READY);
767 + zio_notify_parent(pio, zio, ZIO_WAIT_READY, NULL);
770 if (zio->io_flags & ZIO_FLAG_NODATA) {
771 @@ -3652,7 +3658,7 @@ zio_ready(zio_t *zio)
772 zio->io_spa->spa_syncing_txg == zio->io_txg)
773 zio_handle_ignored_writes(zio);
775 - return (ZIO_PIPELINE_CONTINUE);
780 @@ -3716,7 +3722,7 @@ zio_dva_throttle_done(zio_t *zio)
781 zio_allocate_dispatch(zio->io_spa);
789 @@ -3733,7 +3739,7 @@ zio_done(zio_t *zio)
790 * wait for them and then repeat this pipeline stage.
792 if (zio_wait_for_children(zio, ZIO_CHILD_ALL_BITS, ZIO_WAIT_DONE)) {
793 - return (ZIO_PIPELINE_STOP);
798 @@ -3957,7 +3963,12 @@ zio_done(zio_t *zio)
799 if ((pio->io_flags & ZIO_FLAG_GODFATHER) &&
800 (zio->io_reexecute & ZIO_REEXECUTE_SUSPEND)) {
801 zio_remove_child(pio, zio, remove_zl);
802 - zio_notify_parent(pio, zio, ZIO_WAIT_DONE);
804 + * This is a rare code path, so we don't
805 + * bother with "next_to_execute".
807 + zio_notify_parent(pio, zio, ZIO_WAIT_DONE,
812 @@ -3969,7 +3980,11 @@ zio_done(zio_t *zio)
814 ASSERT(!(zio->io_flags & ZIO_FLAG_GODFATHER));
815 zio->io_flags |= ZIO_FLAG_DONT_PROPAGATE;
816 - zio_notify_parent(pio, zio, ZIO_WAIT_DONE);
818 + * This is a rare code path, so we don't bother with
819 + * "next_to_execute".
821 + zio_notify_parent(pio, zio, ZIO_WAIT_DONE, NULL);
822 } else if (zio->io_reexecute & ZIO_REEXECUTE_SUSPEND) {
824 * We'd fail again if we reexecuted now, so suspend
825 @@ -3987,7 +4002,7 @@ zio_done(zio_t *zio)
826 (task_func_t *)zio_reexecute, zio, 0,
829 - return (ZIO_PIPELINE_STOP);
833 ASSERT(zio->io_child_count == 0);
834 @@ -4023,12 +4038,17 @@ zio_done(zio_t *zio)
835 zio->io_state[ZIO_WAIT_DONE] = 1;
836 mutex_exit(&zio->io_lock);
839 + * We are done executing this zio. We may want to execute a parent
840 + * next. See the comment in zio_notify_parent().
842 + zio_t *next_to_execute = NULL;
844 for (pio = zio_walk_parents(zio, &zl); pio != NULL; pio = pio_next) {
845 zio_link_t *remove_zl = zl;
846 pio_next = zio_walk_parents(zio, &zl);
847 zio_remove_child(pio, zio, remove_zl);
848 - zio_notify_parent(pio, zio, ZIO_WAIT_DONE);
849 + zio_notify_parent(pio, zio, ZIO_WAIT_DONE, &next_to_execute);
852 if (zio->io_waiter != NULL) {
853 @@ -4040,7 +4060,7 @@ zio_done(zio_t *zio)
857 - return (ZIO_PIPELINE_STOP);
858 + return (next_to_execute);