Message ID | 795fcb629a2bbfeaf39023d971b7cb3a468aa87f.1706819794.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fstests: add a regression test for fiemap into an mmap range | expand |
On 2024/2/2 07:06, Josef Bacik wrote: > Btrfs had a deadlock that you could trigger by mmap'ing a large file and > using that as the buffer for fiemap. This test adds a c program to do > this, and the fstest creates a large enough file and then runs the > reproducer on the file. Without the fix btrfs deadlocks, with the fix > we pass fine. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> > --- > src/Makefile | 2 +- > tests/generic/740 | 41 +++++++++++++++++++++++++++++++++++++++++ > tests/generic/740.out | 2 ++ I guess you forgot to add the source file of fiemap-fault? Thanks, Qu > 3 files changed, 44 insertions(+), 1 deletion(-) > create mode 100644 tests/generic/740 > create mode 100644 tests/generic/740.out > > diff --git a/src/Makefile b/src/Makefile > index d79015ce..916f6755 100644 > --- a/src/Makefile > +++ b/src/Makefile > @@ -34,7 +34,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ > attr_replace_test swapon mkswap t_attr_corruption t_open_tmpfiles \ > fscrypt-crypt-util bulkstat_null_ocount splice-test chprojid_fail \ > detached_mounts_propagation ext4_resize t_readdir_3 splice2pipe \ > - uuid_ioctl > + uuid_ioctl fiemap-fault > > EXTRA_EXECS = dmerror fill2attr fill2fs fill2fs_check scaleread.sh \ > btrfs_crc32c_forged_name.py popdir.pl popattr.py \ > diff --git a/tests/generic/740 b/tests/generic/740 > new file mode 100644 > index 00000000..46ec5820 > --- /dev/null > +++ b/tests/generic/740 > @@ -0,0 +1,41 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved. > +# > +# FS QA Test 708 > +# > +# Test fiemap into an mmaped buffer of the same file > +# > +# Create a reasonably large file, then run a program which mmaps it and uses > +# that as a buffer for an fiemap call. This is a regression test for btrfs > +# where we used to hold a lock for the duration of the fiemap call which would > +# result in a deadlock if we page faulted. > +# > +. ./common/preamble > +_begin_fstest quick auto > +[ $FSTYP == "btrfs" ] && \ > + _fixed_by_kernel_commit xxxxxxxxxxxx \ > + "btrfs: fix deadlock with fiemap and extent locking" > + > +# real QA test starts here > +_supported_fs generic > +_require_test > +_require_odirect > +_require_test_program fiemap-fault > +dst=$TEST_DIR/fiemap-fault-$seq > + > +echo "Silence is golden" > + > +for i in $(seq 0 2 1000) > +do > + $XFS_IO_PROG -d -f -c "pwrite -q $((i * 4096)) 4096" $dst > +done > + > +$here/src/fiemap-fault $dst > /dev/null || _fail "failed doing fiemap" > + > +rm -f $dst > + > +# success, all done > +status=$? > +exit > + > diff --git a/tests/generic/740.out b/tests/generic/740.out > new file mode 100644 > index 00000000..3f841e60 > --- /dev/null > +++ b/tests/generic/740.out > @@ -0,0 +1,2 @@ > +QA output created by 740 > +Silence is golden
On Thu, Feb 1, 2024 at 8:37 PM Josef Bacik <josef@toxicpanda.com> wrote: > > Btrfs had a deadlock that you could trigger by mmap'ing a large file and > using that as the buffer for fiemap. This test adds a c program to do > this, and the fstest creates a large enough file and then runs the > reproducer on the file. Without the fix btrfs deadlocks, with the fix > we pass fine. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> > --- > src/Makefile | 2 +- > tests/generic/740 | 41 +++++++++++++++++++++++++++++++++++++++++ > tests/generic/740.out | 2 ++ > 3 files changed, 44 insertions(+), 1 deletion(-) > create mode 100644 tests/generic/740 > create mode 100644 tests/generic/740.out > > diff --git a/src/Makefile b/src/Makefile > index d79015ce..916f6755 100644 > --- a/src/Makefile > +++ b/src/Makefile > @@ -34,7 +34,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ > attr_replace_test swapon mkswap t_attr_corruption t_open_tmpfiles \ > fscrypt-crypt-util bulkstat_null_ocount splice-test chprojid_fail \ > detached_mounts_propagation ext4_resize t_readdir_3 splice2pipe \ > - uuid_ioctl > + uuid_ioctl fiemap-fault > > EXTRA_EXECS = dmerror fill2attr fill2fs fill2fs_check scaleread.sh \ > btrfs_crc32c_forged_name.py popdir.pl popattr.py \ > diff --git a/tests/generic/740 b/tests/generic/740 > new file mode 100644 > index 00000000..46ec5820 > --- /dev/null > +++ b/tests/generic/740 > @@ -0,0 +1,41 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved. > +# > +# FS QA Test 708 > +# > +# Test fiemap into an mmaped buffer of the same file > +# > +# Create a reasonably large file, then run a program which mmaps it and uses > +# that as a buffer for an fiemap call. This is a regression test for btrfs > +# where we used to hold a lock for the duration of the fiemap call which would > +# result in a deadlock if we page faulted. > +# > +. ./common/preamble > +_begin_fstest quick auto Besides the missing C file, please also add the "fiemap" group to the test. Thanks. > +[ $FSTYP == "btrfs" ] && \ > + _fixed_by_kernel_commit xxxxxxxxxxxx \ > + "btrfs: fix deadlock with fiemap and extent locking" > + > +# real QA test starts here > +_supported_fs generic > +_require_test > +_require_odirect > +_require_test_program fiemap-fault > +dst=$TEST_DIR/fiemap-fault-$seq > + > +echo "Silence is golden" > + > +for i in $(seq 0 2 1000) > +do > + $XFS_IO_PROG -d -f -c "pwrite -q $((i * 4096)) 4096" $dst > +done > + > +$here/src/fiemap-fault $dst > /dev/null || _fail "failed doing fiemap" > + > +rm -f $dst > + > +# success, all done > +status=$? > +exit > + > diff --git a/tests/generic/740.out b/tests/generic/740.out > new file mode 100644 > index 00000000..3f841e60 > --- /dev/null > +++ b/tests/generic/740.out > @@ -0,0 +1,2 @@ > +QA output created by 740 > +Silence is golden > -- > 2.43.0 > >
diff --git a/src/Makefile b/src/Makefile index d79015ce..916f6755 100644 --- a/src/Makefile +++ b/src/Makefile @@ -34,7 +34,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ attr_replace_test swapon mkswap t_attr_corruption t_open_tmpfiles \ fscrypt-crypt-util bulkstat_null_ocount splice-test chprojid_fail \ detached_mounts_propagation ext4_resize t_readdir_3 splice2pipe \ - uuid_ioctl + uuid_ioctl fiemap-fault EXTRA_EXECS = dmerror fill2attr fill2fs fill2fs_check scaleread.sh \ btrfs_crc32c_forged_name.py popdir.pl popattr.py \ diff --git a/tests/generic/740 b/tests/generic/740 new file mode 100644 index 00000000..46ec5820 --- /dev/null +++ b/tests/generic/740 @@ -0,0 +1,41 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved. +# +# FS QA Test 708 +# +# Test fiemap into an mmaped buffer of the same file +# +# Create a reasonably large file, then run a program which mmaps it and uses +# that as a buffer for an fiemap call. This is a regression test for btrfs +# where we used to hold a lock for the duration of the fiemap call which would +# result in a deadlock if we page faulted. +# +. ./common/preamble +_begin_fstest quick auto +[ $FSTYP == "btrfs" ] && \ + _fixed_by_kernel_commit xxxxxxxxxxxx \ + "btrfs: fix deadlock with fiemap and extent locking" + +# real QA test starts here +_supported_fs generic +_require_test +_require_odirect +_require_test_program fiemap-fault +dst=$TEST_DIR/fiemap-fault-$seq + +echo "Silence is golden" + +for i in $(seq 0 2 1000) +do + $XFS_IO_PROG -d -f -c "pwrite -q $((i * 4096)) 4096" $dst +done + +$here/src/fiemap-fault $dst > /dev/null || _fail "failed doing fiemap" + +rm -f $dst + +# success, all done +status=$? +exit + diff --git a/tests/generic/740.out b/tests/generic/740.out new file mode 100644 index 00000000..3f841e60 --- /dev/null +++ b/tests/generic/740.out @@ -0,0 +1,2 @@ +QA output created by 740 +Silence is golden
Btrfs had a deadlock that you could trigger by mmap'ing a large file and using that as the buffer for fiemap. This test adds a c program to do this, and the fstest creates a large enough file and then runs the reproducer on the file. Without the fix btrfs deadlocks, with the fix we pass fine. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- src/Makefile | 2 +- tests/generic/740 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/generic/740.out | 2 ++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/generic/740 create mode 100644 tests/generic/740.out