public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: fix submission-failure handling for uring-cmd
       [not found] <CGME20220823152018epcas5p3141ae99b73ba495f1501723d7834ee32@epcas5p3.samsung.com>
@ 2022-08-23 15:10 ` Kanchan Joshi
  2022-08-23 15:47   ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Kanchan Joshi @ 2022-08-23 15:10 UTC (permalink / raw)
  To: axboe, asml.silence, io-uring, anuj20.g; +Cc: Kanchan Joshi

If ->uring_cmd returned an error value different from -EAGAIN or
-EIOCBQUEUED, it gets overridden with IOU_OK. This invites trouble
as caller (io_uring core code) handles IOU_OK differently than other
error codes.
Fix this by returning the actual error code.

Signed-off-by: Kanchan Joshi <[email protected]>
---
 io_uring/uring_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
index b0e7feeed365..6f99dbd5d550 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -119,7 +119,7 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
 		if (ret < 0)
 			req_set_fail(req);
 		io_req_set_res(req, ret, 0);
-		return IOU_OK;
+		return ret;
 	}
 
 	return IOU_ISSUE_SKIP_COMPLETE;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] io_uring: fix submission-failure handling for uring-cmd
  2022-08-23 15:10 ` [PATCH] io_uring: fix submission-failure handling for uring-cmd Kanchan Joshi
@ 2022-08-23 15:47   ` Jens Axboe
  2022-08-23 16:47     ` Kanchan Joshi
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2022-08-23 15:47 UTC (permalink / raw)
  To: Kanchan Joshi, asml.silence, io-uring, anuj20.g

On 8/23/22 9:10 AM, Kanchan Joshi wrote:
> If ->uring_cmd returned an error value different from -EAGAIN or
> -EIOCBQUEUED, it gets overridden with IOU_OK. This invites trouble
> as caller (io_uring core code) handles IOU_OK differently than other
> error codes.
> Fix this by returning the actual error code.

Not sure if this is strictly needed, as the cqe error is set just
fine. But I guess some places also check return value of the issue
path.

Applied.

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] io_uring: fix submission-failure handling for uring-cmd
  2022-08-23 15:47   ` Jens Axboe
@ 2022-08-23 16:47     ` Kanchan Joshi
  2022-08-23 17:38       ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Kanchan Joshi @ 2022-08-23 16:47 UTC (permalink / raw)
  To: Jens Axboe; +Cc: asml.silence, io-uring, anuj20.g

[-- Attachment #1: Type: text/plain, Size: 836 bytes --]

On Tue, Aug 23, 2022 at 09:47:39AM -0600, Jens Axboe wrote:
>On 8/23/22 9:10 AM, Kanchan Joshi wrote:
>> If ->uring_cmd returned an error value different from -EAGAIN or
>> -EIOCBQUEUED, it gets overridden with IOU_OK. This invites trouble
>> as caller (io_uring core code) handles IOU_OK differently than other
>> error codes.
>> Fix this by returning the actual error code.
>
>Not sure if this is strictly needed, as the cqe error is set just
>fine. But I guess some places also check return value of the issue
>path.

So I was testing iopoll support and ran into this issue - submission
failed (expected one), control came back to this point, error code
got converted to IOU_OK, and it started polling endlessly for a command
that never got submitted.
io_issue_sqe continued to invoke io_iopoll_req_issued() rather than
bailing out.

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] io_uring: fix submission-failure handling for uring-cmd
  2022-08-23 16:47     ` Kanchan Joshi
@ 2022-08-23 17:38       ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-08-23 17:38 UTC (permalink / raw)
  To: Kanchan Joshi; +Cc: asml.silence, io-uring, anuj20.g

On 8/23/22 10:47, Kanchan Joshi wrote:
> On Tue, Aug 23, 2022 at 09:47:39AM -0600, Jens Axboe wrote:
>> On 8/23/22 9:10 AM, Kanchan Joshi wrote:
>>> If ->uring_cmd returned an error value different from -EAGAIN or
>>> -EIOCBQUEUED, it gets overridden with IOU_OK. This invites trouble
>>> as caller (io_uring core code) handles IOU_OK differently than other
>>> error codes.
>>> Fix this by returning the actual error code.
>>
>> Not sure if this is strictly needed, as the cqe error is set just
>> fine. But I guess some places also check return value of the issue
>> path.
> 
> So I was testing iopoll support and ran into this issue - submission
> failed (expected one), control came back to this point, error code
> got converted to IOU_OK, and it started polling endlessly for a command
> that never got submitted.
> io_issue_sqe continued to invoke io_iopoll_req_issued() rather than
> bailing out.

Ah ok, yes for iopoll it'd make a difference...

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-23 19:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20220823152018epcas5p3141ae99b73ba495f1501723d7834ee32@epcas5p3.samsung.com>
2022-08-23 15:10 ` [PATCH] io_uring: fix submission-failure handling for uring-cmd Kanchan Joshi
2022-08-23 15:47   ` Jens Axboe
2022-08-23 16:47     ` Kanchan Joshi
2022-08-23 17:38       ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox