linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Liu Aleaxander <aleaxander@gmail.com>
To: "Américo Wang" <xiyou.wangcong@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] vfs: does call expand_files when needed
Date: Wed, 18 Nov 2009 15:41:46 +0800	[thread overview]
Message-ID: <b741c2440911172341g2251707fj999482473ab97830@mail.gmail.com> (raw)
In-Reply-To: <2375c9f90911172317x781e22a9y56ecb8e682e8e061@mail.gmail.com>

On Wed, Nov 18, 2009 at 3:17 PM, Américo Wang <xiyou.wangcong@gmail.com> wrote:
>
> On Wed, Nov 18, 2009 at 1:54 PM, Liu Aleaxander <aleaxander@gmail.com> wrote:
> > From: Liu Aleaxander <Aleaxander@gmail.com>
> > 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 <Aleaxander@gmail.com>
> > ---
> >  fs/file.c |   27 ++++++++++++++-------------
> >  1 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:
> >        if (fd < files->next_fd)
> >                fd = files->next_fd;
> >
> > -       if (fd < fdt->max_fds)
> > +       if (likely(fd < fdt->max_fds)) {
> >                fd = find_next_zero_bit(fdt->open_fds->fds_bits,
> >                                           fdt->max_fds, fd);
> > -
> > -       error = expand_files(files, fd);
> > -       if (error < 0)
> > -               goto out;
> > -
> > -       /*
> > -        * If we needed to expand the fs array we
> > -        * might have blocked - try again.
> > -        */
> > -       if (error)
> > -               goto repeat;
> > -
> > +       } else {
> > +               error = expand_files(files, fd);
>
>
> In expand_files(), it has the check for
> ' < fdt->max_fds', so this change is not necessary.

Yeah, indeed. But why we should go into an another function to do a
_double_ check especially we mostly don't need to do that?

>
> > +               if (error < 0)
> > +                       goto out;
> > +
> > +               /*
> > +                * If we needed to expand the fs array we
> > +                * might have blocked - try again.
> > +                */
> > +               if (error)
> > +                       goto repeat;
> > +       }
> > +
> >        if (start <= files->next_fd)
> >                files->next_fd = fd + 1;
> >
> > --
> > 1.6.2.5
> >
> > --
> > regards
> > Liu Aleaxander
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> >



--
regards
Liu Aleaxander
--
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

  reply	other threads:[~2009-11-18  7:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-18  5:54 [PATCH] vfs: does call expand_files when needed Liu Aleaxander
2009-11-18  7:17 ` Américo Wang
2009-11-18  7:41   ` Liu Aleaxander [this message]
2009-11-18  8:35     ` Américo Wang
2009-11-18  8:54       ` Liu Aleaxander
2009-11-18  9:22         ` Américo Wang
2009-11-18  9:37           ` Liu Aleaxander

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b741c2440911172341g2251707fj999482473ab97830@mail.gmail.com \
    --to=aleaxander@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).