From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Am=C3=A9rico_Wang?= Subject: Re: [PATCH] vfs: does call expand_files when needed Date: Wed, 18 Nov 2009 15:17:59 +0800 Message-ID: <2375c9f90911172317x781e22a9y56ecb8e682e8e061@mail.gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Alexander Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Liu Aleaxander Return-path: Received: from qw-out-2122.google.com ([74.125.92.26]:64420 "EHLO qw-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751330AbZKRHRx convert rfc822-to-8bit (ORCPT ); Wed, 18 Nov 2009 02:17:53 -0500 In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Nov 18, 2009 at 1:54 PM, Liu Aleaxander = wrote: > From: Liu Aleaxander > Date: Wed, 18 Nov 2009 10:59:09 +0800 > Subject: [PATCH] vfs: does call expand_files when needed > > I don't think we should call expand_files every time we open a > file for a new unused fd, so does the expand when necessary. > > Signed-off-by: Liu Aleaxander > --- > =C2=A0fs/file.c | =C2=A0 27 ++++++++++++++------------- > =C2=A01 files changed, 14 insertions(+), 13 deletions(-) > > diff --git a/fs/file.c b/fs/file.c > index 87e1290..3f3d0fc 100644 > --- a/fs/file.c > +++ b/fs/file.c > @@ -452,22 +452,22 @@ repeat: > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fd < files->next_fd) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fd =3D files->= next_fd; > > - =C2=A0 =C2=A0 =C2=A0 if (fd < fdt->max_fds) > + =C2=A0 =C2=A0 =C2=A0 if (likely(fd < fdt->max_fds)) { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fd =3D find_ne= xt_zero_bit(fdt->open_fds->fds_bits, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 fdt->max_fds, fd); > - > - =C2=A0 =C2=A0 =C2=A0 error =3D expand_files(files, fd); > - =C2=A0 =C2=A0 =C2=A0 if (error < 0) > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto out; > - > - =C2=A0 =C2=A0 =C2=A0 /* > - =C2=A0 =C2=A0 =C2=A0 =C2=A0* If we needed to expand the fs array we > - =C2=A0 =C2=A0 =C2=A0 =C2=A0* might have blocked - try again. > - =C2=A0 =C2=A0 =C2=A0 =C2=A0*/ > - =C2=A0 =C2=A0 =C2=A0 if (error) > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto repeat; > - > + =C2=A0 =C2=A0 =C2=A0 } else { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 error =3D expand_f= iles(files, fd); In expand_files(), it has the check for ' < fdt->max_fds', so this change is not necessary. > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (error < 0) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 goto out; > + > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* If we need= ed to expand the fs array we > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* might have= blocked - try again. > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/ > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (error) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 goto repeat; > + =C2=A0 =C2=A0 =C2=A0 } > + > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (start <=3D files->next_fd) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0files->next_fd= =3D fd + 1; > > -- > 1.6.2.5 > > -- > regards > Liu Aleaxander > -- > To unsubscribe from this list: send the line "unsubscribe linux-kerne= l" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at =C2=A0http://vger.kernel.org/majordomo-info.ht= ml > Please read the FAQ at =C2=A0http://www.tux.org/lkml/ > -- 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