]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commit
btrfs: verify the read behavior of compressed inline extent
authorQu Wenruo <wqu@suse.com>
Sat, 27 Jan 2024 20:44:17 +0000 (07:14 +1030)
committerZorro Lang <zlang@kernel.org>
Fri, 9 Feb 2024 05:27:17 +0000 (13:27 +0800)
commit52c6d0f30ae5d087baff79a270f33144effd02e1
treeec80112e5c3be644a1b572bbe2b187f0ff9ed331
parent7e1ca29d30389f385086f7be2c6547d05b208afd
btrfs: verify the read behavior of compressed inline extent

[BUG]
There is a report about reading a zstd compressed inline file extent
would lead to either a VM_BUG_ON() crash, or lead to incorrect file
content.

[CAUSE]
The root cause is a incorrect memcpy_to_page() call, which uses
incorrect page offset, and can lead to either the VM_BUG_ON() as we may
write beyond the page boundary, or writes into the incorrect offset of
the page.

[TEST CASE]
The test case would:

- Mount with the specified compress algorithm
- Create a 4K file
- Verify the 4K file is all inlined and compressed
- Verify the content of the initial write
- Cycle mount to drop all the page cache
- Verify the content of the file again
- Unmount and fsck the fs

This workload would be applied to all supported compression algorithms.
And it can catch the problem correctly by triggering VM_BUG_ON(), as our
workload would result decompressed extent size to be 4K, and would
trigger the VM_BUG_ON() 100%.
And with the revert or the new fix, the test case can pass safely.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Neal Gompa <neal@gompa.dev>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/btrfs/310 [new file with mode: 0755]
tests/btrfs/310.out [new file with mode: 0644]