summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHou Pengyang <houpengyang@huawei.com>2017-02-25 03:57:38 +0000
committerJaegeuk Kim <jaegeuk@kernel.org>2017-03-08 22:01:14 -0800
commit1b30dde97f843a00bd6c19c3bd6fe501a4487b8f (patch)
treeb58a74b2b58bf0d20258c9c04ca7617bef364e34
parent377816fec3f305ab5f4f72356363bfa98b992db5 (diff)
f2fs: avoid bggc->fggc when enough free segments are avaliable after cp
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 <houpengyang@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/gc.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index b77d1c806aba..8c8e7135ef58 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -953,21 +953,22 @@ gc_more:
goto stop;
}
- if (gc_type == BG_GC && has_not_enough_free_secs(sbi, sec_freed, 0)) {
- gc_type = FG_GC;
+ if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) {
/*
- * If there is no victim and no prefree segment but still not
- * enough free sections, we should flush dent/node blocks and do
- * garbage collections.
+ * For example, if there are many prefree_segments below given
+ * threshold, we can make them free by checkpoint. Then, we
+ * secure free segments which doesn't need fggc any more.
*/
ret = write_checkpoint(sbi, &cpc);
if (ret)
goto stop;
- } else if (gc_type == BG_GC && !background) {
- /* f2fs_balance_fs doesn't need to do BG_GC in critical path. */
- goto stop;
+ if (has_not_enough_free_secs(sbi, 0, 0))
+ gc_type = FG_GC;
}
+ /* f2fs_balance_fs doesn't need to do BG_GC in critical path. */
+ if (gc_type == BG_GC && !background)
+ goto stop;
if (!__get_victim(sbi, &segno, gc_type))
goto stop;
ret = 0;