Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

f2fs:Fix incomplete search range in f2fs_get_victim when f2fs_need_rand_seg is enabled

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 <liujinbao1@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

liujinbao1 and committed by
Jaegeuk Kim
5604129b 3cf11e6f

+3 -2
+3 -2
fs/f2fs/gc.c
··· 316 316 p->max_search = sbi->max_victim_search; 317 317 318 318 /* let's select beginning hot/small space first. */ 319 - if (f2fs_need_rand_seg(sbi)) 319 + if (f2fs_need_rand_seg(sbi)) { 320 320 p->offset = get_random_u32_below(MAIN_SECS(sbi) * 321 321 SEGS_PER_SEC(sbi)); 322 - else if (type == CURSEG_HOT_DATA || IS_NODESEG(type)) 322 + SIT_I(sbi)->last_victim[p->gc_mode] = p->offset; 323 + } else if (type == CURSEG_HOT_DATA || IS_NODESEG(type)) 323 324 p->offset = 0; 324 325 else 325 326 p->offset = SIT_I(sbi)->last_victim[p->gc_mode];