linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/11] fhandle, pidfs: allow open_by_handle_at() purely based on file handle
@ 2025-06-24  8:29 Christian Brauner
  2025-06-24  8:29 ` [PATCH v2 01/11] fhandle: raise FILEID_IS_DIR in handle_type Christian Brauner
                   ` (12 more replies)
  0 siblings, 13 replies; 47+ messages in thread
From: Christian Brauner @ 2025-06-24  8:29 UTC (permalink / raw)
  To: Jeff Layton, Chuck Lever, Jan Kara, Amir Goldstein, Simona Vetter
  Cc: linux-fsdevel, linux-nfs, Christian Brauner, stable

Various filesystems such as pidfs and drm support opening file handles
without having to require a file descriptor to identify the filesystem.
The filesystem are global single instances and can be trivially
identified solely on the information encoded in the file handle.

This makes it possible to not have to keep or acquire a sentinal file
descriptor just to pass it to open_by_handle_at() to identify the
filesystem. That's especially useful when such sentinel file descriptor
cannot or should not be acquired.

For pidfs this means a file handle can function as full replacement for
storing a pid in a file. Instead a file handle can be stored and
reopened purely based on the file handle.

Such autonomous file handles can be opened with or without specifying a
a file descriptor. If no proper file descriptor is used the FD_INVALID
sentinel must be passed. This allows us to define further special
negative fd sentinels in the future.

Userspace can trivially test for support by trying to open the file
handle with an invalid file descriptor.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
Changes in v2:
- Simplify the FILEID_PIDFS enum.
- Introduce FD_INVALID.
- Require FD_INVALID for autonomous file handles.
- Link to v1: https://lore.kernel.org/20250623-work-pidfs-fhandle-v1-0-75899d67555f@kernel.org

---
Christian Brauner (11):
      fhandle: raise FILEID_IS_DIR in handle_type
      fhandle: hoist copy_from_user() above get_path_from_fd()
      fhandle: rename to get_path_anchor()
      pidfs: add pidfs_root_path() helper
      fhandle: reflow get_path_anchor()
      uapi/fcntl: mark range as reserved
      uapi/fcntl: add FD_INVALID
      exportfs: add FILEID_PIDFS
      fhandle: add EXPORT_OP_AUTONOMOUS_HANDLES marker
      fhandle, pidfs: support open_by_handle_at() purely based on file handle
      selftests/pidfd: decode pidfd file handles withou having to specify an fd

 fs/fhandle.c                                       | 82 ++++++++++++++--------
 fs/internal.h                                      |  1 +
 fs/pidfs.c                                         | 16 ++++-
 include/linux/exportfs.h                           |  9 ++-
 include/uapi/linux/fcntl.h                         | 17 +++++
 include/uapi/linux/pidfd.h                         | 15 ----
 tools/testing/selftests/pidfd/Makefile             |  2 +-
 tools/testing/selftests/pidfd/pidfd.h              |  6 +-
 .../selftests/pidfd/pidfd_file_handle_test.c       | 60 ++++++++++++++++
 9 files changed, 158 insertions(+), 50 deletions(-)
---
base-commit: 4e3d1e6e1b2d9df9650be14380c534b3c5081ddd
change-id: 20250619-work-pidfs-fhandle-b63ff35c4924


^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2025-06-25  7:53 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24  8:29 [PATCH v2 00/11] fhandle, pidfs: allow open_by_handle_at() purely based on file handle Christian Brauner
2025-06-24  8:29 ` [PATCH v2 01/11] fhandle: raise FILEID_IS_DIR in handle_type Christian Brauner
2025-06-24  9:31   ` Jan Kara
2025-06-24  8:29 ` [PATCH v2 02/11] fhandle: hoist copy_from_user() above get_path_from_fd() Christian Brauner
2025-06-24  9:31   ` Jan Kara
2025-06-24  8:29 ` [PATCH v2 03/11] fhandle: rename to get_path_anchor() Christian Brauner
2025-06-24  9:31   ` Jan Kara
2025-06-24  8:29 ` [PATCH v2 04/11] pidfs: add pidfs_root_path() helper Christian Brauner
2025-06-24  9:31   ` Jan Kara
2025-06-24  8:29 ` [PATCH v2 05/11] fhandle: reflow get_path_anchor() Christian Brauner
2025-06-24  9:16   ` Jan Kara
2025-06-24 10:16     ` Christian Brauner
2025-06-24  8:29 ` [PATCH v2 06/11] uapi/fcntl: mark range as reserved Christian Brauner
2025-06-24  9:16   ` Jan Kara
2025-06-24 10:57   ` Amir Goldstein
2025-06-24 13:47     ` Christian Brauner
2025-06-24  8:29 ` [PATCH v2 07/11] uapi/fcntl: add FD_INVALID Christian Brauner
2025-06-24  9:17   ` Jan Kara
2025-06-24  8:29 ` [PATCH v2 08/11] exportfs: add FILEID_PIDFS Christian Brauner
2025-06-24  9:17   ` Jan Kara
2025-06-24 13:15   ` Amir Goldstein
2025-06-24 13:43     ` Christian Brauner
2025-06-24 14:20       ` Amir Goldstein
2025-06-24  8:29 ` [PATCH v2 09/11] fhandle: add EXPORT_OP_AUTONOMOUS_HANDLES marker Christian Brauner
2025-06-24  9:18   ` Jan Kara
2025-06-24  9:20   ` Jan Kara
2025-06-24 10:16     ` Christian Brauner
2025-06-24  8:29 ` [PATCH v2 10/11] fhandle, pidfs: support open_by_handle_at() purely based on file handle Christian Brauner
2025-06-24  9:30   ` Jan Kara
2025-06-24 10:15     ` Christian Brauner
2025-06-24 10:53     ` Amir Goldstein
2025-06-24 14:28       ` Amir Goldstein
2025-06-24 14:51         ` Christian Brauner
2025-06-24 15:07           ` Amir Goldstein
2025-06-24 15:23             ` Christian Brauner
2025-06-24 17:45               ` Jan Kara
2025-06-24 19:23               ` Amir Goldstein
2025-06-25  7:52                 ` Christian Brauner
2025-06-24 23:07   ` Al Viro
2025-06-25  7:52     ` Christian Brauner
2025-06-24  8:29 ` [PATCH v2 11/11] selftests/pidfd: decode pidfd file handles withou having to specify an fd Christian Brauner
2025-06-24  9:39   ` Jan Kara
2025-06-24 10:58 ` [PATCH v2 00/11] fhandle, pidfs: allow open_by_handle_at() purely based on file handle Amir Goldstein
2025-06-24 10:59 ` Christian Brauner
2025-06-24 14:15   ` Jan Kara
2025-06-24 14:34     ` Amir Goldstein
2025-06-24 14:39     ` Christian Brauner

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).