summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/f2fs/segment.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 7fd742f747ce..dedf0209d820 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1062,6 +1062,7 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond)
struct blk_plug plug;
int iter = 0, issued = 0;
int i;
+ bool io_interrupted = false;
mutex_lock(&dcc->cmd_lock);
f2fs_bug_on(sbi,
@@ -1083,11 +1084,20 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond)
continue;
}
- if (!issue_cond || is_idle(sbi)) {
+ if (!issue_cond) {
+ __submit_discard_cmd(sbi, dc);
issued++;
+ continue;
+ }
+
+ if (is_idle(sbi)) {
__submit_discard_cmd(sbi, dc);
+ issued++;
+ } else {
+ io_interrupted = true;
}
- if (issue_cond && iter++ > DISCARD_ISSUE_RATE)
+
+ if (++iter >= DISCARD_ISSUE_RATE)
goto out;
}
if (list_empty(pend_list) && dcc->pend_list_tag[i] & P_TRIM)
@@ -1097,6 +1107,9 @@ out:
blk_finish_plug(&plug);
mutex_unlock(&dcc->cmd_lock);
+ if (!issued && io_interrupted)
+ issued = -1;
+
return issued;
}