block/io_uring: resubmit when result is -EAGAIN
PATCH v2 1/1 block/io_uring: resubmit when result is -EAGAIN
Linux SCSI can throw spurious -EAGAIN in some corner cases in its completion path, which will end up being the result in the completed io_uring request.
Resubmitting such requests should allow block jobs to complete, even if such spurious errors are encountered.
---
Changes from v1:
* Focus on what's relevant for the patch itself in the commit message.
* Add Stefan's comment.
* Add Stefano's R-b tag (I hope that's fine, since there was no change code-wise).
block/io_uring.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
block/io_uring.c +15 -1
@@ -165,7 +165,21 @@ static void luring_process_completions(LuringState *s) total_bytes = ret + luringcb->total_read;if (ret <0 ) { -if (ret == -EINTR ) { +/* +* Only writev/readv/fsync requests on regular files or host block +* devices are submitted. Therefore -EAGAIN is not expected but it's +* known to happen sometimes with Linux SCSI. Submit again and hope +* the request completes successfully. +* +* For more information, see: +* https://lore.kernel.org/io-uring/[email protected]/T/#u +* +* If the code is changed to submit other types of requests in the +* future, then this workaround may need to be extended to deal with +* genuine -EAGAIN results that should not be resubmitted +* immediately. +*/ +if (ret == -EINTR || ret == -EAGAIN ) {luring_resubmit (s, luringcb);continue ; }
Signature · 1 line
2.30.2
Quoted 10 lines · Fabian Ebner
Linux SCSI can throw spurious
-EAGAINin some corner cases in its completion path, which will end up being the result in the completedio_uringrequest.Resubmitting such requests should allow block jobs to complete, even if such spurious errors are encountered.
Co-authored-by Stefan Hajnoczi <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>Signed-off-by Fabian Ebner <[email protected]>
Quoted 8 lines
---
Changes from v1:
* Focus on what's relevant for the patch itself in the commit message.
* Add Stefan's comment.
* Add Stefano's R-b tag (I hope that's fine, since there was no change code-wise).
Yep, it's fine :-)
Thanks,
Stefano
Stefan Hajnoczi
AppliedQuoted 19 lines · Fabian Ebner
Linux SCSI can throw spurious
-EAGAINin some corner cases in its completion path, which will end up being the result in the completedio_uringrequest.Resubmitting such requests should allow block jobs to complete, even if such spurious errors are encountered.
Co-authored-by Stefan Hajnoczi <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>Signed-off-by Fabian Ebner <[email protected]>---
Changes from v1:
* Focus on what's relevant for the patch itself in the commit message.
* Add Stefan's comment.
* Add Stefano's R-b tag (I hope that's fine, since there was no change code-wise).
Quoted 2 lines
block/io_uring.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
Thanks, applied to my block tree:
https://gitlab.com/stefanha/qemu/commits/block
Stefan
Am 29.07.2021 um 11:10 hat Fabian Ebner geschrieben:
Quoted 39 lines
Linux SCSI can throw spurious
-EAGAINin some corner cases in its completion path, which will end up being the result in the completedio_uringrequest.Resubmitting such requests should allow block jobs to complete, even if such spurious errors are encountered.
Co-authored-by Stefan Hajnoczi <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>Signed-off-by Fabian Ebner <[email protected]>---
Changes from v1:
* Focus on what's relevant for the patch itself in the commit message.
* Add Stefan's comment.
* Add Stefano's R-b tag (I hope that's fine, since there was no change code-wise).block/io_uring.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)block/io_uring.c +8
-1@@ -165,7 +165,21 @@ static void luring_process_completions(LuringState *s) total_bytes = ret + luringcb->total_read;if (ret <0 ) { -if (ret == -EINTR ) { +/* +* Only writev/readv/fsync requests on regular files or host block +* devices are submitted. Therefore -EAGAIN is not expected but it's +* known to happen sometimes with Linux SCSI. Submit again and hope +* the request completes successfully. +* +* For more information, see: +* https://lore.kernel.org/io-uring/[email protected]/T/#u
block/io_uring.c static void luring_process_completions(LuringState *s) · line 185
Quoted 10 lines
block/io_uring.c +7
-0+* +* If the code is changed to submit other types of requests in the +* future, then this workaround may need to be extended to deal with +* genuine -EAGAIN results that should not be resubmitted +* immediately. +*/ +if (ret == -EINTR || ret == -EAGAIN ) {luring_resubmit (s, luringcb);continue ; }
Question about the preexisting code, though: luring_resubmit() requires that the caller calls ioq_submit() later so that the request doesn't just sit in a queue without getting any attention, but actually gets submitted to the kernel.
In the call chain ioq_submit() -> luring_process_completions() -> luring_resubmit(), who takes care of that?
Kevin
Quoted 53 lines · Kevin Wolf
Am 29.07.2021 um 11:10 hat Fabian Ebner geschrieben:
Quoted 39 lines
Linux SCSI can throw spurious
-EAGAINin some corner cases in its completion path, which will end up being the result in the completedio_uringrequest.Resubmitting such requests should allow block jobs to complete, even if such spurious errors are encountered.
Co-authored-by Stefan Hajnoczi <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>Signed-off-by Fabian Ebner <[email protected]>---
Changes from v1:
* Focus on what's relevant for the patch itself in the commit message.
* Add Stefan's comment.
* Add Stefano's R-b tag (I hope that's fine, since there was no change code-wise).block/io_uring.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)block/io_uring.c +8
-1@@ -165,7 +165,21 @@ static void luring_process_completions(LuringState *s) total_bytes = ret + luringcb->total_read;if (ret <0 ) { -if (ret == -EINTR ) { +/* +* Only writev/readv/fsync requests on regular files or host block +* devices are submitted. Therefore -EAGAIN is not expected but it's +* known to happen sometimes with Linux SCSI. Submit again and hope +* the request completes successfully. +* +* For more information, see: +* https://lore.kernel.org/io-uring/[email protected]/T/#u block/io_uring.c static void luring_process_completions(LuringState *s) · line 185
Quoted 10 lines
block/io_uring.c +7
-0+* +* If the code is changed to submit other types of requests in the +* future, then this workaround may need to be extended to deal with +* genuine -EAGAIN results that should not be resubmitted +* immediately. +*/ +if (ret == -EINTR || ret == -EAGAIN ) {luring_resubmit (s, luringcb);continue ; }Reviewed-by Kevin Wolf <[email protected]>
Quoted 7 lines
Question about the preexisting code, though:
luring_resubmit()requires that the caller callsioq_submit()later so that the request doesn't just sit in a queue without getting any attention, but actually gets submitted to the kernel.In the call chain
ioq_submit()->luring_process_completions()->luring_resubmit(), who takes care of that?
Mmm, good point.
There should be the same problem with ioq_submit() -> luring_process_completions() -> luring_resubmit_short_read() -> luring_resubmit().
Should we schedule a BH for example in luring_resubmit() to make sure that ioq_submit() is invoked after a resubmission?
Thanks,
Stefano
Am 04.08.2021 um 16:50 hat Stefano Garzarella geschrieben:
Quoted 62 lines · Kevin Wolf
Quoted 53 lines
Am 29.07.2021 um 11:10 hat Fabian Ebner geschrieben:
Quoted 39 lines
Linux SCSI can throw spurious
-EAGAINin some corner cases in its completion path, which will end up being the result in the completedio_uringrequest.Resubmitting such requests should allow block jobs to complete, even if such spurious errors are encountered.
Co-authored-by Stefan Hajnoczi <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>Signed-off-by Fabian Ebner <[email protected]>---
Changes from v1:
* Focus on what's relevant for the patch itself in the commit message.
* Add Stefan's comment.
* Add Stefano's R-b tag (I hope that's fine, since there was no change code-wise).block/io_uring.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)block/io_uring.c +8
-1@@ -165,7 +165,21 @@ static void luring_process_completions(LuringState *s) total_bytes = ret + luringcb->total_read;if (ret <0 ) { -if (ret == -EINTR ) { +/* +* Only writev/readv/fsync requests on regular files or host block +* devices are submitted. Therefore -EAGAIN is not expected but it's +* known to happen sometimes with Linux SCSI. Submit again and hope +* the request completes successfully. +* +* For more information, see: +* https://lore.kernel.org/io-uring/[email protected]/T/#u block/io_uring.c static void luring_process_completions(LuringState *s) · line 185
Quoted 10 lines
block/io_uring.c +7
-0+* +* If the code is changed to submit other types of requests in the +* future, then this workaround may need to be extended to deal with +* genuine -EAGAIN results that should not be resubmitted +* immediately. +*/ +if (ret == -EINTR || ret == -EAGAIN ) {luring_resubmit (s, luringcb);continue ; }Reviewed-by Kevin Wolf <[email protected]>Quoted 7 lines
Question about the preexisting code, though:
luring_resubmit()requires that the caller callsioq_submit()later so that the request doesn't just sit in a queue without getting any attention, but actually gets submitted to the kernel.In the call chain
ioq_submit()->luring_process_completions()->luring_resubmit(), who takes care of that?
Quoted 7 lines
Mmm, good point.
There should be the same problem withioq_submit()->luring_process_completions()->luring_resubmit_short_read()->luring_resubmit().Should we schedule a BH for example in
luring_resubmit()to make sure thatioq_submit()is invoked after a resubmission?
Or just loop in ioq_submit() after calling luring_process_completions() if new requests were added to the queue?
Kevin
Quoted 68 lines · Kevin Wolf
Am 04.08.2021 um 16:50 hat Stefano Garzarella geschrieben:
Quoted 67 lines · Kevin Wolf
Quoted 53 lines
Am 29.07.2021 um 11:10 hat Fabian Ebner geschrieben:
Quoted 39 lines
Linux SCSI can throw spurious
-EAGAINin some corner cases in its completion path, which will end up being the result in the completedio_uringrequest.Resubmitting such requests should allow block jobs to complete, even if such spurious errors are encountered.
Co-authored-by Stefan Hajnoczi <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>Signed-off-by Fabian Ebner <[email protected]>---
Changes from v1:
* Focus on what's relevant for the patch itself in the commit message.
* Add Stefan's comment.
* Add Stefano's R-b tag (I hope that's fine, since there was no change code-wise).block/io_uring.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)block/io_uring.c +8
-1@@ -165,7 +165,21 @@ static void luring_process_completions(LuringState *s) total_bytes = ret + luringcb->total_read;if (ret <0 ) { -if (ret == -EINTR ) { +/* +* Only writev/readv/fsync requests on regular files or host block +* devices are submitted. Therefore -EAGAIN is not expected but it's +* known to happen sometimes with Linux SCSI. Submit again and hope +* the request completes successfully. +* +* For more information, see: +* https://lore.kernel.org/io-uring/[email protected]/T/#u block/io_uring.c static void luring_process_completions(LuringState *s) · line 185
Quoted 10 lines
block/io_uring.c +7
-0+* +* If the code is changed to submit other types of requests in the +* future, then this workaround may need to be extended to deal with +* genuine -EAGAIN results that should not be resubmitted +* immediately. +*/ +if (ret == -EINTR || ret == -EAGAIN ) {luring_resubmit (s, luringcb);continue ; }Reviewed-by Kevin Wolf <[email protected]>Quoted 7 lines
Question about the preexisting code, though:
luring_resubmit()requires that the caller callsioq_submit()later so that the request doesn't just sit in a queue without getting any attention, but actually gets submitted to the kernel.In the call chain
ioq_submit()->luring_process_completions()->luring_resubmit(), who takes care of that?Mmm, good point.
There should be the same problem withioq_submit()->luring_process_completions()->luring_resubmit_short_read()->luring_resubmit().
Quoted 6 lines
Quoted 2 lines
Should we schedule a BH for example in
luring_resubmit()to make sure thatioq_submit()is invoked after a resubmission?Or just loop in
ioq_submit()after callingluring_process_completions()if new requests were added to the queue?
I was just concerned that we might cycle a bit if a request always returns -EAGAIN, while scheduling a task might give room for other devices to queue other requests.
But maybe this happens so occasionally that we might not worry about it...
Stefano