defrag.f2fs: eliminate unexpected journal entries

When moving data or node blocks, it changes current segment information
dynamtically. Meanwhile, its journal entry space is recovered by old
stale data.
This patch makes sure that its journal space is zeroed out.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
diff --git a/fsck/defrag.c b/fsck/defrag.c
index 7ca7260..7abc0bf 100644
--- a/fsck/defrag.c
+++ b/fsck/defrag.c
@@ -90,6 +90,7 @@
 
 	/* update curseg info; can update sit->types */
 	move_curseg_info(sbi, to);
+	zero_journal_entries(sbi);
 	write_curseg_info(sbi);
 
 	/* flush dirty sit entries */
diff --git a/fsck/fsck.h b/fsck/fsck.h
index 1464146..3870948 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -135,6 +135,7 @@
 extern void f2fs_do_umount(struct f2fs_sb_info *);
 
 extern void flush_journal_entries(struct f2fs_sb_info *);
+extern void zero_journal_entries(struct f2fs_sb_info *);
 extern void flush_sit_entries(struct f2fs_sb_info *);
 extern void move_curseg_info(struct f2fs_sb_info *, u64);
 extern void write_curseg_info(struct f2fs_sb_info *);
diff --git a/fsck/mount.c b/fsck/mount.c
index 8418dcc..735ed90 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1446,6 +1446,14 @@
 	}
 }
 
+void zero_journal_entries(struct f2fs_sb_info *sbi)
+{
+	int i;
+
+	for (i = 0; i < NO_CHECK_TYPE; i++)
+		CURSEG_I(sbi, i)->sum_blk->n_nats = 0;
+}
+
 void write_curseg_info(struct f2fs_sb_info *sbi)
 {
 	struct f2fs_checkpoint *cp = F2FS_CKPT(sbi);