return GET_SEC_FROM_SEG(sbi, reserved_segments(sbi));
}
+static inline unsigned int get_left_section_blocks(struct f2fs_sb_info *sbi,
+ enum log_type type, unsigned int segno)
+{
+ if (f2fs_lfs_mode(sbi) && __is_large_section(sbi))
+ return CAP_BLKS_PER_SEC(sbi) - SEGS_TO_BLKS(sbi,
+ (segno - GET_START_SEG_FROM_SEC(sbi, segno))) -
+ CURSEG_I(sbi, type)->next_blkoff;
+ return CAP_BLKS_PER_SEC(sbi) - get_ckpt_valid_blocks(sbi, segno, true);
+}
+
static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi,
unsigned int node_blocks, unsigned int data_blocks,
unsigned int dent_blocks)
if (unlikely(segno == NULL_SEGNO))
return false;
- if (f2fs_lfs_mode(sbi) && __is_large_section(sbi)) {
- left_blocks = CAP_BLKS_PER_SEC(sbi) -
- SEGS_TO_BLKS(sbi, (segno - GET_START_SEG_FROM_SEC(sbi, segno))) -
- CURSEG_I(sbi, i)->next_blkoff;
- } else {
- left_blocks = CAP_BLKS_PER_SEC(sbi) -
- get_ckpt_valid_blocks(sbi, segno, true);
- }
+ left_blocks = get_left_section_blocks(sbi, i, segno);
blocks = i <= CURSEG_COLD_DATA ? data_blocks : node_blocks;
if (blocks > left_blocks)
if (unlikely(segno == NULL_SEGNO))
return false;
- if (f2fs_lfs_mode(sbi) && __is_large_section(sbi)) {
- left_blocks = CAP_BLKS_PER_SEC(sbi) -
- SEGS_TO_BLKS(sbi, (segno - GET_START_SEG_FROM_SEC(sbi, segno))) -
- CURSEG_I(sbi, CURSEG_HOT_DATA)->next_blkoff;
- } else {
- left_blocks = CAP_BLKS_PER_SEC(sbi) -
- get_ckpt_valid_blocks(sbi, segno, true);
- }
+ left_blocks = get_left_section_blocks(sbi, CURSEG_HOT_DATA, segno);
if (dent_blocks > left_blocks)
return false;