On 6/15/16, 11:14, "Christoph Hellwig" wrote: >On Wed, Jun 15, 2016 at 03:09:23PM +0000, Trond Myklebust wrote: >> As I said earlier, the problem with that is you end up artificially serialising buffered reads and buffered writes. > >If you actually want to be Posix compiant you need to serialize buffered >reads against buffererd writes - it's just that most Linux file systems >happen to get this wrong. > >> ??? The reads only need a shared lock in order to protect the I/O mode from flipping to O_DIRECT (and relying on page locks to protect against buffered writes). > >Which strictly speaking is not enough, although as said above most >Linux filesystems get this wrong. If you indeed want to keep that >(incorrect) behavior you need another lock. It's defintively not >"simpler", though. > Serialisation is not mandatory in POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html “Writes can be serialized with respect to other reads and writes. If a read() of file data can be proven (by any means) to occur after a write() of the data, it must reflect that write(), even if the calls are made by different processes. A similar requirement applies to multiple write operations to the same file position. This is needed to guarantee the propagation of data from write() calls to subsequent read() calls. This requirement is particularly significant for networked file systems, where some caching schemes violate these semantics.” Disclaimer The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.