O_SYNC
O_SYNC is an open-file status flag requiring write operations to complete with synchronized I/O file integrity, covering data and associated file metadata.
On Linux this provides the completion semantics of a write followed by fsync, whereas O_DSYNC requires only the metadata needed to retrieve the data. Neither flag requires O_DIRECT or means the page cache is bypassed. [1] A positive write result can be shorter than requested: check the returned byte count as well as errors before declaring the application record complete. [2] File synchronization does not by itself establish persistence of a newly created directory entry. [3]
Relations
- related
- o-dsync, fdatasync, fsync, directory-fsync, direct-io, open-file-description
Advantages
- Requests file-integrity completion as part of each write operation.
Limitations
- Does not make multiple writes or files one atomic transaction.
- Does not repair earlier failed writes.
- Metadata synchronization can add work; no universal latency benefit is implied.