Skip to content

Commit 2c70c5e

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: introduce __is_large_section() for cleanup
Introduce a wrapper __is_large_section() to clean up codes. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 7beb01f commit 2c70c5e

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

fs/f2fs/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
197197
si->base_mem += 2 * SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi);
198198
si->base_mem += SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi);
199199
si->base_mem += SIT_VBLOCK_MAP_SIZE;
200-
if (sbi->segs_per_sec > 1)
200+
if (__is_large_section(sbi))
201201
si->base_mem += MAIN_SECS(sbi) * sizeof(struct sec_entry);
202202
si->base_mem += __bitmap_size(sbi, SIT_BITMAP);
203203

fs/f2fs/f2fs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,6 +2762,8 @@ static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi,
27622762
spin_unlock(&sbi->iostat_lock);
27632763
}
27642764

2765+
#define __is_large_section(sbi) ((sbi)->segs_per_sec > 1)
2766+
27652767
#define __is_meta_io(fio) (PAGE_TYPE_OF_BIO(fio->type) == META && \
27662768
(!is_read_io(fio->op) || fio->is_meta))
27672769

fs/f2fs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2560,7 +2560,7 @@ static int f2fs_ioc_flush_device(struct file *filp, unsigned long arg)
25602560
return -EFAULT;
25612561

25622562
if (sbi->s_ndevs <= 1 || sbi->s_ndevs - 1 <= range.dev_num ||
2563-
sbi->segs_per_sec != 1) {
2563+
__is_large_section(sbi)) {
25642564
f2fs_msg(sbi->sb, KERN_WARNING,
25652565
"Can't flush %u in %d for segs_per_sec %u != 1\n",
25662566
range.dev_num, sbi->s_ndevs,

fs/f2fs/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
11091109
int submitted = 0;
11101110

11111111
/* readahead multi ssa blocks those have contiguous address */
1112-
if (sbi->segs_per_sec > 1)
1112+
if (__is_large_section(sbi))
11131113
f2fs_ra_meta_pages(sbi, GET_SUM_BLOCK(sbi, segno),
11141114
sbi->segs_per_sec, META_SSA, true);
11151115

@@ -1318,7 +1318,7 @@ void f2fs_build_gc_manager(struct f2fs_sb_info *sbi)
13181318
sbi->gc_pin_file_threshold = DEF_GC_FAILED_PINNED_FILES;
13191319

13201320
/* give warm/cold data area from slower device */
1321-
if (sbi->s_ndevs && sbi->segs_per_sec == 1)
1321+
if (sbi->s_ndevs && !__is_large_section(sbi))
13221322
SIT_I(sbi)->last_victim[ALLOC_NEXT] =
13231323
GET_SEGNO(sbi, FDEV(0).end_blk) + 1;
13241324
}

fs/f2fs/segment.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
18841884
unsigned int start = 0, end = -1;
18851885
unsigned int secno, start_segno;
18861886
bool force = (cpc->reason & CP_DISCARD);
1887-
bool need_align = test_opt(sbi, LFS) && sbi->segs_per_sec > 1;
1887+
bool need_align = test_opt(sbi, LFS) && __is_large_section(sbi);
18881888

18891889
mutex_lock(&dirty_i->seglist_lock);
18901890

@@ -1916,7 +1916,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
19161916
(end - 1) <= cpc->trim_end)
19171917
continue;
19181918

1919-
if (!test_opt(sbi, LFS) || sbi->segs_per_sec == 1) {
1919+
if (!test_opt(sbi, LFS) || !__is_large_section(sbi)) {
19201920
f2fs_issue_discard(sbi, START_BLOCK(sbi, start),
19211921
(end - start) << sbi->log_blocks_per_seg);
19221922
continue;
@@ -2148,7 +2148,7 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
21482148
/* update total number of valid blocks to be written in ckpt area */
21492149
SIT_I(sbi)->written_valid_blocks += del;
21502150

2151-
if (sbi->segs_per_sec > 1)
2151+
if (__is_large_section(sbi))
21522152
get_sec_entry(sbi, segno)->valid_blocks += del;
21532153
}
21542154

@@ -2414,7 +2414,7 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)
24142414
static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)
24152415
{
24162416
/* if segs_per_sec is large than 1, we need to keep original policy. */
2417-
if (sbi->segs_per_sec != 1)
2417+
if (__is_large_section(sbi))
24182418
return CURSEG_I(sbi, type)->segno;
24192419

24202420
if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
@@ -2724,7 +2724,7 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
27242724
struct discard_policy dpolicy;
27252725
unsigned long long trimmed = 0;
27262726
int err = 0;
2727-
bool need_align = test_opt(sbi, LFS) && sbi->segs_per_sec > 1;
2727+
bool need_align = test_opt(sbi, LFS) && __is_large_section(sbi);
27282728

27292729
if (start >= MAX_BLKADDR(sbi) || range->len < sbi->blocksize)
27302730
return -EINVAL;
@@ -3882,7 +3882,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
38823882
if (!sit_i->tmp_map)
38833883
return -ENOMEM;
38843884

3885-
if (sbi->segs_per_sec > 1) {
3885+
if (__is_large_section(sbi)) {
38863886
sit_i->sec_entries =
38873887
f2fs_kvzalloc(sbi, array_size(sizeof(struct sec_entry),
38883888
MAIN_SECS(sbi)),
@@ -4037,7 +4037,7 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
40374037
se->valid_blocks;
40384038
}
40394039

4040-
if (sbi->segs_per_sec > 1)
4040+
if (__is_large_section(sbi))
40414041
get_sec_entry(sbi, start)->valid_blocks +=
40424042
se->valid_blocks;
40434043
}
@@ -4081,7 +4081,7 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
40814081
sbi->discard_blks -= se->valid_blocks;
40824082
}
40834083

4084-
if (sbi->segs_per_sec > 1) {
4084+
if (__is_large_section(sbi)) {
40854085
get_sec_entry(sbi, start)->valid_blocks +=
40864086
se->valid_blocks;
40874087
get_sec_entry(sbi, start)->valid_blocks -=

fs/f2fs/segment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ static inline unsigned int get_valid_blocks(struct f2fs_sb_info *sbi,
333333
* In order to get # of valid blocks in a section instantly from many
334334
* segments, f2fs manages two counting structures separately.
335335
*/
336-
if (use_section && sbi->segs_per_sec > 1)
336+
if (use_section && __is_large_section(sbi))
337337
return get_sec_entry(sbi, segno)->valid_blocks;
338338
else
339339
return get_seg_entry(sbi, segno)->valid_blocks;

0 commit comments

Comments
 (0)