I am running an application which opens a file in an NFS mount with O_DSYNC
option. The application then writes 6500
bytes of data 1000 times to the file in a loop.
I monitored the client behavior and noticed that it was sending the writes to the underlying filesystem in batches of 4096 and 8192 bytes.
As per man open
, Write operations on a file opened with O_DSYNC
will complete according to the requirements of synchronized I/O data integrity completion. It further says that,
O_DSYNC provides synchronized I/O data integrity completion, meaning write operations will flush data to the underlying hardware, but will only flush metadata updates that are required to allow a subsequent read operation to complete successfully.
I assumed that with O_DSYNC
, write()
call will not return until the underlying filesystem has successfully written the data. That's not what's happening here. NFS client is caching writes and flushing them in multiples of 4k. Why is this so?
Note that, I am using an Amazon EC2 instance running Linux version 4.9, with a page size of 4096.