mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
io_uring/net: extract io_send_select_buffer()
Extract a helper out of io_send() for provided buffer selection to improve readability as it has grown to take too many lines. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de> Link: https://lore.kernel.org/r/26a769cdabd61af7f40c5d88a22469c5ad071796.1738087204.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
2b350f756b
commit
86e62354ee
|
|
@ -566,29 +566,12 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
|
|||
return IOU_OK;
|
||||
}
|
||||
|
||||
int io_send(struct io_kiocb *req, unsigned int issue_flags)
|
||||
static int io_send_select_buffer(struct io_kiocb *req, unsigned int issue_flags,
|
||||
struct io_async_msghdr *kmsg)
|
||||
{
|
||||
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
|
||||
struct io_async_msghdr *kmsg = req->async_data;
|
||||
struct socket *sock;
|
||||
unsigned flags;
|
||||
int min_ret = 0;
|
||||
|
||||
int ret;
|
||||
|
||||
sock = sock_from_file(req->file);
|
||||
if (unlikely(!sock))
|
||||
return -ENOTSOCK;
|
||||
|
||||
if (!(req->flags & REQ_F_POLLED) &&
|
||||
(sr->flags & IORING_RECVSEND_POLL_FIRST))
|
||||
return -EAGAIN;
|
||||
|
||||
flags = sr->msg_flags;
|
||||
if (issue_flags & IO_URING_F_NONBLOCK)
|
||||
flags |= MSG_DONTWAIT;
|
||||
|
||||
retry_bundle:
|
||||
if (io_do_buffer_select(req)) {
|
||||
struct buf_sel_arg arg = {
|
||||
.iovs = &kmsg->fast_iov,
|
||||
.max_len = min_not_zero(sr->len, INT_MAX),
|
||||
|
|
@ -627,6 +610,36 @@ retry_bundle:
|
|||
iov_iter_init(&kmsg->msg.msg_iter, ITER_SOURCE,
|
||||
arg.iovs, ret, arg.out_len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int io_send(struct io_kiocb *req, unsigned int issue_flags)
|
||||
{
|
||||
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
|
||||
struct io_async_msghdr *kmsg = req->async_data;
|
||||
struct socket *sock;
|
||||
unsigned flags;
|
||||
int min_ret = 0;
|
||||
int ret;
|
||||
|
||||
sock = sock_from_file(req->file);
|
||||
if (unlikely(!sock))
|
||||
return -ENOTSOCK;
|
||||
|
||||
if (!(req->flags & REQ_F_POLLED) &&
|
||||
(sr->flags & IORING_RECVSEND_POLL_FIRST))
|
||||
return -EAGAIN;
|
||||
|
||||
flags = sr->msg_flags;
|
||||
if (issue_flags & IO_URING_F_NONBLOCK)
|
||||
flags |= MSG_DONTWAIT;
|
||||
|
||||
retry_bundle:
|
||||
if (io_do_buffer_select(req)) {
|
||||
ret = io_send_select_buffer(req, issue_flags, kmsg);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user