aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/netmap/netmap_kloop.c
diff options
context:
space:
mode:
authorCyrille C. <18537428+CrochetFeve0251@users.noreply.github.com>2026-10-06 23:11:09 +0000
committerRyan Moeller <rmoeller@FreeBSD.org>2026-11-14 04:45:48 +0000
commit78ca640f79c585ea737c03a0c427bfe53582fd30 (patch)
tree04fc369389357b1efa72f913cc2031e6b917ab2f /sys/dev/netmap/netmap_kloop.c
parentfdd6b206a303a0bdef94a6468b345c10ac53351d (diff)
dbuf: restore BP_IS_HOLE() recheck after dnode_block_freed()
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 Approved by: kevans (mentor) (cherry picked from commit f1f96f5e7b01c791add67b27e8014e3986d10513)
Diffstat (limited to 'sys/dev/netmap/netmap_kloop.c')
0 files changed, 0 insertions, 0 deletions