mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 05:55:44 +02:00
f2fs: write checkpoint during FG_GC
[ Upstream commit a9163b947a ]
If there's not enough free sections each of which consistis of large segments,
we can hit no free section for upcoming section allocation. Let's reclaim some
prefree segments by writing checkpoints.
Signed-off-by: Byungki Lee <dominicus79@gmail.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
d031105739
commit
ec769406d0
36
fs/f2fs/gc.c
36
fs/f2fs/gc.c
|
|
@ -1741,23 +1741,31 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
|
||||||
if (sync)
|
if (sync)
|
||||||
goto stop;
|
goto stop;
|
||||||
|
|
||||||
if (has_not_enough_free_secs(sbi, sec_freed, 0)) {
|
if (!has_not_enough_free_secs(sbi, sec_freed, 0))
|
||||||
if (skipped_round <= MAX_SKIP_GC_COUNT ||
|
goto stop;
|
||||||
skipped_round * 2 < round) {
|
|
||||||
segno = NULL_SEGNO;
|
|
||||||
goto gc_more;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (first_skipped < last_skipped &&
|
if (skipped_round <= MAX_SKIP_GC_COUNT || skipped_round * 2 < round) {
|
||||||
(last_skipped - first_skipped) >
|
|
||||||
sbi->skipped_gc_rwsem) {
|
/* Write checkpoint to reclaim prefree segments */
|
||||||
f2fs_drop_inmem_pages_all(sbi, true);
|
if (free_sections(sbi) < NR_CURSEG_PERSIST_TYPE &&
|
||||||
segno = NULL_SEGNO;
|
prefree_segments(sbi) &&
|
||||||
goto gc_more;
|
!is_sbi_flag_set(sbi, SBI_CP_DISABLED)) {
|
||||||
}
|
|
||||||
if (gc_type == FG_GC && !is_sbi_flag_set(sbi, SBI_CP_DISABLED))
|
|
||||||
ret = f2fs_write_checkpoint(sbi, &cpc);
|
ret = f2fs_write_checkpoint(sbi, &cpc);
|
||||||
|
if (ret)
|
||||||
|
goto stop;
|
||||||
|
}
|
||||||
|
segno = NULL_SEGNO;
|
||||||
|
goto gc_more;
|
||||||
}
|
}
|
||||||
|
if (first_skipped < last_skipped &&
|
||||||
|
(last_skipped - first_skipped) >
|
||||||
|
sbi->skipped_gc_rwsem) {
|
||||||
|
f2fs_drop_inmem_pages_all(sbi, true);
|
||||||
|
segno = NULL_SEGNO;
|
||||||
|
goto gc_more;
|
||||||
|
}
|
||||||
|
if (gc_type == FG_GC && !is_sbi_flag_set(sbi, SBI_CP_DISABLED))
|
||||||
|
ret = f2fs_write_checkpoint(sbi, &cpc);
|
||||||
stop:
|
stop:
|
||||||
SIT_I(sbi)->last_victim[ALLOC_NEXT] = 0;
|
SIT_I(sbi)->last_victim[ALLOC_NEXT] = 0;
|
||||||
SIT_I(sbi)->last_victim[FLUSH_DEVICE] = init_segno;
|
SIT_I(sbi)->last_victim[FLUSH_DEVICE] = init_segno;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user