mirror of
https://github.com/torvalds/linux.git
synced 2025-11-02 17:49:03 +02:00
io_uring/msg_ring: refactor a few helper functions
Mostly just to skip them taking an io_kiocb, rather just pass in the ctx and io_msg directly. In preparation for being able to issue a MSG_RING request without having an io_kiocb. No functional changes in this patch. Link: https://lore.kernel.org/r/20240924115932.116167-2-axboe@kernel.dk Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
f4bb2f65bb
commit
95d6c9229a
1 changed files with 20 additions and 11 deletions
|
|
@ -116,14 +116,13 @@ static struct io_kiocb *io_msg_get_kiocb(struct io_ring_ctx *ctx)
|
||||||
return kmem_cache_alloc(req_cachep, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);
|
return kmem_cache_alloc(req_cachep, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int io_msg_data_remote(struct io_kiocb *req)
|
static int io_msg_data_remote(struct io_ring_ctx *target_ctx,
|
||||||
|
struct io_msg *msg)
|
||||||
{
|
{
|
||||||
struct io_ring_ctx *target_ctx = req->file->private_data;
|
|
||||||
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
|
||||||
struct io_kiocb *target;
|
struct io_kiocb *target;
|
||||||
u32 flags = 0;
|
u32 flags = 0;
|
||||||
|
|
||||||
target = io_msg_get_kiocb(req->ctx);
|
target = io_msg_get_kiocb(target_ctx);
|
||||||
if (unlikely(!target))
|
if (unlikely(!target))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
@ -134,10 +133,9 @@ static int io_msg_data_remote(struct io_kiocb *req)
|
||||||
msg->user_data);
|
msg->user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int io_msg_ring_data(struct io_kiocb *req, unsigned int issue_flags)
|
static int __io_msg_ring_data(struct io_ring_ctx *target_ctx,
|
||||||
|
struct io_msg *msg, unsigned int issue_flags)
|
||||||
{
|
{
|
||||||
struct io_ring_ctx *target_ctx = req->file->private_data;
|
|
||||||
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
|
||||||
u32 flags = 0;
|
u32 flags = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
@ -149,7 +147,7 @@ static int io_msg_ring_data(struct io_kiocb *req, unsigned int issue_flags)
|
||||||
return -EBADFD;
|
return -EBADFD;
|
||||||
|
|
||||||
if (io_msg_need_remote(target_ctx))
|
if (io_msg_need_remote(target_ctx))
|
||||||
return io_msg_data_remote(req);
|
return io_msg_data_remote(target_ctx, msg);
|
||||||
|
|
||||||
if (msg->flags & IORING_MSG_RING_FLAGS_PASS)
|
if (msg->flags & IORING_MSG_RING_FLAGS_PASS)
|
||||||
flags = msg->cqe_flags;
|
flags = msg->cqe_flags;
|
||||||
|
|
@ -166,6 +164,14 @@ static int io_msg_ring_data(struct io_kiocb *req, unsigned int issue_flags)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int io_msg_ring_data(struct io_kiocb *req, unsigned int issue_flags)
|
||||||
|
{
|
||||||
|
struct io_ring_ctx *target_ctx = req->file->private_data;
|
||||||
|
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
||||||
|
|
||||||
|
return __io_msg_ring_data(target_ctx, msg, issue_flags);
|
||||||
|
}
|
||||||
|
|
||||||
static struct file *io_msg_grab_file(struct io_kiocb *req, unsigned int issue_flags)
|
static struct file *io_msg_grab_file(struct io_kiocb *req, unsigned int issue_flags)
|
||||||
{
|
{
|
||||||
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
||||||
|
|
@ -271,10 +277,8 @@ static int io_msg_send_fd(struct io_kiocb *req, unsigned int issue_flags)
|
||||||
return io_msg_install_complete(req, issue_flags);
|
return io_msg_install_complete(req, issue_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int io_msg_ring_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
|
static int __io_msg_ring_prep(struct io_msg *msg, const struct io_uring_sqe *sqe)
|
||||||
{
|
{
|
||||||
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
|
||||||
|
|
||||||
if (unlikely(sqe->buf_index || sqe->personality))
|
if (unlikely(sqe->buf_index || sqe->personality))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
@ -291,6 +295,11 @@ int io_msg_ring_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int io_msg_ring_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
|
||||||
|
{
|
||||||
|
return __io_msg_ring_prep(io_kiocb_to_cmd(req, struct io_msg), sqe);
|
||||||
|
}
|
||||||
|
|
||||||
int io_msg_ring(struct io_kiocb *req, unsigned int issue_flags)
|
int io_msg_ring(struct io_kiocb *req, unsigned int issue_flags)
|
||||||
{
|
{
|
||||||
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue