diff mbox series

io_uring: Add skip option for __io_sqe_files_update

Message ID 20210126202326.3143037-1-goldstein.w.n@gmail.com (mailing list archive)
State New
Headers show
Series io_uring: Add skip option for __io_sqe_files_update | expand

Commit Message

noah Jan. 26, 2021, 8:23 p.m. UTC
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 <goldstein.w.n@gmail.com>
---
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(+)

Comments

Jens Axboe Feb. 2, 2021, 8:29 p.m. UTC | #1
On 2/2/21 1:16 PM, Noah Goldstein wrote:
> Ping

It's already in.
diff mbox series

Patch

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 {