io_uring: Add skip option for __io_sqe_files_update
authornoah <goldstein.w.n@gmail.com>
Tue, 26 Jan 2021 20:23:28 +0000 (15:23 -0500)
committerJens Axboe <axboe@kernel.dk>
Mon, 1 Feb 2021 17:02:43 +0000 (10:02 -0700)
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>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c
include/uapi/linux/io_uring.h

index 0ca99bd..dd83a64 100644 (file)
@@ -8038,6 +8038,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;
index f9f106c..ac4e173 100644 (file)
@@ -298,6 +298,9 @@ struct io_uring_rsrc_update {
        __aligned_u64 data;
 };
 
+/* Skip updating fd indexes set to this value in the fd table */
+#define IORING_REGISTER_FILES_SKIP     (-2)
+
 #define IO_URING_OP_SUPPORTED  (1U << 0)
 
 struct io_uring_probe_op {