In designing a streaming media application, I want to use a single eventprocessing loop for both disk and network I/O. The idea is that the I/Odone in this loop should never block. Doing this for network I/O is prettystandard (i.e. set O_NONBLOCK and use a poll variant).

Asynchronous/nonblocking file I/O has its limitations, however. AIO canonly be used in conjunction with O_DIRECT, and I'd rather be able toutilize the page cache. Even so, it is difficult to mix io_getevents withpoll in a single event loop. You could use mmap/mincore, but there isstill a race between the mincore call and the actual read of the data.

So, have I missed any other tools which would help to solve this problem?

It seems that if we introduced a nonblocking flag for file I/O, thisproblem would be addressed. Call it O_ATOMICREAD or some such thing. It'sactually quite easy to do (patch attached).

I even went so far as to modify squid's aufs store type to use this, sothere is use outside of just the streaming media example given above(though I haven't had time to benchmark it).