f2fs: test for race condition in between atomic_write and dio
PATCH 1/1 f2fs: test for race condition in between atomic_write and dio
In this patch, we simulate race case in between sqlite atomic write and direct IO w/ below steps:
1. create a regular file, and initialize it w/ 0xff data
2. start transaction (via F2FS_IOC_START_ATOMIC_WRITE) on it
3. write transaction data
4. trigger direct read/write IO on it to check whether it fails or not
5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE) This is a regression test to check handling of race condition in between atomic_write and direct IO.
--- tests/f2fs/004 | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/004.out | 3 +++ 2 files changed, 48 insertions(+) create mode 100755 tests/f2fs/004 create mode 100644 tests/f2fs/004.out
tests/f2fs/004 new file +45 -0
@@ -0,0 +1,45 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oppo. All Rights Reserved. +# +# FS QA Test No. f2fs/004 +# +# Test that we will simulate race case in between sqlite atomic write +# and direct IO w/ below steps: +# 1. create a regular file, and initialize it w/ 0xff data +# 2. start transaction (via F2FS_IOC_START_ATOMIC_WRITE) on it +# 3. write transaction data +# 4. trigger direct read/write IO to check whether it fails or not +# 5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE) +# This is a regression test to check handling of race condition in +# between atomic_write and direct IO. +# +. ./common/preamble +_begin_fstest auto quick + +. ./common/filter + +_supported_fs f2fs +_require_scratch +_require_xfs_io_command "pwrite" + +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +dbfile=$SCRATCH_MNT/dbfile + +# start atomic_write on dbfile & write data to dbfile +touch $dbfile +$F2FS_IO_PROG write 1 0 32 zero atomic_commit $dbfile 3000 >> $seqres.full & + +# simulate concurrent direct read/write IO +$XFS_IO_PROG -d -c "pread 0 128k" $dbfile +$XFS_IO_PROG -d -c "pwrite 0 128k" $dbfile + +# wait for atomic_write commit completion +sleep 5 + +_scratch_unmount + +status=0 +exit
tests/f2fs/004.out new file +3 -0
@@ -0,0 +1,3 @@ +QA output created by 004 +pread: Operation not supported +pwrite: Operation not supported
Signature · 1 line
2.40.1
Quoted 31 lines · Chao Yu
In this patch, we simulate race case in between sqlite atomic write and direct IO w/ below steps:
1. create a regular file, and initialize it w/0xffdata
2. start transaction (viaF2FS_IOC_START_ATOMIC_WRITE) on it
3. write transaction data
4. trigger direct read/write IO on it to check whether it fails or not
5. commit and end the transaction (viaF2FS_IOC_COMMIT_ATOMIC_WRITE) This is a regression test to check handling of race condition in betweenatomic_writeand direct IO.Cc Jaegeuk Kim <[email protected]>Cc Daeho Jeong <[email protected]>Signed-off-by Chao Yu <[email protected]>--- tests/f2fs/004 | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/004.out | 3 +++ 2 files changed, 48 insertions(+) create mode 100755 tests/f2fs/004 create mode 100644 tests/f2fs/004.outtests/f2fs/004 new file +5
-0@@ -0,0 +1,45 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oppo. All Rights Reserved. +# +# FS QA Test No. f2fs/004
tests/f2fs/004 line 15
Quoted 10 lines
tests/f2fs/004 new file +10
-0+# +# Test that we will simulate race case in between sqlite atomic write +# and direct IO w/ below steps: +# 1. create a regular file, and initialize it w/ 0xff data +# 2. start transaction (via F2FS_IOC_START_ATOMIC_WRITE) on it +# 3. write transaction data +# 4. trigger direct read/write IO to check whether it fails or not +# 5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE) +# This is a regression test to check handling of race condition in +# between atomic_write and direct IO.
Same as last patch, please add _fixed_by_kernel_commit.
tests/f2fs/004 line 22
Quoted 7 lines
tests/f2fs/004 new file +7
-0+# +. ./common/preamble +_begin_fstest auto quick + +. ./common/filter + +_supported_fs f2fs
^^^^^
It's not needed
tests/f2fs/004 line 24
Quoted 2 lines
tests/f2fs/004 new file +2
-0+_require_scratch +_require_xfs_io_command "pwrite"
^^^^
It can be removed too I think.
tests/f2fs/004 line 33
Quoted 9 lines
tests/f2fs/004 new file +9
-0+ +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +dbfile=$SCRATCH_MNT/dbfile + +# start atomic_write on dbfile & write data to dbfile +touch $dbfile +$F2FS_IO_PROG write 1 0 32 zero atomic_commit $dbfile 3000 >> $seqres.full &
There's a backgroup process too. Better to make sure it's done "kill && wait" before the end of the test.
tests/f2fs/004 line 37
Quoted 4 lines
tests/f2fs/004 new file +4
-0+ +# simulate concurrent direct read/write IO +$XFS_IO_PROG -d -c "pread 0 128k" $dbfile +$XFS_IO_PROG -d -c "pwrite 0 128k" $dbfile
Do you need _require_odirect (not sure about that:).
tests/f2fs/004 line 42
Quoted 5 lines
tests/f2fs/004 new file +5
-0+ +# wait for atomic_write commit completion +sleep 5 + +_scratch_unmount
^^^^
It's not necessary.
Thanks,
Zorro
Quoted 16 lines
tests/f2fs/004 new file +3
-0+ +status=0 +exittests/f2fs/004.out new file +3
-0@@ -0,0 +1,3 @@ +QA output created by 004 +pread: Operation not supported +pwrite: Operation not supportedSignature · 1 line
2.40.1
Quoted 80 lines · Zorro Lang
Quoted 31 lines · Chao Yu
In this patch, we simulate race case in between sqlite atomic write and direct IO w/ below steps:
1. create a regular file, and initialize it w/0xffdata
2. start transaction (viaF2FS_IOC_START_ATOMIC_WRITE) on it
3. write transaction data
4. trigger direct read/write IO on it to check whether it fails or not
5. commit and end the transaction (viaF2FS_IOC_COMMIT_ATOMIC_WRITE) This is a regression test to check handling of race condition in betweenatomic_writeand direct IO.Cc Jaegeuk Kim <[email protected]>Cc Daeho Jeong <[email protected]>Signed-off-by Chao Yu <[email protected]>--- tests/f2fs/004 | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/004.out | 3 +++ 2 files changed, 48 insertions(+)create mode 100755 tests/f2fs/004
create mode 100644 tests/f2fs/004.outtests/f2fs/004 new file +5
-0@@ -0,0 +1,45 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oppo. All Rights Reserved. +# +# FS QA Test No. f2fs/004tests/f2fs/004 line 15
Quoted 10 lines
tests/f2fs/004 new file +10
-0+# +# Test that we will simulate race case in between sqlite atomic write +# and direct IO w/ below steps: +# 1. create a regular file, and initialize it w/ 0xff data +# 2. start transaction (via F2FS_IOC_START_ATOMIC_WRITE) on it +# 3. write transaction data +# 4. trigger direct read/write IO to check whether it fails or not +# 5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE) +# This is a regression test to check handling of race condition in +# between atomic_write and direct IO.Same as last patch, please add
_fixed_by_kernel_commit.tests/f2fs/004 line 22
Quoted 7 lines
tests/f2fs/004 new file +7
-0+# +. ./common/preamble +_begin_fstest auto quick + +. ./common/filter + +_supported_fs f2fs^^^^^It's not needed
tests/f2fs/004 line 24
Quoted 2 lines
tests/f2fs/004 new file +2
-0+_require_scratch +_require_xfs_io_command "pwrite"^^^^It can be removed too I think.
tests/f2fs/004 line 33
Quoted 9 lines
tests/f2fs/004 new file +9
-0+ +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +dbfile=$SCRATCH_MNT/dbfile + +# start atomic_write on dbfile & write data to dbfile +touch $dbfile +$F2FS_IO_PROG write 1 0 32 zero atomic_commit $dbfile 3000 >> $seqres.full &There's a backgroup process too. Better to make sure it's done "kill && wait" before the end of the test.
tests/f2fs/004 line 37
Quoted 4 lines
tests/f2fs/004 new file +4
-0+ +# simulate concurrent direct read/write IO +$XFS_IO_PROG -d -c "pread 0 128k" $dbfile +$XFS_IO_PROG -d -c "pwrite 0 128k" $dbfileDo you need
_require_odirect(not sure about that:).
Quoted 7 lines
tests/f2fs/004 line 42
Quoted 5 lines
tests/f2fs/004 new file +5
-0+ +# wait for atomic_write commit completion +sleep 5 + +_scratch_unmount^^^^It's not necessary.
Zorro, thanks for the comments, will update.
Thanks,
Quoted 21 lines
Thanks,
ZorroQuoted 16 lines
tests/f2fs/004 new file +3
-0+ +status=0 +exittests/f2fs/004.out new file +3
-0@@ -0,0 +1,3 @@ +QA output created by 004 +pread: Operation not supported +pwrite: Operation not supportedSignature · 1 line
2.40.1