liburing
liburing copied to clipboard
io_uring_submit error behavior questions
I'm working on a project where I need to submit open/read/close tasks for many (mostly small) files (typically ~10k files) from /proc (and subdirs). How would I best size my ring size (batches of 20 files should be possible, but some of the files will take long time to read). Any considerations re number of open files I would need to take care of (apart from hard-linking the close op)?
When submitting multiple SQE by calling io_uring_submit, the manpage states that the number of submitted SQE is returned. Will this always be equal to the number of calls to io_uring_get_sqe (since last submission) on success, or may this number diverge (up or down)?
Furthermore, the manpage states, that on failure to submit -errno is returned. Which errors should be expected? Can submitting a SQE retrieved from io_uring_get_sqe fail to submit? And if so, in which way? How are SQE handled that appeared before the SQE that failed to submit?
Is submission atomic in the sense that it satisfies an all-or-nothing approach for batching requests? Or may io_uring_submit only submit a subset of the SQE it is given?
Assuming I have a ring with depth 8. I want to submit 16 SQE, would it suffice to submit these as 2 batches of 8 each, or would I need to submit the first batch and handle one CQE for each further SQE I want to submit? (Assuming I handle all remaining CQE once I'm done with all the submissions). Are SQE freed up once the resulting CQE are handled or by the act of calling io_uring_submit, or something else?
When submitting multiple SQE by calling io_uring_submit, the manpage states that the number of submitted SQE is returned. Will this always be equal to the number of calls to io_uring_get_sqe (since last submission) on success, or may this number diverge (up or down)?
It will if you set IORING_SETUP_SUBMIT_ALL, otherwise io_uring might halt submission early for some types of errors (mainly when it can't do a allocation for the request or the SQE was not filled correctly)
Furthermore, the manpage states, that on failure to submit -errno is returned. Which errors should be expected?
The submission syscall, e.g. via io_uring_submit, may return -EAGAIN (but only when nothing has been submitted), -ENOMEM (when the first submission by this thread fails to allocate some stuff), and a bunch of errors for misconfigured rings.
Can submitting a SQE retrieved from io_uring_get_sqe fail to submit? And if so, in which way? How are SQE handled that appeared before the SQE that failed to submit?
It can, in which case it'll either post a CQE or the submission syscall will adjust the return value. With IORING_SETUP_SUBMIT_ALL it's only the former option.
Is submission atomic in the sense that it satisfies an all-or-nothing approach for batching requests? Or may io_uring_submit only submit a subset of the SQE it is given?
Mostly answered above, but there are also additional caveats for SQPOLL
Assuming I have a ring with depth 8. I want to submit 16 SQE, would it suffice to submit these as 2 batches of 8 each, or would I need to submit the first batch and handle one CQE for each further SQE I want to submit? (Assuming I handle all remaining CQE once I'm done with all the submissions). Are SQE freed up once the resulting CQE are handled or by the act of calling io_uring_submit, or something else?
It's ok to do multiple submits (exceeding the SQ size) without reaping CQEs. Specifically for your case 8 + 8 is fine