From 370570890f4350b26053a1e2687d528fc28fb72e Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Wed, 18 Feb 2026 21:12:13 -0500 Subject: [PATCH] Remove parent ZIO from dbuf_prefetch() I am not sure why it was added there 10 years ago, but it seems not needed now. According to my tests removing it improves sequential read performance with recordsize=4K by 5-10% by reducing the CPU overhead in prefetcher. Reviewed-by: Brian Behlendorf Reviewed-by: Rob Norris Reviewed-by: Ameer Hamza Reviewed-by: Akash B Signed-off-by: Alexander Motin Closes #18214 --- module/zfs/dbuf.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index 8d7dbbc11..df75d3fbe 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -3553,7 +3553,6 @@ typedef struct dbuf_prefetch_arg { int dpa_curlevel; /* The current level that we're reading */ dnode_t *dpa_dnode; /* The dnode associated with the prefetch */ zio_priority_t dpa_prio; /* The priority I/Os should be issued at. */ - zio_t *dpa_zio; /* The parent zio_t for all prefetches. */ arc_flags_t dpa_aflags; /* Flags to pass to the final prefetch. */ dbuf_prefetch_fn dpa_cb; /* prefetch completion callback */ void *dpa_arg; /* prefetch completion arg */ @@ -3605,8 +3604,7 @@ dbuf_issue_final_prefetch(dbuf_prefetch_arg_t *dpa, blkptr_t *bp) ASSERT3U(dpa->dpa_curlevel, ==, BP_GET_LEVEL(bp)); ASSERT3U(dpa->dpa_curlevel, ==, dpa->dpa_zb.zb_level); - ASSERT(dpa->dpa_zio != NULL); - (void) arc_read(dpa->dpa_zio, dpa->dpa_spa, bp, + (void) arc_read(NULL, dpa->dpa_spa, bp, dbuf_issue_final_prefetch_done, dpa, dpa->dpa_prio, zio_flags, &aflags, &dpa->dpa_zb); } @@ -3706,7 +3704,7 @@ dbuf_prefetch_indirect_done(zio_t *zio, const zbookmark_phys_t *zb, SET_BOOKMARK(&zb, dpa->dpa_zb.zb_objset, dpa->dpa_zb.zb_object, dpa->dpa_curlevel, nextblkid); - (void) arc_read(dpa->dpa_zio, dpa->dpa_spa, + (void) arc_read(NULL, dpa->dpa_spa, bp, dbuf_prefetch_indirect_done, dpa, ZIO_PRIORITY_SYNC_READ, ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE, @@ -3801,9 +3799,6 @@ dbuf_prefetch_impl(dnode_t *dn, int64_t level, uint64_t blkid, ASSERT3U(curlevel, ==, BP_GET_LEVEL(&bp)); - zio_t *pio = zio_root(dmu_objset_spa(dn->dn_objset), NULL, NULL, - ZIO_FLAG_CANFAIL); - dbuf_prefetch_arg_t *dpa = kmem_zalloc(sizeof (*dpa), KM_SLEEP); dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset; SET_BOOKMARK(&dpa->dpa_zb, ds != NULL ? ds->ds_object : DMU_META_OBJSET, @@ -3814,7 +3809,6 @@ dbuf_prefetch_impl(dnode_t *dn, int64_t level, uint64_t blkid, dpa->dpa_spa = dn->dn_objset->os_spa; dpa->dpa_dnode = dn; dpa->dpa_epbs = epbs; - dpa->dpa_zio = pio; dpa->dpa_cb = cb; dpa->dpa_arg = arg; @@ -3843,17 +3837,12 @@ dbuf_prefetch_impl(dnode_t *dn, int64_t level, uint64_t blkid, SET_BOOKMARK(&zb, ds != NULL ? ds->ds_object : DMU_META_OBJSET, dn->dn_object, curlevel, curblkid); - (void) arc_read(dpa->dpa_zio, dpa->dpa_spa, + (void) arc_read(NULL, dpa->dpa_spa, &bp, dbuf_prefetch_indirect_done, dpa, ZIO_PRIORITY_SYNC_READ, ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE, &iter_aflags, &zb); } - /* - * We use pio here instead of dpa_zio since it's possible that - * dpa may have already been freed. - */ - zio_nowait(pio); return (1); no_issue: if (cb != NULL)