mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 15:18:19 +00:00
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>
This commit is contained in:
parent
635a52da86
commit
2d3f197bad
1 changed files with 13 additions and 14 deletions
27
fs/f2fs/gc.c
27
fs/f2fs/gc.c
|
@ -1829,7 +1829,10 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
|
||||||
goto stop;
|
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
|
* For example, if there are many prefree_segments below given
|
||||||
* threshold, we can make them free by checkpoint. Then, we
|
* threshold, we can make them free by checkpoint. Then, we
|
||||||
|
@ -1840,8 +1843,6 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto stop;
|
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. */
|
/* f2fs_balance_fs doesn't need to do BG_GC in critical path. */
|
||||||
|
@ -1868,19 +1869,15 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
|
||||||
if (seg_freed == f2fs_usable_segs_in_sec(sbi, segno))
|
if (seg_freed == f2fs_usable_segs_in_sec(sbi, segno))
|
||||||
sec_freed++;
|
sec_freed++;
|
||||||
|
|
||||||
if (gc_type == FG_GC)
|
if (gc_type == FG_GC) {
|
||||||
sbi->cur_victim_sec = NULL_SEGNO;
|
sbi->cur_victim_sec = NULL_SEGNO;
|
||||||
|
|
||||||
if (gc_control->init_gc_type == FG_GC ||
|
if (!has_not_enough_free_secs(sbi, sec_freed, 0)) {
|
||||||
!has_not_enough_free_secs(sbi,
|
if (!gc_control->no_bg_gc &&
|
||||||
(gc_type == FG_GC) ? sec_freed : 0, 0)) {
|
sec_freed < gc_control->nr_free_secs)
|
||||||
if (gc_type == FG_GC && sec_freed < gc_control->nr_free_secs)
|
goto go_gc_more;
|
||||||
goto go_gc_more;
|
goto stop;
|
||||||
goto stop;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* FG_GC stops GC by skip_count */
|
|
||||||
if (gc_type == FG_GC) {
|
|
||||||
if (sbi->skipped_gc_rwsem)
|
if (sbi->skipped_gc_rwsem)
|
||||||
skipped_round++;
|
skipped_round++;
|
||||||
round++;
|
round++;
|
||||||
|
@ -1889,6 +1886,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
|
||||||
ret = f2fs_write_checkpoint(sbi, &cpc);
|
ret = f2fs_write_checkpoint(sbi, &cpc);
|
||||||
goto stop;
|
goto stop;
|
||||||
}
|
}
|
||||||
|
} else if (!has_not_enough_free_secs(sbi, 0, 0)) {
|
||||||
|
goto stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
__get_secs_required(sbi, NULL, &upper_secs, NULL);
|
__get_secs_required(sbi, NULL, &upper_secs, NULL);
|
||||||
|
|
Loading…
Reference in a new issue