Commit 4379d5f1 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: rename IORING_OP_FILES_UPDATE

IORING_OP_FILES_UPDATE will be a more generic opcode serving different
resource types, rename it into IORING_OP_RSRC_UPDATE and add subtype
handling.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/0a907133907d9af3415a8a7aa1802c6aa97c03c6.1657643355.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 63809137
...@@ -174,7 +174,8 @@ enum io_uring_op { ...@@ -174,7 +174,8 @@ enum io_uring_op {
IORING_OP_FALLOCATE, IORING_OP_FALLOCATE,
IORING_OP_OPENAT, IORING_OP_OPENAT,
IORING_OP_CLOSE, IORING_OP_CLOSE,
IORING_OP_FILES_UPDATE, IORING_OP_RSRC_UPDATE,
IORING_OP_FILES_UPDATE = IORING_OP_RSRC_UPDATE,
IORING_OP_STATX, IORING_OP_STATX,
IORING_OP_READ, IORING_OP_READ,
IORING_OP_WRITE, IORING_OP_WRITE,
...@@ -223,6 +224,7 @@ enum io_uring_op { ...@@ -223,6 +224,7 @@ enum io_uring_op {
#define IORING_TIMEOUT_ETIME_SUCCESS (1U << 5) #define IORING_TIMEOUT_ETIME_SUCCESS (1U << 5)
#define IORING_TIMEOUT_CLOCK_MASK (IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME) #define IORING_TIMEOUT_CLOCK_MASK (IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME)
#define IORING_TIMEOUT_UPDATE_MASK (IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE) #define IORING_TIMEOUT_UPDATE_MASK (IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE)
/* /*
* sqe->splice_flags * sqe->splice_flags
* extends splice(2) flags * extends splice(2) flags
...@@ -289,6 +291,14 @@ enum io_uring_op { ...@@ -289,6 +291,14 @@ enum io_uring_op {
*/ */
#define IORING_ACCEPT_MULTISHOT (1U << 0) #define IORING_ACCEPT_MULTISHOT (1U << 0)
/*
* IORING_OP_RSRC_UPDATE flags
*/
enum {
IORING_RSRC_UPDATE_FILES,
};
/* /*
* IORING_OP_MSG_RING command types, stored in sqe->addr * IORING_OP_MSG_RING command types, stored in sqe->addr
*/ */
......
...@@ -246,12 +246,13 @@ const struct io_op_def io_op_defs[] = { ...@@ -246,12 +246,13 @@ const struct io_op_def io_op_defs[] = {
.prep = io_close_prep, .prep = io_close_prep,
.issue = io_close, .issue = io_close,
}, },
[IORING_OP_FILES_UPDATE] = { [IORING_OP_RSRC_UPDATE] = {
.audit_skip = 1, .audit_skip = 1,
.iopoll = 1, .iopoll = 1,
.name = "FILES_UPDATE", .name = "RSRC_UPDATE",
.prep = io_files_update_prep, .prep = io_rsrc_update_prep,
.issue = io_files_update, .issue = io_rsrc_update,
.ioprio = 1,
}, },
[IORING_OP_STATX] = { [IORING_OP_STATX] = {
.audit_skip = 1, .audit_skip = 1,
......
...@@ -21,6 +21,7 @@ struct io_rsrc_update { ...@@ -21,6 +21,7 @@ struct io_rsrc_update {
u64 arg; u64 arg;
u32 nr_args; u32 nr_args;
u32 offset; u32 offset;
int type;
}; };
static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov, static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov,
...@@ -657,7 +658,7 @@ __cold int io_register_rsrc(struct io_ring_ctx *ctx, void __user *arg, ...@@ -657,7 +658,7 @@ __cold int io_register_rsrc(struct io_ring_ctx *ctx, void __user *arg,
return -EINVAL; return -EINVAL;
} }
int io_files_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) int io_rsrc_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
{ {
struct io_rsrc_update *up = io_kiocb_to_cmd(req); struct io_rsrc_update *up = io_kiocb_to_cmd(req);
...@@ -671,6 +672,7 @@ int io_files_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -671,6 +672,7 @@ int io_files_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
if (!up->nr_args) if (!up->nr_args)
return -EINVAL; return -EINVAL;
up->arg = READ_ONCE(sqe->addr); up->arg = READ_ONCE(sqe->addr);
up->type = READ_ONCE(sqe->ioprio);
return 0; return 0;
} }
...@@ -713,7 +715,7 @@ static int io_files_update_with_index_alloc(struct io_kiocb *req, ...@@ -713,7 +715,7 @@ static int io_files_update_with_index_alloc(struct io_kiocb *req,
return ret; return ret;
} }
int io_files_update(struct io_kiocb *req, unsigned int issue_flags) static int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
{ {
struct io_rsrc_update *up = io_kiocb_to_cmd(req); struct io_rsrc_update *up = io_kiocb_to_cmd(req);
struct io_ring_ctx *ctx = req->ctx; struct io_ring_ctx *ctx = req->ctx;
...@@ -742,6 +744,17 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags) ...@@ -742,6 +744,17 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
return IOU_OK; return IOU_OK;
} }
int io_rsrc_update(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_rsrc_update *up = io_kiocb_to_cmd(req);
switch (up->type) {
case IORING_RSRC_UPDATE_FILES:
return io_files_update(req, issue_flags);
}
return -EINVAL;
}
int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx, int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx,
struct io_rsrc_node *node, void *rsrc) struct io_rsrc_node *node, void *rsrc)
{ {
......
...@@ -167,6 +167,6 @@ static inline u64 *io_get_tag_slot(struct io_rsrc_data *data, unsigned int idx) ...@@ -167,6 +167,6 @@ static inline u64 *io_get_tag_slot(struct io_rsrc_data *data, unsigned int idx)
return &data->tags[table_idx][off]; return &data->tags[table_idx][off];
} }
int io_files_update(struct io_kiocb *req, unsigned int issue_flags); int io_rsrc_update(struct io_kiocb *req, unsigned int issue_flags);
int io_files_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); int io_rsrc_update_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment