From: liujinbao1 <[email protected]> During the f2fs_get_victim process, when the f2fs_need_rand_seg is enabled in select_policy, p->offset is a random value, and the search range is from p->offset to MAIN_SECS. When segno >= last_segment, the loop breaks and exits directly without searching the range from 0 to p->offset.This results in an incomplete search when the random offset is not zero.
Signed-off-by: liujinbao1 <[email protected]> --- fs/f2fs/gc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 384fa7e2085b..100b8fc3e65a 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -781,6 +781,7 @@ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result, unsigned int valid_thresh_ratio = 100; bool is_atgc; int ret = 0; + unsigned int original_offset; mutex_lock(&dirty_i->seglist_lock); last_segment = MAIN_SECS(sbi) * SEGS_PER_SEC(sbi); @@ -799,6 +800,7 @@ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result, p.min_segno = NULL_SEGNO; p.oldest_age = 0; p.min_cost = get_max_cost(sbi, &p); + original_offset = p.offset; is_atgc = (p.gc_mode == GC_AT || p.alloc_mode == AT_SSR); nsearched = 0; @@ -859,11 +861,11 @@ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result, p.offset / p.ofs_unit); segno = unit_no * p.ofs_unit; if (segno >= last_segment) { - if (sm->last_victim[p.gc_mode]) { - last_segment = - sm->last_victim[p.gc_mode]; - sm->last_victim[p.gc_mode] = 0; + if (original_offset != 0) { + last_segment = original_offset; p.offset = 0; + if (sm->last_victim[p.gc_mode]) + sm->last_victim[p.gc_mode] = 0; continue; } break; -- 2.25.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
