Fix read corruption after block clone after truncate
When copy_file_range overwrites a recent truncation, subsequent reads can incorrectly determine that it is read hole instead of reading the cloned blocks.
This can happen when the following conditions are met:
- Truncate adds blkid to dn_free_ranges
- A new TXG is created
- copy_file_range calls dmu_brt_clone which override the block pointer and set DB_NOFILL
- Subsequent read, given DB_NOFILL, hits dbuf_read_impl and dbuf_read_hole
- dbuf_read_hole calls dnode_block_freed, which returns TRUE because the truncated blkids are still in dn_free_ranges
This will not happen if the clone and truncate are in the same TXG, because the block clone would update the current TXG’s dn_free_ranges, which is why this bug only triggers under high IO load (such as compilation).
Fix this by skipping the dnode_block_freed call if the block is overridden. The fix shouldn’t cause an issue when the cloned block is subsequently freed in later TXGs, as dbuf_undirty would remove the override.
This requires a dedicated test program as it is much harder to trigger with scripts (this needs to generate a lot of I/O in short period of time for the bug to trigger reliably).
Assisted-by: Gemini:gemini-3.1-pro Reviewed-by: Brian Behlendorf behlendorf1@llnl.gov Reviewed-by: Tony Hutter hutter2@llnl.gov Signed-off-by: Gary Guo gary@kernel.org Closes #18412 Closes #18421
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
OpenZFS is an advanced file system and volume manager which was originally developed for Solaris and is now maintained by the OpenZFS community. This repository contains the code for running OpenZFS on Linux and FreeBSD.
Official Resources
Installation
Full documentation for installing OpenZFS on your favorite operating system can be found at the Getting Started Page.
Contribute & Develop
We have a separate document with contribution guidelines.
We have a Code of Conduct.
Release
OpenZFS is released under a CDDL license. For more details see the NOTICE, LICENSE and COPYRIGHT files;
UCRL-CODE-235197Supported Kernels and Distributions
Linux
Given the wide variety of Linux environments, we prioritize development and testing on stable, supported kernels and distributions.
Kernel (kernel.org)
All longterm kernels from kernel.org are supported. stable kernels are usually supported in the next OpenZFS release.
Supported longterm kernels: 6.18, 6.12, 6.6, 6.1, 5.15, 5.10.
Red Hat Enterprise Linux (RHEL)
All RHEL (and compatible systems: AlmaLinux OS, Rocky Linux, etc) on the full or maintenance support tracks are supported.
Supported RHEL releases: 8.10, 9.7, 10.1.
Ubuntu
All Ubuntu LTS releases are supported.
Supported Ubuntu releases: 24.04 “Noble”, 22.04 “Jammy”.
Debian
All Debian stable and LTS releases are supported.
Supported Debian releases: 13 “Trixie”, 12 “Bookworm”, 11 “Bullseye”.
Other Distributions
Generally, if a distribution is following an LTS kernel, it should work well with OpenZFS.
FreeBSD
All FreeBSD releases receiving security support are supported by OpenZFS.
Supported FreeBSD releases: 15.0, 14.4, 13.5.