summaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2023-04-10 23:48:50 +0200
committerJaegeuk Kim <jaegeuk@kernel.org>2023-04-18 18:05:43 +0200
commit2d3f197bad9796f81bc0c0c41f571b0e418f266f (patch)
tree098edb8e343018184f7a7f9da8b7d14c11a3693b /fs/f2fs
parentf2fs: remove folio_detach_private() in .invalidate_folio and .release_folio (diff)
downloadlinux-2d3f197bad9796f81bc0c0c41f571b0e418f266f.tar.xz
linux-2d3f197bad9796f81bc0c0c41f571b0e418f266f.zip
f2fs: refactor f2fs_gc to call checkpoint in urgent condition
The major change is to call checkpoint, if there's not enough space while having some prefree segments in FG_GC case. Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/gc.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index c748cdfb0501..ba5775dcade6 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -1829,7 +1829,10 @@ gc_more:
goto stop;
}
- if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) {
+ /* Let's run FG_GC, if we don't have enough space. */
+ if (has_not_enough_free_secs(sbi, 0, 0)) {
+ gc_type = FG_GC;
+
/*
* For example, if there are many prefree_segments below given
* threshold, we can make them free by checkpoint. Then, we
@@ -1840,8 +1843,6 @@ gc_more:
if (ret)
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. */
@@ -1868,19 +1869,15 @@ retry:
if (seg_freed == f2fs_usable_segs_in_sec(sbi, segno))
sec_freed++;
- if (gc_type == FG_GC)
+ if (gc_type == FG_GC) {
sbi->cur_victim_sec = NULL_SEGNO;
- if (gc_control->init_gc_type == FG_GC ||
- !has_not_enough_free_secs(sbi,
- (gc_type == FG_GC) ? sec_freed : 0, 0)) {
- if (gc_type == FG_GC && sec_freed < gc_control->nr_free_secs)
- goto go_gc_more;
- goto stop;
- }
-
- /* FG_GC stops GC by skip_count */
- if (gc_type == FG_GC) {
+ if (!has_not_enough_free_secs(sbi, sec_freed, 0)) {
+ if (!gc_control->no_bg_gc &&
+ sec_freed < gc_control->nr_free_secs)
+ goto go_gc_more;
+ goto stop;
+ }
if (sbi->skipped_gc_rwsem)
skipped_round++;
round++;
@@ -1889,6 +1886,8 @@ retry:
ret = f2fs_write_checkpoint(sbi, &cpc);
goto stop;
}
+ } else if (!has_not_enough_free_secs(sbi, 0, 0)) {
+ goto stop;
}
__get_secs_required(sbi, NULL, &upper_secs, NULL);