Skip to content

Commit 9817ad8

Browse files
committed
io_uring/net: remove dependency on REQ_F_PARTIAL_IO for sr->done_io
Ensure that prep handlers always initialize sr->done_io before any potential failure conditions, and with that, we now it's always been set even for the failure case. With that, we don't need to use the REQ_F_PARTIAL_IO flag to gate on that. Additionally, we should not overwrite req->cqe.res unless sr->done_io is actually positive. Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent deaef31 commit 9817ad8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

io_uring/net.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
387387
{
388388
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
389389

390+
sr->done_io = 0;
391+
390392
if (req->opcode == IORING_OP_SEND) {
391393
if (READ_ONCE(sqe->__pad3[0]))
392394
return -EINVAL;
@@ -409,7 +411,6 @@ int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
409411
if (req->ctx->compat)
410412
sr->msg_flags |= MSG_CMSG_COMPAT;
411413
#endif
412-
sr->done_io = 0;
413414
return 0;
414415
}
415416

@@ -631,6 +632,8 @@ int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
631632
{
632633
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
633634

635+
sr->done_io = 0;
636+
634637
if (unlikely(sqe->file_index || sqe->addr2))
635638
return -EINVAL;
636639

@@ -667,7 +670,6 @@ int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
667670
if (req->ctx->compat)
668671
sr->msg_flags |= MSG_CMSG_COMPAT;
669672
#endif
670-
sr->done_io = 0;
671673
sr->nr_multishot_loops = 0;
672674
return 0;
673675
}
@@ -1055,6 +1057,8 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
10551057
struct io_ring_ctx *ctx = req->ctx;
10561058
struct io_kiocb *notif;
10571059

1060+
zc->done_io = 0;
1061+
10581062
if (unlikely(READ_ONCE(sqe->__pad2[0]) || READ_ONCE(sqe->addr3)))
10591063
return -EINVAL;
10601064
/* we don't support IOSQE_CQE_SKIP_SUCCESS just yet */
@@ -1107,8 +1111,6 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
11071111
if (zc->msg_flags & MSG_DONTWAIT)
11081112
req->flags |= REQ_F_NOWAIT;
11091113

1110-
zc->done_io = 0;
1111-
11121114
#ifdef CONFIG_COMPAT
11131115
if (req->ctx->compat)
11141116
zc->msg_flags |= MSG_CMSG_COMPAT;
@@ -1353,7 +1355,7 @@ void io_sendrecv_fail(struct io_kiocb *req)
13531355
{
13541356
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
13551357

1356-
if (req->flags & REQ_F_PARTIAL_IO)
1358+
if (sr->done_io)
13571359
req->cqe.res = sr->done_io;
13581360

13591361
if ((req->flags & REQ_F_NEED_CLEANUP) &&

0 commit comments

Comments
 (0)