{
  "status": "shipping",
  "advantages": [
    {
      "text": "After a power or hardware failure the written range holds either all old or all new data, never a mix.",
      "citationIds": [
        "pwritev2"
      ]
    }
  ],
  "limitations": [
    {
      "text": "Filesystem support varies, so limits have to be queried for each file before use.",
      "citationIds": [
        "statx"
      ]
    },
    {
      "text": "Only pwritev2 honours the flag, so ordinary write calls cannot request the protection.",
      "citationIds": [
        "pwritev2"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-22",
  "slug": "rwf-atomic",
  "term": "RWF_ATOMIC",
  "aliases": [],
  "definition": "RWF_ATOMIC is a Linux pwritev2 flag requesting torn-write protection for the data range of a supported direct-I/O write.",
  "note": "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. [pwritev2] [open]\n\nThe 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. [pwritev2]\n\nstatx 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. [statx]",
  "related": [
    "torn-write",
    "statx-write-atomic",
    "direct-io",
    "fsync",
    "advfs-syncv"
  ],
  "citations": [
    {
      "id": "pwritev2",
      "title": "Linux man-pages, readv(2): pwritev2 and RWF_ATOMIC",
      "url": "https://man7.org/linux/man-pages/man2/readv.2.html",
      "accessed": "2026-10-22"
    },
    {
      "id": "open",
      "title": "Linux man-pages, open(2): O_DIRECT, O_DSYNC and O_SYNC",
      "url": "https://man7.org/linux/man-pages/man2/open.2.html",
      "accessed": "2026-10-12"
    },
    {
      "id": "hesela-atomic",
      "title": "Linux atomic writes: untorn does not mean durable",
      "url": "https://hesela.com/analyses/linux-atomic-writes-durability/",
      "accessed": "2026-10-12"
    },
    {
      "id": "statx",
      "title": "Linux man-pages, statx(2): STATX_WRITE_ATOMIC and atomic write limits",
      "url": "https://man7.org/linux/man-pages/man2/statx.2.html",
      "accessed": "2026-10-22"
    }
  ],
  "provenance": [
    "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."
  ]
}
