1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/kernel.h>
3 #include <linux/errno.h>
4 #include <linux/file.h>
5 #include <linux/slab.h>
6 #include <linux/io_uring.h>
8 #include <uapi/linux/io_uring.h>
10 #include "io_uring_types.h"
20 int io_msg_ring_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
22 struct io_msg *msg = io_kiocb_to_cmd(req);
24 if (unlikely(sqe->addr || sqe->rw_flags || sqe->splice_fd_in ||
25 sqe->buf_index || sqe->personality))
28 msg->user_data = READ_ONCE(sqe->off);
29 msg->len = READ_ONCE(sqe->len);
33 int io_msg_ring(struct io_kiocb *req, unsigned int issue_flags)
35 struct io_msg *msg = io_kiocb_to_cmd(req);
36 struct io_ring_ctx *target_ctx;
41 if (!io_is_uring_fops(req->file))
45 target_ctx = req->file->private_data;
47 spin_lock(&target_ctx->completion_lock);
48 filled = io_fill_cqe_aux(target_ctx, msg->user_data, msg->len, 0);
49 io_commit_cqring(target_ctx);
50 spin_unlock(&target_ctx->completion_lock);
53 io_cqring_ev_posted(target_ctx);
60 io_req_set_res(req, ret, 0);
61 /* put file to avoid an attempt to IOPOLL the req */
62 io_put_file(req->file);