Suppose a database reads an 8 KiB page into its own buffer pool. With normal file I/O, Linux may also keep the same data in the page cache, so the page exists in memory twice.
For most applications, this is useful. The page cache provides caching, read-ahead, and buffered writes automatically. But databases often manage their own cache and may want tighter control over memory and I/O.
Linux provides O_DIRECT for this purpose. It performs file I/O while largely bypassing the page cache.
Direct I/O bypasses the page cache for file data, not the operating system or the storage stack.
It also does not guarantee zero copies or durable writes. Choosing between buffered and direct I/O is mainly a decision about caching, memory ownership, alignment requirements, and workload behavior.
This chapter compares buffered and direct I/O data paths, explains O_DIRECT alignment and memory requirements, and examines workload fit, performance trade-offs, mixed-mode hazards, and an important fork interaction.