Skip to content

Commit

Permalink
f2fs: stop issuing discard immediately if there is queued IO
Browse files Browse the repository at this point in the history
For background discard policy, even if there is queued user IO, still
we will check max_requests times for next discard entry, it is unneeded,
let's just stop this round submission immediately.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
  • Loading branch information
Chao Yu authored and Jaegeuk Kim committed Aug 1, 2018
1 parent 4c6b56c commit 522d171
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ 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, iter = 0, issued = 0;
int i, issued = 0;
bool io_interrupted = false;

for (i = MAX_PLIST_NUM - 1; i >= 0; i--) {
Expand All @@ -1209,20 +1209,19 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
if (dpolicy->io_aware && i < dpolicy->io_aware_gran &&
!is_idle(sbi)) {
io_interrupted = true;
goto skip;
break;
}

__submit_discard_cmd(sbi, dpolicy, dc);
issued++;
skip:
if (++iter >= dpolicy->max_requests)

if (++issued >= dpolicy->max_requests)
break;
}
blk_finish_plug(&plug);
next:
mutex_unlock(&dcc->cmd_lock);

if (iter >= dpolicy->max_requests)
if (issued >= dpolicy->max_requests || io_interrupted)
break;
}

Expand Down

0 comments on commit 522d171

Please sign in to comment.