f2fs: support async discard
Chao Yu
maintainerPATCH 1/1 f2fs: support async discard
From: Chao Yu <[email protected]>
Like most filesystems, f2fs will issue discard command synchronously, so when user trigger fstrim through ioctl, multiple discard commands will be issued serially with sync mode, which makes poor performance.
In this patch we try to support async discard, so that all discard commands can be issued and be waited for endio in batch to improve performance.
Signed-off-by Chao Yu <[email protected]>
--- fs/f2fs/checkpoint.c | 3 ++ fs/f2fs/f2fs.h | 9 ++++++ fs/f2fs/recovery.c | 2 ++ fs/f2fs/segment.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 99 insertions(+), 2 deletions(-)
fs/f2fs/checkpoint.c +3 -0
@@ -1205,6 +1205,7 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)f2fs_bug_on (sbi,prefree_segments (sbi));flush_sit_entries (sbi, cpc);clear_prefree_segments (sbi, cpc); +f2fs_wait_all_discard_bio (sbi);unblock_operations (sbi); goto out; }
@@ -1224,6 +1225,8 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)/* unlock all the fs_lock[] in do_checkpoint() */ err =do_checkpoint (sbi, cpc); +f2fs_wait_all_discard_bio (sbi); +unblock_operations (sbi);stat_inc_cp_count (sbi->stat_info);
fs/f2fs/f2fs.h +9 -0
@@ -211,6 +211,13 @@ struct discard_entry {int len;/* # of consecutive blocks of the discard */ }; +struct bio_entry { +struct list_head list; +struct bio *bio; +struct completion event; +int error; +}; +/* for the list of fsync inodes, used only during recovery */ struct fsync_inode_entry {struct list_head list;/* list head */
@@ -665,6 +672,7 @@ struct f2fs_sm_info {/* for small discard management */ struct list_head discard_list;/* 4KB discard list */ +struct list_head wait_list;/* linked with issued discard bio */ int nr_discards;/* # of discards in the list */ int max_discards;/* max. discards to be issued */
@@ -2046,6 +2054,7 @@ void destroy_flush_cmd_control(struct f2fs_sb_info *);void invalidate_blocks (struct f2fs_sb_info *,block_t );bool is_checkpointed_data (struct f2fs_sb_info *,block_t );void refresh_sit_entry (struct f2fs_sb_info *,block_t ,block_t ); +void f2fs_wait_all_discard_bio (struct f2fs_sb_info *);void clear_prefree_segments (struct f2fs_sb_info *,struct cp_control *);void release_discard_addrs (struct f2fs_sb_info *);bool discard_next_dnode (struct f2fs_sb_info *,block_t );
fs/f2fs/recovery.c +2 -0
@@ -636,6 +636,8 @@ out: invalidate = true; } +f2fs_wait_all_discard_bio (sbi); +/* Flush all the NAT/SIT pages */ while (get_pages (sbi,F2FS_DIRTY_META ))sync_meta_pages (sbi,META ,LONG_MAX );
fs/f2fs/segment.c +85 -2
149 lines not on this page · raw message
Signature · 4 lines
2.7.2 ------------------------------------------------------------------------------