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

Commit 258483eb authored by Sahitya Tummala's avatar Sahitya Tummala
Browse files

f2fs: fix long latency due to discard during umount



F2FS already has a default timeout of 5 secs for discards that
can be issued during umount, but it can take more than the 5 sec
timeout if the underlying UFS device queue is already full and there
are no more available free tags to be used. Fix this by submitting a
small batch of discard requests so that it won't cause the device
queue to be full at any time and thus doesn't incur its wait time
in the umount context.

Change-Id: Ib9669453795601e9e602c204aad31a5cb70688a4
Signed-off-by: default avatarSahitya Tummala <stummala@codeaurora.org>
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
Git-commit: 141af6ba5216d4d49de683582b600d5c9b51792c
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/


[stummala@codeaurora.org: Fix trivial merge conflicts]
Signed-off-by: default avatarSahitya Tummala <stummala@codeaurora.org>
parent 2f9a4a4b
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -1100,7 +1100,6 @@ static void __init_discard_policy(struct f2fs_sb_info *sbi,
	} else if (discard_type == DPOLICY_FSTRIM) {
		dpolicy->io_aware = false;
	} else if (discard_type == DPOLICY_UMOUNT) {
		dpolicy->max_requests = UINT_MAX;
		dpolicy->io_aware = false;
		/* we need to issue all to keep CP_TRIMMED_FLAG */
		dpolicy->granularity = 1;
@@ -1461,6 +1460,8 @@ static unsigned int __issue_discard_cmd_orderly(struct f2fs_sb_info *sbi,

	return issued;
}
static unsigned int __wait_all_discard_cmd(struct f2fs_sb_info *sbi,
					struct discard_policy *dpolicy);

static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
					struct discard_policy *dpolicy)
@@ -1469,12 +1470,14 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
	struct list_head *pend_list;
	struct discard_cmd *dc, *tmp;
	struct blk_plug plug;
	int i, issued = 0;
	int i, issued;
	bool io_interrupted = false;

	if (dpolicy->timeout != 0)
		f2fs_update_time(sbi, dpolicy->timeout);

retry:
	issued = 0;
	for (i = MAX_PLIST_NUM - 1; i >= 0; i--) {
		if (dpolicy->timeout != 0 &&
				f2fs_time_over(sbi, dpolicy->timeout))
@@ -1521,6 +1524,11 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
			break;
	}

	if (dpolicy->type == DPOLICY_UMOUNT && issued) {
		__wait_all_discard_cmd(sbi, dpolicy);
		goto retry;
	}

	if (!issued && io_interrupted)
		issued = -1;