On Tue, 23 Jan 2024 14:19:08 +1030, Qu Wenruo wrote: > [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@xxxxxxxx> > --- > tests/btrfs/310 | 81 +++++++++++++++++++++++++++++++++++++++++++++ > tests/btrfs/310.out | 2 ++ > 2 files changed, 83 insertions(+) > create mode 100755 tests/btrfs/310 > create mode 100644 tests/btrfs/310.out > > diff --git a/tests/btrfs/310 b/tests/btrfs/310 > new file mode 100755 > index 00000000..b514a8bc > --- /dev/null > +++ b/tests/btrfs/310 > @@ -0,0 +1,81 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (C) 2024 SUSE Linux Products GmbH. All Rights Reserved. > +# > +# FS QA Test 310 > +# > +# Make sure reading on an compressed inline extent is behaving correctly > +# > +. ./common/preamble > +_begin_fstest auto quick compress > + > +# Import common functions. > +# . ./common/filter > + > +# real QA test starts here > + > +# Modify as appropriate. > +_supported_fs btrfs > +_require_scratch > + > +# This test require inlined compressed extents creation, and all the writes > +# are designed for 4K sector size. > +_require_btrfs_inline_extents_creation > +_require_btrfs_support_sectorsize 4096 Hopefully coverage can be expanded in future to cover some other sector sizes. This looks fine for now: Reviewed-by: David Disseldorp <ddiss@xxxxxxx>