f2fs: introduce IS_F2FS_IPU_* macro
IS_F2FS_IPU_* macro can be used to identify whether f2fs ipu related policies are enabled. BTW, convert to use BIT() instead of open code. Signed-off-by: Yangtao Li <frank.li@vivo.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
fdbf69a7f5
commit
fdb7ccc3f9
@ -2539,34 +2539,29 @@ static inline bool check_inplace_update_policy(struct inode *inode,
|
|||||||
struct f2fs_io_info *fio)
|
struct f2fs_io_info *fio)
|
||||||
{
|
{
|
||||||
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
||||||
unsigned int policy = SM_I(sbi)->ipu_policy;
|
|
||||||
|
|
||||||
if (policy & (0x1 << F2FS_IPU_HONOR_OPU_WRITE) &&
|
if (IS_F2FS_IPU_HONOR_OPU_WRITE(sbi) &&
|
||||||
is_inode_flag_set(inode, FI_OPU_WRITE))
|
is_inode_flag_set(inode, FI_OPU_WRITE))
|
||||||
return false;
|
return false;
|
||||||
if (policy & (0x1 << F2FS_IPU_FORCE))
|
if (IS_F2FS_IPU_FORCE(sbi))
|
||||||
return true;
|
return true;
|
||||||
if (policy & (0x1 << F2FS_IPU_SSR) && f2fs_need_SSR(sbi))
|
if (IS_F2FS_IPU_SSR(sbi) && f2fs_need_SSR(sbi))
|
||||||
return true;
|
return true;
|
||||||
if (policy & (0x1 << F2FS_IPU_UTIL) &&
|
if (IS_F2FS_IPU_UTIL(sbi) && utilization(sbi) > SM_I(sbi)->min_ipu_util)
|
||||||
utilization(sbi) > SM_I(sbi)->min_ipu_util)
|
|
||||||
return true;
|
return true;
|
||||||
if (policy & (0x1 << F2FS_IPU_SSR_UTIL) && f2fs_need_SSR(sbi) &&
|
if (IS_F2FS_IPU_SSR_UTIL(sbi) && f2fs_need_SSR(sbi) &&
|
||||||
utilization(sbi) > SM_I(sbi)->min_ipu_util)
|
utilization(sbi) > SM_I(sbi)->min_ipu_util)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IPU for rewrite async pages
|
* IPU for rewrite async pages
|
||||||
*/
|
*/
|
||||||
if (policy & (0x1 << F2FS_IPU_ASYNC) &&
|
if (IS_F2FS_IPU_ASYNC(sbi) && fio && fio->op == REQ_OP_WRITE &&
|
||||||
fio && fio->op == REQ_OP_WRITE &&
|
!(fio->op_flags & REQ_SYNC) && !IS_ENCRYPTED(inode))
|
||||||
!(fio->op_flags & REQ_SYNC) &&
|
|
||||||
!IS_ENCRYPTED(inode))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* this is only set during fdatasync */
|
/* this is only set during fdatasync */
|
||||||
if (policy & (0x1 << F2FS_IPU_FSYNC) &&
|
if (IS_F2FS_IPU_FSYNC(sbi) && is_inode_flag_set(inode, FI_NEED_IPU))
|
||||||
is_inode_flag_set(inode, FI_NEED_IPU))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (unlikely(fio && is_sbi_flag_set(sbi, SBI_CP_DISABLED) &&
|
if (unlikely(fio && is_sbi_flag_set(sbi, SBI_CP_DISABLED) &&
|
||||||
|
@ -3487,7 +3487,7 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio)
|
|||||||
|
|
||||||
stat_inc_inplace_blocks(fio->sbi);
|
stat_inc_inplace_blocks(fio->sbi);
|
||||||
|
|
||||||
if (fio->bio && !(SM_I(sbi)->ipu_policy & (1 << F2FS_IPU_NOCACHE)))
|
if (fio->bio && !IS_F2FS_IPU_NOCACHE(sbi))
|
||||||
err = f2fs_merge_page_bio(fio);
|
err = f2fs_merge_page_bio(fio);
|
||||||
else
|
else
|
||||||
err = f2fs_submit_page_bio(fio);
|
err = f2fs_submit_page_bio(fio);
|
||||||
@ -5126,7 +5126,7 @@ int f2fs_build_segment_manager(struct f2fs_sb_info *sbi)
|
|||||||
sm_info->rec_prefree_segments = DEF_MAX_RECLAIM_PREFREE_SEGMENTS;
|
sm_info->rec_prefree_segments = DEF_MAX_RECLAIM_PREFREE_SEGMENTS;
|
||||||
|
|
||||||
if (!f2fs_lfs_mode(sbi))
|
if (!f2fs_lfs_mode(sbi))
|
||||||
sm_info->ipu_policy = 1 << F2FS_IPU_FSYNC;
|
sm_info->ipu_policy = BIT(F2FS_IPU_FSYNC);
|
||||||
sm_info->min_ipu_util = DEF_MIN_IPU_UTIL;
|
sm_info->min_ipu_util = DEF_MIN_IPU_UTIL;
|
||||||
sm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS;
|
sm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS;
|
||||||
sm_info->min_seq_blocks = sbi->blocks_per_seg;
|
sm_info->min_seq_blocks = sbi->blocks_per_seg;
|
||||||
|
@ -681,6 +681,21 @@ enum {
|
|||||||
F2FS_IPU_HONOR_OPU_WRITE,
|
F2FS_IPU_HONOR_OPU_WRITE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define F2FS_IPU_POLICY(name) \
|
||||||
|
static inline int IS_##name(struct f2fs_sb_info *sbi) \
|
||||||
|
{ \
|
||||||
|
return SM_I(sbi)->ipu_policy & BIT(name); \
|
||||||
|
}
|
||||||
|
|
||||||
|
F2FS_IPU_POLICY(F2FS_IPU_FORCE);
|
||||||
|
F2FS_IPU_POLICY(F2FS_IPU_SSR);
|
||||||
|
F2FS_IPU_POLICY(F2FS_IPU_UTIL);
|
||||||
|
F2FS_IPU_POLICY(F2FS_IPU_SSR_UTIL);
|
||||||
|
F2FS_IPU_POLICY(F2FS_IPU_FSYNC);
|
||||||
|
F2FS_IPU_POLICY(F2FS_IPU_ASYNC);
|
||||||
|
F2FS_IPU_POLICY(F2FS_IPU_NOCACHE);
|
||||||
|
F2FS_IPU_POLICY(F2FS_IPU_HONOR_OPU_WRITE);
|
||||||
|
|
||||||
static inline unsigned int curseg_segno(struct f2fs_sb_info *sbi,
|
static inline unsigned int curseg_segno(struct f2fs_sb_info *sbi,
|
||||||
int type)
|
int type)
|
||||||
{
|
{
|
||||||
|
@ -4089,8 +4089,8 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
|
|||||||
if (f2fs_block_unit_discard(sbi))
|
if (f2fs_block_unit_discard(sbi))
|
||||||
SM_I(sbi)->dcc_info->discard_granularity =
|
SM_I(sbi)->dcc_info->discard_granularity =
|
||||||
MIN_DISCARD_GRANULARITY;
|
MIN_DISCARD_GRANULARITY;
|
||||||
SM_I(sbi)->ipu_policy = 1 << F2FS_IPU_FORCE |
|
SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) |
|
||||||
1 << F2FS_IPU_HONOR_OPU_WRITE;
|
BIT(F2FS_IPU_HONOR_OPU_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
sbi->readdir_ra = true;
|
sbi->readdir_ra = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user