o-sync · shipping · also synchronized I/O file integrity completion

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.

Related Observatory article: Read on hesela.com

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]

Configuration: Linux F_SETFL leaves O_SYNC and O_DSYNC unchanged, even when fcntl returns success. Choose the required mode when opening the file, then inspect it with F_GETFL. The Linux v6.12 setfl implementation preserves these bits outside its mutable-flag mask. [5] [6]

Per-write option: pwritev2 RWF_SYNC and RWF_DSYNC request the corresponding synchronized completion for the written range, without changing the descriptor's mode. Check returned bytes and errors; neither flag supplies failure atomicity. [8]

Relations

related
O_DSYNC, fdatasync, fsync, Directory fsync, Direct I/O, Open file description, RWF_SYNC, O_RSYNC

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.

Citations

  1. Linux man-pages 6.19: open(2), O_SYNC and O_DSYNC (accessed 2026-10-15)
  2. POSIX.1-2024: write(), synchronized I/O and partial writes (accessed 2026-10-15)
  3. Linux man-pages 6.19: fsync(2), metadata and directory synchronization (accessed 2026-10-15)
  4. Linux man-pages 6.19: F_GETFL and F_SETFL, unchanged synchronization flags (accessed 2026-11-05)
  5. Linux v6.12: fs/fcntl.c, SETFL_MASK and setfl() (accessed 2026-11-05)
  6. Linux man-pages 6.19: pwritev2(), per-write synchronization flags (accessed 2026-11-05)

Further reading

  1. Hesela: Why retrying a failed fsync does not prove durability (accessed 2026-10-15)
  2. Hesela: Linux atomic writes and synchronization configuration (accessed 2026-11-05)

JSON: /data/terms/o-sync.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. O_SYNC. Hesela. 2026-11-12. https://hesela.dev/terms/o-sync/