From mboxrd@z Thu Jan 1 00:00:00 1970 From: Changli Gao Subject: Re: [PATCH 1/2] fs: optimize mpage_readpage() Date: Sat, 29 May 2010 21:26:47 +0800 Message-ID: References: <1275095926-18345-1-git-send-email-xiaosuo@gmail.com> <20100529121019.GA25092@liondog.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE To: Borislav Petkov , Changli Gao , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Return-path: Received: from mail-px0-f174.google.com ([209.85.212.174]:57565 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752929Ab0E2N1I convert rfc822-to-8bit (ORCPT ); Sat, 29 May 2010 09:27:08 -0400 In-Reply-To: <20100529121019.GA25092@liondog.tnic> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sat, May 29, 2010 at 8:10 PM, Borislav Petkov wrote: > From: Changli Gao > Date: Sat, May 29, 2010 at 09:18:46AM +0800 > >> optimize mpage_readpage() >> >> we don't need to initialize bio, and pass it to do_mpage_readpage() = as >> parameter, as it is returned by do_mpage_readpage(). >> >> Signed-off-by: Changli Gao >> ---- >> =C2=A0fs/mpage.c | =C2=A0 =C2=A04 ++-- >> =C2=A01 file changed, 2 insertions(+), 2 deletions(-) >> diff --git a/fs/mpage.c b/fs/mpage.c >> index fd56ca2..94ff0d1 100644 >> --- a/fs/mpage.c >> +++ b/fs/mpage.c >> @@ -409,14 +409,14 @@ EXPORT_SYMBOL(mpage_readpages); >> =C2=A0 */ >> =C2=A0int mpage_readpage(struct page *page, get_block_t get_block) >> =C2=A0{ >> - =C2=A0 =C2=A0 struct bio *bio =3D NULL; >> + =C2=A0 =C2=A0 struct bio *bio; >> =C2=A0 =C2=A0 =C2=A0 sector_t last_block_in_bio =3D 0; >> =C2=A0 =C2=A0 =C2=A0 struct buffer_head map_bh; >> =C2=A0 =C2=A0 =C2=A0 unsigned long first_logical_block =3D 0; >> >> =C2=A0 =C2=A0 =C2=A0 map_bh.b_state =3D 0; >> =C2=A0 =C2=A0 =C2=A0 map_bh.b_size =3D 0; >> - =C2=A0 =C2=A0 bio =3D do_mpage_readpage(bio, page, 1, &last_block_= in_bio, >> + =C2=A0 =C2=A0 bio =3D do_mpage_readpage(NULL, page, 1, &last_block= _in_bio, >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 &map_bh, &first_logical_block, get_block); >> =C2=A0 =C2=A0 =C2=A0 if (bio) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mpage_bio_submit(RE= AD, bio); > > Nope, I don't think that's a good idea. > > On the one hand, this is a trick to shut up gcc: > > fs/mpage.c: In function =E2=80=98mpage_readpage=E2=80=99: > fs/mpage.c:419: warning: =E2=80=98bio=E2=80=99 is used uninitialized = in this function > > and, on the other hand, make sure bio is NULL and not some random sta= ck > value since bio is explicitly checked for NULL in do_mpage_readpage()= =2E > Did the compiler warning appear after applying my patch? It doesn't happen when I testing it. And I don't pass bio to do_mpage_readpage(), but I pass NULL instead. --=20 Regards=EF=BC=8C Changli Gao(xiaosuo@gmail.com) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html