From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932333AbdCUMMe (ORCPT ); Tue, 21 Mar 2017 08:12:34 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:4441 "EHLO dggrg03-dlp.huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1757265AbdCUMMa (ORCPT ); Tue, 21 Mar 2017 08:12:30 -0400 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH 2/2] f2fs: fix recording invalid last_victim Date: Tue, 21 Mar 2017 20:09:45 +0800 Message-ID: <20170321120945.76050-2-yuchao0@huawei.com> X-Mailer: git-send-email 2.8.2.295.g3f1c1d0 In-Reply-To: <20170321120945.76050-1-yuchao0@huawei.com> References: <20170321120945.76050-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.58D11813.0337,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 12bdc98911ccacf38589cdb650eaef64 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- fs/f2fs/gc.c | 1 + 1 file changed, 1 insertion(+) 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 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi, 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; } } -- 2.8.2.295.g3f1c1d0