From: Jaegeuk Kim Date: Wed, 17 Nov 2021 12:20:52 +0000 (+0900) Subject: f2fs: flush data when enabling checkpoint back X-Git-Tag: submit/tizen/20211117.113146~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F61%2F266761%2F1;p=platform%2Fkernel%2Flinux-amlogic.git 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 --- diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index be58d77f9b69..dacb3bc8330f 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);