linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Thomas Bertschinger <tahbertschinger@gmail.com>
Cc: io-uring@vger.kernel.org, axboe@kernel.dk,
	linux-fsdevel@vger.kernel.org,  viro@zeniv.linux.org.uk,
	brauner@kernel.org, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 4/6] fhandle: create __do_handle_open() helper
Date: Fri, 15 Aug 2025 12:33:11 +0200	[thread overview]
Message-ID: <CAOQ4uxhg6N1vwkE8PnxEnrLEhGq5SPGB1wg3RPymRx2yn+e6PQ@mail.gmail.com> (raw)
In-Reply-To: <20250814235431.995876-5-tahbertschinger@gmail.com>

On Fri, Aug 15, 2025 at 1:52 AM Thomas Bertschinger
<tahbertschinger@gmail.com> wrote:
>
> do_handle_open() takes care of both opening a file via its file handle,
> and associating it with a file descriptor.
>
> For io_uring, it is useful to do just the opening part separately,
> because io_uring might not want to install it into the main open files
> table when using fixed descriptors.
>
> This creates a helper which will enable io_uring to do that.
>
> Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
> ---
>  fs/fhandle.c  | 24 +++++++++++++++++-------
>  fs/internal.h |  2 ++
>  2 files changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/fs/fhandle.c b/fs/fhandle.c
> index dbb273a26214..b14884a93867 100644
> --- a/fs/fhandle.c
> +++ b/fs/fhandle.c
> @@ -397,8 +397,8 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
>         return retval;
>  }
>
> -static long do_handle_open(int mountdirfd, struct file_handle __user *ufh,
> -                          int open_flag)
> +struct file *__do_handle_open(int mountdirfd, struct file_handle __user *ufh,
> +                             int open_flag)
>  {
>         long retval = 0;
>         struct path path __free(path_put) = {};
> @@ -407,17 +407,27 @@ static long do_handle_open(int mountdirfd, struct file_handle __user *ufh,
>
>         retval = handle_to_path(mountdirfd, ufh, &path, open_flag);
>         if (retval)
> -               return retval;
> -
> -       CLASS(get_unused_fd, fd)(open_flag);
> -       if (fd < 0)
> -               return fd;
> +               return ERR_PTR(retval);
>
>         eops = path.mnt->mnt_sb->s_export_op;
>         if (eops->open)
>                 file = eops->open(&path, open_flag);
>         else
>                 file = file_open_root(&path, "", open_flag, 0);
> +
> +       return file;
> +}
> +
> +static long do_handle_open(int mountdirfd, struct file_handle __user *ufh,
> +                          int open_flag)
> +{
> +       struct file *file;
> +
> +       CLASS(get_unused_fd, fd)(open_flag);
> +       if (fd < 0)
> +               return fd;
> +
> +       file = __do_handle_open(mountdirfd, ufh, open_flag);
>         if (IS_ERR(file))
>                 return PTR_ERR(file);
>
> diff --git a/fs/internal.h b/fs/internal.h
> index af7e0810a90d..26ac6f356313 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -362,3 +362,5 @@ void pidfs_get_root(struct path *path);
>  long do_name_to_handle_at(int dfd, const char __user *name,
>                           struct file_handle __user *handle,
>                           void __user *mnt_id, int flag, int lookup_flags);
> +struct file *__do_handle_open(int mountdirfd, struct file_handle __user *ufh,
> +                             int open_flag);

As I said I displike exported do_XXX() helpers, but I __do_XXX() exported
helpers are much worse.

How about do_filp_handle_open()?

Thanks,
Amir.

  reply	other threads:[~2025-08-15 10:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14 23:54 [PATCHSET RFC 0/6] add support for name_to, open_by_handle_at(2) to io_uring Thomas Bertschinger
2025-08-14 23:54 ` [PATCH 1/6] fhandle: create helper for name_to_handle_at(2) Thomas Bertschinger
2025-08-15 10:21   ` Amir Goldstein
2025-08-15 18:17     ` Thomas Bertschinger
2025-08-14 23:54 ` [PATCH 2/6] io_uring: add support for IORING_OP_NAME_TO_HANDLE_AT Thomas Bertschinger
2025-08-15 10:40   ` Amir Goldstein
2025-08-16  7:43   ` kernel test robot
2025-08-14 23:54 ` [PATCH 3/6] fhandle: do_handle_open() should get FD with user flags Thomas Bertschinger
2025-08-15  9:17   ` Amir Goldstein
2025-08-15 13:46     ` Christian Brauner
2025-08-15 13:51       ` Amir Goldstein
2025-08-19  9:43         ` Christian Brauner
2025-08-15 13:47   ` (subset) " Christian Brauner
2025-08-14 23:54 ` [PATCH 4/6] fhandle: create __do_handle_open() helper Thomas Bertschinger
2025-08-15 10:33   ` Amir Goldstein [this message]
2025-08-14 23:54 ` [PATCH 5/6] io_uring: add __io_open_prep() helper Thomas Bertschinger
2025-08-14 23:54 ` [PATCH 6/6] io_uring: add support for IORING_OP_OPEN_BY_HANDLE_AT Thomas Bertschinger
2025-08-16 10:10   ` kernel test robot
2025-08-15  9:52 ` [PATCHSET RFC 0/6] add support for name_to, open_by_handle_at(2) to io_uring Amir Goldstein
2025-08-15 18:24   ` Thomas Bertschinger
2025-08-19 15:11 ` Jens Axboe
2025-08-20  3:01   ` Thomas Bertschinger
2025-08-20  8:34     ` Amir Goldstein
2025-08-20 15:05       ` Thomas Bertschinger
2025-08-20 19:58         ` Amir Goldstein
2025-08-21  7:47           ` Christian Brauner

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=CAOQ4uxhg6N1vwkE8PnxEnrLEhGq5SPGB1wg3RPymRx2yn+e6PQ@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=tahbertschinger@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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).