fstests: remove dio related target file to respect mount options that only affecst new inodes
PATCH 1/1 fstests: remove dio related target file to respect mount options that only affecst new inodes
[BUG]
Test case generic/362 and generic/365 will fail with nodatasum, but that's only when TEST_DEV is newly formated.
FSTYP -- btrfs PLATFORM -- Linux/x86_64 btrfs-vm 7.1.0-rc4-custom+ #381 SMP PREEMPT_DYNAMIC Tue May 26 10:47:14 ACST 2026 MKFS_OPTIONS -- -O bgt -K /dev/mapper/test-scratch1
MOUNT_OPTIONS -- -o nodatasum /dev/mapper/test-scratch1 /mnt/scratch
generic/362 0s ... - output mismatch (see /home/adam/xfstests/results//generic/362.out.bad)
--- tests/generic/362.out 2024-08-24 15:31:37.200000000 +0930
+++ /home/adam/xfstests/results//generic/362.out.bad 2026-05-28 16:18:33.866141979 +0930
@@ -1,2 +1,3 @@
QA output created by 362
+First write failed: Input/output error
Silence is golden
...
(Run 'diff -u /home/adam/xfstests/tests/generic/362.out /home/adam/xfstests/results//generic/362.out.bad' to see the entire diff)
generic/364 11s ... - output mismatch (see /home/adam/xfstests/results//generic/364.out.bad)
--- tests/generic/364.out 2024-09-30 09:09:51.216666681 +0930
+++ /home/adam/xfstests/results//generic/364.out.bad 2026-05-28 16:18:34.318532257 +0930
@@ -1,2 +1,3 @@
QA output created by 364
+Fsync failed: Input/output error
Silence is golden
...
(Run 'diff -u /home/adam/xfstests/tests/generic/364.out /home/adam/xfstests/results//generic/364.out.bad' to see the entire diff)
But if one has formated TEST_DEV, run test with default mount option, then change the mount option to "nodatasum", the test will not fail anymore:
FSTYP -- btrfs PLATFORM -- Linux/x86_64 btrfs-vm 7.1.0-rc4-custom+ #381 SMP PREEMPT_DYNAMIC Tue May 26 10:47:14 ACST 2026 MKFS_OPTIONS -- -O bgt -K /dev/mapper/test-scratch1
MOUNT_OPTIONS -- /dev/mapper/test-scratch1 /mnt/scratch
generic/362 0s ... 1s
generic/364 11s ... 10s
Ran: generic/362 generic/364
Passed all 2 tests
FSTYP -- btrfs PLATFORM -- Linux/x86_64 btrfs-vm 7.1.0-rc4-custom+ #381 SMP PREEMPT_DYNAMIC Tue May 26 10:47:14 ACST 2026 MKFS_OPTIONS -- -O bgt -K /dev/mapper/test-scratch1
MOUNT_OPTIONS -- -o nodatasum /dev/mapper/test-scratch1 /mnt/scratch
generic/362 1s ... 0s
generic/364 10s ... 11s
Ran: generic/362 generic/364
Passed all 2 tests
[CAUSE]
Btrfs' nodatasum mount option only affect new files, but the test cases are using TEST_DEV, and never delete the target files "$TEST_DIR/dio-append-buf-fault" for generic/362 and "$TEST_DIR/dio-write-fsync-same-fd" for generic/364.
So if the files are created with default mount option, then all later "nodatasum" mount option will not affect those files, thus hide the test failure.
[FIX]
For all test cases utilizing "$here/src/dio*", add a _cleanup() function, to remove target files, so that for mount options that only affect new inodes, the mount options will be respected, and expose failures.
Now generic/36[24] will properly fail for "nodatasum" mount option on btrfs.
--- tests/generic/362 | 6 ++++++ tests/generic/364 | 7 +++++++ tests/generic/418 | 7 +++++++ tests/generic/708 | 6 ++++++ 4 files changed, 26 insertions(+)
tests/generic/362 +6 -0
@@ -10,6 +10,12 @@ . ./common/preamble _begin_fstest auto quick +_cleanup() +{ + cd / + rm -f "$TEST_DIR/dio-append-buf-fault" +} + # NFS forbade open with O_APPEND|O_DIRECT _exclude_fs nfs
tests/generic/364 +7 -0
@@ -11,6 +11,13 @@ . ./common/preamble _begin_fstest auto quick +_cleanup() +{ + cd / + rm -f "$TEST_DIR/dio-write-fsync-same-fd" +} + + _require_test _require_odirect _require_test_program dio-write-fsync-same-fd
tests/generic/418 +7 -0
@@ -26,6 +26,13 @@ _require_block_device $TEST_DEV _require_test_program "dio-invalidate-cache" _require_test_program "feature" +_cleanup() +{ + cd / + rm -f $tmp.* + rm -f "$testfile" +} + diotest=$here/src/dio-invalidate-cache testfile=$TEST_DIR/$seq-diotest sectorsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
tests/generic/708 +6 -0
@@ -14,6 +14,12 @@ . ./common/preamble _begin_fstest quick auto mmap +_cleanup() +{ + cd / + rm -f "$src" "$dst" +} + _fixed_by_fs_commit btrfs b73a6fd1b1ef \ "btrfs: split partial dio bios before submit"
Signature · 1 line
2.51.2
Quoted 4 lines · Qu Wenruo
[BUG]
Test case generic/362 and generic/365 will fail with nodatasum, but that's only whenTEST_DEVis newly formated.
formated -> formatted
Quoted 45 lines
FSTYP -- btrfs PLATFORM -- Linux/x86_64 btrfs-vm 7.1.0-rc4-custom+ #381 SMP PREEMPT_DYNAMIC Tue May 26 10:47:14 ACST 2026 MKFS_OPTIONS -- -O bgt -K /dev/mapper/test-scratch1
MOUNT_OPTIONS-- -o nodatasum/dev/mapper/test-scratch1/mnt/scratchgeneric/362 0s ... - output mismatch (see
/home/adam/xfstests/results//generic/362.out.bad)
--- tests/generic/362.out 2024-08-24 15:31:37.200000000 +0930
+++/home/adam/xfstests/results//generic/362.out.bad2026-05-28 16:18:33.866141979 +0930
@@ -1,2 +1,3 @@
QA output created by 362
+First write failed: Input/output error
Silence is golden
...
(Run 'diff -u/home/adam/xfstests/tests/generic/362.out/home/adam/xfstests/results//generic/362.out.bad' to see the entire diff)generic/364 11s ... - output mismatch (see
/home/adam/xfstests/results//generic/364.out.bad)
--- tests/generic/364.out 2024-09-30 09:09:51.216666681 +0930
+++/home/adam/xfstests/results//generic/364.out.bad2026-05-28 16:18:34.318532257 +0930
@@ -1,2 +1,3 @@
QA output created by 364
+Fsync failed: Input/output error
Silence is golden
...
(Run 'diff -u/home/adam/xfstests/tests/generic/364.out/home/adam/xfstests/results//generic/364.out.bad' to see the entire diff)But if one has formated
TEST_DEV, run test with default mount option, then change the mount option to "nodatasum", the test will not fail anymore:FSTYP -- btrfs PLATFORM -- Linux/x86_64 btrfs-vm 7.1.0-rc4-custom+ #381 SMP PREEMPT_DYNAMIC Tue May 26 10:47:14 ACST 2026 MKFS_OPTIONS -- -O bgt -K /dev/mapper/test-scratch1
MOUNT_OPTIONS--/dev/mapper/test-scratch1/mnt/scratchgeneric/362 0s ... 1s
generic/364 11s ... 10s
Ran: generic/362 generic/364
Passed all 2 testsFSTYP -- btrfs PLATFORM -- Linux/x86_64 btrfs-vm 7.1.0-rc4-custom+ #381 SMP PREEMPT_DYNAMIC Tue May 26 10:47:14 ACST 2026 MKFS_OPTIONS -- -O bgt -K /dev/mapper/test-scratch1
MOUNT_OPTIONS-- -o nodatasum/dev/mapper/test-scratch1/mnt/scratch
Quoted 7 lines
generic/362 1s ... 0s
generic/364 10s ... 11s
Ran: generic/362 generic/364
Passed all 2 tests[CAUSE]
Btrfs' nodatasum mount option only affect new files, but the test cases
affect -> affects
Quoted 5 lines
are using
TEST_DEV, and never delete the target files "$TEST_DIR/dio-append-buf-fault" for generic/362 and "$TEST_DIR/dio-write-fsync-same-fd" for generic/364.So if the files are created with default mount option, then all later
option -> options
Quoted 25 lines
"nodatasum" mount option will not affect those files, thus hide the test failure.
[FIX]
For all test cases utilizing "$here/src/dio*", add a_cleanup()function, to remove target files, so that for mount options that only affect new inodes, the mount options will be respected, and expose failures.Now generic/36[24] will properly fail for "nodatasum" mount option on btrfs.
Signed-off-by Qu Wenruo <[email protected]>--- tests/generic/362 | 6 ++++++ tests/generic/364 | 7 +++++++ tests/generic/418 | 7 +++++++ tests/generic/708 | 6 ++++++ 4 files changed, 26 insertions(+)tests/generic/362 +0
-0
tests/generic/362 line 15
Quoted 6 lines
tests/generic/362 +3
-0@@ -10,6 +10,12 @@ . ./common/preamble _begin_fstest auto quick +_cleanup() +{ + cd /
I think we need to have here:
rm -f $tmp.*
It's standard practice to paste the code from the default _cleanup function. I don't bother much with it though, just to be consistent.
Quoted 29 lines
tests/generic/362 +3
-0+ rm -f "$TEST_DIR/dio-append-buf-fault" +} + # NFS forbade open with O_APPEND|O_DIRECT _exclude_fs nfstests/generic/364 +7
-0@@ -11,6 +11,13 @@ . ./common/preamble _begin_fstest auto quick +_cleanup() +{ + cd / + rm -f "$TEST_DIR/dio-write-fsync-same-fd" +} + + _require_test _require_odirect _require_test_program dio-write-fsync-same-fdtests/generic/418 +0
-0
tests/generic/418 _require_block_device $TEST_DEV · line 32
Quoted 7 lines
tests/generic/418 +4
-0@@ -26,6 +26,13 @@ _require_block_device $TEST_DEV _require_test_program "dio-invalidate-cache" _require_test_program "feature" +_cleanup() +{ + cd / + rm -f $tmp.*
Here you added it.
Quoted 11 lines
tests/generic/418 +3
-0+ rm -f "$testfile" +} + diotest=$here/src/dio-invalidate-cache testfile=$TEST_DIR/$seq-diotest sectorsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`tests/generic/708 +0
-0
tests/generic/708 line 19
Quoted 6 lines
tests/generic/708 +3
-0@@ -14,6 +14,12 @@ . ./common/preamble _begin_fstest quick auto mmap +_cleanup() +{ + cd /
Missing again.
Though those are small things that can be fixed when applying the patch.
Thanks.
Quoted 10 lines
tests/generic/708 +3
-1+ rm -f "$src" "$dst" +} + _fixed_by_fs_commit btrfs b73a6fd1b1ef \ "btrfs: split partial dio bios before submit" --2.51.2