public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] New IORING_OP_DUP
@ 2026-03-21 23:21 Daniele Di Proietto
  2026-03-21 23:21 ` [PATCH v3 1/4] io_uring: Extract io_file_get_fixed_node() helper Daniele Di Proietto
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Daniele Di Proietto @ 2026-03-21 23:21 UTC (permalink / raw)
  To: io-uring
  Cc: Jens Axboe, Keith Busch, Pavel Begunkov, linux-fsdevel,
	Alexander Viro, Christian Brauner, Jan Kara, Daniele Di Proietto

The new operation is like dup3(). The source file can be a regular file
descriptor or a direct descriptor. The destination is a regular file
descriptor.

The direct descriptor variant is useful to move a descriptor to an fd
and close the existing fd with a single acquisition of the `struct
files_struct` `file_lock`. Combined with IORING_OP_ACCEPT or
IORING_OP_OPENAT2 with direct descriptors, it can reduce lock contention
for multithreaded applications.

Changes since v2:
* Split the fs/ changes into separate commits
* Minor fixes, as suggested
* Avoided use of gotos in io_dup_to_fd() with guard(), as suggested

v2: https://lore.kernel.org/io-uring/20260320182341.780295-1-daniele.di.proietto@gmail.com/T/#t

Changes since v1:
* Implemented dup to direct descriptors as well
* dup from fd to fd is now atomic
* Punt to io-wq if the operation might sleep
* Removed prep() check on fd
* Avoided use of IOSQE_FIXED_FILE flag

v1: https://lore.kernel.org/io-uring/086190ca-1c34-448f-a565-aa41f671971f@gmail.com/T/#t

Daniele Di Proietto (4):
  io_uring: Extract io_file_get_fixed_node() helper
  fs: Export expand_files()
  fs: Export new helper do_replace_fd_locked()
  io_uring: Add IORING_OP_DUP

 fs/file.c                     | 102 ++++++++++++-------
 fs/internal.h                 |   5 +
 include/uapi/linux/io_uring.h |  17 ++++
 io_uring/io_uring.c           |  20 +++-
 io_uring/io_uring.h           |   2 +
 io_uring/opdef.c              |   8 ++
 io_uring/openclose.c          | 180 ++++++++++++++++++++++++++++++++++
 io_uring/openclose.h          |   4 +
 io_uring/splice.c             |   6 +-
 9 files changed, 298 insertions(+), 46 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2026-03-23 14:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21 23:21 [PATCH v3 0/4] New IORING_OP_DUP Daniele Di Proietto
2026-03-21 23:21 ` [PATCH v3 1/4] io_uring: Extract io_file_get_fixed_node() helper Daniele Di Proietto
2026-03-21 23:21 ` [PATCH v3 2/4] fs: Export expand_files() Daniele Di Proietto
2026-03-21 23:21 ` [PATCH v3 3/4] fs: Export new helper do_replace_fd_locked() Daniele Di Proietto
2026-03-23 12:00   ` Christian Brauner
2026-03-23 14:20     ` Jens Axboe
2026-03-21 23:21 ` [PATCH v3 4/4] io_uring: Add IORING_OP_DUP Daniele Di Proietto
2026-03-23 14:23   ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox