rwf-atomic · shipping

RWF_ATOMIC

RWF_ATOMIC is a Linux pwritev2 flag requesting torn-write protection for the data range of a supported direct-I/O write.

Related Observatory article: Read on hesela.com

Request geometry must obey the reported size and vector limits, with power-of-two total length and natural offset alignment. Synchronized I/O semantics are separate from this protection, and O_DIRECT alone does not supply O_SYNC guarantees. [1] [2]

The flag dates from Linux 6.11. The length must lie between stx_atomic_write_unit_min and stx_atomic_write_unit_max, so a 32 KiB write at offset 32 KiB is valid but the same write at offset 48 KiB is not. The vector count is capped by stx_atomic_write_segments_max, and buffered writes are not supported. [1]

statx reports these limits through STATX_WRITE_ATOMIC, available for block devices since Linux 6.11 and for files on ext4 and XFS since Linux 6.13. A nonzero stx_atomic_write_unit_max_opt marks the largest size that avoids slower writes. [4]

Relations

related
Torn write, STATX_WRITE_ATOMIC, Direct I/O, fsync, AdvFS syncv

Advantages

  • After a power or hardware failure the written range holds either all old or all new data, never a mix. [1]

Limitations

  • Filesystem support varies, so limits have to be queried for each file before use. [4]
  • Only pwritev2 honours the flag, so ordinary write calls cannot request the protection. [1]

Citations

  1. Linux man-pages, readv(2): pwritev2 and RWF_ATOMIC (accessed 2026-10-22)
  2. Linux man-pages, open(2): O_DIRECT, O_DSYNC and O_SYNC (accessed 2026-10-12)
  3. Linux man-pages, statx(2): STATX_WRITE_ATOMIC and atomic write limits (accessed 2026-10-22)

Further reading

  1. Linux atomic writes: untorn does not mean durable (accessed 2026-10-12)
Sources & caveats
  • pwritev2 is the Linux man-pages readv(2) page, reread on the access date in the RWF_ATOMIC entry.
  • open is the Linux man-pages open(2) page, cited for O_DIRECT and synchronized I/O and not reread.
  • statx is the Linux man-pages statx(2) page, read in the STATX_WRITE_ATOMIC mask and the stx_atomic_write_* fields.
  • 6.11, 32 KiB and 48 KiB come from pwritev2. 6.11 and 6.13 come from statx.

JSON: /data/terms/rwf-atomic.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. RWF_ATOMIC. Hesela. 2026-10-22. https://hesela.dev/terms/rwf-atomic/