Closed ZhenbangYou closed 5 months ago
Generally, yes. Earlier kernels would abort submission on error, you can setup your ring with IORING_SETUP_SUBMIT_ALL to turn that off on more recent kernels. If that is set, and some request has an error while being submitted, a CQE is posted. Without that setup flag, or on early kernels, io_uring would stop submitting when that happened. This condition can cause io_uring_submit() to return less than what was available to submit, with the remainder still in the queue.
Outside of that, yes it always flushes everything and hence the return value of io_uring_submit() will be identical to the number of requests that were prepared since the last submission.
Thanks Jens! These are very helpful!
@axboe I have a follow-up question: if some request has an error while being submitted, will io_uring_submit
return -errno
or the number of successfully submitted SQEs? If it returns the latter, how can I know what error occured (e.g., will that error be shown in a CQE)?
It returns the number of successfully submitted SQEs. For example, if you have 8 queued and number 4 has an error, then it'll return 4 and there will be a CQE posted for the 4th one telling you what error it was. As mentioned earlier, this is how it should just work. Just set IORING_SETUP_SUBMIT_ALL and this is how any submission will work.
I see! Thank you so much! Love this clear answer.
It's sad that the latest WSL only support Linux 5.15, but IORING_SETUP_SUBMIT_ALL
requires 5.18.
People running ancient kernels is the bane of my existence.
Haha. I found 6.1 in WSL's repo. Let me try to grab it. Being unable to use useful new features is really annoying.
Just to be clear, this wasn't a jab at you, just systems/distro using ancient stuff to begin with.
The return value of
io_uring_submit
is the number of successfully submitted SQEs on success. I wonder if this is always equal to the number of SQEs in SQ. Thanks!