Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751409AbdHEFla (ORCPT ); Sat, 5 Aug 2017 01:41:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:35042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751189AbdHEFl2 (ORCPT ); Sat, 5 Aug 2017 01:41:28 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6B5522CB7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=chao@kernel.org Subject: Re: [PATCH] f2fs: fix the size value in __check_sit_bitmap To: Yunlong Song , jaegeuk@kernel.org, yuchao0@huawei.com, yunlong.song@icloud.com Cc: miaoxie@huawei.com, bintian.wang@huawei.com, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, chao@kernel.org References: <1501837635-128934-1-git-send-email-yunlong.song@huawei.com> From: Chao Yu Message-ID: <0f1a4338-9aa7-5427-6ca2-2102027cf3c4@kernel.org> Date: Sat, 5 Aug 2017 13:40:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1501837635-128934-1-git-send-email-yunlong.song@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1014 Lines: 33 On 2017/8/4 17:07, Yunlong Song wrote: > The current size value is not correct and will miss bitmap check. > > Signed-off-by: Yunlong Song Reviewed-by: Chao Yu > --- > fs/f2fs/segment.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index f336f8c..45fb534 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -787,11 +787,14 @@ void __check_sit_bitmap(struct f2fs_sb_info *sbi, > sentry = get_seg_entry(sbi, segno); > offset = GET_BLKOFF_FROM_SEG0(sbi, blk); > > - size = min((unsigned long)(end - blk), max_blocks); > + if (end < START_BLOCK(sbi, segno + 1)) > + size = GET_BLKOFF_FROM_SEG0(sbi, end); > + else > + size = max_blocks; > map = (unsigned long *)(sentry->cur_valid_map); > offset = __find_rev_next_bit(map, size, offset); > f2fs_bug_on(sbi, offset != size); > - blk += size; > + blk = START_BLOCK(sbi, segno + 1); > } > #endif > } >