summaryrefslogtreecommitdiff
path: root/fs/f2fs/super.c
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2021-08-19 14:00:57 -0700
committerJaegeuk Kim <jaegeuk@kernel.org>2021-08-30 10:12:47 -0700
commitdddd3d65293a52c2c3850c19b1e5115712e534d8 (patch)
treedfbcce98983e1e41ed25cee8365056fe6112df5a /fs/f2fs/super.c
parentc8dc3047c48540183744f959412d44b08c5435e1 (diff)
f2fs: guarantee to write dirty data when enabling checkpoint back
We must flush all the dirty data when enabling checkpoint back. Let's guarantee that first by adding a retry logic on sync_inodes_sb(). In addition to that, this patch adds to flush data in fsync when checkpoint is disabled, which can mitigate the sync_inodes_sb() failures in advance. Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/super.c')
-rw-r--r--fs/f2fs/super.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index d18271f3d190..703fe8991838 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2083,8 +2083,17 @@ restore_flag:
static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
{
+ int retry = DEFAULT_RETRY_IO_COUNT;
+
/* we should flush all the data to keep data consistency */
- sync_inodes_sb(sbi->sb);
+ do {
+ sync_inodes_sb(sbi->sb);
+ cond_resched();
+ congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT);
+ } while (get_pages(sbi, F2FS_DIRTY_DATA) && retry--);
+
+ if (unlikely(retry < 0))
+ f2fs_warn(sbi, "checkpoint=enable has some unwritten data.");
down_write(&sbi->gc_lock);
f2fs_dirty_to_prefree(sbi);