f2fs: split discard_cmd_list
PATCH v3 1/4 f2fs: split discard_cmd_list
Split discard_cmd_list to discard_{pend,wait}_list, so while sending/waiting discard command, we can avoid traversing unneeded entries in original list.
Signed-off-by Chao Yu <[email protected]>
Signed-off-by Jaegeuk Kim <[email protected]>
---
v3: handle discard command correctly in f2fs_wait_discard_bio
fs/f2fs/f2fs.h | 3 ++- fs/f2fs/segment.c | 47 ++++++++++++++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 18 deletions(-)
fs/f2fs/f2fs.h +2 -1
@@ -210,7 +210,8 @@ struct discard_cmd_control {struct task_struct *f2fs_issue_discard;/* discard thread */ struct list_head discard_entry_list;/* 4KB discard entry list */ int nr_discards;/* # of discards in the list */ -struct list_head discard_cmd_list;/* discard cmd list */ +struct list_head discard_pend_list;/* store pending entries */ +struct list_head discard_wait_list;/* store on-flushing entries */ wait_queue_head_t discard_wait_queue;/* waiting queue for wake-up */ struct mutex cmd_lock;int max_discards;/* max. discards to be issued */
fs/f2fs/segment.c +30 -17
116 lines not on this page · raw message
Signature · 6 lines
2.12.2.510.ge1104a5ee539 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH v3 2/4 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 Chao Yu <[email protected]>
Signed-off-by Jaegeuk Kim <[email protected]>
--- fs/f2fs/f2fs.h | 2 +- fs/f2fs/segment.c | 37 ++++++++++++++++++++++--------------- fs/f2fs/super.c | 2 +- 3 files changed, 24 insertions(+), 17 deletions(-)
fs/f2fs/f2fs.h +1 -1
@@ -2187,7 +2187,7 @@ void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free);void invalidate_blocks (struct f2fs_sb_info *sbi,block_t addr);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 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 release_discard_addrs (struct f2fs_sb_info *sbi);int npages_for_summary_flush (struct f2fs_sb_info *sbi,bool for_ra);
fs/f2fs/segment.c +22 -15
@@ -786,13 +786,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 *wait_list = &(dcc->discard_wait_list);struct discard_cmd *dc, *tmp; -struct blk_plug plug;mutex_lock (&dcc->cmd_lock); -if (blkaddr ==NULL_ADDR ) - goto release_discard; -list_for_each_entry_safe (dc, tmp, pend_list, list) {if (dc->lstart <= blkaddr && blkaddr < dc->lstart + dc->len)__punch_discard_cmd (sbi, dc, blkaddr);
@@ -806,19 +802,30 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr) } } -release_discard: -/* this comes from f2fs_put_super */ -if (blkaddr ==NULL_ADDR ) { -blk_start_plug (&plug); -list_for_each_entry_safe (dc, tmp, pend_list, list) -__submit_discard_cmd (sbi, dc); -blk_finish_plug (&plug); +mutex_unlock (&dcc->cmd_lock); +} -list_for_each_entry_safe (dc, tmp, wait_list, list) { -wait_for_completion_io (&dc->wait); -__remove_discard_cmd (sbi, dc); - } +/* 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); +list_for_each_entry_safe (dc, tmp, pend_list, list) +__submit_discard_cmd (sbi, dc); +blk_finish_plug (&plug); + +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); }
fs/f2fs/super.c +1 -1
@@ -793,7 +793,7 @@ static void f2fs_put_super(struct super_block *sb) }/* 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 */ f2fs_destroy_stats (sbi);
Signature · 6 lines
2.12.2.510.ge1104a5ee539 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot