btrfs: fix generic/563 failures with sectorsize < PAGE_SIZE
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | btrfs: make btrfs_do_readpage() to do block-by-block readfs/ | +12 | 0 replies | |
| 2/2 | btrfs: allow buffered write to skip full page if it's sector alignedfs/ fs/ | +9 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] btrfs: fix generic/563 failures with sectorsize < PAGE_SIZE
The test case generic/563 always fail on 64K page sized systems with btrfs, however there are two different causes:
- sector size == page size
In that case, it's the test case not using aligned block size, causing the btrfs (and ext4) to read out the full page before buffered write.
This is fixed by the following patch:
https://lore.kernel.org/linux-btrfs/[email protected]/
- sector size < page size
This is a problem inside btrfs, which can not handle partial uptodate pages, thus even if the buffered write covers a full sector, btrfs will still read the full page, causing unnecessary IO. This is btrfs specific, and ext4/xfs doesn't not have this problem.
This patchset fix the sector size < page size case for btrfs, by:
- Changing btrfs_do_readpage() to do block-by-block read This allows btrfs to do per-sector uptodate check, not just relying on the extent map checks.
- Changing both buffered read and write path to handle partial uptodate pages
For the buffered write path, it's pretty straight forward, just skip the full page read if the range covers full sectors.
It's the buffered read path needs the extra work, by skipping any read into the already uptodate sectors.
Or we can have a dirtied range, and read (from holes) re-fill the dirtied range with 0, causing data corruption.
With these two patches, 4K sector sized btrfs on 64K page sized systems can pass generic/563 now.
Although considering I have hit data corruption due to the above read path not skipping uptodate sectors, I'm wondering should I put the full page read skip code under EXPERIMENTAL flags.
At least this is only affecting subpage cases, the more common x86_64 cases will not be affected.
Qu Wenruo (2):
btrfs: make btrfs_do_readpage() to do block-by-block read
btrfs: allow buffered write to skip full page if it's sector aligned
fs/btrfs/extent_io.c | 43 ++++++++++++++++++------------------------- fs/btrfs/file.c | 5 +++-- 2 files changed, 21 insertions(+), 27 deletions(-)
Signature · 1 line
2.46.2