From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752258AbbCXEmR (ORCPT ); Tue, 24 Mar 2015 00:42:17 -0400 Received: from mail.kernel.org ([198.145.29.136]:48080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750902AbbCXEmO (ORCPT ); Tue, 24 Mar 2015 00:42:14 -0400 Date: Mon, 23 Mar 2015 21:42:11 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Changman Lee , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/4] f2fs: limit b_size of mapped bh in f2fs_map_bh Message-ID: <20150324044211.GA35842@jaegeuk-mac02.hsd1.ca.comcast.net> References: <002201d06511$16e17c70$44a47550$@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <002201d06511$16e17c70$44a47550$@samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chao, On Mon, Mar 23, 2015 at 10:28:00AM +0800, Chao Yu wrote: > Map bh over max size which caller defined is not needed, limit it in > f2fs_map_bh. > > Signed-off-by: Chao Yu > --- > fs/f2fs/data.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index f0a18a0..a99bc7f 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -255,15 +255,16 @@ static void f2fs_map_bh(struct super_block *sb, pgoff_t pgofs, > struct extent_info *ei, struct buffer_head *bh_result) > { > unsigned int blkbits = sb->s_blocksize_bits; > + unsigned int maxblocks = bh_result->b_size >> blkbits; > size_t count; > > clear_buffer_new(bh_result); > map_bh(bh_result, sb, ei->blk + pgofs - ei->fofs); > count = ei->fofs + ei->len - pgofs; > - if (count < (UINT_MAX >> blkbits)) > - bh_result->b_size = (count << blkbits); > + if (count > maxblocks) > + bh_result->b_size = maxblocks << blkbits; > else > - bh_result->b_size = UINT_MAX; > + bh_result->b_size = count << blkbits; How about using min()? Thanks, > } > > static bool lookup_extent_info(struct inode *inode, pgoff_t pgofs, > -- > 2.3.3