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: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Chao Yu and committed by
Jaegeuk Kim
e6c6de18 80647e5f

+16 -3
+16 -3
fs/f2fs/segment.c
··· 1062 1062 struct blk_plug plug; 1063 1063 int iter = 0, issued = 0; 1064 1064 int i; 1065 + bool io_interrupted = false; 1065 1066 1066 1067 mutex_lock(&dcc->cmd_lock); 1067 1068 f2fs_bug_on(sbi, ··· 1084 1083 continue; 1085 1084 } 1086 1085 1087 - if (!issue_cond || is_idle(sbi)) { 1088 - issued++; 1086 + if (!issue_cond) { 1089 1087 __submit_discard_cmd(sbi, dc); 1088 + issued++; 1089 + continue; 1090 1090 } 1091 - if (issue_cond && iter++ > DISCARD_ISSUE_RATE) 1091 + 1092 + if (is_idle(sbi)) { 1093 + __submit_discard_cmd(sbi, dc); 1094 + issued++; 1095 + } else { 1096 + io_interrupted = true; 1097 + } 1098 + 1099 + if (++iter >= DISCARD_ISSUE_RATE) 1092 1100 goto out; 1093 1101 } 1094 1102 if (list_empty(pend_list) && dcc->pend_list_tag[i] & P_TRIM) ··· 1106 1096 out: 1107 1097 blk_finish_plug(&plug); 1108 1098 mutex_unlock(&dcc->cmd_lock); 1099 + 1100 + if (!issued && io_interrupted) 1101 + issued = -1; 1109 1102 1110 1103 return issued; 1111 1104 }