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>
19 int io_msg_ring_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
21 struct io_msg *msg = io_kiocb_to_cmd(req);
23 if (unlikely(sqe->addr || sqe->rw_flags || sqe->splice_fd_in ||
24 sqe->buf_index || sqe->personality))
27 msg->user_data = READ_ONCE(sqe->off);
28 msg->len = READ_ONCE(sqe->len);
32 int io_msg_ring(struct io_kiocb *req, unsigned int issue_flags)
34 struct io_msg *msg = io_kiocb_to_cmd(req);
35 struct io_ring_ctx *target_ctx;
39 if (!io_is_uring_fops(req->file))
43 target_ctx = req->file->private_data;
44 if (io_post_aux_cqe(target_ctx, msg->user_data, msg->len, 0))
50 io_req_set_res(req, ret, 0);
51 /* put file to avoid an attempt to IOPOLL the req */
52 io_put_file(req->file);