RWF_DONTCACHE
RWF_DONTCACHE is a Linux per-operation flag requesting best-effort removal of page-cache content newly instantiated by a buffered read or write.
The flag is documented since Linux 6.14; previously cached ranges are not pruned by the hint, and unsupported targets report EOPNOTSUPP. Writes initiate writeback, which is not a durability guarantee. [1] The v6.14 filemap_read path still copies cached folios to the caller before attempting drop-behind; this is not O_DIRECT or proof of zero-copy transfer. [2]
In Linux v6.14, __filemap_get_folio() clears an existing drop-behind mark when the lookup lacks FGP_DONTCACHE. The buffered-read cleanup path skips dirty or writeback folios and only attempts invalidation after acquiring a nonblocking folio lock. These shared-cache implementation conditions do not promise that another access will keep a folio resident. [2]
The userspace error contract differs from Linux v7.2 NFSD's server DONTCACHE policy: without FOP_DONTCACHE, NFSD continues through buffered I/O without adding the drop-behind flag. Do not infer an NFS server error from the userspace EOPNOTSUPP rule, or successful eviction from the server setting. [5]
Relations
Advantages
- Can limit cache retention for one-pass buffered access while retaining already cached ranges.
Limitations
- No hard guarantee of final cache state, durable completion or improved throughput.
Citations
- Linux man-pages 6.19: readv(2), RWF_DONTCACHE and RWF_DSYNC/RWF_SYNC.
- Linux v6.14 mm/filemap.c: filemap_read and drop-behind read completion.
- Linux v7.2 fs/nfsd/vfs.c: nfsd_iter_read and nfsd_vfs_write capability checks.
Further reading
- Hesela: O_DIRECT alignment and shared page-cache advice
- Linux v7.2 NFSD IO MODES: experimental server read/write policy and DONTCACHE fallback.
Sources & caveats
- NFSD supplement: source review pinned to Linux v7.2, not a feature-introduction date, server benchmark or cache-residency measurement.