From: Chao Yu Date: Tue, 21 Mar 2017 12:09:45 +0000 (+0800) Subject: f2fs: fix recording invalid last_victim X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9897159a7b1aa98ec0bc8fc053ab822e6634e7fa;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git f2fs: fix recording invalid last_victim When doing garbage collection, we try to record segment offset which locates at next one of last victim, using it as the start offset in next searching. But in some corner cases, recorded offset may cross the end of main segment area, it will cause incorrectly searching in dirty_segmap bitmap. This patch adds modular operation to avoid this issue. Reported-by: Yunlei He Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim --- diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 418fd9881646..939be88a8833 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -361,6 +361,7 @@ next: sbi->last_victim[p.gc_mode] = last_victim + 1; else sbi->last_victim[p.gc_mode] = segno + 1; + sbi->last_victim[p.gc_mode] %= MAIN_SEGS(sbi); break; } }