summaryrefslogtreecommitdiff
path: root/fs/f2fs
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2017-04-25 20:21:37 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2017-05-02 21:19:44 -0700
commitbd5b07383a9057f9b6aefad6c784af95ffde8a67 (patch)
tree515d36b8f9dd74a9a9d7b48e4462e7d200f99900 /fs/f2fs
parentd618ebaf0aa83d175658aea5291e0c459d471d39 (diff)
f2fs: introduce __issue_discard_cmd
Just cleanup, no logic change. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/segment.c63
1 files changed, 30 insertions, 33 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 7ded7da5b7cb..13e073a9d859 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -971,6 +971,32 @@ static int __queue_discard_cmd(struct f2fs_sb_info *sbi,
return 0;
}
+static void __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond)
+{
+ struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
+ struct list_head *pend_list;
+ struct discard_cmd *dc, *tmp;
+ struct blk_plug plug;
+ int i, iter = 0;
+
+ mutex_lock(&dcc->cmd_lock);
+ blk_start_plug(&plug);
+ for (i = MAX_PLIST_NUM - 1; i >= 0; i--) {
+ pend_list = &dcc->pend_list[i];
+ list_for_each_entry_safe(dc, tmp, pend_list, list) {
+ f2fs_bug_on(sbi, dc->state != D_PREP);
+
+ if (!issue_cond || is_idle(sbi))
+ __submit_discard_cmd(sbi, dc);
+ if (issue_cond && iter++ > DISCARD_ISSUE_RATE)
+ goto out;
+ }
+ }
+out:
+ blk_finish_plug(&plug);
+ mutex_unlock(&dcc->cmd_lock);
+}
+
/* This should be covered by global mutex, &sit_i->sentry_lock */
void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
{
@@ -993,27 +1019,16 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi)
{
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
- struct list_head *pend_list;
struct list_head *wait_list = &(dcc->wait_list);
struct discard_cmd *dc, *tmp;
- struct blk_plug plug;
- int i;
- mutex_lock(&dcc->cmd_lock);
-
- blk_start_plug(&plug);
- for (i = 0; i < MAX_PLIST_NUM; i++) {
- pend_list = &dcc->pend_list[i];
- list_for_each_entry_safe(dc, tmp, pend_list, list)
- __submit_discard_cmd(sbi, dc);
- }
- blk_finish_plug(&plug);
+ __issue_discard_cmd(sbi, false);
+ mutex_lock(&dcc->cmd_lock);
list_for_each_entry_safe(dc, tmp, wait_list, list) {
wait_for_completion_io(&dc->wait);
__remove_discard_cmd(sbi, dc);
}
-
mutex_unlock(&dcc->cmd_lock);
}
@@ -1022,32 +1037,15 @@ static int issue_discard_thread(void *data)
struct f2fs_sb_info *sbi = data;
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
wait_queue_head_t *q = &dcc->discard_wait_queue;
- struct list_head *pend_list;
struct list_head *wait_list = &dcc->wait_list;
struct discard_cmd *dc, *tmp;
- struct blk_plug plug;
- int iter = 0, i;
repeat:
if (kthread_should_stop())
return 0;
- mutex_lock(&dcc->cmd_lock);
- blk_start_plug(&plug);
- for (i = MAX_PLIST_NUM - 1; i >= 0; i--) {
- pend_list = &dcc->pend_list[i];
- list_for_each_entry_safe(dc, tmp, pend_list, list) {
- f2fs_bug_on(sbi, dc->state != D_PREP);
-
- if (is_idle(sbi))
- __submit_discard_cmd(sbi, dc);
-
- if (iter++ > DISCARD_ISSUE_RATE)
- goto next_step;
- }
- }
-next_step:
- blk_finish_plug(&plug);
+ __issue_discard_cmd(sbi, true);
+ mutex_lock(&dcc->cmd_lock);
list_for_each_entry_safe(dc, tmp, wait_list, list) {
if (dc->state == D_DONE) {
wait_for_completion_io(&dc->wait);
@@ -1056,7 +1054,6 @@ next_step:
}
mutex_unlock(&dcc->cmd_lock);
- iter = 0;
congestion_wait(BLK_RW_SYNC, HZ/50);
wait_event_interruptible(*q, kthread_should_stop() ||