public inbox for [email protected]
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <[email protected]>
To: Josh Triplett <[email protected]>
Cc: [email protected],
	"[email protected]" <[email protected]>,
	lkml <[email protected]>,
	Alexander Viro <[email protected]>,
	Arnd Bergmann <[email protected]>, Jens Axboe <[email protected]>,
	Aleksa Sarai <[email protected]>,
	linux-man <[email protected]>,
	Linux API <[email protected]>
Subject: Re: [PATCH v5 0/3] Support userspace-selected fds
Date: Wed, 22 Apr 2020 08:05:43 +0200	[thread overview]
Message-ID: <CAKgNAkjMH6YvHa3LavDo4udDS4CxtJL80uenQN-SVd+Ef0-3Kg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>

[CC += linux-api]

On Wed, 22 Apr 2020 at 07:19, Josh Triplett <[email protected]> wrote:
>
> 5.8 material, not intended for 5.7. Now includes a patch for man-pages,
> attached to this cover letter.
>
> Inspired by the X protocol's handling of XIDs, allow userspace to select
> the file descriptor opened by a call like openat2, so that it can use
> the resulting file descriptor in subsequent system calls without waiting
> for the response to the initial openat2 syscall.
>
> The first patch is independent of the other two; it allows reserving
> file descriptors below a certain minimum for userspace-selected fd
> allocation only.
>
> The second patch implements userspace-selected fd allocation for
> openat2, introducing a new O_SPECIFIC_FD flag and an fd field in struct
> open_how. In io_uring, this allows sequences like openat2/read/close
> without waiting for the openat2 to complete. Multiple such sequences can
> overlap, as long as each uses a distinct file descriptor.
>
> The third patch adds userspace-selected fd allocation to pipe2 as well.
> I did this partly as a demonstration of how simple it is to wire up
> O_SPECIFIC_FD support for any fd-allocating system call, and partly in
> the hopes that this may make it more useful to wire up io_uring support
> for pipe2 in the future.
>
> v5:
>
> Rename padding field to __padding.
> Add tests for non-zero __padding.
> Include patch for man-pages.
>
> v4:
>
> Changed fd field to __u32.
> Expanded and consolidated checks that return -EINVAL for invalid arguments.
> Simplified and commented build_open_how.
> Add documentation comment for fd field.
> Add kselftests.
>
> Thanks to Aleksa Sarai for feedback.
>
> v3:
>
> This new version has an API to atomically increase the minimum fd and
> return the previous minimum, rather than just getting and setting the
> minimum; this makes it easier to allocate a range. (A library that might
> initialize after the program has already opened other file descriptors
> may need to check for existing open fds in the range after reserving it,
> and reserve more fds if needed; this can be done entirely in userspace,
> and we can't really do anything simpler in the kernel due to limitations
> on file-descriptor semantics, so this patch series avoids introducing
> any extra complexity in the kernel.)
>
> This new version also supports a __get_specific_unused_fd_flags call
> which accepts the limit for RLIMIT_NOFILE as an argument, analogous to
> __get_unused_fd_flags, since io_uring needs that to correctly handle
> RLIMIT_NOFILE.
>
> Thanks to Jens Axboe for review and feedback.
>
> v2:
>
> Version 2 was a version incorporated into a larger patch series from Jens Axboe
> on io_uring.
>
> Josh Triplett (3):
>   fs: Support setting a minimum fd for "lowest available fd" allocation
>   fs: openat2: Extend open_how to allow userspace-selected fds
>   fs: pipe2: Support O_SPECIFIC_FD
>
>  fs/fcntl.c                                    |  2 +-
>  fs/file.c                                     | 62 +++++++++++++++++--
>  fs/io_uring.c                                 |  3 +-
>  fs/open.c                                     |  8 ++-
>  fs/pipe.c                                     | 16 +++--
>  include/linux/fcntl.h                         |  5 +-
>  include/linux/fdtable.h                       |  1 +
>  include/linux/file.h                          |  4 ++
>  include/uapi/asm-generic/fcntl.h              |  4 ++
>  include/uapi/linux/openat2.h                  |  3 +
>  include/uapi/linux/prctl.h                    |  3 +
>  kernel/sys.c                                  |  5 ++
>  tools/testing/selftests/openat2/helpers.c     |  2 +-
>  tools/testing/selftests/openat2/helpers.h     | 21 +++++--
>  .../testing/selftests/openat2/openat2_test.c  | 35 ++++++++++-
>  15 files changed, 150 insertions(+), 24 deletions(-)
>
> --
> 2.26.2
>


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

      parent reply	other threads:[~2020-04-22  6:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22  5:19 [PATCH v5 0/3] Support userspace-selected fds Josh Triplett
2020-04-22  5:19 ` [PATCH v5 1/3] fs: Support setting a minimum fd for "lowest available fd" allocation Josh Triplett
2020-04-22  6:06   ` Michael Kerrisk (man-pages)
2020-04-23  1:12   ` Dmitry V. Levin
2020-04-23  4:51     ` Josh Triplett
2020-04-23  9:24   ` Arnd Bergmann
2020-04-22  5:20 ` [PATCH v5 2/3] fs: openat2: Extend open_how to allow userspace-selected fds Josh Triplett
2020-04-22  6:06   ` Michael Kerrisk (man-pages)
2020-04-22  7:55     ` Miklos Szeredi
2020-04-23  0:48       ` Josh Triplett
2020-04-23  4:24         ` Miklos Szeredi
2020-04-23  4:42           ` Josh Triplett
2020-04-23  6:04             ` Miklos Szeredi
2020-04-23  7:33               ` Josh Triplett
2020-04-23  7:45                 ` Miklos Szeredi
2020-04-23  7:57                   ` Miklos Szeredi
2020-04-23  9:20                     ` Miklos Szeredi
2020-04-23  9:46                       ` Miklos Szeredi
2020-04-23  8:06                   ` Josh Triplett
2020-04-22  5:20 ` [PATCH v5 3/3] fs: pipe2: Support O_SPECIFIC_FD Josh Triplett
2020-04-22  6:06   ` Michael Kerrisk (man-pages)
2020-04-22 15:44   ` Florian Weimer
2020-04-23  0:44     ` Josh Triplett
2020-04-22  6:05 ` Michael Kerrisk (man-pages) [this message]

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=CAKgNAkjMH6YvHa3LavDo4udDS4CxtJL80uenQN-SVd+Ef0-3Kg@mail.gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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