From 807584df1d5f372074d914624d94c2c69c3de362 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Wed, 17 Nov 2021 21:20:52 +0900 Subject: [PATCH] f2fs: flush data when enabling checkpoint back 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 Signed-off-by: Jaegeuk Kim [dwoo08.lee: backport from mainline commit b0ff4fe746fd] Signed-off-by: Dongwoo Lee Change-Id: Ic0810d99c5a3938e191461bd66e7862a4a68e12b --- fs/f2fs/super.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index be58d77..dacb3bc 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -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); -- 2.7.4