]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
filters: add a filter that accepts EIO instead of other errors
authorDave Chinner <dchinner@redhat.com>
Tue, 26 Nov 2024 21:01:01 +0000 (08:01 +1100)
committerZorro Lang <zlang@kernel.org>
Sun, 8 Dec 2024 14:14:17 +0000 (22:14 +0800)
Running a dm-flakey or dm-error test that loads a table that returns
EIO to all IO and then running a command that is expected to fail
with a specific error is racy.

If there is memory pressure at the same time that the table is
loaded, cached inodes can be turfed from memory and the command then
needs to read the inode it is about to act on from disk again. This
results in the inode read getting EIO and failing (e.g. xfs_io will
return a stat() error) rather than having the desired operation
fail.

This results in spurious test failures that look like this:

generic/331       - output mismatch (see /mnt/xfs/runner-41/results-2024-11-20-10:57:31/xfs/generic/331.out.bad)
    --- tests/generic/331.out   2022-12-21 15:53:25.487044098 +1100
    +++ /mnt/xfs/runner-41/results-2024-11-20-10:57:31/xfs/generic/331.out.bad  2024-11-20 11:02:12.123572607 +1100
    @@ -5,7 +5,8 @@
     1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-331/file1
     1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-331/file2
     CoW and unmount
    -fdatasync: Input/output error
    +/mnt/xfs/runner-41/scratch/test-331/file2: Input/output error
    +stat: Input/output error
     Compare files
    ...

Add a new "flakey EIO filter" that will catch -any- EIO error from
the command and change it to the error we expected to see.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Zorro lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/filter
tests/btrfs/160
tests/generic/252
tests/generic/329
tests/generic/331
tests/generic/484
tests/generic/743
tests/xfs/237
tests/xfs/240

index 6a509d8b511f91981577eebb16eb9768c1c62469..7e02ded377cc9b863d7a52eaed76c6ca8cfe7162 100644 (file)
@@ -662,5 +662,14 @@ _filter_trailing_whitespace()
        sed -E -e "s/\s+$//"
 }
 
+# Catch -any- EIO error regardless of it's source and replace it with the
+# supplied error message.
+_filter_flakey_EIO()
+{
+       local message="$*"
+
+       sed -e "s#.*: Input\/output error#$message#"
+}
+
 # make sure this script returns success
 /bin/true
index 04ed1f176568a3029333f02c18df02cc0863f436..c4a01d3304264276c825db85889cc56e8edbfaec 100755 (executable)
@@ -66,7 +66,8 @@ _dmerror_load_working_table
 
 # open again and call fsync
 echo "The following fsync should fail with EIO:"
-$XFS_IO_PROG -c fsync $testfile
+$XFS_IO_PROG -c fsync $testfile |& \
+               _filter_flakey_EIO "fsync: Input/output error"
 echo "done"
 
 # close file
index ddf950e34193fc2c6e524561c5df7c4d38afd740..2ad0524c2037f958dca9b2ba01d11b2f685f65f4 100755 (executable)
@@ -66,7 +66,8 @@ $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
 _scratch_sync
 _dmerror_load_error_table
-$AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
+$AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 |& \
+               _filter_flakey_EIO "write missed bytes expect 8388608 got 0"
 _dmerror_load_working_table
 _dmerror_unmount
 _dmerror_mount
index e4300f92ce0da44b80fb79a4f473a69e811258a6..96a5ad54cbefdc4ad175b25d1434db5f9dd88496 100755 (executable)
@@ -59,7 +59,8 @@ $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
 _scratch_sync
 _dmerror_load_error_table
-$AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
+$AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 |& \
+               _filter_flakey_EIO "write missed bytes expect 8388608 got 0"
 _dmerror_load_working_table
 _dmerror_unmount
 _dmerror_mount
index fe12ec4ebacdf574482752d8065226d1555d8966..704bb1283ecb85fe098b7f673b8662a866b54218 100755 (executable)
@@ -59,8 +59,9 @@ $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
 _scratch_sync
 _dmerror_load_error_table
-$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
-$XFS_IO_PROG -c "fdatasync" $testdir/file2
+$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full 2>&1
+$XFS_IO_PROG -c "fdatasync" $testdir/file2 |& \
+               _filter_flakey_EIO "fdatasync: Input/output error"
 _dmerror_load_working_table
 _dmerror_unmount
 _dmerror_mount
index 09c2c559823b4c907af2e4f112c1e6bbb0c250ad..ec50735a5b584fd0dd5bf6adf317c57b17249200 100755 (executable)
@@ -54,7 +54,8 @@ $XFS_IO_PROG -c "pwrite -W -q 0 $datalen" $testfile
 _dmerror_load_error_table
 
 # rewrite the data and call fdatasync
-$XFS_IO_PROG -c "pwrite -w -q 0 $datalen" $testfile
+$XFS_IO_PROG -c "pwrite -w -q 0 $datalen" $testfile |& \
+               _filter_flakey_EIO "fdatasync: Input/output error"
 
 # heal the device error
 _dmerror_load_working_table
index 228ba764e27e850e1da41bd9124f4bf8332f3c5c..efdeec82d7a78b98d2e7c549fd79d62f8166e42a 100755 (executable)
@@ -21,6 +21,7 @@ _cleanup()
 }
 
 # Import common functions.
+. ./common/filter
 . ./common/dmerror
 
 _fixed_by_kernel_commit 631426ba1d45 \
@@ -55,7 +56,8 @@ _dmerror_mount
 stat "$SCRATCH_MNT/a" >> $seqres.full
 echo read with IO errors
 _dmerror_load_error_table
-$TIMEOUT_PROG -s KILL 10s $XFS_IO_PROG -c "mmap -r 0 $filesz" -c "madvise -R 0 $filesz" "$SCRATCH_MNT/a"
+$TIMEOUT_PROG -s KILL 10s $XFS_IO_PROG -c "mmap -r 0 $filesz" -c "madvise -R 0 $filesz" "$SCRATCH_MNT/a" |& \
+               _filter_flakey_EIO "madvise: Bad address"
 _dmerror_load_working_table
 
 # success, all done
index 91f56d6c1a6ec30b7f2be30f2e62ce2b18c0ffd2..eb5dc5d2f6f6f0f9f525c01d2913ff6d9473bc4a 100755 (executable)
@@ -68,7 +68,8 @@ $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
 _scratch_sync
 _dmerror_load_error_table
-$AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
+$AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 |& \
+               _filter_flakey_EIO "write missed bytes expect 8388608 got 0"
 _dmerror_load_working_table
 _dmerror_unmount
 _dmerror_mount
index e95cf3f5d1582999f2a8ca51fcca00ed6552792b..8916828a8c1958ba91e3c8cb2a8892b9830e3eb3 100755 (executable)
@@ -64,8 +64,9 @@ $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
 _scratch_sync
 _dmerror_load_error_table
-$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
-$XFS_IO_PROG -c "fdatasync" $testdir/file2
+$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full 2>&1
+$XFS_IO_PROG -c "fdatasync" $testdir/file2 |& \
+               _filter_flakey_EIO "fdatasync: Input/output error"
 _dmerror_load_working_table
 _dmerror_unmount
 _dmerror_mount