fsck.f2fs: fix losing journal entries
authorJaegeuk Kim <jaegeuk@kernel.org>
Sun, 20 Dec 2015 07:17:11 +0000 (23:17 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sun, 20 Dec 2015 07:42:31 +0000 (23:42 -0800)
If fsck.f2fs reports a bug, move_curseg_info tries to change the current
segment info.
When it changes the new summary block, it overwrites the existing journal
entries.
This patch fixes it not to overwrite journal entry space.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/mount.c

index d2f1432..fe68f37 100644 (file)
@@ -1438,6 +1438,7 @@ void move_curseg_info(struct f2fs_sb_info *sbi, u64 from)
        /* update summary blocks having nullified journal entries */
        for (i = 0; i < NO_CHECK_TYPE; i++) {
                struct curseg_info *curseg = CURSEG_I(sbi, i);
+               struct f2fs_summary_block buf;
                u32 old_segno;
                u64 ssa_blk, to;
 
@@ -1457,9 +1458,11 @@ void move_curseg_info(struct f2fs_sb_info *sbi, u64 from)
 
                /* update new segno */
                ssa_blk = GET_SUM_BLKADDR(sbi, curseg->segno);
-               ret = dev_read_block(curseg->sum_blk, ssa_blk);
+               ret = dev_read_block(&buf, ssa_blk);
                ASSERT(ret >= 0);
 
+               memcpy(curseg->sum_blk, &buf, SUM_ENTRIES_SIZE);
+
                /* update se->types */
                reset_curseg(sbi, i);