We use has_not_enough_free_secs to check if there are enough free segments,
(free_sections(sbi) + freed) <= (node_secs + 2 * dent_secs + imeta_secs + reserved_sections(sbi) + needed); Under scenario with large number of dirty nodes, these nodes would be flushed during cp, as a result, right side of the inequality would be decreased, while left side stays unchanged if these nodes are flushed in SSR way, which means there are enough free segments after this cp. For this case, we just do a bggc instead of fggc. Signed-off-by: Hou Pengyang <houpengy...@huawei.com> --- fs/f2fs/gc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index ffff67ac..8cf751f 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -952,11 +952,16 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, bool background) } if (gc_type == BG_GC && has_not_enough_free_secs(sbi, sec_freed, 0)) { - gc_type = FG_GC; + /* + * After cp, there may be enough free segments avaliable, In this case, + * We just do a bggc instead of fggc. + */ ret = write_checkpoint(sbi, &cpc); if (ret) goto stop; + if (has_not_enough_free_secs(sbi, sec_freed, 0)) + gc_type = FG_GC; } else if (gc_type == BG_GC && !background) { /* f2fs_balance_fs doesn't need to do BG_GC in critical path. */ goto stop; -- 2.10.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel