Commit d431413f authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: introduce f2fs_wait_discard_bios

Split f2fs_wait_discard_bios from f2fs_wait_discard_bio, just for cleanup,
no logic change.
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 22d375dd
...@@ -2193,7 +2193,7 @@ void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free); ...@@ -2193,7 +2193,7 @@ void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free);
void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr); void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr);
bool is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr); bool is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr);
void refresh_sit_entry(struct f2fs_sb_info *sbi, block_t old, block_t new); void refresh_sit_entry(struct f2fs_sb_info *sbi, block_t old, block_t new);
void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr); void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi);
void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc); void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc);
void release_discard_addrs(struct f2fs_sb_info *sbi); void release_discard_addrs(struct f2fs_sb_info *sbi);
int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra); int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra);
......
...@@ -797,13 +797,9 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr) ...@@ -797,13 +797,9 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
struct list_head *pend_list = &(dcc->discard_pend_list); struct list_head *pend_list = &(dcc->discard_pend_list);
struct list_head *wait_list = &(dcc->discard_wait_list); struct list_head *wait_list = &(dcc->discard_wait_list);
struct discard_cmd *dc, *tmp; struct discard_cmd *dc, *tmp;
struct blk_plug plug;
mutex_lock(&dcc->cmd_lock); mutex_lock(&dcc->cmd_lock);
if (blkaddr == NULL_ADDR)
goto release_discard;
list_for_each_entry_safe(dc, tmp, pend_list, list) { list_for_each_entry_safe(dc, tmp, pend_list, list) {
if (dc->lstart <= blkaddr && blkaddr < dc->lstart + dc->len) if (dc->lstart <= blkaddr && blkaddr < dc->lstart + dc->len)
__punch_discard_cmd(sbi, dc, blkaddr); __punch_discard_cmd(sbi, dc, blkaddr);
...@@ -817,9 +813,20 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr) ...@@ -817,9 +813,20 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
} }
} }
release_discard: mutex_unlock(&dcc->cmd_lock);
/* this comes from f2fs_put_super */ }
if (blkaddr == NULL_ADDR) {
/* This comes from f2fs_put_super */
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 = &(dcc->discard_pend_list);
struct list_head *wait_list = &(dcc->discard_wait_list);
struct discard_cmd *dc, *tmp;
struct blk_plug plug;
mutex_lock(&dcc->cmd_lock);
blk_start_plug(&plug); blk_start_plug(&plug);
list_for_each_entry_safe(dc, tmp, pend_list, list) list_for_each_entry_safe(dc, tmp, pend_list, list)
__submit_discard_cmd(sbi, dc); __submit_discard_cmd(sbi, dc);
...@@ -829,7 +836,7 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr) ...@@ -829,7 +836,7 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
wait_for_completion_io(&dc->wait); wait_for_completion_io(&dc->wait);
__remove_discard_cmd(sbi, dc); __remove_discard_cmd(sbi, dc);
} }
}
mutex_unlock(&dcc->cmd_lock); mutex_unlock(&dcc->cmd_lock);
} }
......
...@@ -795,7 +795,7 @@ static void f2fs_put_super(struct super_block *sb) ...@@ -795,7 +795,7 @@ static void f2fs_put_super(struct super_block *sb)
} }
/* be sure to wait for any on-going discard commands */ /* be sure to wait for any on-going discard commands */
f2fs_wait_discard_bio(sbi, NULL_ADDR); f2fs_wait_discard_bios(sbi);
/* write_checkpoint can update stat informaion */ /* write_checkpoint can update stat informaion */
f2fs_destroy_stats(sbi); f2fs_destroy_stats(sbi);
......
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