Re: [PATCH] vfs: does call expand_files when needed

From: AmÃrico Wang
Date: Wed Nov 18 2009 - 02:18:07 EST


On Wed, Nov 18, 2009 at 1:54 PM, Liu Aleaxander <aleaxander@xxxxxxxxx> wrote:
> From: Liu Aleaxander <Aleaxander@xxxxxxxxx>
> 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@xxxxxxxxx>
> ---
> Â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.


> + Â Â Â Â Â Â Â 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@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/