f2fs: reuse nid if it was cached only
Subsystems (2)
Jaegeuk Kim
maintainerPATCH 1/8 f2fs: reuse nid if it was cached only
If nid's block address is assigned as:
NULL_ADDR -> NEW_ADDR -> NULL_ADDR, we can reset this nid, since its node page
has never written back.
--- fs/f2fs/node.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
fs/f2fs/node.c +10 -4
@@ -317,10 +317,16 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni, }/* change address */ -nat_set_blkaddr (e, new_blkaddr); -if (new_blkaddr ==NEW_ADDR || new_blkaddr ==NULL_ADDR ) -set_nat_flag (e,IS_CHECKPOINTED , false); -__set_nat_cache_dirty (nm_i, e); +if (nat_get_blkaddr (e) ==NEW_ADDR && new_blkaddr ==NULL_ADDR ) { +nat_set_blkaddr (e, new_blkaddr); +nat_reset_flag (e); +__clear_nat_cache_dirty (nm_i, e); + }else { +nat_set_blkaddr (e, new_blkaddr); +if (new_blkaddr ==NEW_ADDR || new_blkaddr ==NULL_ADDR ) +set_nat_flag (e,IS_CHECKPOINTED , false); +__set_nat_cache_dirty (nm_i, e); + }/* update fsync_mark if its inode nat entry is still alive */ if (ni->nid != ni->ino)
Signature · 1 line
2.6.3
Jaegeuk Kim
maintainerPATCH 2/8 f2fs: remove deprecated parameter
Remove deprecated paramter.
--- fs/f2fs/dir.c | 4 ++-- fs/f2fs/f2fs.h | 2 +- fs/f2fs/inline.c | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-)
fs/f2fs/dir.c +2 -2
@@ -664,7 +664,7 @@ fail:return err; } -void f2fs_drop_nlink (struct inode *dir,struct inode *inode,struct page *page) +void f2fs_drop_nlink (struct inode *dir,struct inode *inode) {struct f2fs_sb_info *sbi =F2FS_I_SB (dir);
@@ -723,7 +723,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,mark_inode_dirty_sync (dir);if (inode) -f2fs_drop_nlink (dir, inode,NULL ); +f2fs_drop_nlink (dir, inode);if (bit_pos ==NR_DENTRY_IN_BLOCK && !truncate_hole (dir, page->index, page->index +1 )) {
fs/f2fs/f2fs.h +1 -1
@@ -1915,7 +1915,7 @@ struct page *init_inode_metadata(struct inode *, struct inode *, const struct qstr *, struct page *);void update_parent_metadata (struct inode *,struct inode *,unsigned int );int room_for_filename (const void *,int ,int ); -void f2fs_drop_nlink (struct inode *,struct inode *,struct page *); +void f2fs_drop_nlink (struct inode *,struct inode *);struct f2fs_dir_entry *f2fs_find_entry (struct inode *,struct qstr *,struct page **);struct f2fs_dir_entry *f2fs_parent_dir (struct inode *,struct page **);
fs/f2fs/inline.c +2 -3
@@ -582,14 +582,13 @@ void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page, &inline_dentry->dentry_bitmap);set_page_dirty (page); +f2fs_put_page (page,1 ); dir->i_ctime = dir->i_mtime =CURRENT_TIME ;mark_inode_dirty_sync (dir);if (inode) -f2fs_drop_nlink (dir, inode, page); - -f2fs_put_page (page,1 ); +f2fs_drop_nlink (dir, inode); }bool f2fs_empty_inline_dir (struct inode *dir)
Signature · 1 line
2.6.3
Jaegeuk Kim
maintainerPATCH 3/8 f2fs: avoid wrong count on dirty inodes
In reply to Jaegeuk KimThe number should be covered by spin_lock. Otherwise we can see wrong count in f2fs_stat.
--- fs/f2fs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/super.c +2 -2
@@ -645,8 +645,8 @@ static void f2fs_dirty_inode(struct inode *inode, int flags)list_add_tail (&F2FS_I (inode)->gdirty_list, &sbi->inode_list[DIRTY_META ]);inc_page_count (sbi,F2FS_DIRTY_IMETA ); -spin_unlock (&sbi->inode_lock[DIRTY_META ]);stat_inc_dirty_inode (sbi,DIRTY_META ); +spin_unlock (&sbi->inode_lock[DIRTY_META ]); }void f2fs_inode_synced (struct inode *inode)
@@ -662,8 +662,8 @@ void f2fs_inode_synced(struct inode *inode)clear_inode_flag (inode,FI_DIRTY_INODE );clear_inode_flag (inode,FI_AUTO_RECOVER );dec_page_count (sbi,F2FS_DIRTY_IMETA ); -spin_unlock (&sbi->inode_lock[DIRTY_META ]);stat_dec_dirty_inode (F2FS_I_SB (inode),DIRTY_META ); +spin_unlock (&sbi->inode_lock[DIRTY_META ]); }static void f2fs_i_callback (struct rcu_head *head)
Signature · 1 line
2.6.3
Jaegeuk Kim
maintainerPATCH 4/8 f2fs: skip roll_forward recovery after umount
In reply to Jaegeuk KimIf f2fs was umounted successfully, we don't need to go into roll_forward.
--- fs/f2fs/recovery.c | 3 +++ 1 file changed, 3 insertions(+)
fs/f2fs/recovery.c +3 -0
@@ -579,6 +579,9 @@ int recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)int ret =0 ;bool need_writecp = false; +if (is_set_ckpt_flags (sbi->ckpt,CP_UMOUNT_FLAG )) +return 0 ; + fsync_entry_slab =f2fs_kmem_cache_create ("f2fs_fsync_inode_entry" ,sizeof (struct fsync_inode_entry ));if (!fsync_entry_slab)
Signature · 1 line
2.6.3
Jaegeuk Kim
maintainerPATCH 5/8 f2fs: remove obsolete parameter in f2fs_truncate
In reply to Jaegeuk KimWe don't need lock parameter, which is always true.
--- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 6 +++--- fs/f2fs/inode.c | 2 +- fs/f2fs/super.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
fs/f2fs/f2fs.h +1 -1
@@ -1874,7 +1874,7 @@ static inline void *f2fs_kvzalloc(size_t size, gfp_t flags)int f2fs_sync_file (struct file *,loff_t ,loff_t ,int );void truncate_data_blocks (struct dnode_of_data *);int truncate_blocks (struct inode *,u64 ,bool ); -int f2fs_truncate (struct inode *,bool ); +int f2fs_truncate (struct inode *);int f2fs_getattr (struct vfsmount *,struct dentry *,struct kstat *);int f2fs_setattr (struct dentry *,struct iattr *);int truncate_hole (struct inode *,pgoff_t ,pgoff_t );
fs/f2fs/file.c +3 -3
@@ -647,7 +647,7 @@ free_partial:return err; } -int f2fs_truncate (struct inode *inode,bool lock) +int f2fs_truncate (struct inode *inode) {int err;
@@ -664,7 +664,7 @@ int f2fs_truncate(struct inode *inode, bool lock)return err; } - err =truncate_blocks (inode,i_size_read (inode), lock); + err =truncate_blocks (inode,i_size_read (inode), true);if (err)return err;
@@ -728,7 +728,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)if (attr->ia_size <=i_size_read (inode)) {truncate_setsize (inode, attr->ia_size); - err =f2fs_truncate (inode, true); + err =f2fs_truncate (inode);if (err)return err;f2fs_balance_fs (F2FS_I_SB (inode), true);
fs/f2fs/inode.c +1 -1
@@ -355,7 +355,7 @@ void f2fs_evict_inode(struct inode *inode)i_size_write (inode,0 ); retry:if (F2FS_HAS_BLOCKS (inode)) - err =f2fs_truncate (inode, true); + err =f2fs_truncate (inode);if (!err) {f2fs_lock_op (sbi);
fs/f2fs/super.c +1 -1
@@ -590,7 +590,7 @@ static int f2fs_drop_inode(struct inode *inode)f2fs_i_size_write (inode,0 );if (F2FS_HAS_BLOCKS (inode)) -f2fs_truncate (inode, true); +f2fs_truncate (inode);sb_end_intwrite (inode->i_sb);
Signature · 1 line
2.6.3
Jaegeuk Kim
maintainerPATCH 6/8 f2fs: avoid data race between FI_DIRTY_INODE flag and update_inode
In reply to Jaegeuk KimFI_DIRTY_INODE flag is not covered by inode page lock, so it can be unset at any time like below.
Thread #1 Thread #2
- lock_page(ipage)
- update i_fields
- update i_size/i_blocks/and so on
- set FI_DIRTY_INODE
- reset FI_DIRTY_INODE
- set_page_dirty(ipage)
In this case, we can lose the latest i_field information.
--- fs/f2fs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/inode.c +2 -1
@@ -231,6 +231,8 @@ int update_inode(struct inode *inode, struct page *node_page) {struct f2fs_inode *ri; +f2fs_inode_synced (inode); +f2fs_wait_on_page_writeback (node_page,NODE , true); ri =F2FS_INODE (node_page);
@@ -265,7 +267,6 @@ int update_inode(struct inode *inode, struct page *node_page)__set_inode_rdev (inode, ri);set_cold_node (inode, node_page); -f2fs_inode_synced (inode);/* deleted inode */ if (inode->i_nlink ==0 )
Signature · 9 lines
2.6.3 ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
Jaegeuk Kim
maintainerPATCH 7/8 f2fs: fix wrong percentage
In reply to Jaegeuk KimThis should be 1%, 10MB / 1GB.
--- fs/f2fs/node.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/node.h +1 -1
@@ -23,7 +23,7 @@#define MAX_RA_NODE 128/* control the memory footprint threshold (10MB per 1GB ram) */ -#define DEF_RAM_THRESHOLD 10 +#define DEF_RAM_THRESHOLD 1/* control dirty nats ratio threshold (default: 10% over max nid count) */ #define DEF_DIRTY_NAT_RATIO_THRESHOLD 10
Signature · 1 line
2.6.3
Jaegeuk Kim
maintainerPATCH 8/8 f2fs: control not to exceed # of cached nat entries
In reply to Jaegeuk KimThis is to avoid cache entry management overhead including radix tree.
--- fs/f2fs/node.c | 4 ++++ fs/f2fs/node.h | 7 +++++++ fs/f2fs/segment.c | 5 +++++ 3 files changed, 16 insertions(+)
fs/f2fs/node.c +4 -0
@@ -52,6 +52,10 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type) mem_size = (nm_i->nat_cnt *sizeof (struct nat_entry )) >>PAGE_SHIFT ; res = mem_size < ((avail_ram * nm_i->ram_thresh /100 ) >>2 ); +if (excess_cached_nats (sbi)) + res = false; +if (nm_i->nat_cnt >DEF_NAT_CACHE_THRESHOLD ) + res = false; }else if (type ==DIRTY_DENTS ) {if (sbi->sb->s_bdi->wb.dirty_exceeded)return false;
fs/f2fs/node.h +7 -0
@@ -27,6 +27,8 @@/* control dirty nats ratio threshold (default: 10% over max nid count) */ #define DEF_DIRTY_NAT_RATIO_THRESHOLD 10 +/* control total # of nats */ +#define DEF_NAT_CACHE_THRESHOLD 50000/* vector size for gang look-up from nat cache that consists of radix tree */ #define NATVEC_SIZE 64
@@ -126,6 +128,11 @@ static inline bool excess_dirty_nats(struct f2fs_sb_info *sbi)NM_I (sbi)->dirty_nats_ratio /100 ; } +static inline bool excess_cached_nats (struct f2fs_sb_info *sbi) +{ +return NM_I (sbi)->nat_cnt >=DEF_NAT_CACHE_THRESHOLD ; +} +enum mem_type {FREE_NIDS ,/* indicates the free nid list */ NAT_ENTRIES ,/* indicates the cached nat entry */
fs/f2fs/segment.c +5 -0
@@ -345,6 +345,11 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need) {if (!need)return ; + +/* balance_fs_bg is able to be pending */ +if (excess_cached_nats (sbi)) +f2fs_balance_fs_bg (sbi); +/* * We should do GC or end up with checkpoint, if there are so many dirty * dir/node pages without enough free segments.
Signature · 1 line
2.6.3