f2fs: show # of APPEND and UPDATE inodes
Subsystems (3)
Jaegeuk Kim
maintainerPATCH 1/5 f2fs: show # of APPEND and UPDATE inodes
This patch shows cached # of APPEND and UPDATE inode entries.
--- fs/f2fs/debug.c | 6 ++++-- fs/f2fs/f2fs.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-)
fs/f2fs/debug.c +4 -2
@@ -70,6 +70,8 @@ static void update_general_status(struct f2fs_sb_info *sbi) si->inline_xattr =atomic_read (&sbi->inline_xattr); si->inline_inode =atomic_read (&sbi->inline_inode); si->inline_dir =atomic_read (&sbi->inline_dir); + si->append = sbi->im[APPEND_INO ].ino_num; + si->update = sbi->im[UPDATE_INO ].ino_num; si->orphans = sbi->im[ORPHAN_INO ].ino_num; si->utilization =utilization (sbi);
@@ -264,8 +266,8 @@ static int stat_show(struct seq_file *s, void *v) si->inline_inode);seq_printf (s," - Inline_dentry Inode: %u\n" , si->inline_dir); -seq_printf (s," - Orphan Inode: %u\n" , - si->orphans); +seq_printf (s," - Orphan/Append/Update Inode: %u, %u, %u\n" , + si->orphans, si->append, si->update);seq_printf (s,"\nMain area: %d segs, %d secs %d zones\n" , si->main_area_segs, si->main_area_sections, si->main_area_zones);
fs/f2fs/f2fs.h +1 -1
@@ -2293,7 +2293,7 @@ struct f2fs_stat_info {int nats, dirty_nats, sits, dirty_sits, free_nids, alloc_nids;int total_count, utilization;int bg_gc, nr_wb_cp_data, nr_wb_data, nr_flush, nr_discard; -int inline_xattr, inline_inode, inline_dir, orphans; +int inline_xattr, inline_inode, inline_dir, append, update, orphans;int aw_cnt, max_aw_cnt;unsigned int valid_count, valid_node_count, valid_inode_count, discard_blks;unsigned int bimodal, avg_vblocks;
Signature · 1 line
2.11.0
Jaegeuk Kim
maintainerPATCH 2/5 f2fs: check last page index in cached bio to decide submission
If the cached bio has the last page's index, then we need to submit it. Otherwise, we don't need to submit it and can wait for further IO merges.
--- fs/f2fs/checkpoint.c | 3 ++- fs/f2fs/data.c | 39 +++++++++++++++++++++------------------ fs/f2fs/f2fs.h | 4 ++-- fs/f2fs/node.c | 9 ++++++--- fs/f2fs/segment.c | 8 ++++++-- 5 files changed, 37 insertions(+), 26 deletions(-)
fs/f2fs/checkpoint.c +2 -1
@@ -249,7 +249,8 @@ static int f2fs_write_meta_page(struct page *page,dec_page_count (sbi,F2FS_DIRTY_META );if (wbc->for_reclaim) -f2fs_submit_merged_bio_cond (sbi,NULL , page,0 ,META ,WRITE ); +f2fs_submit_merged_bio_cond (sbi, page->mapping->host, +0 , page->index,META ,WRITE );unlock_page (page);
fs/f2fs/data.c +21 -18
@@ -243,8 +243,8 @@ static void __submit_merged_bio(struct f2fs_bio_info *io) io->bio =NULL ; } -static bool __has_merged_page (struct f2fs_bio_info *io,struct inode *inode, -struct page *page,nid_t ino) +static bool __has_merged_page (struct f2fs_bio_info *io, +struct inode *inode,nid_t ino,pgoff_t idx) {struct bio_vec *bvec;struct page *target;
@@ -253,7 +253,7 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode,if (!io->bio)return false; -if (!inode && !page && !ino) +if (!inode && !ino)return true;bio_for_each_segment_all (bvec, io->bio, i) {
@@ -263,10 +263,11 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode,else target =fscrypt_control_page (bvec->bv_page); +if (idx != target->index) +continue ; +if (inode && inode == target->mapping->host)return true; -if (page && page == target) -return true;if (ino && ino ==ino_of_node (target))return true; }
@@ -275,22 +276,21 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode, }static bool has_merged_page (struct f2fs_sb_info *sbi,struct inode *inode, -struct page *page,nid_t ino, -enum page_type type) +nid_t ino,pgoff_t idx,enum page_type type) {enum page_type btype =PAGE_TYPE_OF_BIO (type);struct f2fs_bio_info *io = &sbi->write_io[btype];bool ret;down_read (&io->io_rwsem); - ret =__has_merged_page (io, inode, page, ino); + ret =__has_merged_page (io, inode, ino, idx);up_read (&io->io_rwsem);return ret; }static void __f2fs_submit_merged_bio (struct f2fs_sb_info *sbi, -struct inode *inode,struct page *page, -nid_t ino,enum page_type type,int rw) +struct inode *inode,nid_t ino,pgoff_t idx, +enum page_type type,int rw) {enum page_type btype =PAGE_TYPE_OF_BIO (type);struct f2fs_bio_info *io;
@@ -299,7 +299,7 @@ static void __f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,down_write (&io->io_rwsem); -if (!__has_merged_page (io, inode, page, ino)) +if (!__has_merged_page (io, inode, ino, idx)) goto out;/* change META to META_FLUSH in the checkpoint procedure */
@@ -318,15 +318,15 @@ static void __f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,void f2fs_submit_merged_bio (struct f2fs_sb_info *sbi,enum page_type type,int rw) { -__f2fs_submit_merged_bio (sbi,NULL ,NULL ,0 , type, rw); +__f2fs_submit_merged_bio (sbi,NULL ,0 ,0 , type, rw); }void f2fs_submit_merged_bio_cond (struct f2fs_sb_info *sbi, -struct inode *inode,struct page *page, -nid_t ino,enum page_type type,int rw) +struct inode *inode,nid_t ino,pgoff_t idx, +enum page_type type,int rw) { -if (has_merged_page (sbi, inode, page, ino, type)) -__f2fs_submit_merged_bio (sbi, inode, page, ino, type, rw); +if (has_merged_page (sbi, inode, ino, idx, type)) +__f2fs_submit_merged_bio (sbi, inode, ino, idx, type, rw); }void f2fs_flush_merged_bios (struct f2fs_sb_info *sbi)
@@ -1428,7 +1428,8 @@ static int f2fs_write_data_page(struct page *page,ClearPageUptodate (page);if (wbc->for_reclaim) { -f2fs_submit_merged_bio_cond (sbi,NULL , page,0 ,DATA ,WRITE ); +f2fs_submit_merged_bio_cond (sbi, inode,0 , page->index, +DATA ,WRITE );remove_dirty_inode (inode); }
@@ -1464,6 +1465,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,pgoff_t index;pgoff_t end;/* Inclusive */ pgoff_t done_index; +pgoff_t last_idx =0 ;int cycled;int range_whole =0 ;int tag;
@@ -1553,6 +1555,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,break ; }else { nwritten++; + last_idx = page->index; } if (--wbc->nr_to_write <= 0 &&
@@ -1576,7 +1579,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,if (nwritten)f2fs_submit_merged_bio_cond (F2FS_M_SB (mapping), mapping->host, -NULL ,0 ,DATA ,WRITE ); +0 , last_idx,DATA ,WRITE );return ret; }
fs/f2fs/f2fs.h +2 -2
@@ -2224,8 +2224,8 @@ void destroy_checkpoint_caches(void);void f2fs_submit_merged_bio (struct f2fs_sb_info *sbi,enum page_type type,int rw);void f2fs_submit_merged_bio_cond (struct f2fs_sb_info *sbi, -struct inode *inode,struct page *page, -nid_t ino,enum page_type type,int rw); +struct inode *inode,nid_t ino,pgoff_t idx, +enum page_type type,int rw);void f2fs_flush_merged_bios (struct f2fs_sb_info *sbi);int f2fs_submit_page_bio (struct f2fs_io_info *fio);int f2fs_submit_page_mbio (struct f2fs_io_info *fio);
fs/f2fs/node.c +6 -3
@@ -1321,7 +1321,7 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)int fsync_node_pages (struct f2fs_sb_info *sbi,struct inode *inode,struct writeback_control *wbc,bool atomic) { -pgoff_t index, end; +pgoff_t index, end, last_idx;struct pagevec pvec;int ret =0 ;struct page *last_page =NULL ;
@@ -1404,6 +1404,7 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,break ; }else { nwritten++; + last_idx = page->index; }if (page == last_page) {
@@ -1430,7 +1431,8 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, } out:if (nwritten) -f2fs_submit_merged_bio_cond (sbi,NULL ,NULL , ino,NODE ,WRITE ); +f2fs_submit_merged_bio_cond (sbi,NULL , ino, last_idx, +NODE ,WRITE );return ret ? -EIO :0 ; }
@@ -1629,7 +1631,8 @@ static int f2fs_write_node_page(struct page *page,up_read (&sbi->node_write);if (wbc->for_reclaim) -f2fs_submit_merged_bio_cond (sbi,NULL , page,0 ,NODE ,WRITE ); +f2fs_submit_merged_bio_cond (sbi, page->mapping->host,0 , + page->index,NODE ,WRITE );unlock_page (page);
fs/f2fs/segment.c +6 -2
@@ -264,6 +264,7 @@ static int __commit_inmem_pages(struct inode *inode, .encrypted_page = NULL, };bool submit_bio = false; +pgoff_t last_idx;int err =0 ;list_for_each_entry_safe (cur, tmp, &fi->inmem_pages, list) {
@@ -291,13 +292,15 @@ static int __commit_inmem_pages(struct inode *inode, cur->old_addr = fio.old_blkaddr; submit_bio = true; + last_idx = page->index; }unlock_page (page);list_move_tail (&cur->list, revoke_list); }if (submit_bio) -f2fs_submit_merged_bio_cond (sbi, inode,NULL ,0 ,DATA ,WRITE ); +f2fs_submit_merged_bio_cond (sbi, inode,0 , last_idx, +DATA ,WRITE );if (!err)__revoke_inmem_pages (inode, revoke_list, false, false);
@@ -1917,7 +1920,8 @@ void f2fs_wait_on_page_writeback(struct page *page,if (PageWriteback (page)) {struct f2fs_sb_info *sbi =F2FS_P_SB (page); -f2fs_submit_merged_bio_cond (sbi,NULL , page,0 , type,WRITE ); +f2fs_submit_merged_bio_cond (sbi, page->mapping->host, +0 , page->index, type,WRITE );if (ordered)wait_on_page_writeback (page);else
Signature · 1 line
2.11.0
Re: [f2fs-dev] [PATCH 2/5] f2fs: check last page index in cached bio to decide submission
Quoted 4 lines · Jaegeuk Kim
If the cached bio has the last page's index, then we need to submit it. Otherwise, we don't need to submit it and can wait for further IO merges.
Signed-off-by Jaegeuk Kim <[email protected]>
Jaegeuk Kim
maintainerPATCH 3/5 f2fs: move flush tracepoint
In reply to Jaegeuk KimThis patch moves the tracepoint location for flush command.
--- fs/f2fs/segment.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/segment.c +3 -3
@@ -429,6 +429,9 @@ static int submit_flush_wait(struct f2fs_sb_info *sbi)int ret =__submit_flush_wait (sbi->sb->s_bdev);int i; +trace_f2fs_issue_flush (sbi->sb,test_opt (sbi,NOBARRIER ), +test_opt (sbi,FLUSH_MERGE )); +if (sbi->s_ndevs && !ret) {for (i =1 ; i < sbi->s_ndevs; i++) { ret =__submit_flush_wait (FDEV (i).bdev);
@@ -474,9 +477,6 @@ int f2fs_issue_flush(struct f2fs_sb_info *sbi)struct flush_cmd_control *fcc =SM_I (sbi)->fcc_info;struct flush_cmd cmd; -trace_f2fs_issue_flush (sbi->sb,test_opt (sbi,NOBARRIER ), -test_opt (sbi,FLUSH_MERGE )); -if (test_opt (sbi,NOBARRIER ))return 0 ;
Signature · 1 line
2.11.0
Re: [f2fs-dev] [PATCH 3/5] f2fs: move flush tracepoint
Quoted 3 lines · Jaegeuk Kim
This patch moves the tracepoint location for flush command.
Signed-off-by Jaegeuk Kim <[email protected]>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Jaegeuk Kim
maintainerPATCH 4/5 f2fs: move write_node_page above fsync_node_pages
In reply to Jaegeuk KimThis patch just moves write_node_page and introduces an inner function.
--- fs/f2fs/node.c | 142 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 74 insertions(+), 68 deletions(-)
fs/f2fs/node.c +74 -68
@@ -1318,6 +1318,79 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)return last_page; } +static int __write_node_page (struct page *page, +struct writeback_control *wbc) +{ +struct f2fs_sb_info *sbi =F2FS_P_SB (page); +nid_t nid; +struct node_info ni; +struct f2fs_io_info fio = { + .sbi = sbi, + .type =NODE , + .op =REQ_OP_WRITE , + .op_flags =wbc_to_write_flags (wbc), + .page = page, + .encrypted_page =NULL , + }; + +trace_f2fs_writepage (page,NODE ); + +if (unlikely (is_sbi_flag_set (sbi,SBI_POR_DOING ))) + goto redirty_out; +if (unlikely (f2fs_cp_error (sbi))) + goto redirty_out; + +/* get old block addr of this node page */ + nid =nid_of_node (page); +f2fs_bug_on (sbi, page->index != nid); + +if (wbc->for_reclaim) { +if (!down_read_trylock (&sbi->node_write)) + goto redirty_out; + }else { +down_read (&sbi->node_write); + } + +get_node_info (sbi, nid, &ni); + +/* This page is already truncated */ +if (unlikely (ni.blk_addr ==NULL_ADDR )) { +ClearPageUptodate (page); +dec_page_count (sbi,F2FS_DIRTY_NODES ); +up_read (&sbi->node_write); +unlock_page (page); +return 0 ; + } + +set_page_writeback (page); + fio.old_blkaddr = ni.blk_addr; +write_node_page (nid, &fio); +set_node_addr (sbi, &ni, fio.new_blkaddr,is_fsync_dnode (page)); +dec_page_count (sbi,F2FS_DIRTY_NODES ); +up_read (&sbi->node_write); + +if (wbc->for_reclaim) +f2fs_submit_merged_bio_cond (sbi, page->mapping->host,0 , + page->index,NODE ,WRITE ); + +unlock_page (page); + +if (unlikely (f2fs_cp_error (sbi))) +f2fs_submit_merged_bio (sbi,NODE ,WRITE ); + +return 0 ; + +redirty_out: +redirty_page_for_writepage (wbc, page); +return AOP_WRITEPAGE_ACTIVATE ; +} + +static int f2fs_write_node_page (struct page *page, +struct writeback_control *wbc) +{ +return __write_node_page (page, wbc); +} +int fsync_node_pages (struct f2fs_sb_info *sbi,struct inode *inode,struct writeback_control *wbc,bool atomic) {
@@ -1397,7 +1470,7 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,if (!clear_page_dirty_for_io (page)) goto continue_unlock; - ret =NODE_MAPPING (sbi)->a_ops->writepage (page, wbc); + ret =__write_node_page (page, wbc);if (ret) {unlock_page (page);f2fs_put_page (last_page,0 );
@@ -1579,73 +1652,6 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)return ret; } -static int f2fs_write_node_page (struct page *page, -struct writeback_control *wbc) -{ -struct f2fs_sb_info *sbi =F2FS_P_SB (page); -nid_t nid; -struct node_info ni; -struct f2fs_io_info fio = { - .sbi = sbi, - .type =NODE , - .op =REQ_OP_WRITE , - .op_flags =wbc_to_write_flags (wbc), - .page = page, - .encrypted_page =NULL , - }; - -trace_f2fs_writepage (page,NODE ); - -if (unlikely (is_sbi_flag_set (sbi,SBI_POR_DOING ))) - goto redirty_out; -if (unlikely (f2fs_cp_error (sbi))) - goto redirty_out; - -/* get old block addr of this node page */ - nid =nid_of_node (page); -f2fs_bug_on (sbi, page->index != nid); - -if (wbc->for_reclaim) { -if (!down_read_trylock (&sbi->node_write)) - goto redirty_out; - }else { -down_read (&sbi->node_write); - } - -get_node_info (sbi, nid, &ni); - -/* This page is already truncated */ -if (unlikely (ni.blk_addr ==NULL_ADDR )) { -ClearPageUptodate (page); -dec_page_count (sbi,F2FS_DIRTY_NODES ); -up_read (&sbi->node_write); -unlock_page (page); -return 0 ; - } - -set_page_writeback (page); - fio.old_blkaddr = ni.blk_addr; -write_node_page (nid, &fio); -set_node_addr (sbi, &ni, fio.new_blkaddr,is_fsync_dnode (page)); -dec_page_count (sbi,F2FS_DIRTY_NODES ); -up_read (&sbi->node_write); - -if (wbc->for_reclaim) -f2fs_submit_merged_bio_cond (sbi, page->mapping->host,0 , - page->index,NODE ,WRITE ); - -unlock_page (page); - -if (unlikely (f2fs_cp_error (sbi))) -f2fs_submit_merged_bio (sbi,NODE ,WRITE ); - -return 0 ; - -redirty_out: -redirty_page_for_writepage (wbc, page); -return AOP_WRITEPAGE_ACTIVATE ; -} -static int f2fs_write_node_pages (struct address_space *mapping,struct writeback_control *wbc) {
Signature · 1 line
2.11.0
Re: [f2fs-dev] [PATCH 4/5] f2fs: move write_node_page above fsync_node_pages
Quoted 3 lines · Jaegeuk Kim
This patch just moves
write_node_pageand introduces an inner function.Signed-off-by Jaegeuk Kim <[email protected]>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Jaegeuk Kim
maintainerPATCH 5/5 f2fs: avoid out-of-order execution of atomic writes
In reply to Jaegeuk KimWe need to flush data writes before flushing last node block writes by using FUA with PREFLUSH. We don't need to guarantee precedent node writes since if those are not written, we can't reach to the last node block when scanning node block chain during roll-forward recovery.
Afterwards f2fs_wait_on_page_writeback guarantees all the IO submission to disk, which builds a valid node block chain.
--- fs/f2fs/file.c | 3 ++- fs/f2fs/node.c | 10 +++++++--- include/trace/events/f2fs.h | 1 + 3 files changed, 10 insertions(+), 4 deletions(-)
fs/f2fs/file.c +2 -1
@@ -278,7 +278,8 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, flush_out:remove_ino_entry (sbi, ino,UPDATE_INO );clear_inode_flag (inode,FI_UPDATE_WRITE ); - ret =f2fs_issue_flush (sbi); +if (!atomic) + ret =f2fs_issue_flush (sbi);f2fs_update_time (sbi,REQ_TIME ); out:trace_f2fs_sync_file_exit (inode, need_cp, datasync, ret);
fs/f2fs/node.c +7 -3
@@ -1318,7 +1318,7 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)return last_page; } -static int __write_node_page (struct page *page, +static int __write_node_page (struct page *page,bool atomic,struct writeback_control *wbc) {struct f2fs_sb_info *sbi =F2FS_P_SB (page);
@@ -1362,6 +1362,9 @@ static int __write_node_page(struct page *page,return 0 ; } +if (atomic) + fio.op_flags |=REQ_PREFLUSH |REQ_FUA ; +set_page_writeback (page); fio.old_blkaddr = ni.blk_addr;write_node_page (nid, &fio);
@@ -1388,7 +1391,7 @@ static int __write_node_page(struct page *page,static int f2fs_write_node_page (struct page *page,struct writeback_control *wbc) { -return __write_node_page (page, wbc); +return __write_node_page (page, false, wbc); } int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
@@ -1470,7 +1473,8 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,if (!clear_page_dirty_for_io (page)) goto continue_unlock; - ret =__write_node_page (page, wbc); + ret =__write_node_page (page, atomic && + page == last_page, wbc);if (ret) {unlock_page (page);f2fs_put_page (last_page,0 );
include/trace/events/f2fs.h +1 -0
@@ -81,6 +81,7 @@ TRACE_DEFINE_ENUM(CP_DISCARD); { REQ_SYNC | REQ_PRIO, "(SP)" }, \ { REQ_META, "(M)" }, \ { REQ_META | REQ_PRIO, "(MP)" }, \ + { REQ_SYNC | REQ_PREFLUSH , "(SF)" }, \ { REQ_SYNC | REQ_META | REQ_PRIO, "(SMP)" }, \ { REQ_PREFLUSH | REQ_META | REQ_PRIO, "(FMP)" }, \ { 0, " \b" })
Signature · 1 line
2.11.0
Re: [f2fs-dev] [PATCH 5/5] f2fs: avoid out-of-order execution of atomic writes
Quoted 8 lines · Jaegeuk Kim
We need to flush data writes before flushing last node block writes by using FUA with PREFLUSH. We don't need to guarantee precedent node writes since if those are not written, we can't reach to the last node block when scanning node block chain during roll-forward recovery.
Afterwardsf2fs_wait_on_page_writebackguarantees all the IO submission to disk, which builds a valid node block chain.Signed-off-by Jaegeuk Kim <[email protected]>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Quoted 3 lines · Jaegeuk Kim
This patch shows cached # of APPEND and UPDATE inode entries.
Signed-off-by Jaegeuk Kim <[email protected]>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot