io_uring: extract a io_msg_install_complete helper
Extract a helper called io_msg_install_complete() from io_msg_send_fd(), will be used later. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/1500ca1054cc4286a3ee1c60aacead57fcdfa02a.1670384893.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Родитель
11373026f2
Коммит
1721131016
|
@ -92,36 +92,25 @@ static struct file *io_msg_grab_file(struct io_kiocb *req, unsigned int issue_fl
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int io_msg_send_fd(struct io_kiocb *req, unsigned int issue_flags)
|
static int io_msg_install_complete(struct io_kiocb *req, unsigned int issue_flags)
|
||||||
{
|
{
|
||||||
struct io_ring_ctx *target_ctx = req->file->private_data;
|
struct io_ring_ctx *target_ctx = req->file->private_data;
|
||||||
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
||||||
struct io_ring_ctx *ctx = req->ctx;
|
|
||||||
struct file *src_file = msg->src_file;
|
struct file *src_file = msg->src_file;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (target_ctx == ctx)
|
|
||||||
return -EINVAL;
|
|
||||||
if (!src_file) {
|
|
||||||
src_file = io_msg_grab_file(req, issue_flags);
|
|
||||||
if (!src_file)
|
|
||||||
return -EBADF;
|
|
||||||
msg->src_file = src_file;
|
|
||||||
req->flags |= REQ_F_NEED_CLEANUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely(io_double_lock_ctx(target_ctx, issue_flags)))
|
if (unlikely(io_double_lock_ctx(target_ctx, issue_flags)))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
|
||||||
ret = __io_fixed_fd_install(target_ctx, src_file, msg->dst_fd);
|
ret = __io_fixed_fd_install(target_ctx, src_file, msg->dst_fd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|
||||||
msg->src_file = NULL;
|
msg->src_file = NULL;
|
||||||
req->flags &= ~REQ_F_NEED_CLEANUP;
|
req->flags &= ~REQ_F_NEED_CLEANUP;
|
||||||
|
|
||||||
if (msg->flags & IORING_MSG_RING_CQE_SKIP)
|
if (msg->flags & IORING_MSG_RING_CQE_SKIP)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this fails, the target still received the file descriptor but
|
* If this fails, the target still received the file descriptor but
|
||||||
* wasn't notified of the fact. This means that if this request
|
* wasn't notified of the fact. This means that if this request
|
||||||
|
@ -135,6 +124,25 @@ out_unlock:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int io_msg_send_fd(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);
|
||||||
|
struct io_ring_ctx *ctx = req->ctx;
|
||||||
|
struct file *src_file = msg->src_file;
|
||||||
|
|
||||||
|
if (target_ctx == ctx)
|
||||||
|
return -EINVAL;
|
||||||
|
if (!src_file) {
|
||||||
|
src_file = io_msg_grab_file(req, issue_flags);
|
||||||
|
if (!src_file)
|
||||||
|
return -EBADF;
|
||||||
|
msg->src_file = src_file;
|
||||||
|
req->flags |= REQ_F_NEED_CLEANUP;
|
||||||
|
}
|
||||||
|
return io_msg_install_complete(req, issue_flags);
|
||||||
|
}
|
||||||
|
|
||||||
int io_msg_ring_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
|
int io_msg_ring_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
|
||||||
{
|
{
|
||||||
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
struct io_msg *msg = io_kiocb_to_cmd(req, struct io_msg);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче