fsck.f2fs: write back last cp block in the end
authorYunlei He <heyunlei@huawei.com>
Wed, 23 Aug 2017 04:13:04 +0000 (12:13 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 29 Aug 2017 17:04:00 +0000 (10:04 -0700)
Write back last cp block in the end in case of sudden power off
during fsck process

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/mount.c

index af5e32e..7a8aeae 100644 (file)
@@ -1934,13 +1934,16 @@ void write_checkpoint(struct f2fs_sb_info *sbi)
                ASSERT(ret >= 0);
        }
 
-       /* write the last cp */
-       ret = dev_write_block(cp, cp_blk_no++);
-       ASSERT(ret >= 0);
-
        /* Write nat bits */
        if (flags & CP_NAT_BITS_FLAG)
                write_nat_bits(sbi, sb, cp, sbi->cur_cp);
+
+       /* in case of sudden power off */
+       f2fs_finalize_device();
+
+       /* write the last cp */
+       ret = dev_write_block(cp, cp_blk_no++);
+       ASSERT(ret >= 0);
 }
 
 void build_nat_area_bitmap(struct f2fs_sb_info *sbi)