diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index de6c41c32c629..06cfb94cc3db2 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -908,10 +908,13 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync) * enough free sections, we should flush dent/node blocks and do * garbage collections. */ - if (__get_victim(sbi, &segno, gc_type) || prefree_segments(sbi)) + if (__get_victim(sbi, &segno, gc_type) || + prefree_segments(sbi)) { write_checkpoint(sbi, &cpc); - else if (has_not_enough_free_secs(sbi, 0)) + segno = NULL_SEGNO; + } else if (has_not_enough_free_secs(sbi, 0)) { write_checkpoint(sbi, &cpc); + } } if (segno == NULL_SEGNO && !__get_victim(sbi, &segno, gc_type))