f2fs: avoid punch_hole overhead when releasing volatile data
Subsystems (3)
Jaegeuk Kim
maintainerPATCH 1/2 f2fs: avoid punch_hole overhead when releasing volatile data
This patch is to avoid some punch_hole overhead when releasing volatile data. If volatile data was not written yet, we just can make the first page as zero.
Signed-off-by Jaegeuk Kim <[email protected]>
--- fs/f2fs/data.c | 2 ++ fs/f2fs/f2fs.h | 6 ++++++ fs/f2fs/file.c | 6 ++++++ fs/f2fs/inode.c | 10 ++++++++++ 4 files changed, 24 insertions(+)
fs/f2fs/data.c +2 -0
@@ -1291,6 +1291,8 @@ int do_write_data_page(struct page *page, struct f2fs_io_info *fio)write_data_page (page, &dn, fio);f2fs_update_extent_cache (&dn);set_inode_flag (F2FS_I (inode),FI_APPEND_WRITE ); +if (page->index ==0 ) +set_inode_flag (F2FS_I (inode),FI_FIRST_BLOCK_WRITTEN ); } out_writepage:f2fs_put_dnode (&dn);
fs/f2fs/f2fs.h +6 -0
@@ -1223,6 +1223,7 @@ enum {FI_NEED_IPU ,/* used for ipu per file */ FI_ATOMIC_FILE ,/* indicate atomic file */ FI_VOLATILE_FILE ,/* indicate volatile file */ +FI_FIRST_BLOCK_WRITTEN ,/* indicate #0 data block was written */ FI_DROP_CACHE ,/* drop dirty page cache */ FI_DATA_EXIST, /* indicate data exists */ };
@@ -1331,6 +1332,11 @@ static inline bool f2fs_is_volatile_file(struct inode *inode)return is_inode_flag_set (F2FS_I (inode),FI_VOLATILE_FILE ); } +static inline bool f2fs_is_first_block_written (struct inode *inode) +{ +return is_inode_flag_set (F2FS_I (inode),FI_FIRST_BLOCK_WRITTEN ); +} +static inline bool f2fs_is_drop_cache (struct inode *inode) {return is_inode_flag_set (F2FS_I (inode),FI_DROP_CACHE );
fs/f2fs/file.c +6 -0
@@ -437,6 +437,9 @@ int truncate_data_blocks_range(struct dnode_of_data *dn, int count) dn->data_blkaddr =NULL_ADDR ;f2fs_update_extent_cache (dn);invalidate_blocks (sbi, blkaddr); +if (dn->ofs_in_node ==0 &&IS_INODE (dn->node_page)) +clear_inode_flag (F2FS_I (dn->inode), +FI_FIRST_BLOCK_WRITTEN ); nr_free++; }if (nr_free) {
@@ -1005,6 +1008,9 @@ static int f2fs_ioc_release_volatile_write(struct file *filp)if (!f2fs_is_volatile_file (inode))return 0 ; +if (!f2fs_is_first_block_written (inode)) +return truncate_partial_data_page (inode,0 , true); +punch_hole (inode,0 ,F2FS_BLKSIZE );return 0 ; }
fs/f2fs/inode.c +10 -0
@@ -51,6 +51,13 @@ static void __get_inode_rdev(struct inode *inode, struct f2fs_inode *ri) } } +static bool __written_first_block (struct f2fs_inode *ri) +{ +if (ri->i_addr[0 ] !=NEW_ADDR && ri->i_addr[0 ] !=NULL_ADDR ) +return true; +return false; +} +static void __set_inode_rdev (struct inode *inode,struct f2fs_inode *ri) {if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode)) {
@@ -143,6 +150,9 @@ static int do_read_inode(struct inode *inode)/* get rdev by using inline_info */ __get_inode_rdev (inode, ri); +if (__written_first_block (ri)) +set_inode_flag (F2FS_I (inode),FI_FIRST_BLOCK_WRITTEN ); +f2fs_put_page (node_page,1 );stat_inc_inline_inode (inode);
Signature · 1 line
2.1.1
Jaegeuk Kim
maintainerPATCH 2/2 f2fs: add some tracepoints to debug volatile and atomic writes
Signed-off-by Jaegeuk Kim <[email protected]>
--- fs/f2fs/data.c | 2 ++ fs/f2fs/f2fs.h | 4 ++++ fs/f2fs/segment.c | 4 ++++ include/trace/events/f2fs.h | 27 ++++++++++++++++++++++++++- 4 files changed, 36 insertions(+), 1 deletion(-)
fs/f2fs/data.c +2 -0
@@ -1287,9 +1287,11 @@ int do_write_data_page(struct page *page, struct f2fs_io_info *fio) need_inplace_update(inode))) { rewrite_data_page(page, fio); set_inode_flag(F2FS_I(inode), FI_UPDATE_WRITE); + trace_f2fs_do_write_data_page(page, IPU); } else {write_data_page (page, &dn, fio);f2fs_update_extent_cache (&dn); +trace_f2fs_do_write_data_page (page,OPU );set_inode_flag (F2FS_I (inode),FI_APPEND_WRITE );if (page->index ==0 )set_inode_flag (F2FS_I (inode),FI_FIRST_BLOCK_WRITTEN );
fs/f2fs/f2fs.h +4 -0
@@ -547,6 +547,10 @@ enum page_type {META ,NR_PAGE_TYPE ,META_FLUSH , +INMEM ,/* the below types are used by tracepoints only. */ +INMEM_DROP , +IPU , + OPU, }; struct f2fs_io_info {
fs/f2fs/segment.c +4 -0
@@ -205,6 +205,8 @@ retry:list_add_tail (&new->list, &fi->inmem_pages);inc_page_count (F2FS_I_SB (inode),F2FS_INMEM_PAGES );mutex_unlock (&fi->inmem_lock); + +trace_f2fs_register_inmem_page (page,INMEM ); }void commit_inmem_pages (struct inode *inode,bool abort)
@@ -238,11 +240,13 @@ void commit_inmem_pages(struct inode *inode, bool abort)f2fs_wait_on_page_writeback (cur->page,DATA );if (clear_page_dirty_for_io (cur->page))inode_dec_dirty_pages (inode); +trace_f2fs_commit_inmem_page (cur->page,INMEM );do_write_data_page (cur->page, &fio); submit_bio = true; }f2fs_put_page (cur->page,1 ); }else { +trace_f2fs_commit_inmem_page (cur->page,INMEM_DROP );put_page (cur->page); }radix_tree_delete (&fi->inmem_root, cur->page->index);
include/trace/events/f2fs.h +26 -1
@@ -14,7 +14,11 @@ { NODE, "NODE" }, \ { DATA, "DATA" }, \ { META, "META" }, \ - { META_FLUSH, "META_FLUSH" }) + { META_FLUSH, "META_FLUSH" }, \ + { INMEM, "INMEM" }, \ + { INMEM_DROP, "INMEM_DROP" }, \ + { IPU, "IN-PLACE" }, \ + { OPU, "OUT-OF-PLACE" }) #define F2FS_BIO_MASK(t) (t & (READA | WRITE_FLUSH_FUA)) #define F2FS_BIO_EXTRA_MASK(t) (t & (REQ_META | REQ_PRIO))
@@ -854,6 +858,13 @@ DEFINE_EVENT(f2fs__page, f2fs_writepage,TP_ARGS (page, type) ); +DEFINE_EVENT (f2fs__page, f2fs_do_write_data_page, + + TP_PROTO(struct page *page, int type), + +TP_ARGS (page, type) +); + DEFINE_EVENT(f2fs__page, f2fs_readpage, TP_PROTO(struct page *page, int type),
@@ -875,6 +886,20 @@ DEFINE_EVENT(f2fs__page, f2fs_vm_page_mkwrite,TP_ARGS (page, type) ); +DEFINE_EVENT (f2fs__page, f2fs_register_inmem_page, + + TP_PROTO(struct page *page, int type), + +TP_ARGS (page, type) +); + +DEFINE_EVENT (f2fs__page, f2fs_commit_inmem_page, + + TP_PROTO(struct page *page, int type), + +TP_ARGS (page, type) +); + TRACE_EVENT(f2fs_writepages, TP_PROTO(struct inode *inode, struct writeback_control *wbc, int type),
Signature · 9 lines
2.1.1 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/