btrfs: fix corner cases for subpage generic/363 failures
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest2 patches 4 repliesIn review
- v32 patches 0 repliesSuperseded
- v22 patches 0 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 2 patches | 10 replies | Superseded |
Changes in v4 from the cover letter
- Rebased to the latest for-next branch btrfs_free_extent_map() renames cause a minor conflict in the first patch.
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | btrfs: make btrfs_truncate_block() to zero involved blocks in a foliofs/ fs/ fs/ | +75 | 2 replies | |
| 2/2 | btrfs: make btrfs_truncate_block() zero folio range for certain subpage corner casesfs/ | +88 | 2 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.
Cover letter [PATCH v4 0/2] btrfs: fix corner cases for subpage generic/363 failures
[CHANGELOG]
v4:
- Rebased to the latest for-next branch btrfs_free_extent_map() renames cause a minor conflict in the first patch.
v3:
- Fix a typo where @block_size should @blocksize.
There is a global function, block_size(), thus this typo will cause type conflicts inside round_down()/round_up().
v2:
- Fix a conversion bug in the first patch that leads to generic/008 failure on x86_64
The range is passed incorrectly and caused btrfs_truncate_block() to incorrectly skip an unaligned range.
Test case generic/363 always fail on subpage (fs block fs < page size) btrfses, there are mostly two kinds of problems here:
All examples are based on 64K page size and 4K fs block size.
1) EOF is polluted and btrfs_truncate_block() only zeros the block that needs to be written back
0 32K 64K
| | |GGGGGGGGGGGGGG|
50K EOF The original file is 50K sized (not 4K aligned), and fsx polluted the range beyond EOF through memory mapped write.
And since memory mapped write is page based, and our page size is larger than block size, the page range [0, 64K) covere blocks beyond EOF.
Those polluted range will not be written back, but will still affect our page cache.
Then some operation happens to expand the inode to size 64K.
In that case btrfs_truncate_block() is called to trim the block [48K, 52K), and that block will be marked dirty for written back.
But the range [52K, 64K) is untouched at all, left the garbage hanging there, triggering fsx -e 1 failure.
Fix this case by force btrfs_truncate_block() to zeroing any involved blocks. (Meanwhile still only one block [48K, 52K) will be written back)
2) EOF is polluted and the original size is block aligned so btrfs_truncate_block() does nothing
0 32K 64K
| | |GGGGGGGGGGGG|
52K EOF Mostly the same as case 1, but this time since the inode size is block aligned, btrfs_truncate_block() will do nothing.
Leaving the garbage range [52K, 64K) untouched and fail fsx -e 1 runs.
Fix this case by force btrfs_truncate_block() to zeroing any involved blocks when the btrfs is subpage and the range is aligned. This will not cause any new dirty blocks, but purely zeroing out EOF to pass fsx -e 1 runs.
Qu Wenruo (2):
btrfs: make btrfs_truncate_block() to zero involved blocks in a folio
btrfs: make btrfs_truncate_block() zero folio range for certain
subpage corner cases
fs/btrfs/btrfs_inode.h | 10 ++- fs/btrfs/file.c | 37 ++++++---- fs/btrfs/inode.c | 153 ++++++++++++++++++++++++++++++++++------- 3 files changed, 162 insertions(+), 38 deletions(-)
Signature · 1 line
2.49.0