Skip to contentSkip to conversation

f2fs/005: add testcase to check checkpoint disabling functionality

PATCH In review Chao Yu 2 participants 2 messages Oct 28, 2024 – Oct 29, 2024

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH v2 1/1 f2fs/005: add testcase to check checkpoint disabling functionality

This patch introduce a regression test to check whether f2fs handles dirty inode correctly when checkpoint is disabled in a corner case, it may hang umount before the bug is fixed.

---
v2:
- add _fixed_by_kernel_commit()
- use _scratch_mkfs_sized() rather than formating size-specified loop device
- code cleanup

 tests/f2fs/005     | 47 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/f2fs/005.out |  2 ++
 2 files changed, 49 insertions(+)
 create mode 100755 tests/f2fs/005
 create mode 100644 tests/f2fs/005.out
tests/f2fs/005 new file +47 -0
new file mode 100755
index 00000000..a817d51a
@@ -0,0 +1,47 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oppo.  All Rights Reserved.
+#
+# FS QA Test No. f2fs/005
+#
+# This is a regression test to check whether f2fs handles dirty
+# inode correctly when checkpoint is disabled, it may hang umount
+# before the bug is fixed.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+_fixed_by_kernel_commit xxxxxxxxxxxx \
+	"f2fs: fix f2fs_bug_on when uninstalling filesystem call f2fs_evict_inode."
+
+_require_scratch
+_scratch_mkfs_sized $((1024*1024*50)) >> $seqres.full
+
+# use mode=lfs to let f2fs always triggers OPU
+_scratch_mount -o mode=lfs,checkpoint=disable:10%,noinline_dentry >> $seqres.full
+
+testfile=$SCRATCH_MNT/testfile
+tmpfile=$SCRATCH_MNT/tmpfile
+tmpdir=$SCRATCH_MNT/tmpdir
+
+dd if=/dev/zero of=$testfile bs=1M count=5 2>/dev/null
+mkdir $tmpdir
+touch $tmpfile
+sync
+
+# it dirties tmpdir inode by updating ctime,
+# but it doesn't moving the inode to gdirty_list.
+mv $tmpfile $tmpdir
+
+# it runs out of free segment
+dd if=/dev/zero of=$testfile bs=1M count=5 conv=notrunc conv=fsync 2>/dev/null
+
+_scratch_mount -o remount,checkpoint=enable
+
+# it may hang umount if tmpdir is still dirty during evict()
+_scratch_unmount
+
+echo "Silence is golden"
+
+status=0
+exit
tests/f2fs/005.out new file +2 -0
new file mode 100644
index 00000000..a5027f12
@@ -0,0 +1,2 @@
+QA output created by 005
+Silence is golden
Signature · 1 line
2.40.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Chao Yu

This patch introduce a regression test to check whether f2fs handles dirty inode correctly when checkpoint is disabled in a corner case, it may hang umount before the bug is fixed.

---
v2:
- add _fixed_by_kernel_commit()
- use _scratch_mkfs_sized() rather than formating size-specified

This test looks good to me, if no more review points from f2fs list, I'll merge it.

Quoted 72 lines

loop device
- code cleanup

 tests/f2fs/005     | 47 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/f2fs/005.out |  2 ++
 2 files changed, 49 insertions(+)
 create mode 100755 tests/f2fs/005
 create mode 100644 tests/f2fs/005.out
tests/f2fs/005 new file +47 -0
new file mode 100755
index 00000000..a817d51a
@@ -0,0 +1,47 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oppo.  All Rights Reserved.
+#
+# FS QA Test No. f2fs/005
+#
+# This is a regression test to check whether f2fs handles dirty
+# inode correctly when checkpoint is disabled, it may hang umount
+# before the bug is fixed.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+_fixed_by_kernel_commit xxxxxxxxxxxx \
+	"f2fs: fix f2fs_bug_on when uninstalling filesystem call f2fs_evict_inode."
+
+_require_scratch
+_scratch_mkfs_sized $((1024*1024*50)) >> $seqres.full
+
+# use mode=lfs to let f2fs always triggers OPU
+_scratch_mount -o mode=lfs,checkpoint=disable:10%,noinline_dentry >> $seqres.full
+
+testfile=$SCRATCH_MNT/testfile
+tmpfile=$SCRATCH_MNT/tmpfile
+tmpdir=$SCRATCH_MNT/tmpdir
+
+dd if=/dev/zero of=$testfile bs=1M count=5 2>/dev/null
+mkdir $tmpdir
+touch $tmpfile
+sync
+
+# it dirties tmpdir inode by updating ctime,
+# but it doesn't moving the inode to gdirty_list.
+mv $tmpfile $tmpdir
+
+# it runs out of free segment
+dd if=/dev/zero of=$testfile bs=1M count=5 conv=notrunc conv=fsync 2>/dev/null
+
+_scratch_mount -o remount,checkpoint=enable
+
+# it may hang umount if tmpdir is still dirty during evict()
+_scratch_unmount
+
+echo "Silence is golden"
+
+status=0
+exit
tests/f2fs/005.out new file +2 -0
new file mode 100644
index 00000000..a5027f12
@@ -0,0 +1,2 @@
+QA output created by 005
+Silence is golden
Signature · 1 line
2.40.1