io_submit() blocks until a previous operation will be completed

大城市里の小女人 提交于 2019-12-11 13:58:00

问题


I'm using the Linux kernel AIO through libaio, and I have to submit the next reading operation before the previous one was completed. The problem is that io_submit() blocks for some time and, as I can deduce from the interval, it waits the previous operation to be completed.

I know that I can enqueue a several operations with a single io_submit(), but it is not an option for me, because I don't know how exactly the next read operation would like when it's already a time to submit the first one.

Is it working like that only for me, or for everyone? In the second case, may I ask if I'm looking for something feasible, or I have to fallback to a threaded model?


回答1:


Frustratingly there are lots of reasons why io_submit may block including:

  • You're doing buffered I/O
  • You're doing I/O into a filesystem and your submission is queued behind a synchronous operation.

It's known that ext4 and AIO may not be the best mix:

Blocking during io_submit on ext4, on buffered operations, network access, pipes, etc. [...] AIO access to a file on a filesystem like ext4 is partially supported: if a metadata read is required to look up the data block (ie if the metadata is not already in memory), then the io_submit call will block on the metadata read. Certain types of file-enlarging writes are completely unsupported and block for the entire duration of the operation.

(extract is from a document that was called AIOUserGuide)

See the asynchronous IO io_submit latency in Ubuntu Linux question for other detailed answers.



来源:https://stackoverflow.com/questions/31175303/io-submit-blocks-until-a-previous-operation-will-be-completed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!