Skip to content

Commit 249ad43

Browse files
yohanjoungJaegeuk Kim
authored andcommitted
f2fs: add a method for calculating the remaining blocks in the current segment in LFS mode.
In LFS mode, the previous segment cannot use invalid blocks, so the remaining blocks from the next_blkoff of the current segment to the end of the section are calculated. Signed-off-by: yohan.joung <yohan.joung@sk.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 54ca9be commit 249ad43

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

fs/f2fs/segment.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi,
102102
#define CAP_SEGS_PER_SEC(sbi) \
103103
(SEGS_PER_SEC(sbi) - \
104104
BLKS_TO_SEGS(sbi, (sbi)->unusable_blocks_per_sec))
105+
#define GET_START_SEG_FROM_SEC(sbi, segno) \
106+
(rounddown(segno, SEGS_PER_SEC(sbi)))
105107
#define GET_SEC_FROM_SEG(sbi, segno) \
106108
(((segno) == -1) ? -1 : (segno) / SEGS_PER_SEC(sbi))
107109
#define GET_SEG_FROM_SEC(sbi, secno) \
@@ -582,8 +584,14 @@ static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi,
582584
if (unlikely(segno == NULL_SEGNO))
583585
return false;
584586

585-
left_blocks = CAP_BLKS_PER_SEC(sbi) -
586-
get_ckpt_valid_blocks(sbi, segno, true);
587+
if (f2fs_lfs_mode(sbi) && __is_large_section(sbi)) {
588+
left_blocks = CAP_BLKS_PER_SEC(sbi) -
589+
SEGS_TO_BLKS(sbi, (segno - GET_START_SEG_FROM_SEC(sbi, segno))) -
590+
CURSEG_I(sbi, i)->next_blkoff;
591+
} else {
592+
left_blocks = CAP_BLKS_PER_SEC(sbi) -
593+
get_ckpt_valid_blocks(sbi, segno, true);
594+
}
587595

588596
blocks = i <= CURSEG_COLD_DATA ? data_blocks : node_blocks;
589597
if (blocks > left_blocks)
@@ -596,8 +604,15 @@ static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi,
596604
if (unlikely(segno == NULL_SEGNO))
597605
return false;
598606

599-
left_blocks = CAP_BLKS_PER_SEC(sbi) -
600-
get_ckpt_valid_blocks(sbi, segno, true);
607+
if (f2fs_lfs_mode(sbi) && __is_large_section(sbi)) {
608+
left_blocks = CAP_BLKS_PER_SEC(sbi) -
609+
SEGS_TO_BLKS(sbi, (segno - GET_START_SEG_FROM_SEC(sbi, segno))) -
610+
CURSEG_I(sbi, CURSEG_HOT_DATA)->next_blkoff;
611+
} else {
612+
left_blocks = CAP_BLKS_PER_SEC(sbi) -
613+
get_ckpt_valid_blocks(sbi, segno, true);
614+
}
615+
601616
if (dent_blocks > left_blocks)
602617
return false;
603618
return true;

0 commit comments

Comments
 (0)