Signed-off-by: Sheng Yong <shengy...@oppo.com> --- tests/f_nat_bad_ino/README | 4 ++++ tests/f_nat_bad_ino/expect.in | 39 +++++++++++++++++++++++++++++++++++ tests/f_nat_bad_ino/script | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 tests/f_nat_bad_ino/README create mode 100644 tests/f_nat_bad_ino/expect.in create mode 100644 tests/f_nat_bad_ino/script
diff --git a/tests/f_nat_bad_ino/README b/tests/f_nat_bad_ino/README new file mode 100644 index 000000000000..b97015297b25 --- /dev/null +++ b/tests/f_nat_bad_ino/README @@ -0,0 +1,4 @@ +1. create f2fs image +2. mount f2fs and create a regular file +3. inject ino in nat entry with value 0x12345 of the regular file +4. fsck fixes the nat entry by nullifying it diff --git a/tests/f_nat_bad_ino/expect.in b/tests/f_nat_bad_ino/expect.in new file mode 100644 index 000000000000..99ad7705fd47 --- /dev/null +++ b/tests/f_nat_bad_ino/expect.in @@ -0,0 +1,39 @@ +Info: Force to fix corruption +Info: checkpoint state = x : nat_bits crc compacted_summary unmount +[ASSERT] (sanity_check_nid: x) --> nid[_INO_] nat_entry->ino[0x12345] footer.ino[_INO_] +[FIX] (__chk_dentries:x) --> Unlink [_INO_] - testfile len[0x8], type[0x1] + +NID[_INO_] is unreachable, blkaddr:_BLK_ +[FSCK] Unreachable nat entries [Fail] [x] +[FSCK] SIT valid block bitmap checking [Fail] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Fail] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Fail] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Fail] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Fail] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: write_checkpoint() cur_cp:x +[FIX] (nullify_nat_entry:x) --> Remove nid [_INO_] in NAT +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] + diff --git a/tests/f_nat_bad_ino/script b/tests/f_nat_bad_ino/script new file mode 100644 index 000000000000..18db1db97b03 --- /dev/null +++ b/tests/f_nat_bad_ino/script @@ -0,0 +1,39 @@ +#!/bin/sh + +DESC="nat entry with invalid ino" + +. $TOPDIR/tests/helpers + +cleanup pre > $LOG 2>&1 +make_f2fs >> $LOG 2>&1 + +mkdir $TESTDIR/mntdir +safe_mount $MNT_OPTS $META $TESTDIR/mntdir >> $LOG 2>&1 +if [ $? -ne 0 ]; then + echo "cannot mount f2fs image" + exit +fi +touch $TESTDIR/mntdir/testfile +ino=`stat -c "%i" $TESTDIR/mntdir/testfile` +safe_umount $TESTDIR/mntdir >> $LOG 2>&1 +if [ $? -ne 0 ]; then + echo "cannot umount f2fs image" + exit +fi +rm -rf $TESTDIR/mntdir + +blk=`$DUMP $DUMP_OPTS -i $ino -d 1 $META | grep nat_entry.block_addr | sed 's/.*nat_entry\.block_addr\s*\[\(0x[0-9a-f]\+\)\]/\1/g'` + +echo "ino:$ino blk:$blk" >> $LOG + +$INJECT --nat 1 --nid $ino --mb ino --val 0x12345 $META >> $LOG 2>&1 +$FSCK $FSCK_OPTS -f $META > $OUT 2>&1 +$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1 +cat $OUT >> $LOG + +INO=`printf "0x%x" $ino` +sed "s/_INO_/$INO/g" $TESTDIR/expect.in > $TESTDIR/expect +sed -i "s/_BLK_/$blk/g" $TESTDIR/expect + +check_result +cleanup post >> $LOG 2>&1 -- 2.40.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel