Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f510d03 authored by Jaegeuk Kim's avatar Jaegeuk Kim Committed by Sayali Lokhande
Browse files

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.

Change-Id: Ia79be96c2fefceeeb862c7d9c7dffc028a7c2762
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
Git-commit: 6608ba097fa7dced01895348972f1c3d1abb1977
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git


Signed-off-by: default avatarSayali Lokhande <quic_sayalil@quicinc.com>
parent 24530313
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -258,8 +258,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
	};
	unsigned int seq_id = 0;

	if (unlikely(f2fs_readonly(inode->i_sb) ||
				is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
	if (unlikely(f2fs_readonly(inode->i_sb)))
		return 0;

	trace_f2fs_sync_file_enter(inode);
@@ -282,7 +281,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
	ret = file_write_and_wait_range(file, start, end);
	clear_inode_flag(inode, FI_NEED_IPU);

	if (ret) {
	if (ret || is_sbi_flag_set(sbi, SBI_CP_DISABLED)) {
		trace_f2fs_sync_file_exit(inode, cp_reason, datasync, ret);
		return ret;
	}
+10 −1
Original line number Diff line number Diff line
@@ -1731,8 +1731,17 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)

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 */
	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);