mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
btrfs: add new filter for file cloning error translation
A bug in file cloning/reflinking was recently found that afftected both
Btrfs and XFS, which was caused by allowing the cloning of an eof block
into the middle of a file when the eof is not aligned to the filesystem's
block size.
The fix consists of returning the errno -EINVAL to user space when the
arguments passed to the system call lead to the scenario of data
corruption. However this overlaps with some cases where the system call,
in Btrfs, returned -EOPNOTSUPP, which means we are trying to reflink
inline extents. That is unsupported in Btrfs due to the huge complexity
of supporting it (due to copying and trimming inline extents, deal with
eventual compression, etc).
We have a few btrfs test cases that verify that attempts to clone inline
extents result in a failure, and are currently expecting an -EINVAL error
message from the output of the cloner program. So create a filter that
converts error messages related to the -EOPNOTSUPP error to messages
related to the -EINVAL error, so that the test can run both on patched
and non-patched linux kernels.
The corresponding btrfs patch for the linux kernel is titled:
"Btrfs: fix data corruption due to cloning of eof block"
And the VFS change that introduces the -EINVAL error return was introduced
by the following linux kernel commit (landed in 4.20-rc1):
07d19dc9fbe9 ("vfs: avoid problematic remapping requests into partial EOF block")
The btrfs patch is not yet in Linus' tree (it was submitted around the
same time as this change) and the VFS change was introduced in 4.10-rc1.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
+17
-8
@@ -23,6 +23,7 @@ _cleanup()
|
||||
# get standard environment, filters and checks
|
||||
. ./common/rc
|
||||
. ./common/filter
|
||||
. ./common/filter.btrfs
|
||||
|
||||
# real QA test starts here
|
||||
_supported_fs btrfs
|
||||
@@ -53,7 +54,8 @@ test_cloning_inline_extents()
|
||||
# clone the inline extent from file bar into this file.
|
||||
$XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 16K" $SCRATCH_MNT/foo \
|
||||
| _filter_xfs_io
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo \
|
||||
| _filter_btrfs_cloner_error
|
||||
|
||||
# Doing IO against any range in the first 4K of the file should work.
|
||||
# Due to a past clone ioctl bug which allowed cloning the inline extent,
|
||||
@@ -69,7 +71,8 @@ test_cloning_inline_extents()
|
||||
# as well to clone the inline extent from file bar into this file.
|
||||
$XFS_IO_PROG -f -c "pwrite -S 0xdd 4K 12K" $SCRATCH_MNT/foo2 \
|
||||
| _filter_xfs_io
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo2
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo2 \
|
||||
| _filter_btrfs_cloner_error
|
||||
|
||||
# Doing IO against any range in the first 4K of the file should work.
|
||||
# Due to a past clone ioctl bug which allowed cloning the inline extent,
|
||||
@@ -84,7 +87,8 @@ test_cloning_inline_extents()
|
||||
# but has a prealloc extent. It should not be possible as well to clone
|
||||
# the inline extent from file bar into this file.
|
||||
$XFS_IO_PROG -f -c "falloc -k 0 1M" $SCRATCH_MNT/foo3 | _filter_xfs_io
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo3
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo3 \
|
||||
| _filter_btrfs_cloner_error
|
||||
|
||||
# Doing IO against any range in the first 4K of the file should work.
|
||||
# Due to a past clone ioctl bug which allowed cloning the inline extent,
|
||||
@@ -101,7 +105,8 @@ test_cloning_inline_extents()
|
||||
# It should be possible to do the extent cloning from bar to this file.
|
||||
$XFS_IO_PROG -f -c "pwrite -S 0x01 0 40" $SCRATCH_MNT/foo4 \
|
||||
| _filter_xfs_io
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo4
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo4 \
|
||||
| _filter_btrfs_cloner_error
|
||||
|
||||
# Doing IO against any range in the first 4K of the file should work.
|
||||
echo "File foo4 data after clone operation:"
|
||||
@@ -116,7 +121,8 @@ test_cloning_inline_extents()
|
||||
# into this file.
|
||||
$XFS_IO_PROG -f -c "pwrite -S 0x03 0 60" $SCRATCH_MNT/foo5 \
|
||||
| _filter_xfs_io
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo5
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo5 \
|
||||
| _filter_btrfs_cloner_error
|
||||
|
||||
# Reading the file should not fail.
|
||||
echo "File foo5 data after clone operation:"
|
||||
@@ -129,7 +135,8 @@ test_cloning_inline_extents()
|
||||
# It should not be possible to clone the inline extent from file bar
|
||||
# into this file.
|
||||
$XFS_IO_PROG -f -c "truncate 16K" $SCRATCH_MNT/foo6 | _filter_xfs_io
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo6
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo6 \
|
||||
| _filter_btrfs_cloner_error
|
||||
|
||||
# Reading the file should not fail.
|
||||
echo "File foo6 data after clone operation:"
|
||||
@@ -142,7 +149,8 @@ test_cloning_inline_extents()
|
||||
# It should be possible to clone the inline extent from file bar into
|
||||
# this file.
|
||||
$XFS_IO_PROG -f -c "truncate 30" $SCRATCH_MNT/foo7 | _filter_xfs_io
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo7
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo7 \
|
||||
| _filter_btrfs_cloner_error
|
||||
|
||||
# Reading the file should not fail.
|
||||
echo "File foo7 data after clone operation:"
|
||||
@@ -156,7 +164,8 @@ test_cloning_inline_extents()
|
||||
$XFS_IO_PROG -f -c "falloc -k 0 1M" \
|
||||
-c "pwrite -S 0x88 0 20" \
|
||||
$SCRATCH_MNT/foo8 | _filter_xfs_io
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo8
|
||||
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo8 \
|
||||
| _filter_btrfs_cloner_error
|
||||
|
||||
echo "File foo8 data after clone operation:"
|
||||
# Must have a size of 20 bytes, with all bytes having a value of 0x88
|
||||
|
||||
Reference in New Issue
Block a user