mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 14:48:06 +00:00
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>
This commit is contained in:
parent
d27c3d89db
commit
19f4e688f8
1 changed files with 9 additions and 8 deletions
17
fs/f2fs/gc.c
17
fs/f2fs/gc.c
|
@ -953,21 +953,22 @@ gc_more:
|
||||||
goto stop;
|
goto stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gc_type == BG_GC && has_not_enough_free_secs(sbi, sec_freed, 0)) {
|
if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) {
|
||||||
gc_type = FG_GC;
|
|
||||||
/*
|
/*
|
||||||
* If there is no victim and no prefree segment but still not
|
* For example, if there are many prefree_segments below given
|
||||||
* enough free sections, we should flush dent/node blocks and do
|
* threshold, we can make them free by checkpoint. Then, we
|
||||||
* garbage collections.
|
* secure free segments which doesn't need fggc any more.
|
||||||
*/
|
*/
|
||||||
ret = write_checkpoint(sbi, &cpc);
|
ret = write_checkpoint(sbi, &cpc);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto stop;
|
goto stop;
|
||||||
} else if (gc_type == BG_GC && !background) {
|
if (has_not_enough_free_secs(sbi, 0, 0))
|
||||||
/* f2fs_balance_fs doesn't need to do BG_GC in critical path. */
|
gc_type = FG_GC;
|
||||||
goto stop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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))
|
if (!__get_victim(sbi, &segno, gc_type))
|
||||||
goto stop;
|
goto stop;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue