f2fs: test for race condition in between atomic_write and gc
PATCH v2 1/1 f2fs: test for race condition in between atomic_write and gc
Test that we will simulate sqlite atomic write logic 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 foreground GC to migrate data block of the file
5. commit and end the transaction
6. check consistency of transaction
This is a regression test to check handling of race condition in between atomic_write and GC.
---
v2:
- add kill&wait in _clean() to avoid umount failure
- some cleanups
- use exported helpler
tests/f2fs/003 | 65 ++++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/003.out | 11 ++++++++ 2 files changed, 76 insertions(+) create mode 100755 tests/f2fs/003 create mode 100644 tests/f2fs/003.out
tests/f2fs/003 new file +65 -0
@@ -0,0 +1,65 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oppo. All Rights Reserved. +# +# FS QA Test No. f2fs/003 +# +# Test that we will simulate sqlite atomic write logic 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 foreground GC to migrate data block of the file +# 5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE) +# 6. check consistency of transaction w/ in-memory and on-disk data +# This is a regression test to check handling of race condition in +# between atomic_write and GC. +# +. ./common/preamble +_begin_fstest auto quick + +. ./common/filter + +_cleanup() +{ + kill -9 $atomic_write_pid > /dev/null 2>&1 + wait > /dev/null 2>&1 +} + +_require_scratch +_require_xfs_io_command "fpunch" + +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +dbfile=$SCRATCH_MNT/dbfile +foo=$SCRATCH_MNT/foo +bar=$SCRATCH_MNT/bar + +$XFS_IO_PROG -c "pwrite 0 512k -S 0xff" -c "fsync" -f $dbfile >> $seqres.full +$XFS_IO_PROG -c "pwrite 0 2m" -c "fsync" -f $foo >> $seqres.full +sync + +# start atomic_write on dbfile & write data to dbfile +$F2FS_IO_PROG write 1 0 32 zero atomic_commit $dbfile 3000 >> $seqres.full & +atomic_write_pid=$! + +$XFS_IO_PROG -c "fpunch 0 2m" $foo >> $seqres.full +$XFS_IO_PROG -c "pwrite 0 2m" -c "fsync" -f $bar >> $seqres.full + +# persist all dirty data +sync +echo 3 > /proc/sys/vm/drop_caches + +# trigger foreground GC to migrate data block of atomic_file +$F2FS_IO_PROG gc 1 $SCRATCH_MNT > /dev/null 2>&1 + +# wait for atomic_write commit completion +sleep 5 +# print in-memory data +_hexdump $dbfile +echo 3 > /proc/sys/vm/drop_caches +# print on-disk data +_hexdump $dbfile + +status=0 +exit
tests/f2fs/003.out new file +11 -0
@@ -0,0 +1,11 @@ +QA output created by 003 +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< +* +020000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >................< +* +080000 +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< +* +020000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >................< +* +080000
Signature · 1 line
2.40.1
Quoted 45 lines · Chao Yu
Test that we will simulate sqlite atomic write logic 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 foreground GC to migrate data block of the file
5. commit and end the transaction
6. check consistency of transaction
This is a regression test to check handling of race condition in betweenatomic_writeand GC.Cc Jaegeuk Kim <[email protected]>Cc Daeho Jeong <[email protected]>Signed-off-by Chao Yu <[email protected]>---
v2:
- add kill&wait in_clean()to avoid umount failure
- some cleanups
- use exported helplertests/f2fs/003 | 65 ++++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/003.out | 11 ++++++++ 2 files changed, 76 insertions(+) create mode 100755 tests/f2fs/003 create mode 100644 tests/f2fs/003.outtests/f2fs/003 new file +15
-0@@ -0,0 +1,65 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oppo. All Rights Reserved. +# +# FS QA Test No. f2fs/003 +# +# Test that we will simulate sqlite atomic write logic 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 foreground GC to migrate data block of the file +# 5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE) +# 6. check consistency of transaction w/ in-memory and on-disk data +# This is a regression test to check handling of race condition in +# between atomic_write and GC.
tests/f2fs/003 line 25
Quoted 10 lines
tests/f2fs/003 new file +10
-0+# +. ./common/preamble +_begin_fstest auto quick + +. ./common/filter + +_cleanup() +{ + kill -9 $atomic_write_pid > /dev/null 2>&1 + wait > /dev/null 2>&1
This version looks good to me, just this place, we need to keep the default _cleanup steps.
cd /
rm -r -f $tmp.*I'll do this change when I merge this patch.
(And please don't forget to update the _fixed_by_xxxxx information later.)
Thanks,
Zorro
Quoted 60 lines
tests/f2fs/003 new file +40
-0+} + +_require_scratch +_require_xfs_io_command "fpunch" + +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +dbfile=$SCRATCH_MNT/dbfile +foo=$SCRATCH_MNT/foo +bar=$SCRATCH_MNT/bar + +$XFS_IO_PROG -c "pwrite 0 512k -S 0xff" -c "fsync" -f $dbfile >> $seqres.full +$XFS_IO_PROG -c "pwrite 0 2m" -c "fsync" -f $foo >> $seqres.full +sync + +# start atomic_write on dbfile & write data to dbfile +$F2FS_IO_PROG write 1 0 32 zero atomic_commit $dbfile 3000 >> $seqres.full & +atomic_write_pid=$! + +$XFS_IO_PROG -c "fpunch 0 2m" $foo >> $seqres.full +$XFS_IO_PROG -c "pwrite 0 2m" -c "fsync" -f $bar >> $seqres.full + +# persist all dirty data +sync +echo 3 > /proc/sys/vm/drop_caches + +# trigger foreground GC to migrate data block of atomic_file +$F2FS_IO_PROG gc 1 $SCRATCH_MNT > /dev/null 2>&1 + +# wait for atomic_write commit completion +sleep 5 +# print in-memory data +_hexdump $dbfile +echo 3 > /proc/sys/vm/drop_caches +# print on-disk data +_hexdump $dbfile + +status=0 +exittests/f2fs/003.out new file +11
-0@@ -0,0 +1,11 @@ +QA output created by 003 +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< +* +020000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >................< +* +080000 +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< +* +020000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >................< +* +080000Signature · 1 line
2.40.1
Quoted 60 lines · Zorro Lang
Quoted 45 lines · Chao Yu
Test that we will simulate sqlite atomic write logic 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 foreground GC to migrate data block of the file
5. commit and end the transaction
6. check consistency of transaction
This is a regression test to check handling of race condition in betweenatomic_writeand GC.Cc Jaegeuk Kim <[email protected]>Cc Daeho Jeong <[email protected]>Signed-off-by Chao Yu <[email protected]>---
v2:
- add kill&wait in_clean()to avoid umount failure
- some cleanups
- use exported helplertests/f2fs/003 | 65 ++++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/003.out | 11 ++++++++ 2 files changed, 76 insertions(+)create mode 100755 tests/f2fs/003
create mode 100644 tests/f2fs/003.outtests/f2fs/003 new file +15
-0@@ -0,0 +1,65 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oppo. All Rights Reserved. +# +# FS QA Test No. f2fs/003 +# +# Test that we will simulate sqlite atomic write logic 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 foreground GC to migrate data block of the file +# 5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE) +# 6. check consistency of transaction w/ in-memory and on-disk data +# This is a regression test to check handling of race condition in +# between atomic_write and GC.tests/f2fs/003 line 25
Quoted 10 lines
tests/f2fs/003 new file +10
-0+# +. ./common/preamble +_begin_fstest auto quick + +. ./common/filter + +_cleanup() +{ + kill -9 $atomic_write_pid > /dev/null 2>&1 + wait > /dev/null 2>&1This version looks good to me, just this place, we need to keep the default
_cleanupsteps.
Quoted 6 lines
cd / rm -r -f $tmp.*I'll do this change when I merge this patch.
(And please don't forget to update the
_fixed_by_xxxxxinformation later.)
No problem.
Quoted 2 lines
Reviewed-by Zorro Lang <[email protected]>
Thank you for the review. :)
Thanks,
Quoted 65 lines
Thanks,
ZorroQuoted 60 lines
tests/f2fs/003 new file +40
-0+} + +_require_scratch +_require_xfs_io_command "fpunch" + +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +dbfile=$SCRATCH_MNT/dbfile +foo=$SCRATCH_MNT/foo +bar=$SCRATCH_MNT/bar + +$XFS_IO_PROG -c "pwrite 0 512k -S 0xff" -c "fsync" -f $dbfile >> $seqres.full +$XFS_IO_PROG -c "pwrite 0 2m" -c "fsync" -f $foo >> $seqres.full +sync + +# start atomic_write on dbfile & write data to dbfile +$F2FS_IO_PROG write 1 0 32 zero atomic_commit $dbfile 3000 >> $seqres.full & +atomic_write_pid=$! + +$XFS_IO_PROG -c "fpunch 0 2m" $foo >> $seqres.full +$XFS_IO_PROG -c "pwrite 0 2m" -c "fsync" -f $bar >> $seqres.full + +# persist all dirty data +sync +echo 3 > /proc/sys/vm/drop_caches + +# trigger foreground GC to migrate data block of atomic_file +$F2FS_IO_PROG gc 1 $SCRATCH_MNT > /dev/null 2>&1 + +# wait for atomic_write commit completion +sleep 5 +# print in-memory data +_hexdump $dbfile +echo 3 > /proc/sys/vm/drop_caches +# print on-disk data +_hexdump $dbfile + +status=0 +exittests/f2fs/003.out new file +11
-0@@ -0,0 +1,11 @@ +QA output created by 003 +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< +* +020000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >................< +* +080000 +000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................< +* +020000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >................< +* +080000Signature · 1 line
2.40.1