The block layer from page cache to platter: bio → request → request_queue (merge/sort/plug), single-queue vs blk-mq multi-queue, the I/O schedulers (none/mq-deadline/bfq/kyber) and why SSD/NVMe prefer none, queue knobs in /sys/block, and stacked devices (LVM/RAID/dm-crypt).
The path from a cached page to sectors on a disk — the block layer, the request queue, and the I/O schedulers that decide order. Where filesystem I/O actually meets storage. Original, interview-focused notes; builds on I/O Architecture and the Page Cache.
Above: filesystems produce I/O in units of pages/blocks. The block layer packages those into bio requests, batches and orders them in a queue, and hands them to the driver, which DMAs them to the device. Reordering/merging exists because disks reward locality — and SSDs/NVMe change that calculus.
page cache / direct I/O
│ submit_bio()
block layer: bio → request → request_queue (merge, sort, schedule)
│
device driver → DMA → disk / SSD / NVMe
bio describes a transfer: target sectors + a list of memory pages. The block
layer coalesces contiguous bios into requests and dispatches them.| Scheduler | Idea | Best for |
|---|---|---|
| none / noop | FIFO, no reordering | Fast SSD/NVMe (seeks are free; reordering just adds latency). |
| mq-deadline | Deadlines per request + sorting; bounds worst-case latency | General SSD/HDD; the safe default. |
| bfq | Budget Fair Queueing — per-process fairness & low latency | Desktops/interactive, HDDs. |
| kyber | Simple latency-target throttling | Fast multi-queue devices. |
The key point: on a spinning disk, sorting/merging to minimize seeks is a huge win; on
SSD/NVMe there's no seek, so heavy scheduling just adds overhead — hence none is often
best. Set it via /sys/block/<dev>/queue/scheduler.
/sys/block/<dev>/queue/: scheduler, nr_requests (queue depth),
read_ahead_kb, rotational (1 = HDD), nomerges.iostat -xz 1 (%util, await, IOPS),
blktrace/biolatency (eBPF) for per-I/O latency. See
Performance Triage.none/kyber — avoid reordering overhead)/sys/block/.../queue, iostat)