Zone write plugging
Zone write plugging is a Linux block-layer mechanism that queues writes per sequential zone so that at most one write to each zone is in flight.
It arrived in Linux 6.10 as the replacement for zone write locking, which lived in the mq-deadline scheduler from kernel 4.16 to 6.9. Plugging sits in the upper submission path of the block layer, so write ordering no longer depends on the chosen I/O scheduler. Reads are never plugged. [1]
Each plug tracks a write pointer offset for its zone. A regular write that does not start at that offset fails before it reaches the driver, and on devices that need zone append emulation an append is turned into a regular write at the current offset. Native zone append is not plugged. Reset and finish only update the tracked offset and are not serialized with writes, and the source comment leaves it to the user not to issue them while writes are in flight. [2]
Plugs come from a memory pool sized to the larger of the device's open and active zone limits. Without either limit the pool holds at most 128 plugs, and when that is fewer than the sequential zones the kernel sets the open zone limit to the pool size. [2]
Write ordering is not a durability guarantee. Volatile device caches require separate flush or FUA semantics. [5]
Relations
Advantages
- Writes to different zones are not serialized against each other, so a device can still run at high queue depth while several zones are written at once. [1]
Limitations
- After a write error the plug enters an error state that is recovered with a zone report to refresh the write pointer offset, and writes to that zone stay plugged until then. [2]
Citations
- Western Digital, Zoned Storage: Write Ordering Control; locking through Linux 6.9 and plugging from Linux 6.10.
- Linux v6.10, block/blk-zoned.c: blk_zone_plug_bio, blk_zone_wplug_prepare_bio and zone resource sizing.
- Linux v6.10: Explicit volatile write back cache control, completion, REQ_PREFLUSH and REQ_FUA.
Further reading
- Linux v6.10, block/blk-mq.c: blk_mq_submit_bio and zone plugging before request allocation.
- Hesela: ZNS resource limits and worked examples
Sources & caveats
- linux-ordering-docs is the Write Ordering Control page of the zonedstorage.io documentation site published by Western Digital, read in full.
- linux610-zoned is the Linux v6.10 block/blk-zoned.c source, read in blk_zone_plug_bio, blk_zone_wplug_prepare_bio and disk_revalidate_zone_resources.
- The 128-plug default is BLK_ZONE_WPLUG_DEFAULT_POOL_SIZE in that source, and later kernels were not checked for changes.