{
  "status": "shipping",
  "advantages": [
    {
      "text": "Reading the limits first lets an application size and align atomic writes before issuing them instead of discovering EINVAL afterwards.",
      "citationIds": [
        "readv"
      ]
    }
  ],
  "limitations": [
    {
      "text": "A filesystem without a software fallback reports usable limits only when the device supports hardware atomic writes, so drive-level limits do not establish the capability of a file.",
      "citationIds": [
        "ext4aw"
      ]
    },
    {
      "text": "Torn-write protection applies only to the data range written by the call.",
      "citationIds": [
        "readv"
      ]
    },
    {
      "text": "Writes larger than a nonzero optimized limit may be slower.",
      "citationIds": [
        "statx"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-23",
  "slug": "statx-write-atomic",
  "term": "STATX_WRITE_ATOMIC",
  "aliases": [],
  "definition": "STATX_WRITE_ATOMIC is a Linux statx request for a file's reported atomic-write size limits and maximum vector count.",
  "note": "Requesting STATX_WRITE_ATOMIC asks statx for stx_atomic_write_unit_min, stx_atomic_write_unit_max, stx_atomic_write_segments_max and stx_atomic_write_unit_max_opt. The returned mask must be checked before the fields are read, because a requested capability is not necessarily supported. The minimum and maximum are sizes in bytes for direct I/O with torn-write protection, each a power of 2. Block devices support the query since Linux 6.11, while support on regular files varies by filesystem. [statx]\n\nThe limits govern a later pwritev2 call with RWF_ATOMIC. Its total length must be a power of 2 within the reported range and its offset naturally aligned to that length, so a 32 KiB write at offset 32 KiB is permitted but one at 48 KiB is not, and the vector count must not exceed stx_atomic_write_segments_max. [readv] A nonzero stx_atomic_write_unit_max_opt is an optimized size limit, not the validity ceiling, and zero means stx_atomic_write_unit_max is the optimized limit. [statx] Direct-I/O buffer alignment is a separate query.",
  "related": [
    "rwf-atomic",
    "torn-write",
    "direct-io",
    "direct-io-alignment"
  ],
  "citations": [
    {
      "id": "statx",
      "title": "Linux man-pages 6.19, statx(2): atomic-write fields and returned masks",
      "url": "https://man7.org/linux/man-pages/man2/statx.2.html",
      "accessed": "2026-10-23"
    },
    {
      "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": "readv",
      "title": "Linux man-pages 6.19, readv(2): pwritev2 and RWF_ATOMIC length, alignment and vector rules",
      "url": "https://man7.org/linux/man-pages/man2/readv.2.html",
      "accessed": "2026-10-23"
    },
    {
      "id": "ext4aw",
      "title": "Linux kernel documentation, ext4 data structures and algorithms, section 2.10: Atomic Block Writes",
      "url": "https://docs.kernel.org/filesystems/ext4/atomic_writes.html",
      "accessed": "2026-10-23"
    }
  ],
  "provenance": [
    "statx is the Linux man-pages 6.19 statx(2) page, re-read for the requested fields, the returned mask, the units and the kernel versions.",
    "readv is the Linux man-pages 6.19 readv(2) page, read for the RWF_ATOMIC length, alignment and vector-count rules and the EINVAL cases.",
    "ext4aw is the Linux kernel documentation on ext4 atomic block writes, read for the dependence on hardware atomic-write support.",
    "The pwrite entry links here because the reported limits decide which positioned atomic writes are valid."
  ]
}
