From: Sheng Yong <shengyo...@xiaomi.com> Signed-off-by: Sheng Yong <shengyo...@xiaomi.com> --- tests/f_loop_fsync_dnodes/README | 5 ++++ tests/f_loop_fsync_dnodes/expect.in | 6 ++++ tests/f_loop_fsync_dnodes/script | 46 +++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 tests/f_loop_fsync_dnodes/README create mode 100644 tests/f_loop_fsync_dnodes/expect.in create mode 100644 tests/f_loop_fsync_dnodes/script
diff --git a/tests/f_loop_fsync_dnodes/README b/tests/f_loop_fsync_dnodes/README new file mode 100644 index 000000000000..4e864fa8c874 --- /dev/null +++ b/tests/f_loop_fsync_dnodes/README @@ -0,0 +1,5 @@ +1. create f2fs image +2. mount f2fs and create 10 regular files with O_SYNC +3. shutdown f2fs without writing checkpoint +4. inject fsync dnodes to generate a loop +5. fsck fixes fsync dnodes by breaking the loop diff --git a/tests/f_loop_fsync_dnodes/expect.in b/tests/f_loop_fsync_dnodes/expect.in new file mode 100644 index 000000000000..23b7fbfc7e82 --- /dev/null +++ b/tests/f_loop_fsync_dnodes/expect.in @@ -0,0 +1,6 @@ +Info: Force to fix corruption +Info: checkpoint stop reason: shutdown(1) +[ASSERT] (sanity_check_node_chain:x) --> detect looped node chain, blkaddr:_BLKADDR_ +[FIX] (loop_node_chain_fix:x) --> Fix looped node chain on blkaddr _BLKADDR_ +Info: Force to fix corruption +Info: checkpoint stop reason: shutdown(1) diff --git a/tests/f_loop_fsync_dnodes/script b/tests/f_loop_fsync_dnodes/script new file mode 100644 index 000000000000..b6f64f384a0e --- /dev/null +++ b/tests/f_loop_fsync_dnodes/script @@ -0,0 +1,46 @@ +#!/bin/bash + +DESC="recover loop fsync dnodes" + +. $TOPDIR/tests/helpers + +# if device is a zoned device, this testcase should be skipped +test_sb_feature blkzoned +if [ $? -ne 0 ]; then + touch $TESTDIR/SKIP + check_result + return +fi + +cleanup +make_f2fs > $LOG + +mkdir $TESTDIR/mntdir +safe_mount $MNT_OPTS $META $TESTDIR/mntdir >> $LOG +mkdir $TESTDIR/mntdir/testdir +touch $TESTDIR/mntdir/testdir/testfile +$F2FS_IO checkpoint $TESTDIR/mntdir/testdir/testfile >> $LOG +i=0 +while [ $i -lt 10 ]; do + # write one all zero 4K chunk to file with O_SYNC + $F2FS_IO write 1 0 1 zero osync $TESTDIR/mntdir/testdir/testfile.$i >> $LOG + i=$((i + 1)) +done +$F2FS_IO shutdown 2 $TESTDIR/mntdir/testdir/testfile >> $LOG +safe_umount $TESTDIR/mntdir >> $LOG +rm -rf $TESTDIR/mntdir + +addr1=`$INJECT --dry-run --cp 0 --mb next_blkaddr --idx 6 --val 0 $META | \ + grep "\[.*1\] blkaddr:" | cut -d ":" -f 3` +addr2=`$INJECT --dry-run --cp 0 --mb next_blkaddr --idx 6 --val 0 $META | \ + grep "\[.*6\] blkaddr:" | cut -d ":" -f 3` +echo "addr1:$addr1, addr2:$addr2" >> $LOG +$INJECT --cp 0 --mb next_blkaddr --idx 6 --val $addr1 $META >> $LOG + +$FSCK $FSCK_OPTS -f $META > $OUT +$FSCK $FSCK_OPTS -f $META >> $OUT +cat $OUT >> $LOG + +sed "s/_BLKADDR_/$((addr2))/g" $TESTDIR/expect.in > $TESTDIR/expect + +check_result -- 2.43.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel