Commit 63a94fa1 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: introduce __wait_discard_cmd

Just cleanup, no logic change.
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent bd5b0738
...@@ -997,6 +997,22 @@ static void __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond) ...@@ -997,6 +997,22 @@ static void __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond)
mutex_unlock(&dcc->cmd_lock); mutex_unlock(&dcc->cmd_lock);
} }
static void __wait_discard_cmd(struct f2fs_sb_info *sbi, bool wait_cond)
{
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
struct list_head *wait_list = &(dcc->wait_list);
struct discard_cmd *dc, *tmp;
mutex_lock(&dcc->cmd_lock);
list_for_each_entry_safe(dc, tmp, wait_list, list) {
if (!wait_cond || dc->state == D_DONE) {
wait_for_completion_io(&dc->wait);
__remove_discard_cmd(sbi, dc);
}
}
mutex_unlock(&dcc->cmd_lock);
}
/* This should be covered by global mutex, &sit_i->sentry_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) void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
{ {
...@@ -1018,18 +1034,8 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr) ...@@ -1018,18 +1034,8 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
/* This comes from f2fs_put_super */ /* This comes from f2fs_put_super */
void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi) void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi)
{ {
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
struct list_head *wait_list = &(dcc->wait_list);
struct discard_cmd *dc, *tmp;
__issue_discard_cmd(sbi, false); __issue_discard_cmd(sbi, false);
__wait_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);
} }
static int issue_discard_thread(void *data) static int issue_discard_thread(void *data)
...@@ -1037,22 +1043,12 @@ static int issue_discard_thread(void *data) ...@@ -1037,22 +1043,12 @@ static int issue_discard_thread(void *data)
struct f2fs_sb_info *sbi = data; struct f2fs_sb_info *sbi = data;
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
wait_queue_head_t *q = &dcc->discard_wait_queue; wait_queue_head_t *q = &dcc->discard_wait_queue;
struct list_head *wait_list = &dcc->wait_list;
struct discard_cmd *dc, *tmp;
repeat: repeat:
if (kthread_should_stop()) if (kthread_should_stop())
return 0; return 0;
__issue_discard_cmd(sbi, true); __issue_discard_cmd(sbi, true);
__wait_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);
__remove_discard_cmd(sbi, dc);
}
}
mutex_unlock(&dcc->cmd_lock);
congestion_wait(BLK_RW_SYNC, HZ/50); congestion_wait(BLK_RW_SYNC, HZ/50);
......
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