f2fs: flush data when enabling checkpoint back 61/266761/1
authorJaegeuk Kim <jaegeuk@kernel.org>
Wed, 17 Nov 2021 12:20:52 +0000 (21:20 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 18 Nov 2021 08:47:10 +0000 (17:47 +0900)
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: 4354994 ("f2fs: checkpoint disabling")
Cc: stable@vger.kernel.org
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
[dwoo08.lee: backport from mainline commit b0ff4fe746fd]
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Change-Id: Ic0810d99c5a3938e191461bd66e7862a4a68e12b

fs/f2fs/super.c

index be58d77f9b69d4352cb5a68b34408105daa37675..dacb3bc8330f56f31ed6b96f875d9afea4f03f0b 100644 (file)
@@ -1465,6 +1465,9 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
 
 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);
+
        mutex_lock(&sbi->gc_mutex);
        f2fs_dirty_to_prefree(sbi);