Message ID | 20240710012659.3415856-1-shengyong@oppo.com (mailing list archive) |
---|---|
State | Accepted |
Commit | e3a19972a49f61775e5e11ac43a663f28cdfb8b2 |
Headers | show |
Series | [f2fs-dev,v3] f2fs: only fragment segment in the same section | expand |
Hello: This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <jaegeuk@kernel.org>: On Wed, 10 Jul 2024 09:26:59 +0800 you wrote: > When new_curseg() is allocating a new segment, if mode=fragment:xxx is > switched on in large section scenario, __get_next_segno() will select > the next segno randomly in the range of [0, maxsegno] in order to > fragment segments. > > If the candidate segno is free, get_new_segment() will use it directly > as the new segment. > > [...] Here is the summary with links: - [f2fs-dev,v3] f2fs: only fragment segment in the same section https://git.kernel.org/jaegeuk/f2fs/c/e3a19972a49f You are awesome, thank you!
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index a0ce3d080f80..161aed632278 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2784,11 +2784,19 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type) unsigned short seg_type = curseg->seg_type; sanity_check_seg_type(sbi, seg_type); - if (f2fs_need_rand_seg(sbi)) - return get_random_u32_below(MAIN_SECS(sbi) * SEGS_PER_SEC(sbi)); + if (__is_large_section(sbi)) { + if (f2fs_need_rand_seg(sbi)) { + unsigned int hint = GET_SEC_FROM_SEG(sbi, curseg->segno); - if (__is_large_section(sbi)) + if (GET_SEC_FROM_SEG(sbi, curseg->segno + 1) != hint) + return curseg->segno; + return get_random_u32_inclusive(curseg->segno + 1, + GET_SEG_FROM_SEC(sbi, hint + 1) - 1); + } return curseg->segno; + } else if (f2fs_need_rand_seg(sbi)) { + return get_random_u32_below(MAIN_SECS(sbi) * SEGS_PER_SEC(sbi)); + } /* inmem log may not locate on any segment after mount */ if (!curseg->inited)