Skip to content

Commit a9163b9

Browse files
chamsolJaegeuk Kim
authored andcommitted
f2fs: write checkpoint during FG_GC
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>
1 parent f2db710 commit a9163b9

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

fs/f2fs/gc.c

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,23 +1790,31 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
17901790
if (sync)
17911791
goto stop;
17921792

1793-
if (has_not_enough_free_secs(sbi, sec_freed, 0)) {
1794-
if (skipped_round <= MAX_SKIP_GC_COUNT ||
1795-
skipped_round * 2 < round) {
1796-
segno = NULL_SEGNO;
1797-
goto gc_more;
1798-
}
1793+
if (!has_not_enough_free_secs(sbi, sec_freed, 0))
1794+
goto stop;
17991795

1800-
if (first_skipped < last_skipped &&
1801-
(last_skipped - first_skipped) >
1802-
sbi->skipped_gc_rwsem) {
1803-
f2fs_drop_inmem_pages_all(sbi, true);
1804-
segno = NULL_SEGNO;
1805-
goto gc_more;
1806-
}
1807-
if (gc_type == FG_GC && !is_sbi_flag_set(sbi, SBI_CP_DISABLED))
1796+
if (skipped_round <= MAX_SKIP_GC_COUNT || skipped_round * 2 < round) {
1797+
1798+
/* Write checkpoint to reclaim prefree segments */
1799+
if (free_sections(sbi) < NR_CURSEG_PERSIST_TYPE &&
1800+
prefree_segments(sbi) &&
1801+
!is_sbi_flag_set(sbi, SBI_CP_DISABLED)) {
18081802
ret = f2fs_write_checkpoint(sbi, &cpc);
1809-
}
1803+
if (ret)
1804+
goto stop;
1805+
}
1806+
segno = NULL_SEGNO;
1807+
goto gc_more;
1808+
}
1809+
if (first_skipped < last_skipped &&
1810+
(last_skipped - first_skipped) >
1811+
sbi->skipped_gc_rwsem) {
1812+
f2fs_drop_inmem_pages_all(sbi, true);
1813+
segno = NULL_SEGNO;
1814+
goto gc_more;
1815+
}
1816+
if (gc_type == FG_GC && !is_sbi_flag_set(sbi, SBI_CP_DISABLED))
1817+
ret = f2fs_write_checkpoint(sbi, &cpc);
18101818
stop:
18111819
SIT_I(sbi)->last_victim[ALLOC_NEXT] = 0;
18121820
SIT_I(sbi)->last_victim[FLUSH_DEVICE] = init_segno;

0 commit comments

Comments
 (0)