f2fs: update i_size when __allocate_data_block
Subsystems (3)
Jaegeuk Kim
maintainerPATCH 1/3 f2fs: update i_size when __allocate_data_block
The f2fs_direct_IO uses __allocate_data_block, but inside the allocation path, we should update i_size at the changed time to update its inode page. Otherwise, we can get wrong i_size after roll-forward recovery.
--- fs/f2fs/data.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/f2fs/data.c +8 -0
@@ -572,9 +572,11 @@ put_err:static int __allocate_data_block (struct dnode_of_data *dn) {struct f2fs_sb_info *sbi =F2FS_I_SB (dn->inode); +struct f2fs_inode_info *fi =F2FS_I (dn->inode);struct f2fs_summary sum;block_t new_blkaddr;struct node_info ni; +pgoff_t fofs;int type;if (unlikely (is_inode_flag_set (F2FS_I (dn->inode),FI_NO_ALLOC )))
@@ -597,6 +599,12 @@ static int __allocate_data_block(struct dnode_of_data *dn)update_extent_cache (new_blkaddr, dn);clear_inode_flag (F2FS_I (dn->inode),FI_NO_EXTENT ); +/* update i_size */ + fofs =start_bidx_of_node (ofs_of_node (dn->node_page), fi) + + dn->ofs_in_node; +if (i_size_read (dn->inode) < ((fofs +1 ) <<PAGE_CACHE_SHIFT )) +i_size_write (dn->inode, ((fofs +1 ) <<PAGE_CACHE_SHIFT )); + dn->data_blkaddr = new_blkaddr;return 0 ; }
Signature · 1 line
1.8.5.2 (Apple Git-48)
Jaegeuk Kim
maintainerPATCH 2/3 f2fs: change the ipu_policy option to enable combinations
This patch changes the ipu_policy setting to use any combination of orthogonal policies.
--- Documentation/filesystems/f2fs.txt | 6 +++--- fs/f2fs/segment.c | 2 +- fs/f2fs/segment.h | 39 ++++++++++++++++---------------------- 3 files changed, 20 insertions(+), 27 deletions(-)
Documentation/filesystems/f2fs.txt +3 -3
@@ -192,9 +192,9 @@ Files in /sys/fs/f2fs/<devname> ipu_policy This parameter controls the policy of in-place updates in f2fs. There are five policies: - 0: F2FS_IPU_FORCE, 1: F2FS_IPU_SSR, - 2: F2FS_IPU_UTIL, 3: F2FS_IPU_SSR_UTIL, - 4: F2FS_IPU_FSYNC, 5: F2FS_IPU_DISABLE. + 0x01: F2FS_IPU_FORCE, 0x02: F2FS_IPU_SSR, + 0x04: F2FS_IPU_UTIL, 0x08: F2FS_IPU_SSR_UTIL, + 0x10: F2FS_IPU_FSYNC. min_ipu_util This parameter controls the threshold to trigger in-place-updates. The number indicates percentage
fs/f2fs/segment.c +1 -1
@@ -1928,7 +1928,7 @@ int build_segment_manager(struct f2fs_sb_info *sbi) sm_info->ssa_blkaddr =le32_to_cpu (raw_super->ssa_blkaddr); sm_info->rec_prefree_segments = sm_info->main_segments *DEF_RECLAIM_PREFREE_SEGMENTS /100 ; - sm_info->ipu_policy =F2FS_IPU_FSYNC ; + sm_info->ipu_policy =1 <<F2FS_IPU_FSYNC ; sm_info->min_ipu_util =DEF_MIN_IPU_UTIL ; sm_info->min_fsync_blocks =DEF_MIN_FSYNC_BLOCKS ;
fs/f2fs/segment.h +16 -23
@@ -487,40 +487,33 @@ enum {F2FS_IPU_UTIL ,F2FS_IPU_SSR_UTIL , F2FS_IPU_FSYNC, - F2FS_IPU_DISABLE, };static inline bool need_inplace_update (struct inode *inode) {struct f2fs_sb_info *sbi =F2FS_I_SB (inode); +unsigned int policy =SM_I (sbi)->ipu_policy;/* IPU can be done only for the user data */ if (S_ISDIR (inode->i_mode))return false; -switch (SM_I (sbi)->ipu_policy) { -case F2FS_IPU_FORCE : +if (policy & (0x1 <<F2FS_IPU_FORCE ))return true; -case F2FS_IPU_SSR : -if (need_SSR (sbi)) -return true; -break ; -case F2FS_IPU_UTIL : -if (utilization (sbi) >SM_I (sbi)->min_ipu_util) -return true; -break ; -case F2FS_IPU_SSR_UTIL : -if (need_SSR (sbi) &&utilization (sbi) >SM_I (sbi)->min_ipu_util) -return true; -break ; -case F2FS_IPU_FSYNC : -/* this is only set during fdatasync */ -if (is_inode_flag_set (F2FS_I (inode),FI_NEED_IPU )) -return true; -break ; -case F2FS_IPU_DISABLE : -break ; - } +if (policy & (0x1 <<F2FS_IPU_SSR ) &&need_SSR (sbi)) +return true; +if (policy & (0x1 <<F2FS_IPU_UTIL ) && +utilization (sbi) >SM_I (sbi)->min_ipu_util) +return true; +if (policy & (0x1 <<F2FS_IPU_SSR_UTIL ) &&need_SSR (sbi) && +utilization (sbi) >SM_I (sbi)->min_ipu_util) +return true; + +/* this is only set during fdatasync */ +if (policy & (0x1 <<F2FS_IPU_FSYNC ) && +is_inode_flag_set (F2FS_I (inode),FI_NEED_IPU )) +return true; +return false; }
Signature · 1 line
1.8.5.2 (Apple Git-48)
Jaegeuk Kim
maintainerPATCH 3/3 f2fs: use more free segments until SSR is activated
In reply to Jaegeuk KimPreviously, f2fs activates SSR if the # of free segments reaches to the # of overprovisioned segments.
In this case, SSR starts to use dirty segments only, so that the overprovisoned space cannot be selected for new data.
This means that we have no chance to utilizae the overprovisioned space at all.
This patch fixes that by allowing LFS allocations until the # of free segments reaches to the last threshold, reserved space.
--- fs/f2fs/segment.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/segment.h +3 -2
@@ -437,8 +437,9 @@ static inline int reserved_sections(struct f2fs_sb_info *sbi)static inline bool need_SSR (struct f2fs_sb_info *sbi) { -return (prefree_segments (sbi) / sbi->segs_per_sec) - +free_sections (sbi) <overprovision_sections (sbi); +int node_secs =get_blocktype_secs (sbi,F2FS_DIRTY_NODES ); +return (prefree_segments (sbi) / sbi->segs_per_sec) + +free_sections (sbi) < (reserved_sections (sbi) + node_secs); }static inline bool has_not_enough_free_secs (struct f2fs_sb_info *sbi,int freed)
Signature · 9 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk