xref: /qemu/docs/devel/zoned-storage.rst (revision ab4c44d657aeca7e1da6d6dcb1741c8e7d357b8b)
190fd9746SSam Li=============
290fd9746SSam Lizoned-storage
390fd9746SSam Li=============
490fd9746SSam Li
590fd9746SSam LiZoned Block Devices (ZBDs) divide the LBA space into block regions called zones
690fd9746SSam Lithat are larger than the LBA size. They can only allow sequential writes, which
790fd9746SSam Lican reduce write amplification in SSDs, and potentially lead to higher
890fd9746SSam Lithroughput and increased capacity. More details about ZBDs can be found at:
990fd9746SSam Li
1090fd9746SSam Lihttps://zonedstorage.io/docs/introduction/zoned-storage
1190fd9746SSam Li
1290fd9746SSam Li1. Block layer APIs for zoned storage
1390fd9746SSam Li-------------------------------------
1490fd9746SSam LiQEMU block layer supports three zoned storage models:
1590fd9746SSam Li- BLK_Z_HM: The host-managed zoned model only allows sequential writes access
1690fd9746SSam Lito zones. It supports ZBD-specific I/O commands that can be used by a host to
1790fd9746SSam Limanage the zones of a device.
1890fd9746SSam Li- BLK_Z_HA: The host-aware zoned model allows random write operations in
1990fd9746SSam Lizones, making it backward compatible with regular block devices.
2090fd9746SSam Li- BLK_Z_NONE: The non-zoned model has no zones support. It includes both
2190fd9746SSam Liregular and drive-managed ZBD devices. ZBD-specific I/O commands are not
2290fd9746SSam Lisupported.
2390fd9746SSam Li
2490fd9746SSam LiThe block device information resides inside BlockDriverState. QEMU uses
2590fd9746SSam LiBlockLimits struct(BlockDriverState::bl) that is continuously accessed by the
2690fd9746SSam Liblock layer while processing I/O requests. A BlockBackend has a root pointer to
2790fd9746SSam Lia BlockDriverState graph(for example, raw format on top of file-posix). The
2890fd9746SSam Lizoned storage information can be propagated from the leaf BlockDriverState all
2990fd9746SSam Lithe way up to the BlockBackend. If the zoned storage model in file-posix is
3090fd9746SSam Liset to BLK_Z_HM, then block drivers will declare support for zoned host device.
3190fd9746SSam Li
3290fd9746SSam LiThe block layer APIs support commands needed for zoned storage devices,
3390fd9746SSam Liincluding report zones, four zone operations, and zone append.
3490fd9746SSam Li
3590fd9746SSam Li2. Emulating zoned storage controllers
3690fd9746SSam Li--------------------------------------
3790fd9746SSam LiWhen the BlockBackend's BlockLimits model reports a zoned storage device, users
3890fd9746SSam Lilike the virtio-blk emulation or the qemu-io-cmds.c utility can use block layer
3990fd9746SSam LiAPIs for zoned storage emulation or testing.
4090fd9746SSam Li
4190fd9746SSam LiFor example, to test zone_report on a null_blk device using qemu-io is::
4290fd9746SSam Li
4390fd9746SSam Li  $ path/to/qemu-io --image-opts -n driver=host_device,filename=/dev/nullb0 -c "zrp offset nr_zones"
44*01562feeSSam Li
45*01562feeSSam LiTo expose the host's zoned block device through virtio-blk, the command line
46*01562feeSSam Lican be (includes the -device parameter)::
47*01562feeSSam Li
48*01562feeSSam Li  -blockdev node-name=drive0,driver=host_device,filename=/dev/nullb0,cache.direct=on \
49*01562feeSSam Li  -device virtio-blk-pci,drive=drive0
50*01562feeSSam Li
51*01562feeSSam LiOr only use the -drive parameter::
52*01562feeSSam Li
53*01562feeSSam Li  -driver driver=host_device,file=/dev/nullb0,if=virtio,cache.direct=on
54*01562feeSSam Li
55*01562feeSSam LiAdditionally, QEMU has several ways of supporting zoned storage, including:
56*01562feeSSam Li(1) Using virtio-scsi: --device scsi-block allows for the passing through of
57*01562feeSSam LiSCSI ZBC devices, enabling the attachment of ZBC or ZAC HDDs to QEMU.
58*01562feeSSam Li(2) PCI device pass-through: While NVMe ZNS emulation is available for testing
59*01562feeSSam Lipurposes, it cannot yet pass through a zoned device from the host. To pass on
60*01562feeSSam Lithe NVMe ZNS device to the guest, use VFIO PCI pass the entire NVMe PCI adapter
61*01562feeSSam Lithrough to the guest. Likewise, an HDD HBA can be passed on to QEMU all HDDs
62*01562feeSSam Liattached to the HBA.
63