Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: introduce __is_large_section() for cleanup

Introduce a wrapper __is_large_section() to clean up codes.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Chao Yu and committed by
Jaegeuk Kim
2c70c5e3 7beb01f7

+15 -13
+1 -1
fs/f2fs/debug.c
··· 197 197 si->base_mem += 2 * SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); 198 198 si->base_mem += SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); 199 199 si->base_mem += SIT_VBLOCK_MAP_SIZE; 200 - if (sbi->segs_per_sec > 1) 200 + if (__is_large_section(sbi)) 201 201 si->base_mem += MAIN_SECS(sbi) * sizeof(struct sec_entry); 202 202 si->base_mem += __bitmap_size(sbi, SIT_BITMAP); 203 203
+2
fs/f2fs/f2fs.h
··· 2762 2762 spin_unlock(&sbi->iostat_lock); 2763 2763 } 2764 2764 2765 + #define __is_large_section(sbi) ((sbi)->segs_per_sec > 1) 2766 + 2765 2767 #define __is_meta_io(fio) (PAGE_TYPE_OF_BIO(fio->type) == META && \ 2766 2768 (!is_read_io(fio->op) || fio->is_meta)) 2767 2769
+1 -1
fs/f2fs/file.c
··· 2560 2560 return -EFAULT; 2561 2561 2562 2562 if (sbi->s_ndevs <= 1 || sbi->s_ndevs - 1 <= range.dev_num || 2563 - sbi->segs_per_sec != 1) { 2563 + __is_large_section(sbi)) { 2564 2564 f2fs_msg(sbi->sb, KERN_WARNING, 2565 2565 "Can't flush %u in %d for segs_per_sec %u != 1\n", 2566 2566 range.dev_num, sbi->s_ndevs,
+2 -2
fs/f2fs/gc.c
··· 1109 1109 int submitted = 0; 1110 1110 1111 1111 /* readahead multi ssa blocks those have contiguous address */ 1112 - if (sbi->segs_per_sec > 1) 1112 + if (__is_large_section(sbi)) 1113 1113 f2fs_ra_meta_pages(sbi, GET_SUM_BLOCK(sbi, segno), 1114 1114 sbi->segs_per_sec, META_SSA, true); 1115 1115 ··· 1318 1318 sbi->gc_pin_file_threshold = DEF_GC_FAILED_PINNED_FILES; 1319 1319 1320 1320 /* 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)) 1322 1322 SIT_I(sbi)->last_victim[ALLOC_NEXT] = 1323 1323 GET_SEGNO(sbi, FDEV(0).end_blk) + 1; 1324 1324 }
+8 -8
fs/f2fs/segment.c
··· 1884 1884 unsigned int start = 0, end = -1; 1885 1885 unsigned int secno, start_segno; 1886 1886 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); 1888 1888 1889 1889 mutex_lock(&dirty_i->seglist_lock); 1890 1890 ··· 1916 1916 (end - 1) <= cpc->trim_end) 1917 1917 continue; 1918 1918 1919 - if (!test_opt(sbi, LFS) || sbi->segs_per_sec == 1) { 1919 + if (!test_opt(sbi, LFS) || !__is_large_section(sbi)) { 1920 1920 f2fs_issue_discard(sbi, START_BLOCK(sbi, start), 1921 1921 (end - start) << sbi->log_blocks_per_seg); 1922 1922 continue; ··· 2148 2148 /* update total number of valid blocks to be written in ckpt area */ 2149 2149 SIT_I(sbi)->written_valid_blocks += del; 2150 2150 2151 - if (sbi->segs_per_sec > 1) 2151 + if (__is_large_section(sbi)) 2152 2152 get_sec_entry(sbi, segno)->valid_blocks += del; 2153 2153 } 2154 2154 ··· 2414 2414 static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type) 2415 2415 { 2416 2416 /* 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)) 2418 2418 return CURSEG_I(sbi, type)->segno; 2419 2419 2420 2420 if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) ··· 2724 2724 struct discard_policy dpolicy; 2725 2725 unsigned long long trimmed = 0; 2726 2726 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); 2728 2728 2729 2729 if (start >= MAX_BLKADDR(sbi) || range->len < sbi->blocksize) 2730 2730 return -EINVAL; ··· 3882 3882 if (!sit_i->tmp_map) 3883 3883 return -ENOMEM; 3884 3884 3885 - if (sbi->segs_per_sec > 1) { 3885 + if (__is_large_section(sbi)) { 3886 3886 sit_i->sec_entries = 3887 3887 f2fs_kvzalloc(sbi, array_size(sizeof(struct sec_entry), 3888 3888 MAIN_SECS(sbi)), ··· 4037 4037 se->valid_blocks; 4038 4038 } 4039 4039 4040 - if (sbi->segs_per_sec > 1) 4040 + if (__is_large_section(sbi)) 4041 4041 get_sec_entry(sbi, start)->valid_blocks += 4042 4042 se->valid_blocks; 4043 4043 } ··· 4081 4081 sbi->discard_blks -= se->valid_blocks; 4082 4082 } 4083 4083 4084 - if (sbi->segs_per_sec > 1) { 4084 + if (__is_large_section(sbi)) { 4085 4085 get_sec_entry(sbi, start)->valid_blocks += 4086 4086 se->valid_blocks; 4087 4087 get_sec_entry(sbi, start)->valid_blocks -=
+1 -1
fs/f2fs/segment.h
··· 333 333 * In order to get # of valid blocks in a section instantly from many 334 334 * segments, f2fs manages two counting structures separately. 335 335 */ 336 - if (use_section && sbi->segs_per_sec > 1) 336 + if (use_section && __is_large_section(sbi)) 337 337 return get_sec_entry(sbi, segno)->valid_blocks; 338 338 else 339 339 return get_seg_entry(sbi, segno)->valid_blocks;