Since you comment that you are unclear about the relation and distinction between non-blocking I/O and asynchronous I/O:
I/O operations on a file open in non-blocking mode do not block, even if no data can be transferred immediately. If they transfer less data than was requested (or none at all) then it is up to the caller to try again later if they wish. Nothing is queued for later action.
The POSIX AIO interface provides for I/O operations to be performed asynchronously with respect to the caller's thread. AIO calls return without waiting for the I/O, while that I/O is being attempted in a different execution context. The caller can arrange to be notified in various ways of the completion of the operation (or not). In the meantime, it can perform whatever other work it wants.
There is no particular relationship between these. Neither the POSIX specifications, such as those for aio_read()
, nor the Linux manual for the POSIX AIO interfaces document any requirement that the file on which AIO is performed be in non-blocking mode, nor do they define any error condition for the case that it is in blocking mode. Non-blocking mode is not a requirement.
Indeed, although it is allowed, it would not even be particularly useful to perform AIO on a non-blocking file. If you can rely on your operation not to block, then what do you gain from performing it asynchronously? The main point of AIO is that the caller does not have to wait, but the I/O is performed.