mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 05:04:02 +02:00
f2fs: cleanup w/ f2fs_need_rand_{blk, seg, seg_blk}
No logic changes. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
5d49025a4e
commit
6da62bbde4
|
|
@ -4142,10 +4142,19 @@ static inline struct inode *fio_inode(struct f2fs_io_info *fio)
|
|||
#define MIN_FRAGMENT_SIZE 1
|
||||
#define MAX_FRAGMENT_SIZE 512
|
||||
|
||||
static inline bool f2fs_need_rand_blk(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
return F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_BLK;
|
||||
}
|
||||
|
||||
static inline bool f2fs_need_rand_seg(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
return F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_SEG ||
|
||||
F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_BLK;
|
||||
return F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_SEG;
|
||||
}
|
||||
|
||||
static inline bool f2fs_need_rand_seg_blk(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
return f2fs_need_rand_blk(sbi) || f2fs_need_rand_seg(sbi);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type,
|
|||
p->max_search = sbi->max_victim_search;
|
||||
|
||||
/* let's select beginning hot/small space first. */
|
||||
if (f2fs_need_rand_seg(sbi)) {
|
||||
if (f2fs_need_rand_seg_blk(sbi)) {
|
||||
p->offset = get_random_u32_below(MAIN_SECS(sbi) *
|
||||
SEGS_PER_SEC(sbi));
|
||||
SIT_I(sbi)->last_victim[p->gc_mode] = p->offset;
|
||||
|
|
|
|||
|
|
@ -3052,7 +3052,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)
|
|||
|
||||
sanity_check_seg_type(sbi, seg_type);
|
||||
if (__is_large_section(sbi)) {
|
||||
if (f2fs_need_rand_seg(sbi)) {
|
||||
if (f2fs_need_rand_seg_blk(sbi)) {
|
||||
unsigned int hint = GET_SEC_FROM_SEG(sbi, curseg->segno);
|
||||
|
||||
if (GET_SEC_FROM_SEG(sbi, curseg->segno + 1) != hint)
|
||||
|
|
@ -3061,7 +3061,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)
|
|||
GET_SEG_FROM_SEC(sbi, hint + 1) - 1);
|
||||
}
|
||||
return curseg->segno;
|
||||
} else if (f2fs_need_rand_seg(sbi)) {
|
||||
} else if (f2fs_need_rand_seg_blk(sbi)) {
|
||||
return get_random_u32_below(MAIN_SECS(sbi) * SEGS_PER_SEC(sbi));
|
||||
}
|
||||
|
||||
|
|
@ -3117,7 +3117,7 @@ static int new_curseg(struct f2fs_sb_info *sbi, int type, bool new_sec)
|
|||
curseg->next_segno = segno;
|
||||
reset_curseg(sbi, type, 1);
|
||||
curseg->alloc_type = LFS;
|
||||
if (F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_BLK)
|
||||
if (f2fs_need_rand_blk(sbi))
|
||||
curseg->fragment_remained_chunk =
|
||||
get_random_u32_inclusive(1, sbi->max_fragment_chunk);
|
||||
return 0;
|
||||
|
|
@ -3936,7 +3936,7 @@ int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct folio *folio,
|
|||
curseg->next_blkoff = f2fs_find_next_ssr_block(sbi, curseg);
|
||||
} else {
|
||||
curseg->next_blkoff++;
|
||||
if (F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_BLK)
|
||||
if (f2fs_need_rand_blk(sbi))
|
||||
f2fs_randomize_chunk(sbi, curseg);
|
||||
}
|
||||
if (curseg->next_blkoff >= f2fs_usable_blks_in_seg(sbi, curseg->segno))
|
||||
|
|
|
|||
|
|
@ -2457,9 +2457,9 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
|
|||
seq_puts(seq, "adaptive");
|
||||
else if (F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS)
|
||||
seq_puts(seq, "lfs");
|
||||
else if (F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_SEG)
|
||||
else if (f2fs_need_rand_seg(sbi))
|
||||
seq_puts(seq, "fragment:segment");
|
||||
else if (F2FS_OPTION(sbi).fs_mode == FS_MODE_FRAGMENT_BLK)
|
||||
else if (f2fs_need_rand_blk(sbi))
|
||||
seq_puts(seq, "fragment:block");
|
||||
seq_printf(seq, ",active_logs=%u", F2FS_OPTION(sbi).active_logs);
|
||||
if (test_opt(sbi, RESERVE_ROOT) || test_opt(sbi, RESERVE_NODE))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user