Commit 79cf54582 ("Fix reads for blocks freed after being cloned")
reworked the level-0 check in dbuf_read_hole() and dropped the
BP_IS_HOLE() recheck that followed dnode_block_freed(), together with
the comment explaining it. That recheck was not about overrides: it
closes a race with dnode_sync().
dnode_sync_free_ranges() drops dn_mtx, clears the bps through
dnode_sync_free_range_impl() -> free_blocks(), then retakes dn_mtx and
removes the range from dn_free_ranges. For blkptrs held in the dnode
(dn_nlevels == 1), free_blocks() writes the bp without the parent's
db_rwlock, so holding that lock in dbuf_read() does not serialize
against it. A reader that saw a non-hole bp, then waited on dn_mtx in
dnode_block_freed() until the range was removed, gets "not freed" while
the bp it is about to copy is already a hole (with HOLE_BIRTH, lsize
and birth preserved). dbuf_read_impl() then hands that hole to
arc_read(): no child I/O is issued, checksum verification fails with
EINVAL, and without ZIO_FLAG_CANFAIL the pool is suspended.
Restore the recheck for the non-override path. The override path
(block clone / Direct I/O) checks the overriding bp, which
free_blocks() does not touch, so it is left as is.
Reproduced on 2.3.9 with a test-only delay widening the window between
the first BP_IS_HOLE() and dnode_block_freed(): reads of punched
single-block files return EINVAL with the same ereport as in #19185.
With this change, the same test returns no error.
This change, its analysis and its description were prepared with the
help of an AI assistant (Claude), then reviewed and tested by the
submitter.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Cyrille C. <coquardcyr@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Fixes: a6f557c2cb58 ("Fix reads for blocks freed after being cloned")
Closes #19185
Closes #19234
(cherry picked from commit f1f96f5e7b01c791add67b27e8014e3986d10513)