Skip to content

Commit 4978f0a

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: clean up w/ get_left_section_blocks()
Introduce get_left_section_blocks() for cleanup, no logic changes. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 248a998 commit 4978f0a

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

fs/f2fs/segment.h

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,16 @@ static inline int reserved_sections(struct f2fs_sb_info *sbi)
600600
return GET_SEC_FROM_SEG(sbi, reserved_segments(sbi));
601601
}
602602

603+
static inline unsigned int get_left_section_blocks(struct f2fs_sb_info *sbi,
604+
enum log_type type, unsigned int segno)
605+
{
606+
if (f2fs_lfs_mode(sbi) && __is_large_section(sbi))
607+
return CAP_BLKS_PER_SEC(sbi) - SEGS_TO_BLKS(sbi,
608+
(segno - GET_START_SEG_FROM_SEC(sbi, segno))) -
609+
CURSEG_I(sbi, type)->next_blkoff;
610+
return CAP_BLKS_PER_SEC(sbi) - get_ckpt_valid_blocks(sbi, segno, true);
611+
}
612+
603613
static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi,
604614
unsigned int node_blocks, unsigned int data_blocks,
605615
unsigned int dent_blocks)
@@ -614,14 +624,7 @@ static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi,
614624
if (unlikely(segno == NULL_SEGNO))
615625
return false;
616626

617-
if (f2fs_lfs_mode(sbi) && __is_large_section(sbi)) {
618-
left_blocks = CAP_BLKS_PER_SEC(sbi) -
619-
SEGS_TO_BLKS(sbi, (segno - GET_START_SEG_FROM_SEC(sbi, segno))) -
620-
CURSEG_I(sbi, i)->next_blkoff;
621-
} else {
622-
left_blocks = CAP_BLKS_PER_SEC(sbi) -
623-
get_ckpt_valid_blocks(sbi, segno, true);
624-
}
627+
left_blocks = get_left_section_blocks(sbi, i, segno);
625628

626629
blocks = i <= CURSEG_COLD_DATA ? data_blocks : node_blocks;
627630
if (blocks > left_blocks)
@@ -634,14 +637,7 @@ static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi,
634637
if (unlikely(segno == NULL_SEGNO))
635638
return false;
636639

637-
if (f2fs_lfs_mode(sbi) && __is_large_section(sbi)) {
638-
left_blocks = CAP_BLKS_PER_SEC(sbi) -
639-
SEGS_TO_BLKS(sbi, (segno - GET_START_SEG_FROM_SEC(sbi, segno))) -
640-
CURSEG_I(sbi, CURSEG_HOT_DATA)->next_blkoff;
641-
} else {
642-
left_blocks = CAP_BLKS_PER_SEC(sbi) -
643-
get_ckpt_valid_blocks(sbi, segno, true);
644-
}
640+
left_blocks = get_left_section_blocks(sbi, CURSEG_HOT_DATA, segno);
645641

646642
if (dent_blocks > left_blocks)
647643
return false;

0 commit comments

Comments
 (0)