]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
f2fs: add testcase to check resize corrupting root inode
authorYangyang Zang <zangyangyang66@gmail.com>
Thu, 19 Mar 2026 03:35:19 +0000 (11:35 +0800)
committerZorro Lang <zlang@kernel.org>
Tue, 31 Mar 2026 19:40:34 +0000 (03:40 +0800)
This is a regression test to check whether the f2fs root inode
is corrupted after the resize operation.
During the resize operation, SSA data blocks are migrated and
zeroed. This process may incorrectly zero out the main area
blocks, leading to root inode corruption.

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Chao Yu <chao@kernel.org>
Signed-off-by: Yangyang Zang <zangyangyang1@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/f2fs/024 [new file with mode: 0644]
tests/f2fs/024.out [new file with mode: 0644]

diff --git a/tests/f2fs/024 b/tests/f2fs/024
new file mode 100644 (file)
index 0000000..1ca7ee2
--- /dev/null
@@ -0,0 +1,39 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Yangyang Zang.  All Rights Reserved.
+#
+# FS QA Test No. f2fs/024
+#
+# This test case tries to check whether resize.f2fs can correctly
+# zero out ssa blocks without corrupting the main area blocks.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+_fixed_by_git_commit f2fs-tools xxxxxxxxxxxx \
+       "resize.f2fs: fix to avoid zeroing main area blocks in migrate_ssa()"
+
+# magic size
+target_fs_size=$((2*1024*1024*1024+4*1024*1204))
+
+_require_scratch_size_nocheck $(($target_fs_size/1024))
+_require_command "$F2FS_RESIZE_PROG" resize.f2fs
+_require_command "$DUMP_F2FS_PROG" dump.f2fs
+
+# remove all mkfs options to avoid layout change of on-disk inode
+export MKFS_OPTIONS=""
+
+_scratch_mkfs_sized $((512*1024*1024)) "" "-g android" >> $seqres.full
+
+sector_size=$(blockdev --getss $SCRATCH_DEV)
+target_sectors=$(($target_fs_size/$sector_size))
+
+$F2FS_RESIZE_PROG -F $SCRATCH_DEV -t $target_sectors >> $seqres.full 2>&1 || \
+        $F2FS_RESIZE_PROG $SCRATCH_DEV -t $target_sectors >> $seqres.full 2>&1 || \
+        _fail "resize fs failed"
+
+echo n | $DUMP_F2FS_PROG -d 1 -i 3 $SCRATCH_DEV | grep "dump_node:" | sed 's/^\[[^]]*\] //'
+_scratch_mount
+
+status=0
+exit
diff --git a/tests/f2fs/024.out b/tests/f2fs/024.out
new file mode 100644 (file)
index 0000000..a7a553f
--- /dev/null
@@ -0,0 +1,7 @@
+QA output created by 024
+Node ID               [0x3]
+nat_entry.block_addr  [0x1a00]
+nat_entry.version     [0x0]
+nat_entry.ino         [0x3]
+node_blk.footer.ino [0x3]
+node_blk.footer.nid [0x3]