f2fs: flush data when enabling checkpoint back
authorJaegeuk Kim <jaegeuk@kernel.org>
Wed, 27 Jan 2021 01:00:42 +0000 (17:00 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 1 Feb 2021 22:32:50 +0000 (14:32 -0800)
During checkpoint=disable period, f2fs bypasses all the synchronous IOs such as
sync and fsync. So, when enabling it back, we must flush all of them in order
to keep the data persistent. Otherwise, suddern power-cut right after enabling
checkpoint will cause data loss.

Fixes: 4354994f097d ("f2fs: checkpoint disabling")
Cc: stable@vger.kernel.org
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/super.c

index fc343243799c083b74f7d040b9beb3da1f28ae82..429bc00af4406ecbd818faaf9814c4832f56958c 100644 (file)
@@ -1892,6 +1892,9 @@ restore_flag:
 
 static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
 {
+       /* we should flush all the data to keep data consistency */
+       sync_inodes_sb(sbi->sb);
+
        down_write(&sbi->gc_lock);
        f2fs_dirty_to_prefree(sbi);