Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: libc: sync write seek fixup proposal
This tries to solve the problems around multiple queued async writes to the same file for the non-append case, but still needs confirmation and testing. The append-case will work fine when async_write() is called from a synchronous write operation (because that blocks until the write is completed) but will likely end up with reordering or even intertwined writes for async writes to files opened with O_APPEND> POSIX.1-2024 2.8.2 Asynchronous I/O states: "If O_APPEND is set for the file descriptor, or if aio_fildes is associated with a device that is incapable of seeking, write operations append to the file in the same order as the calls were made, with the following exception: under implementation-defined circumstances, such as operation on a multi-processor or when requests of differing priorities are submitted at the same time, the ordering restriction may be relaxed." We could try to do a full write in the append case (just like with O_NONBLOCK), but in that case we would change the normal, synchronous case for a very slight improvment: Since under the hood the Job Registry reverses the order of all incomplete jobs after each run, such a reordering is even likely and by Posix' "relaxed" ordering, doing to do async writes to O_APPEND files doesn't seem like such a great idea anyway. To recap: the current code might even end up with interleaved writes for async writes to a file opened with O_APPEND. This could be mitigated by attempting to write out the write request in full, which would lead to possibly reordered but at least not interleaved writes to O_APPEND files. We currently don't do this, because it would change the write approach for synchronous writes to O_APPEND files as well, which seems like the much saner case, and thus it does not seem like a good tradeoff. Issue genodelabs#5302
- Loading branch information