f2fs: remove checking dirty_exceed
Subsystems (2)
Jaegeuk Kim
maintainerPATCH 1/7 f2fs: remove checking dirty_exceed
We don't need to force to write dirty_exceeded for f2fs_balance_fs_bg. This flag was only meaningful to write bypassing conditions.
--- fs/f2fs/node.c | 2 -- 1 file changed, 2 deletions(-)
fs/f2fs/node.c +0 -2
@@ -57,8 +57,6 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type) }else if (type ==INO_ENTRIES ) {int i; -if (sbi->sb->s_bdi->dirty_exceeded) -return false;for (i =0 ; i <=UPDATE_INO ; i++) mem_size += (sbi->im[i].ino_num *sizeof (struct ino_entry )) >>PAGE_CACHE_SHIFT ;
Signature · 1 line
2.1.1
Jaegeuk Kim
maintainerPATCH 2/7 f2fs: fix wrong condition check to trigger f2fs_sync_fs
If there is not enough available memory, we need to trigger f2fs_sync_fs.
--- fs/f2fs/segment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +1 -1
@@ -290,7 +290,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)/* check the # of cached NAT entries and prefree segments */ if (try_to_free_nats (sbi,NAT_ENTRY_PER_BLOCK ) ||excess_prefree_segs (sbi) || -available_free_memory (sbi,INO_ENTRIES )) + !available_free_memory (sbi,INO_ENTRIES ))f2fs_sync_fs (sbi->sb, true); }
Signature · 9 lines
2.1.1 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
Jaegeuk Kim
maintainerPATCH 3/7 f2fs: don't need to call lock_op and lock_page for abort
In reply to Jaegeuk KimWe don't need to call lock_op and lock_page at the aborting path.
--- fs/f2fs/segment.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-)
fs/f2fs/segment.c +20 -15
@@ -240,33 +240,38 @@ void commit_inmem_pages(struct inode *inode, bool abort)* Otherwise, f2fs_gc in f2fs_balance_fs can wait forever until this * inode becomes free by iget_locked in f2fs_iget. */ -if (!abort) +if (!abort) {f2fs_balance_fs (sbi); - -f2fs_lock_op (sbi); +f2fs_lock_op (sbi); + }mutex_lock (&fi->inmem_lock);list_for_each_entry_safe (cur, tmp, &fi->inmem_pages, list) { -lock_page (cur->page); -if (!abort && cur->page->mapping == inode->i_mapping) { -f2fs_wait_on_page_writeback (cur->page,DATA ); -if (clear_page_dirty_for_io (cur->page)) -inode_dec_dirty_pages (inode); -do_write_data_page (cur->page, &fio); - submit_bio = true; +if (!abort) { +lock_page (cur->page); +if (cur->page->mapping == inode->i_mapping) { +f2fs_wait_on_page_writeback (cur->page,DATA ); +if (clear_page_dirty_for_io (cur->page)) +inode_dec_dirty_pages (inode); +do_write_data_page (cur->page, &fio); + submit_bio = true; + } +f2fs_put_page (cur->page,1 ); + }else { +put_page (cur->page); }radix_tree_delete (&fi->inmem_root, cur->page->index); -f2fs_put_page (cur->page,1 );list_del (&cur->list);kmem_cache_free (inmem_entry_slab, cur);dec_page_count (F2FS_I_SB (inode),F2FS_INMEM_PAGES ); } -if (submit_bio) -f2fs_submit_merged_bio (sbi,DATA ,WRITE );mutex_unlock (&fi->inmem_lock); -filemap_fdatawait_range (inode->i_mapping,0 ,LLONG_MAX ); -f2fs_unlock_op (sbi); +if (!abort) { +f2fs_unlock_op (sbi); +if (submit_bio) +f2fs_submit_merged_bio (sbi,DATA ,WRITE ); + } }/*
Signature · 9 lines
2.1.1 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
Jaegeuk Kim
maintainerPATCH 4/7 f2fs: change atomic and volatile write policies
In reply to Jaegeuk KimThis patch adds two new ioctls to release inmemory pages grabbed by atomic writes.
o f2fs_ioc_abort_volatile_write
- If transaction was failed, all the grabbed pages and data should be written.
o f2fs_ioc_release_volatile_write
- This is to enhance the performance of PERSIST mode in sqlite.
In order to avoid huge memory consumption which causes OOM, this patch changes volatile writes to use normal dirty pages, instead blocked flushing to the disk as long as system does not suffer from memory pressure.
--- fs/f2fs/data.c | 9 +++++-- fs/f2fs/f2fs.h | 8 ++++++ fs/f2fs/file.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++-------- fs/f2fs/inode.c | 2 +- fs/f2fs/node.c | 3 +++ fs/f2fs/node.h | 1 + fs/f2fs/segment.c | 2 +- 7 files changed, 88 insertions(+), 14 deletions(-)
fs/f2fs/data.c +7 -2
@@ -814,6 +814,11 @@ static int f2fs_write_data_page(struct page *page, write:if (unlikely (sbi->por_doing)) goto redirty_out; +if (f2fs_is_drop_cache (inode)) + goto out; +if (f2fs_is_volatile_file (inode) && !wbc->for_reclaim && +available_free_memory (sbi,BASE_CHECK )) + goto redirty_out;/* Dentry blocks are controlled by checkpoint */ if (S_ISDIR (inode->i_mode)) {
@@ -1109,7 +1114,7 @@ static void f2fs_invalidate_data_page(struct page *page, unsigned int offset,if (offset %PAGE_CACHE_SIZE || length !=PAGE_CACHE_SIZE )return ; -if (f2fs_is_atomic_file (inode) ||f2fs_is_volatile_file (inode)) +if (f2fs_is_atomic_file (inode))invalidate_inmem_page (inode, page);if (PageDirty (page))
@@ -1132,7 +1137,7 @@ static int f2fs_set_data_page_dirty(struct page *page)SetPageUptodate (page); -if (f2fs_is_atomic_file (inode) ||f2fs_is_volatile_file (inode)) { +if (f2fs_is_atomic_file (inode)) {register_inmem_page (inode, page);return 1 ; }
fs/f2fs/f2fs.h +8 -0
@@ -201,6 +201,8 @@ static inline bool __has_cursum_space(struct f2fs_summary_block *sum, int size,#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3) +#define F2FS_IOC_RELEASE_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 4) +#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)#if defined(__KERNEL__) && defined(CONFIG_COMPAT )/*
@@ -1113,6 +1115,7 @@ enum {FI_NEED_IPU ,/* used for ipu per file */ FI_ATOMIC_FILE ,/* indicate atomic file */ FI_VOLATILE_FILE ,/* indicate volatile file */ +FI_DROP_CACHE ,/* drop dirty page cache */ FI_DATA_EXIST, /* indicate data exists */ };
@@ -1220,6 +1223,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_drop_cache (struct inode *inode) +{ +return is_inode_flag_set (F2FS_I (inode),FI_DROP_CACHE ); +} +static inline void *inline_data_addr (struct page *page) {struct f2fs_inode *ri =F2FS_INODE (page);
fs/f2fs/file.c +67 -10
122 lines not on this page · raw message
fs/f2fs/inode.c +1 -1
@@ -304,7 +304,7 @@ void f2fs_evict_inode(struct inode *inode)nid_t xnid =F2FS_I (inode)->i_xattr_nid;/* some remained atomic pages should discarded */ -if (f2fs_is_atomic_file (inode) ||f2fs_is_volatile_file (inode)) +if (f2fs_is_atomic_file (inode))commit_inmem_pages (inode, true);trace_f2fs_evict_inode (inode);
fs/f2fs/node.c +3 -0
@@ -61,6 +61,9 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type) mem_size += (sbi->im[i].ino_num *sizeof (struct ino_entry )) >>PAGE_CACHE_SHIFT ; res = mem_size < ((avail_ram * nm_i->ram_thresh /100 ) >>1 ); + }else { +if (sbi->sb->s_bdi->dirty_exceeded) +return false; }return res; }
fs/f2fs/node.h +1 -0
@@ -108,6 +108,7 @@ enum mem_type {NAT_ENTRIES ,/* indicates the cached nat entry */ DIRTY_DENTS ,/* indicates dirty dentry pages */ INO_ENTRIES ,/* indicates inode entries */ + BASE_CHECK, /* check kernel status */ }; struct nat_entry_set {
fs/f2fs/segment.c +1 -1
@@ -230,7 +230,7 @@ void commit_inmem_pages(struct inode *inode, bool abort)bool submit_bio = false;struct f2fs_io_info fio = { .type =DATA , - .rw =WRITE_SYNC , + .rw =WRITE_SYNC |REQ_PRIO , };/*
Signature · 9 lines
2.1.1 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
Jaegeuk Kim
maintainerPATCH 5/7 f2fs: fix small discards not to issue redundantly
In reply to Jaegeuk KimThe ckpt_valid_map and cur_valid_map are synced by seg_info_to_raw_sit.
In the case of small discards, the candidates are selected before sync, while fitrim selects candidates after sync.
So, for small discards, we need to add candidates only just being obsoleted.
--- fs/f2fs/segment.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/f2fs/segment.c +5 -3
@@ -525,7 +525,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)bool force = (cpc->reason ==CP_DISCARD );int i; -if (!force && !test_opt (sbi,DISCARD )) +if (!force && (!test_opt (sbi,DISCARD ) || +SM_I (sbi)->nr_discards >=SM_I (sbi)->max_discards))return ;if (force && !se->valid_blocks) {
@@ -553,7 +554,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)/* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */ for (i =0 ; i < entries; i++) - dmap[i] = ~(cur_map[i] | ckpt_map[i]); + dmap[i] = force ? ~ckpt_map[i] : + (cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];while (force ||SM_I (sbi)->nr_discards <=SM_I (sbi)->max_discards) { start =__find_rev_next_bit (dmap, max_blocks, end +1 );
@@ -1759,7 +1761,7 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) se =get_seg_entry (sbi, segno);/* add discard candidates */ -if (SM_I (sbi)->nr_discards <SM_I (sbi)->max_discards) { +if (cpc->reason !=CP_DISCARD ) { cpc->trim_start = segno;add_discard_addrs (sbi, cpc); }
Signature · 1 line
2.1.1
Jaegeuk Kim
maintainerPATCH 6/7 f2fs: remove unnecessary call to invalidate inmemory pages
In reply to Jaegeuk KimNow we use inmemory pages for atomic write only and provide abort procedure, we don't need to truncate them explicitly.
--- fs/f2fs/data.c | 3 --- fs/f2fs/f2fs.h | 1 - fs/f2fs/segment.c | 17 ----------------- 3 files changed, 21 deletions(-)
fs/f2fs/data.c +0 -3
@@ -1114,9 +1114,6 @@ static void f2fs_invalidate_data_page(struct page *page, unsigned int offset,if (offset %PAGE_CACHE_SIZE || length !=PAGE_CACHE_SIZE )return ; -if (f2fs_is_atomic_file (inode)) -invalidate_inmem_page (inode, page); -if (PageDirty (page))inode_dec_dirty_pages (inode);ClearPagePrivate (page);
fs/f2fs/f2fs.h +0 -1
@@ -1397,7 +1397,6 @@ void destroy_node_manager_caches(void);* segment.c */ void register_inmem_page (struct inode *,struct page *); -void invalidate_inmem_page (struct inode *,struct page *);void commit_inmem_pages (struct inode *,bool );void f2fs_balance_fs (struct f2fs_sb_info *);void f2fs_balance_fs_bg (struct f2fs_sb_info *);
fs/f2fs/segment.c +0 -17
@@ -205,23 +205,6 @@ retry:mutex_unlock (&fi->inmem_lock); } -void invalidate_inmem_page (struct inode *inode,struct page *page) -{ -struct f2fs_inode_info *fi =F2FS_I (inode); -struct inmem_pages *cur; - -mutex_lock (&fi->inmem_lock); - cur =radix_tree_lookup (&fi->inmem_root, page->index); -if (cur) { -radix_tree_delete (&fi->inmem_root, cur->page->index); -f2fs_put_page (cur->page,0 ); -list_del (&cur->list); -kmem_cache_free (inmem_entry_slab, cur); -dec_page_count (F2FS_I_SB (inode),F2FS_INMEM_PAGES ); - } -mutex_unlock (&fi->inmem_lock); -} -void commit_inmem_pages (struct inode *inode,bool abort) {struct f2fs_sb_info *sbi =F2FS_I_SB (inode);
Signature · 9 lines
2.1.1 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
Jaegeuk Kim
maintainerPATCH 7/7 f2fs: use missing the use of f2fs_kunmap_page
In reply to Jaegeuk KimThis patch calls f2fs_kunmap_page which I missed before.
--- fs/f2fs/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/dir.c +1 -2
@@ -286,8 +286,7 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,f2fs_wait_on_page_writeback (page, type); de->ino =cpu_to_le32 (inode->i_ino);set_de_type (de, inode); -if (!f2fs_has_inline_dentry (dir)) -kunmap (page); +f2fs_dentry_kunmap (dir, page);set_page_dirty (page); dir->i_mtime = dir->i_ctime =CURRENT_TIME ;mark_inode_dirty (dir);
Signature · 9 lines
2.1.1 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk