f2fs: send discard commands in larger extent
Subsystems (3)
Jaegeuk Kim
maintainerPATCH 1/4 f2fs: send discard commands in larger extent
If there is a chance to make a huge sized discard command, we don't need to split it out, since each blkdev_issue_discard should wait one at a time.
--- fs/f2fs/segment.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-)
fs/f2fs/segment.c +27 -17
@@ -469,10 +469,33 @@ void discard_next_dnode(struct f2fs_sb_info *sbi, block_t blkaddr) } } -static void add_discard_addrs (struct f2fs_sb_info *sbi,struct cp_control *cpc) +static void __add_discard_entry (struct f2fs_sb_info *sbi, +struct cp_control *cpc,unsigned int start,unsigned int end) {struct list_head *head = &SM_I (sbi)->discard_list; -struct discard_entry *new; +struct discard_entry *new, *last; + +if (!list_empty (head)) { + last = list_last_entry(head, struct discard_entry, list); +if (START_BLOCK (sbi, cpc->trim_start) + start == + last->blkaddr + last->len) { + last->len += end - start; + goto done; + } + } + + new =f2fs_kmem_cache_alloc (discard_entry_slab,GFP_NOFS ); +INIT_LIST_HEAD (&new->list); + new->blkaddr =START_BLOCK (sbi, cpc->trim_start) + start; + new->len = end - start; +list_add_tail (&new->list, head); +done: +SM_I (sbi)->nr_discards += end - start; + cpc->trimmed += end - start; +} + +static void add_discard_addrs (struct f2fs_sb_info *sbi,struct cp_control *cpc) +{int entries =SIT_VBLOCK_MAP_SIZE /sizeof (unsigned long );int max_blocks = sbi->blocks_per_seg;struct seg_entry *se =get_seg_entry (sbi, cpc->trim_start);
@@ -501,13 +524,7 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc) }mutex_unlock (&dirty_i->seglist_lock); - new =f2fs_kmem_cache_alloc (discard_entry_slab,GFP_NOFS ); -INIT_LIST_HEAD (&new->list); - new->blkaddr =START_BLOCK (sbi, cpc->trim_start); - new->len = sbi->blocks_per_seg; -list_add_tail (&new->list, head); -SM_I (sbi)->nr_discards += sbi->blocks_per_seg; - cpc->trimmed += sbi->blocks_per_seg; +__add_discard_entry (sbi, cpc,0 , sbi->blocks_per_seg);return ; }
@@ -529,14 +546,7 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)if (end - start < cpc->trim_minlen)continue ; - new =f2fs_kmem_cache_alloc (discard_entry_slab,GFP_NOFS ); -INIT_LIST_HEAD (&new->list); - new->blkaddr =START_BLOCK (sbi, cpc->trim_start) + start; - new->len = end - start; - cpc->trimmed += end - start; - -list_add_tail (&new->list, head); -SM_I (sbi)->nr_discards += end - start; +__add_discard_entry (sbi, cpc, start, end); } }
Signature · 1 line
2.1.1
Jaegeuk Kim
maintainerPATCH 2/4 f2fs: avoid race condition in handling wait_io
__submit_merged_bio f2fs_write_end_io f2fs_write_end_io
wait_io = X wait_io = x
complete(X) complete(X) wait_io = NULLwait_for_completion()
free(X)
spin_lock(X) kernel panic
In order to avoid this, this patch removes the wait_io facility. Instead, we can use wait_on_all_pages_writeback(sbi) to wait for end_ios.
--- fs/f2fs/checkpoint.c | 3 +++ fs/f2fs/data.c | 35 +++++++---------------------------- fs/f2fs/f2fs.h | 1 - 3 files changed, 10 insertions(+), 29 deletions(-)
fs/f2fs/checkpoint.c +3 -0
@@ -978,6 +978,9 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)/* Here, we only have one bio having CP pack */ sync_meta_pages (sbi,META_FLUSH ,LONG_MAX ); +/* wait for previous submitted meta pages writeback */ +wait_on_all_pages_writeback (sbi); +release_dirty_inode (sbi);if (unlikely (f2fs_cp_error (sbi)))
fs/f2fs/data.c +7 -28
@@ -61,11 +61,6 @@ static void f2fs_write_end_io(struct bio *bio, int err)dec_page_count (sbi,F2FS_WRITEBACK ); } -if (sbi->wait_io) { -complete (sbi->wait_io); - sbi->wait_io =NULL ; - } -if (!get_pages (sbi,F2FS_WRITEBACK ) && !list_empty (&sbi->cp_wait.task_list))wake_up (&sbi->cp_wait);
@@ -95,34 +90,18 @@ static struct bio *__bio_alloc(struct f2fs_sb_info *sbi, block_t blk_addr,static void __submit_merged_bio (struct f2fs_bio_info *io) {struct f2fs_io_info *fio = &io->fio; -int rw;if (!io->bio)return ; - rw = fio->rw; - -if (is_read_io (rw)) { -trace_f2fs_submit_read_bio (io->sbi->sb, rw, - fio->type, io->bio); -submit_bio (rw, io->bio); - }else { -trace_f2fs_submit_write_bio (io->sbi->sb, rw, - fio->type, io->bio); -/* -* META_FLUSH is only from the checkpoint procedure, and we -* should wait this metadata bio for FS consistency. -*/ -if (fio->type ==META_FLUSH ) { -DECLARE_COMPLETION_ONSTACK (wait); - io->sbi->wait_io = &wait; -submit_bio (rw, io->bio); -wait_for_completion (&wait); - }else { -submit_bio (rw, io->bio); - } - } +if (is_read_io (fio->rw)) +trace_f2fs_submit_read_bio (io->sbi->sb, fio->rw, + fio->type, io->bio); +else +trace_f2fs_submit_write_bio (io->sbi->sb, fio->rw, + fio->type, io->bio); +submit_bio (fio->rw, io->bio); io->bio =NULL ; }
fs/f2fs/f2fs.h +0 -1
@@ -516,7 +516,6 @@ struct f2fs_sb_info {/* for bio operations */ struct f2fs_bio_info read_io;/* for read bios */ struct f2fs_bio_info write_io[NR_PAGE_TYPE ];/* for write bios */ -struct completion *wait_io;/* for completion bios */ /* for checkpoint */ struct f2fs_checkpoint *ckpt;/* raw checkpoint pointer */
Signature · 4 lines
2.1.1 ------------------------------------------------------------------------------
Jaegeuk Kim
maintainerPATCH 3/4 f2fs: remove unnecessary macro
In reply to Jaegeuk KimLet's remove unused macro.
--- include/linux/f2fs_fs.h | 4 ---- 1 file changed, 4 deletions(-)
include/linux/f2fs_fs.h +0 -4
@@ -177,10 +177,6 @@ struct f2fs_extent {#define MAX_INLINE_DATA (sizeof(__le32) * (DEF_ADDRS_PER_INODE - \ F2FS_INLINE_XATTR_ADDRS - 1)) -#define INLINE_DATA_OFFSET (PAGE_CACHE_SIZE - sizeof(struct node_footer) -\ - sizeof(__le32) * (DEF_ADDRS_PER_INODE + \ - DEF_NIDS_PER_INODE - 1)) -struct f2fs_inode {__le16 i_mode;/* file mode */ __u8 i_advise;/* file hints */
Signature · 4 lines
2.1.1 ------------------------------------------------------------------------------
Jaegeuk Kim
maintainerPATCH 4/4 f2fs: introduce -o fastboot for reducing booting time only
In reply to Jaegeuk KimIf a system wants to reduce the booting time as a top priority, now we can use a mount option, -o fastboot.
With this option, f2fs conducts a little bit slow write_checkpoint, but it can avoid the node page reads during the next mount time.
--- Documentation/filesystems/f2fs.txt | 3 +++ fs/f2fs/f2fs.h | 1 + fs/f2fs/file.c | 2 ++ fs/f2fs/gc.c | 6 +++--- fs/f2fs/super.c | 13 ++++++++++--- 5 files changed, 19 insertions(+), 6 deletions(-)
Documentation/filesystems/f2fs.txt +3 -0
@@ -135,6 +135,9 @@ nobarrier This option can be used if underlying storage guarantees If this option is set, no cache_flush commands are issued but f2fs still guarantees the write ordering of all the data writes. +fastboot This option is used when a system wants to reduce mount + time as much as possible, even though normal performance + can be sacrificed. ================================================================================ DEBUGFS ENTRIES
fs/f2fs/f2fs.h +1 -0
@@ -49,6 +49,7 @@#define F2FS_MOUNT_INLINE_DENTRY 0x00000200#define F2FS_MOUNT_FLUSH_MERGE 0x00000400#define F2FS_MOUNT_NOBARRIER 0x00000800 +#define F2FS_MOUNT_FASTBOOT 0x00001000#define clear_opt (sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option)#define set_opt (sbi, option) (sbi->mount_opt.opt |= F2FS_MOUNT_##option)
fs/f2fs/file.c +2 -0
@@ -135,6 +135,8 @@ static inline bool need_do_checkpoint(struct inode *inode) need_cp = true; else if (F2FS_I(inode)->xattr_ver == cur_cp_version(F2FS_CKPT(sbi))) need_cp = true; + else if (test_opt(sbi, FASTBOOT)) + need_cp = true;return need_cp; }
fs/f2fs/gc.c +3 -3
@@ -695,9 +695,9 @@ int f2fs_gc(struct f2fs_sb_info *sbi)int gc_type =BG_GC ;int nfree =0 ;int ret =-1 ; -struct cp_control cpc = { - .reason =CP_SYNC , - }; +struct cp_control cpc; + + cpc.reason =test_opt (sbi,FASTBOOT ) ?CP_UMOUNT :CP_SYNC ;INIT_LIST_HEAD (&ilist); gc_more:
fs/f2fs/super.c +10 -3
@@ -54,6 +54,7 @@ enum { Opt_inline_dentry, Opt_flush_merge, Opt_nobarrier, + Opt_fastboot, Opt_err, };
@@ -73,6 +74,7 @@ static match_table_t f2fs_tokens = { {Opt_inline_dentry, "inline_dentry"}, {Opt_flush_merge, "flush_merge"}, {Opt_nobarrier, "nobarrier"}, + {Opt_fastboot, "fastboot"}, {Opt_err, NULL}, };
@@ -351,6 +353,9 @@ static int parse_options(struct super_block *sb, char *options)case Opt_nobarrier:set_opt (sbi,NOBARRIER );break ; +case Opt_fastboot: +set_opt (sbi,FASTBOOT ); +break ;default : f2fs_msg(sb, KERN_ERR, "Unrecognized mount option \"%s\" or missing value",
@@ -479,9 +484,9 @@ int f2fs_sync_fs(struct super_block *sb, int sync)trace_f2fs_sync_fs (sb, sync);if (sync) { -struct cp_control cpc = { - .reason =CP_SYNC , - }; +struct cp_control cpc; + + cpc.reason =test_opt (sbi,FASTBOOT ) ?CP_UMOUNT :CP_SYNC ;mutex_lock (&sbi->gc_mutex);write_checkpoint (sbi, &cpc);mutex_unlock (&sbi->gc_mutex);
@@ -574,6 +579,8 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)seq_puts (seq,",flush_merge" );if (test_opt (sbi,NOBARRIER ))seq_puts (seq,",nobarrier" ); +if (test_opt (sbi,FASTBOOT )) +seq_puts (seq,",fastboot" );seq_printf (seq,",active_logs=%u" , sbi->active_logs);return 0 ;
Signature · 4 lines
2.1.1 ------------------------------------------------------------------------------