RWF_SYNC
RWF_SYNC is a Linux per-write flag that requests synchronized file-integrity completion for the range written by pwritev2().
Documented since Linux 4.7, this is the per-call counterpart of O_SYNC, and does not change the synchronization mode stored in the open file description. Within the preadv2/pwritev2 pair, the flag affects writes, not reads; check the returned byte count for a short transfer. [1]
File-integrity completion includes associated file metadata as well as data. It does not require cache bypass or turn several writes into one failure-atomic transaction. [2]
Linux v6.12 combines per-call synchronization bits with inherited open-mode bits: flags=0 does not disable O_SYNC or O_DSYNC. This is source inspection, not a power-loss test. [3]
Relations
Advantages
- Requests file-integrity completion for a selected write without changing the open mode.
Limitations
- Does not provide torn-write protection or a multi-file transaction.
- Does not establish persistence of a new directory entry.
- Does not promise a smaller physical flush or lower latency.
Citations
- Linux man-pages: readv(2), per-write flags and short transfers
- Linux man-pages: open(2), synchronized I/O completion
- Linux v6.12: init_sync_kiocb, iocb_flags, kiocb_set_rw_flags and generic_write_sync