defrag.f2fs: eliminate unexpected journal entries
authorJaegeuk Kim <jaegeuk@kernel.org>
Thu, 17 Dec 2015 01:43:34 +0000 (17:43 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 17 Dec 2015 01:46:32 +0000 (17:46 -0800)
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>
fsck/defrag.c
fsck/fsck.h
fsck/mount.c

index 7ca7260..7abc0bf 100644 (file)
@@ -90,6 +90,7 @@ int f2fs_defragment(struct f2fs_sb_info *sbi, u64 from, u64 len, u64 to, int lef
 
        /* update curseg info; can update sit->types */
        move_curseg_info(sbi, to);
+       zero_journal_entries(sbi);
        write_curseg_info(sbi);
 
        /* flush dirty sit entries */
index 1464146..3870948 100644 (file)
@@ -135,6 +135,7 @@ extern int f2fs_do_mount(struct f2fs_sb_info *);
 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 *);
index 8418dcc..735ed90 100644 (file)
@@ -1446,6 +1446,14 @@ void move_curseg_info(struct f2fs_sb_info *sbi, u64 from)
        }
 }
 
+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);