new file mode 100644
@@ -0,0 +1,8 @@
+1. create f2fs image
+2. mount f2fs
+3. create an inline dentry directory, and create a file in it
+4. inject dentry's hash_code of the file
+5. fsck fixes the dentry's hash_code
+6. create a non-inline dentry directory (by converting), and create a file in it
+7. inject dentry's hash_code of the file
+8. fsck fixes the dentry's hash_code
new file mode 100644
@@ -0,0 +1,62 @@
+Info: Force to fix corruption
+Info: checkpoint state = x : nat_bits crc compacted_summary unmount
+[FIX] (f2fs_check_hash_code:x) --> Mismatch hash_code for "testfile1" [12345:_HASH1_]
+
+[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..]
+
+Info: Force to fix corruption
+Info: checkpoint state = x : nat_bits crc compacted_summary 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..]
+
+Info: Force to fix corruption
+Info: checkpoint state = x : nat_bits crc compacted_summary unmount
+[FIX] (f2fs_check_hash_code:x) --> Mismatch hash_code for "testfile2" [12345:_HASH2_]
+
+[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..]
+
+Info: Force to fix corruption
+Info: checkpoint state = x : nat_bits crc compacted_summary 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,71 @@
+#!/bin/sh
+
+DESC="dentry with invalid hash_code"
+
+. $TOPDIR/tests/helpers
+
+cleanup pre > $LOG 2>&1
+make_f2fs >> $LOG 2>&1
+
+mkdir $TESTDIR/mntdir
+# inject inline dentry
+safe_mount $MNT_OPTS $META $TESTDIR/mntdir >> $LOG 2>&1
+if [ $? -ne 0 ]; then
+ echo "cannot mount f2fs image"
+ exit
+fi
+mkdir $TESTDIR/mntdir/testdir1
+touch $TESTDIR/mntdir/testdir1/testfile1
+ino=`stat -c "%i" $TESTDIR/mntdir/testdir1/testfile1`
+safe_umount $TESTDIR/mntdir >> $LOG 2>&1
+if [ $? -ne 0 ]; then
+ echo "cannot umount f2fs image"
+ exit
+fi
+
+hash_code=`$INJECT --dry-run --dent --nid $ino --mb d_hash $META | grep "Info: inject dentry d_hash of nid" | awk '{print $(NF-2)}'`
+echo "ino:$ino hash_code=$hash_code" >> $LOG
+
+$INJECT --dent --nid $ino --mb d_hash --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
+skip_lines=`wc -l $OUT`
+
+HASH_CODE=`printf "%x" $hash_code`
+sed "s/_HASH1_/$HASH_CODE/g" $TESTDIR/expect.in > $TESTDIR/expect
+
+# inject non-inline dentry
+safe_mount $MNT_OPTS $META $TESTDIR/mntdir >> $LOG 2>&1
+if [ $? -ne 0 ]; then
+ echo "cannot mount f2fs image"
+ exit
+fi
+mkdir $TESTDIR/mntdir/testdir2
+i=0
+while [ $i -lt 30 ]; do
+ touch $TESTDIR/mntdir/testdir2/loooooooooooooooooooooooooognametestfile$i
+ i=$(($i + 1))
+done
+touch $TESTDIR/mntdir/testdir2/testfile2
+ino=`stat -c "%i" $TESTDIR/mntdir/testdir2/testfile2`
+safe_umount $TESTDIR/mntdir >> $LOG 2>&1
+if [ $? -ne 0 ]; then
+ echo "cannot umount f2fs image"
+ exit
+fi
+rm -rf $TESTDIR/mntdir
+
+hash_code=`$INJECT --dry-run --dent --nid $ino --mb d_hash $META | grep "Info: inject dentry d_hash of nid" | awk '{print $(NF-2)}'`
+echo "ino:$ino hash_code=$hash_code" >> $LOG
+
+$INJECT --dent --nid $ino --mb d_hash --val 0x12345 $META >> $LOG 2>&1
+$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1
+$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1
+cat $OUT | tail -n +$skip_lines >> $LOG
+
+HASH_CODE=`printf "%x" $hash_code`
+sed -i "s/_HASH2_/$HASH_CODE/g" $TESTDIR/expect
+
+check_result
+cleanup post >> $LOG 2>&1
Signed-off-by: Sheng Yong <shengyong@oppo.com> --- tests/f_dentry_bad_hash/README | 8 ++++ tests/f_dentry_bad_hash/expect.in | 62 +++++++++++++++++++++++++++ tests/f_dentry_bad_hash/script | 71 +++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 tests/f_dentry_bad_hash/README create mode 100644 tests/f_dentry_bad_hash/expect.in create mode 100644 tests/f_dentry_bad_hash/script