f2fs: flush data when enabling checkpoint back

commit b0ff4fe746fd028eef920ddc8c7b0361c1ede6ec upstream.

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: 4354994f09 ("f2fs: checkpoint disabling")
Cc: stable@vger.kernel.org
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jaegeuk Kim 2021-01-26 17:00:42 -08:00 committed by Greg Kroah-Hartman
parent 04a495780f
commit f98be16898

View File

@ -1764,6 +1764,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);
down_write(&sbi->gc_lock);
f2fs_dirty_to_prefree(sbi);