new file mode 100644
@@ -0,0 +1,4 @@
+1. create f2fs image
+2. mount f2fs and create a regular file
+3. inject block_addr in nat entry with value 0x12345 of the regular file
+4. fsck fixes the nat entry by nullifying it
new file mode 100644
@@ -0,0 +1,39 @@
+Info: Force to fix corruption
+Info: checkpoint state = x : nat_bits crc compacted_summary unmount
+[ASSERT] (sanity_check_nat: x) --> blkaddress is not valid. [_BLK_]
+[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..]
+
new file mode 100644
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+DESC="nat entry with invalid block_addr"
+
+. $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
+
+$INJECT --nat 0 --nid $ino --mb block_addr --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_/0x12345/g" $TESTDIR/expect
+
+check_result
+cleanup post >> $LOG 2>&1
Signed-off-by: Sheng Yong <shengyong@oppo.com> --- tests/f_nat_bad_blkaddr/README | 4 ++++ tests/f_nat_bad_blkaddr/expect.in | 39 +++++++++++++++++++++++++++++++ tests/f_nat_bad_blkaddr/script | 35 +++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 tests/f_nat_bad_blkaddr/README create mode 100644 tests/f_nat_bad_blkaddr/expect.in create mode 100644 tests/f_nat_bad_blkaddr/script