f2fs/010: test dirty status handling on database file
PATCH 1/1 f2fs/010: test dirty status handling on database file
This is a regression testcase to check whether we will handle database inode dirty status correctly:
1. create a regular file, and write data into the file
2. start transaction on the file (via F2FS_IOC_START_ATOMIC_WRITE)
3. write transaction data to the file
4. rename the file
5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE)
6. drop caches in order to call f2fs_evict_inode()
It expects kernel panic will gone after we apply commit 03511e936916 ("f2fs: fix inconsistent dirty state of atomic file").
--- tests/f2fs/010 | 68 ++++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/010.out | 2 ++ 2 files changed, 70 insertions(+) create mode 100755 tests/f2fs/010 create mode 100644 tests/f2fs/010.out
tests/f2fs/010 new file +68 -0
@@ -0,0 +1,68 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Chao Yu. All Rights Reserved. +# +# FS QA Test No. f2fs/010 +# +# This is a regression testcase to check whether we will handle database +# inode dirty status correctly: +# 1. create a regular file, and write data into the file +# 2. start transaction on the file (via F2FS_IOC_START_ATOMIC_WRITE) +# 3. write transaction data to the file +# 4. rename the file +# 5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE) +# 6. drop caches in order to call f2fs_evict_inode() +# It expects kernel panic will gone after we apply commit 03511e936916 +# ("f2fs: fix inconsistent dirty state of atomic file"). +# +. ./common/preamble +_begin_fstest auto quick + +_cleanup() +{ + kill -9 $atomic_write_pid > /dev/null 2>&1 + wait + cd / + rm -r -f $tmp.* +} + +_fixed_by_kernel_commit 03511e936916 \ + "f2fs: fix inconsistent dirty state of atomic file" + +_require_scratch +_require_command "$F2FS_IO_PROG" f2fs_io + +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +src_db=$SCRATCH_MNT/src.db +dst_db=$SCRATCH_MNT/dst.db + +# initialize database file +$XFS_IO_PROG -c "pwrite 0 4k" -c "fsync" -f $src_db >> $seqres.full + +# sync filesystem to clear dirty inode +sync + +# start atomic_write on src.db database file and commit transaction after 3000ms +$F2FS_IO_PROG write 1 0 0 zero atomic_commit $src_db 3000 >> $seqres.full & +atomic_write_pid=$! + +# wait a moment to let atomic write starts +sleep 1 + +# it will dirty inode when updating i_pino +mv $src_db $dst_db + +# wait for atomic_write commit completion +sleep 4 + +# drop caches in order to call f2fs_evict_inode() +echo 3 > /proc/sys/vm/drop_caches + +wait $atomic_write_pid + +echo "Silence is golden" + +status=0 +exit
tests/f2fs/010.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 010 +Silence is golden
Signature · 1 line
2.48.1
Quoted 41 lines · Chao Yu
This is a regression testcase to check whether we will handle database inode dirty status correctly:
1. create a regular file, and write data into the file
2. start transaction on the file (viaF2FS_IOC_START_ATOMIC_WRITE)
3. write transaction data to the file
4. rename the file
5. commit and end the transaction (viaF2FS_IOC_COMMIT_ATOMIC_WRITE)
6. drop caches in order to callf2fs_evict_inode()
It expects kernel panic will gone after we apply commit03511e936916("f2fs: fix inconsistent dirty state of atomic file").Cc Jaegeuk Kim <[email protected]>Cc Daeho Jeong <[email protected]>Cc Jianan Huang <[email protected]>Signed-off-by Chao Yu <[email protected]>--- tests/f2fs/010 | 68 ++++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/010.out | 2 ++ 2 files changed, 70 insertions(+) create mode 100755 tests/f2fs/010 create mode 100644 tests/f2fs/010.outtests/f2fs/010 new file +13
-0@@ -0,0 +1,68 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Chao Yu. All Rights Reserved. +# +# FS QA Test No. f2fs/010 +# +# This is a regression testcase to check whether we will handle database +# inode dirty status correctly: +# 1. create a regular file, and write data into the file +# 2. start transaction on the file (via F2FS_IOC_START_ATOMIC_WRITE) +# 3. write transaction data to the file +# 4. rename the file +# 5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE)
tests/f2fs/010 line 23
Quoted 10 lines
tests/f2fs/010 new file +10
-0+# 6. drop caches in order to call f2fs_evict_inode() +# It expects kernel panic will gone after we apply commit 03511e936916 +# ("f2fs: fix inconsistent dirty state of atomic file"). +# +. ./common/preamble +_begin_fstest auto quick + +_cleanup() +{ + kill -9 $atomic_write_pid > /dev/null 2>&1
[ -n "$atomic_write_pid" ] && kill -9 $atomic_write_pid
Quoted 30 lines
tests/f2fs/010 new file +30
-0+ wait + cd / + rm -r -f $tmp.* +} + +_fixed_by_kernel_commit 03511e936916 \ + "f2fs: fix inconsistent dirty state of atomic file" + +_require_scratch +_require_command "$F2FS_IO_PROG" f2fs_io + +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +src_db=$SCRATCH_MNT/src.db +dst_db=$SCRATCH_MNT/dst.db + +# initialize database file +$XFS_IO_PROG -c "pwrite 0 4k" -c "fsync" -f $src_db >> $seqres.full + +# sync filesystem to clear dirty inode +sync + +# start atomic_write on src.db database file and commit transaction after 3000ms +$F2FS_IO_PROG write 1 0 0 zero atomic_commit $src_db 3000 >> $seqres.full & +atomic_write_pid=$! + +# wait a moment to let atomic write starts +sleep 1 +
tests/f2fs/010 line 63
Quoted 10 lines
tests/f2fs/010 new file +10
-0+# it will dirty inode when updating i_pino +mv $src_db $dst_db + +# wait for atomic_write commit completion +sleep 4 + +# drop caches in order to call f2fs_evict_inode() +echo 3 > /proc/sys/vm/drop_caches + +wait $atomic_write_pid
So after this line, the $atomic_write_pid has been released. If so, how about:
unset atomic_write_pid
And then in _cleanup function .... (see above)
Others look good to me,
Thanks,
Zorro
Quoted 16 lines
tests/f2fs/010 new file +5
-0+ +echo "Silence is golden" + +status=0 +exittests/f2fs/010.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 010 +Silence is goldenSignature · 1 line
2.48.1
Quoted 98 lines · Zorro Lang
Quoted 41 lines · Chao Yu
This is a regression testcase to check whether we will handle database inode dirty status correctly:
1. create a regular file, and write data into the file
2. start transaction on the file (viaF2FS_IOC_START_ATOMIC_WRITE)
3. write transaction data to the file
4. rename the file
5. commit and end the transaction (viaF2FS_IOC_COMMIT_ATOMIC_WRITE)
6. drop caches in order to callf2fs_evict_inode()
It expects kernel panic will gone after we apply commit03511e936916("f2fs: fix inconsistent dirty state of atomic file").Cc Jaegeuk Kim <[email protected]>Cc Daeho Jeong <[email protected]>Cc Jianan Huang <[email protected]>Signed-off-by Chao Yu <[email protected]>--- tests/f2fs/010 | 68 ++++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/010.out | 2 ++ 2 files changed, 70 insertions(+) create mode 100755 tests/f2fs/010 create mode 100644 tests/f2fs/010.outtests/f2fs/010 new file +13
-0@@ -0,0 +1,68 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Chao Yu. All Rights Reserved. +# +# FS QA Test No. f2fs/010 +# +# This is a regression testcase to check whether we will handle database +# inode dirty status correctly: +# 1. create a regular file, and write data into the file +# 2. start transaction on the file (via F2FS_IOC_START_ATOMIC_WRITE) +# 3. write transaction data to the file +# 4. rename the file +# 5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE)tests/f2fs/010 line 23
Quoted 10 lines
tests/f2fs/010 new file +10
-0+# 6. drop caches in order to call f2fs_evict_inode() +# It expects kernel panic will gone after we apply commit 03511e936916 +# ("f2fs: fix inconsistent dirty state of atomic file"). +# +. ./common/preamble +_begin_fstest auto quick + +_cleanup() +{ + kill -9 $atomic_write_pid > /dev/null 2>&1[ -n "$atomic_write_pid" ] && kill -9 $atomic_write_pid
Quoted 30 lines
tests/f2fs/010 new file +30
-0+ wait + cd / + rm -r -f $tmp.* +} + +_fixed_by_kernel_commit 03511e936916 \ + "f2fs: fix inconsistent dirty state of atomic file" + +_require_scratch +_require_command "$F2FS_IO_PROG" f2fs_io + +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +src_db=$SCRATCH_MNT/src.db +dst_db=$SCRATCH_MNT/dst.db + +# initialize database file +$XFS_IO_PROG -c "pwrite 0 4k" -c "fsync" -f $src_db >> $seqres.full + +# sync filesystem to clear dirty inode +sync + +# start atomic_write on src.db database file and commit transaction after 3000ms +$F2FS_IO_PROG write 1 0 0 zero atomic_commit $src_db 3000 >> $seqres.full & +atomic_write_pid=$! + +# wait a moment to let atomic write starts +sleep 1 +tests/f2fs/010 line 63
Quoted 10 lines
tests/f2fs/010 new file +10
-0+# it will dirty inode when updating i_pino +mv $src_db $dst_db + +# wait for atomic_write commit completion +sleep 4 + +# drop caches in order to call f2fs_evict_inode() +echo 3 > /proc/sys/vm/drop_caches + +wait $atomic_write_pidSo after this line, the $atomic_write_pid has been released. If so, how about:
Quoted 5 lines
unset
atomic_write_pidAnd then in
_cleanupfunction .... (see above)Others look good to me,
Oh, correct, will fix this. Thank you!
Thanks,
Quoted 21 lines
Thanks,
ZorroQuoted 16 lines
tests/f2fs/010 new file +5
-0+ +echo "Silence is golden" + +status=0 +exittests/f2fs/010.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 010 +Silence is goldenSignature · 1 line
2.48.1