public inbox for [email protected]
 help / color / mirror / Atom feed
From: noah <[email protected]>
To: unlisted-recipients:; (no To-header on input)
Cc: [email protected], [email protected],
	[email protected], [email protected],
	[email protected], [email protected]
Subject: [PATCH] io_uring: Add skip option for __io_sqe_files_update
Date: Tue, 26 Jan 2021 15:23:28 -0500	[thread overview]
Message-ID: <[email protected]> (raw)

This patch adds support for skipping a file descriptor when using
IORING_REGISTER_FILES_UPDATE.  __io_sqe_files_update will skip fds set
to IORING_REGISTER_FILES_SKIP. IORING_REGISTER_FILES_SKIP is inturn
added as a #define in io_uring.h

Signed-off-by: noah <[email protected]>
---
Supporting documentation and tests in liburing can be added in PR284
(https://github.com/axboe/liburing/pull/284) if this patch is applied.
    
 fs/io_uring.c                 | 3 +++
 include/uapi/linux/io_uring.h | 7 +++++++
 2 files changed, 10 insertions(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 2c307dea162b..03748faa5295 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -8039,6 +8039,9 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
 			err = -EFAULT;
 			break;
 		}
+		if (fd == IORING_REGISTER_FILES_SKIP)
+			continue;
+
 		i = array_index_nospec(up->offset + done, ctx->nr_user_files);
 		table = &ctx->file_data->table[i >> IORING_FILE_TABLE_SHIFT];
 		index = i & IORING_FILE_TABLE_MASK;
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index f9f106c54d90..e8b481040fb3 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -298,6 +298,13 @@ struct io_uring_rsrc_update {
 	__aligned_u64 data;
 };
 
+/*
+ * fd value in *((__s32 *)io_uring_rsrc_update->data)
+ */
+
+/* Skip updating fd indexes set to this value */
+#define IORING_REGISTER_FILES_SKIP  (-2)
+
 #define IO_URING_OP_SUPPORTED	(1U << 0)
 
 struct io_uring_probe_op {
-- 
2.29.2


             reply	other threads:[~2021-01-26 23:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26 20:23 noah [this message]
     [not found] ` <CAFUsyfLChkYYjBBtkcAErqrs3XaZ80zaPCB3Qn3rWPYTDd88Mg@mail.gmail.com>
2021-02-02 20:29   ` [PATCH] io_uring: Add skip option for __io_sqe_files_update Jens Axboe

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 \
    [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