Skip to contentSkip to conversation

io_uring: net: fix bug of completing multishot accept twice

PATCH In review Hao Xu 2 participants 4 messages Jun 17, 2022 io_uring

lore
Share & tools
lore

Hao Xu

author
#0 lore raw

PATCH 1/1 io_uring: net: fix bug of completing multishot accept twice

From: Hao Xu <[email protected]>

Now that we use centralized completion in io_issue_sqe, we should skip that for multishot accept requests since we complete them in the specific op function.

Fixes 34106529422e ("io_uring: never defer-complete multi-apoll")

---

I retrieved the history:

in 4e86a2c98013 ("io_uring: implement multishot mode for accept") we add the multishot accept, it repeatly completes cqe in io_accept() until get -EAGAIN [1], then it returns 0 to io_issue_sqe(). io_issue_sqe() does nothing to it then.

in 09eaa49e078c ("io_uring: handle completions in the core") we add __io_req_complete() for IOU_OK in io_issue_sqe(). This causes at [1], we do call __io_req_complete().But since IO_URING_F_COMPLETE_DEFER is set, it does nothing.

in 34106529422e ("io_uring: never defer-complete multi-apoll") we remove IO_URING_F_COMPLETE_DEFER, but unluckily the multishot accept test is broken, we didn't find the error.

So it just has infuence to for-5.20, I'll update the liburing test today.

 io_uring/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/net.c +1 -1
index 207803758222..5097df5b2c46 100644
@@ -630,7 +630,7 @@ int io_accept(struct io_kiocb *req, unsigned int issue_flags)
 			 */
 			if ((req->flags & IO_APOLL_MULTI_POLLED) ==
 			    IO_APOLL_MULTI_POLLED)
-				ret = 0;
+				ret = IOU_ISSUE_SKIP_COMPLETE;
 			return ret;
 		}
 		if (ret == -ERESTARTSYS)

base-commit: 0efaf0d19e9e1271f2275393e62f709907cd40e2

Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 22 lines · Hao Xu

From: Hao Xu <[email protected]>

Now that we use centralized completion in io_issue_sqe, we should skip that for multishot accept requests since we complete them in the specific op function.

Fixes 34106529422e ("io_uring: never defer-complete multi-apoll")

---

I retrieved the history:

in 4e86a2c98013 ("io_uring: implement multishot mode for accept") we add the multishot accept, it repeatly completes cqe in io_accept() until get -EAGAIN [1], then it returns 0 to io_issue_sqe(). io_issue_sqe() does nothing to it then.

in 09eaa49e078c ("io_uring: handle completions in the core") we add __io_req_complete() for IOU_OK in io_issue_sqe(). This causes at [1], we do call __io_req_complete().But since IO_URING_F_COMPLETE_DEFER is set, it does nothing.

Quoted 6 lines

in 34106529422e ("io_uring: never defer-complete multi-apoll") we remove IO_URING_F_COMPLETE_DEFER, but unluckily the multishot accept test is broken, we didn't find the error.

So it just has infuence to for-5.20, I'll update the liburing test today.

Do you mind if I fold this into:

09eaa49e078c ("io_uring: handle completions in the core")

as I'm continually rebasing the 5.20 branch until 5.19 is fully sorted?

Signature · 1 line
Jens Axboe
author
#2 lore raw
Quoted 27 lines · Jens Axboe
Quoted 26 lines · Hao Xu

From: Hao Xu <[email protected]>

Now that we use centralized completion in io_issue_sqe, we should skip that for multishot accept requests since we complete them in the specific op function.

Fixes 34106529422e ("io_uring: never defer-complete multi-apoll")

---

I retrieved the history:

in 4e86a2c98013 ("io_uring: implement multishot mode for accept") we add the multishot accept, it repeatly completes cqe in io_accept() until get -EAGAIN [1], then it returns 0 to io_issue_sqe(). io_issue_sqe() does nothing to it then.

in 09eaa49e078c ("io_uring: handle completions in the core") we add __io_req_complete() for IOU_OK in io_issue_sqe(). This causes at [1], we do call __io_req_complete().But since IO_URING_F_COMPLETE_DEFER is set, it does nothing.

in 34106529422e ("io_uring: never defer-complete multi-apoll") we remove IO_URING_F_COMPLETE_DEFER, but unluckily the multishot accept test is broken, we didn't find the error.

Quoted 9 lines
Quoted 2 lines

So it just has infuence to for-5.20, I'll update the liburing test today.

Do you mind if I fold this into:

09eaa49e078c ("io_uring: handle completions in the core")

as I'm continually rebasing the 5.20 branch until 5.19 is fully sorted?

Please do, that is better.

maintainer
#3 lore raw
Quoted 31 lines · Hao Xu
Quoted 30 lines · Jens Axboe
Quoted 28 lines · Hao Xu

From: Hao Xu <[email protected]>

Now that we use centralized completion in io_issue_sqe, we should skip that for multishot accept requests since we complete them in the specific op function.

Fixes 34106529422e ("io_uring: never defer-complete multi-apoll")

---

I retrieved the history:

in 4e86a2c98013 ("io_uring: implement multishot mode for accept") we add the multishot accept, it repeatly completes cqe in io_accept() until get -EAGAIN [1], then it returns 0 to io_issue_sqe(). io_issue_sqe() does nothing to it then.

in 09eaa49e078c ("io_uring: handle completions in the core") we add __io_req_complete() for IOU_OK in io_issue_sqe(). This causes at [1], we do call __io_req_complete().But since IO_URING_F_COMPLETE_DEFER is set, it does nothing.

in 34106529422e ("io_uring: never defer-complete multi-apoll") we remove IO_URING_F_COMPLETE_DEFER, but unluckily the multishot accept test is broken, we didn't find the error.

So it just has infuence to for-5.20, I'll update the liburing test today.

Quoted 8 lines
Quoted 6 lines

Do you mind if I fold this into:

09eaa49e078c ("io_uring: handle completions in the core")

as I'm continually rebasing the 5.20 branch until 5.19 is fully sorted?

Please do, that is better.

Done, thanks.

Signature · 1 line
Jens Axboe