Skip to content

Commit 37345ea

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix to not account invalid blocks in get_left_section_blocks()
w/ LFS mode, in get_left_section_blocks(), we should not account the blocks which were used before and now are invalided, otherwise those blocks will be counted as freed one in has_curseg_enough_space(), result in missing to trigger GC in time. Cc: [email protected] Fixes: 249ad43 ("f2fs: add a method for calculating the remaining blocks in the current segment in LFS mode.") Fixes: bf34c93 ("f2fs: check curseg space before foreground GC") Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 8f11fe5 commit 37345ea

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

fs/f2fs/segment.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,12 @@ static inline int reserved_sections(struct f2fs_sb_info *sbi)
612612
static inline unsigned int get_left_section_blocks(struct f2fs_sb_info *sbi,
613613
enum log_type type, unsigned int segno)
614614
{
615-
if (f2fs_lfs_mode(sbi) && __is_large_section(sbi))
616-
return CAP_BLKS_PER_SEC(sbi) - SEGS_TO_BLKS(sbi,
617-
(segno - GET_START_SEG_FROM_SEC(sbi, segno))) -
615+
if (f2fs_lfs_mode(sbi)) {
616+
unsigned int used_blocks = __is_large_section(sbi) ? SEGS_TO_BLKS(sbi,
617+
(segno - GET_START_SEG_FROM_SEC(sbi, segno))) : 0;
618+
return CAP_BLKS_PER_SEC(sbi) - used_blocks -
618619
CURSEG_I(sbi, type)->next_blkoff;
620+
}
619621
return CAP_BLKS_PER_SEC(sbi) - get_ckpt_valid_blocks(sbi, segno, true);
620622
}
621623

0 commit comments

Comments
 (0)