Commit 95eafc74 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring/net: reshuffle error handling

We should prioritise send/recv retry cases over failures, they're more
important. Shuffle -ERESTARTSYS after we handled retries.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/d9059691b30d0963b7269fa4a0c81ee7720555e6.1662639236.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent e9a88428
...@@ -291,13 +291,13 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags) ...@@ -291,13 +291,13 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
if (ret < min_ret) { if (ret < min_ret) {
if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK)) if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK))
return io_setup_async_msg(req, kmsg, issue_flags); return io_setup_async_msg(req, kmsg, issue_flags);
if (ret == -ERESTARTSYS)
ret = -EINTR;
if (ret > 0 && io_net_retry(sock, flags)) { if (ret > 0 && io_net_retry(sock, flags)) {
sr->done_io += ret; sr->done_io += ret;
req->flags |= REQ_F_PARTIAL_IO; req->flags |= REQ_F_PARTIAL_IO;
return io_setup_async_msg(req, kmsg, issue_flags); return io_setup_async_msg(req, kmsg, issue_flags);
} }
if (ret == -ERESTARTSYS)
ret = -EINTR;
req_set_fail(req); req_set_fail(req);
} }
/* fast path, check for non-NULL to avoid function call */ /* fast path, check for non-NULL to avoid function call */
...@@ -352,8 +352,6 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags) ...@@ -352,8 +352,6 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
if (ret < min_ret) { if (ret < min_ret) {
if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK)) if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK))
return -EAGAIN; return -EAGAIN;
if (ret == -ERESTARTSYS)
ret = -EINTR;
if (ret > 0 && io_net_retry(sock, flags)) { if (ret > 0 && io_net_retry(sock, flags)) {
sr->len -= ret; sr->len -= ret;
sr->buf += ret; sr->buf += ret;
...@@ -361,6 +359,8 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags) ...@@ -361,6 +359,8 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
req->flags |= REQ_F_PARTIAL_IO; req->flags |= REQ_F_PARTIAL_IO;
return -EAGAIN; return -EAGAIN;
} }
if (ret == -ERESTARTSYS)
ret = -EINTR;
req_set_fail(req); req_set_fail(req);
} }
if (ret >= 0) if (ret >= 0)
...@@ -751,13 +751,13 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags) ...@@ -751,13 +751,13 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
} }
return ret; return ret;
} }
if (ret == -ERESTARTSYS)
ret = -EINTR;
if (ret > 0 && io_net_retry(sock, flags)) { if (ret > 0 && io_net_retry(sock, flags)) {
sr->done_io += ret; sr->done_io += ret;
req->flags |= REQ_F_PARTIAL_IO; req->flags |= REQ_F_PARTIAL_IO;
return io_setup_async_msg(req, kmsg, issue_flags); return io_setup_async_msg(req, kmsg, issue_flags);
} }
if (ret == -ERESTARTSYS)
ret = -EINTR;
req_set_fail(req); req_set_fail(req);
} else if ((flags & MSG_WAITALL) && (kmsg->msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))) { } else if ((flags & MSG_WAITALL) && (kmsg->msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))) {
req_set_fail(req); req_set_fail(req);
...@@ -847,8 +847,6 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags) ...@@ -847,8 +847,6 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
return -EAGAIN; return -EAGAIN;
} }
if (ret == -ERESTARTSYS)
ret = -EINTR;
if (ret > 0 && io_net_retry(sock, flags)) { if (ret > 0 && io_net_retry(sock, flags)) {
sr->len -= ret; sr->len -= ret;
sr->buf += ret; sr->buf += ret;
...@@ -856,6 +854,8 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags) ...@@ -856,6 +854,8 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
req->flags |= REQ_F_PARTIAL_IO; req->flags |= REQ_F_PARTIAL_IO;
return -EAGAIN; return -EAGAIN;
} }
if (ret == -ERESTARTSYS)
ret = -EINTR;
req_set_fail(req); req_set_fail(req);
} else if ((flags & MSG_WAITALL) && (msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))) { } else if ((flags & MSG_WAITALL) && (msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))) {
out_free: out_free:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment