From: Yangyang Zang Date: Thu, 19 Mar 2026 03:35:19 +0000 (+0800) Subject: f2fs: add testcase to check resize corrupting root inode X-Git-Tag: v2026.04.20~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=39b31fe6e746ada86179ecb698d7f891d633218a;p=xfstests-dev.git f2fs: add testcase to check resize corrupting root inode 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 Cc: Chao Yu Signed-off-by: Yangyang Zang Reviewed-by: Chao Yu Signed-off-by: Zorro Lang --- diff --git a/tests/f2fs/024 b/tests/f2fs/024 new file mode 100644 index 00000000..1ca7ee27 --- /dev/null +++ b/tests/f2fs/024 @@ -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 index 00000000..a7a553f0 --- /dev/null +++ b/tests/f2fs/024.out @@ -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]