With kernel AIO and O_DIRECT|O_SYNC
, there is no copying into kernel buffers and it is possible to get fine grained notification when data is actually flushed to disk. However, it requires data to be held in user space buffers for io_prep_pwrite()
.
With splice()
, it is possible to move data directly to disk from kernel space buffers (pipes) without never having to copy it around. However, splice()
returns immediately after data is queued and does not wait for actual writes to the disk.
The goal is to move data from sockets to disk without copying it around while getting confirmation that it has been flushed out. How to combine both previous approaches?
By combining splice()
with O_SYNC
, I expect splice()
to block and one has to use multiple threads to mask latency. Alternatively, one could use asynchronous io_prep_fsync()
/io_prep_fdsync()
, but this waits for all data to be flushed, not for a specific write. Neither is perfect.
What would be required is a combination of splice()
with kernel AIO, allowing zero copy and asynchronous confirmation of writes, such that a single event driven thread can move data from sockets to the disk and get confirmations when required, but this doesn't seem to be supported. Is there a good workaround / alternative approach?