Jonathan Corbet published an in-depth article on LWN explaining the iomap layer in the Linux kernel, which handles mapping between filesystem space and storage space, introduced in kernel 4.8 by Christoph Hellwig. This article fills a knowledge gap about a core filesystem component, enabling kernel developers to better understand and use iomap for efficient I/O and reducing boilerplate code in filesystem implementations. The iomap structure uses a single struct to represent large extents, replacing the older buffer-head mechanism, and supports both block devices and DAX persistent memory. It consists of a low-level mapping layer and a higher-level operation layer.
Background
Before iomap, the Linux kernel used buffer heads to map between disk blocks and memory, which were inefficient for large files and extent-based filesystems. iomap was initially derived from XFS's existing implementation and has since been adopted by many filesystems like ext4 and btrfs for direct I/O. It provides a unified interface for both buffered and direct I/O operations.
References
- 1. Library Design — The Linux Kernel documentation
- KernelProjects/iomap - Linux Kernel Newbies linux/Documentation/filesystems/iomap/design.rst at master ... iomap: Buffered I/O and Direct I/O Mapping | torvalds/linux ... News [LWN.net] [$] The kernel's iomap layer - Linux.org Filesystems and iomap - LWN.net