posix-fadvise · shipping · also posix_fadvise(), file-access advice

posix_fadvise

posix_fadvise is a file-descriptor API that communicates expected data-access patterns as nonbinding advice to the operating system.

Related Observatory article: posix_fadvise on hesela.com

The C interface takes a descriptor, byte offset, byte length and one advice value. A length of zero means all data after the offset, not an empty request; the range need not already exist. The hints are NORMAL, SEQUENTIAL, RANDOM, WILLNEED, DONTNEED and NOREUSE. [1]

Success returns zero; failure returns an error number directly, unlike APIs that return -1 and set errno. Success is not a byte count or proof of residency, eviction or durable completion. WILLNEED requests prefetch, DONTNEED requests cache release, and NOREUSE describes reuse expectations. [1]

The Linux v6.14 generic handler stores NORMAL, SEQUENTIAL, RANDOM and NOREUSE policy on the open file description, while WILLNEED and DONTNEED act on the file mapping. NORMAL restores the device readahead budget and clears RANDOM and NOREUSE; it is not a saved-state undo. The generic DAX/noop path can accept and ignore valid advice, and filesystems may provide their own handler. These are versioned Linux behaviors, not universal effects of the API. [2]

Relations

related
POSIX_FADV_RANDOM, POSIX_FADV_SEQUENTIAL, POSIX_FADV_NOREUSE, POSIX_FADV_DONTNEED, POSIX_FADV_WILLNEED, Open file description, Page cache, readahead (Linux syscall), Buffered I/O

Advantages

  • Expresses access expectations while retaining buffered I/O.

Limitations

  • Is not a file-space reservation operation, a cache-residency guarantee or a substitute for an explicit durability protocol.

Citations

  1. Linux man-pages 6.19: posix_fadvise(2), arguments, advice and return convention. (accessed 2026-11-11)
  2. Linux v6.14 mm/fadvise.c: generic advice, ignored advice and filesystem dispatch. (accessed 2026-11-11)
Sources & caveats
  • Source synthesis of Linux man-pages 6.19 and Linux v6.14 implementation; no new native experiment or performance measurement.

JSON: /data/terms/posix-fadvise.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. posix_fadvise. Hesela. 2026-11-11. https://hesela.dev/terms/posix-fadvise/