Commit e6c6de18 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: hurry up to issue discard after io interruption

Once we encounter I/O interruption during issuing discards, we will delay
long time before next round, but if system status is I/O idle during the
time, it may loses opportunity to issue discards. So this patch changes
to hurry up to issue discard after io interruption.

Besides, this patch also fixes to issue discards accurately with assigned
rate.
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 80647e5f
...@@ -1062,6 +1062,7 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond) ...@@ -1062,6 +1062,7 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond)
struct blk_plug plug; struct blk_plug plug;
int iter = 0, issued = 0; int iter = 0, issued = 0;
int i; int i;
bool io_interrupted = false;
mutex_lock(&dcc->cmd_lock); mutex_lock(&dcc->cmd_lock);
f2fs_bug_on(sbi, f2fs_bug_on(sbi,
...@@ -1083,11 +1084,20 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond) ...@@ -1083,11 +1084,20 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond)
continue; continue;
} }
if (!issue_cond || is_idle(sbi)) { if (!issue_cond) {
__submit_discard_cmd(sbi, dc);
issued++; issued++;
continue;
}
if (is_idle(sbi)) {
__submit_discard_cmd(sbi, dc); __submit_discard_cmd(sbi, dc);
issued++;
} else {
io_interrupted = true;
} }
if (issue_cond && iter++ > DISCARD_ISSUE_RATE)
if (++iter >= DISCARD_ISSUE_RATE)
goto out; goto out;
} }
if (list_empty(pend_list) && dcc->pend_list_tag[i] & P_TRIM) if (list_empty(pend_list) && dcc->pend_list_tag[i] & P_TRIM)
...@@ -1097,6 +1107,9 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond) ...@@ -1097,6 +1107,9 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond)
blk_finish_plug(&plug); blk_finish_plug(&plug);
mutex_unlock(&dcc->cmd_lock); mutex_unlock(&dcc->cmd_lock);
if (!issued && io_interrupted)
issued = -1;
return issued; return issued;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment