docs/system/devices/ufs.rst | 55 ++ hw/ufs/lu.c | 930 ++++++++++++++++++++++++++++- hw/ufs/trace-events | 7 + hw/ufs/ufs.c | 45 +- hw/ufs/ufs.h | 46 ++ include/block/ufs.h | 27 + tests/qtest/ufs-test.c | 1368 ++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 2470 insertions(+), 8 deletions(-)
This series lets a ufs-lu be a host-managed zoned block device (ZBC)
with zoned=on, so that the zoned storage stack, for example f2fs on
host-managed zones, can be tested on UFS without zoned UFS hardware.
Patches 1-3 fix the command path that the zoned code relies on and can
be merged first; patch 4 documents zoned logical units, patch 5 adds
them and patch 6 the tests.
Not modelled: persistent zone state, conventional and gap zones, and the
zoned UFS descriptor bits.
Tested with the UFS qtests (also under ASan and UBSan) and with Linux
7.3-rc7 and android17-6.18 guests, legacy doorbell and MCQ: fio
--zonemode=zbd with verification, blkzone, and f2fs on android17-6.18.
Changes in v3:
- 1/6: fail a missing PRDT with OCS MISMATCH DATA BUFFER SIZE instead of
INVALID COMMAND TABLE ATTRIBUTES.
- 3/6, retitled from "Limit data transfers to the transfer length of
the CDB": also fail a request whose PRDT is shorter than the transfer
length, with the same OCS before it reaches scsi-hd, as proposed in
reply to Stanley [1]. ufs_fit_data_buffer() in ufs.c fits the PRDT;
ufs-lu passes it the parsed transfer length. The HID qtest wrote eight
blocks from a one-block buffer and now has eight blocks.
- 5/6: reject WRITE SAME(10/16) on zoned logical units with INVALID
COMMAND OPERATION CODE and clear its bits in the Logical Block
Provisioning VPD page (Stanley). Change the zone of a write only once
scsi-hd has accepted the write: in v2, a write that scsi-hd refused,
for example for its WRPROTECT field, could still open its zone or close
another one. A write with a short PRDT changes no zone either; REPORT
ZONES and the ZBC VPD page follow the same PRDT rule.
- 4/6, 6/6: documentation and tests follow.
- Rebased on current master.
- Link to v2: https://lore.kernel.org/qemu-devel/20261016092423epcms2p83f80a8dd8f7c1ddc3a94541e0771c306@epcms2p8
[1] https://lore.kernel.org/qemu-devel/20261019013307epcms2p14049cf5797cbe5332877ddeb950f18bc@epcms2p1
Changes in v2:
- Drop the hw/scsi patch: scsi-hd stays TYPE_DISK and ufs-lu reports
TYPE_ZBC itself. With v1's TYPE_ZBC scsi-hd, MODE SENSE failed and the
guest never sent a flush.
- New patches 1-3: a crash on commands without a PRDT, SYNCHRONIZE
CACHE(16), and PRDTs longer than the CDB transfer length.
- Fix v1's REPORT ZONES buffer overflow, NULL zone dereference past the
last zone, division by zero with zoned.zone_size=0, and its zone state
handling.
- Move the write pointer back when a write fails or is aborted, reject
UNMAP, drop zoned.zone_capacity.
- Add trace events, tests and documentation.
- Jeuk's Reviewed-by on v1 is not carried over, since both patches
changed substantially.
- Link to v1: https://lore.kernel.org/qemu-devel/20231208060902epcms2p3810b29fefbddaf16a7f3f2758cf218ba@epcms2p3
---
Daejun Park (6):
hw/ufs: Fail SCSI commands that move data without a PRDT
hw/ufs: Pass SYNCHRONIZE CACHE(16) to scsi-hd as SYNCHRONIZE CACHE(10)
hw/ufs: Check the PRDT size against the transfer length of the CDB
docs/system: Document zoned UFS logical units
hw/ufs: Support for Zoned UFS
tests/qtest: Add tests for Zoned UFS
docs/system/devices/ufs.rst | 55 ++
hw/ufs/lu.c | 930 ++++++++++++++++++++++++++++-
hw/ufs/trace-events | 7 +
hw/ufs/ufs.c | 45 +-
hw/ufs/ufs.h | 46 ++
include/block/ufs.h | 27 +
tests/qtest/ufs-test.c | 1368 ++++++++++++++++++++++++++++++++++++++++++-
7 files changed, 2470 insertions(+), 8 deletions(-)
---
base-commit: a19f59a72d96056d9a8f48cf6c77f5787491e414
change-id: 20261016-zoned-ufs-0a6c741446a9
Best regards,
--
Daejun Park <daejun7.park@samsung.com>
Hello Daejun, On Tue, Oct 20, 2026 at 09:16:47AM +0900, Daejun Park wrote: > This series lets a ufs-lu be a host-managed zoned block device (ZBC) > with zoned=on, so that the zoned storage stack, for example f2fs on > host-managed zones, can be tested on UFS without zoned UFS hardware. > Patches 1-3 fix the command path that the zoned code relies on and can > be merged first; patch 4 documents zoned logical units, patch 5 adds > them and patch 6 the tests. > > Not modelled: persistent zone state, conventional and gap zones, and the > zoned UFS descriptor bits. > > Tested with the UFS qtests (also under ASan and UBSan) and with Linux > 7.3-rc7 and android17-6.18 guests, legacy doorbell and MCQ: fio > --zonemode=zbd with verification, blkzone, and f2fs on android17-6.18. This series does not appear to be making use of the zoned block layer APIs that currently exist in QEMU (see e.g. include/block/block-common.h and block/io.c). I know that NVMe currently does not use it, but I don't think we should allow adding zoned storage support in additional storage protocols, if they do not make use of the QEMU zoned block layer APIs. Sam Li has a series that converts NVMe to use the QEMU zoned block layer APIs, even though that series seems to have stalled: https://lore.kernel.org/qemu-devel/20240122190013.41302-1-faithilikerun@gmail.com/ Currently, it is only virtio-blk which is making use of the QEMU zoned block layer APIs, and the only supported backend is file-posix.c. However, there is work in progress to add qcow2 backend support for the QEMU zoned block layer APIs: https://lore.kernel.org/qemu-devel/20261026121259.3354561-1-cassel@kernel.org/ Which requires the (still not merged...) prep series: https://lore.kernel.org/qemu-devel/20260921142819.2916043-1-cassel@kernel.org/ If you make use of the QEMU zoned block layer APIs, you will get support for conventional zones, and will not need to add a UFS property for max_open_zones. Once the qcow2 series lands, you will also get persistence. If you want inspiration, you can see how virtio_blk_zone_report_complete() (hw/block/virtio-blk.c) converts between the QEMU zoned block layer zone states BLK_ZS_* and the virtio-blk VIRTIO_BLK_ZS_* defined zone states. If you want futher inspiration, you could look at my (work in progress) branch (note: this branch is going to be rebased multiple times), which converts between the QEMU zoned block layer zone states BLK_ZS_* and the zone states defined by the Zone ATA Commands (ZAC) specification: https://github.com/floatious/qemu/tree/zac/ Kind regards, Niklas
On Mon, Oct 26, 2026 at 02:04:52PM +0100, Niklas Cassel wrote:
> This series does not appear to be making use of the zoned block layer APIs
> that currently exist in QEMU (see e.g. include/block/block-common.h and
> block/io.c).
Thank you, Niklas. I have reworked the series on the zoned block layer
API, on top of your qcow2 v15. The zones live in the image, and the UFS
logical unit calls blk_co_zone_report() and blk_co_zone_mgmt().
Conventional zones and the open zone limit come from the image, and the
UFS zone properties are gone.
> If you want futher inspiration, you could look at my (work in progress)
> branch (note: this branch is going to be rebased multiple times), which
> converts between the QEMU zoned block layer zone states BLK_ZS_* and the
> zone states defined by the Zone ATA Commands (ZAC) specification:
> https://github.com/floatious/qemu/tree/zac/
v4 uses two commits of that branch:
67ced597c3 scsi: add the sense codes of zoned block devices
4373841591 block: add accessors for the zone model, capacity and open
zone limit
May I post them in v4 under your authorship, as they are? If you would
rather post them yourself, I will base v4 on your posting instead.
One question: qcow2 fails a write to a full zone with
BLK_ZE_UNALIGNED_WRITE, so the guest gets UNALIGNED WRITE COMMAND. A ZBC
device, and scsi_debug, report INVALID FIELD IN CDB there. Would you
take a separate errno for a full zone in v16? Linux with write
pipelining retries UNALIGNED WRITE COMMAND as a reordering.
Two more things you may want to know:
- v4 adds scsi_sense_from_zone_errno() to scsi/utils.c, which maps the
BLK_ZE_* errnos to these sense codes. IDE ZAC could use it instead of
its own copy in ide_sense_for_errno().
- qcow2 v15 calls error_report() on every rejected zone write
(qcow2.c:3582, 3591, 3618, 3633). A guest can fill stderr this way
through any device model.
Daejun
On Tue, 20 Oct 2026 09:16:47 +0900, Daejun Park <daejun7.park@samsung.com> wrote: > Support for Zoned UFS > > This series lets a ufs-lu be a host-managed zoned block device (ZBC) > with zoned=on, so that the zoned storage stack, for example f2fs on > host-managed zones, can be tested on UFS without zoned UFS hardware. > Patches 1-3 fix the command path that the zoned code relies on and can > be merged first; patch 4 documents zoned logical units, patch 5 adds > them and patch 6 the tests. > > [...] Reviewed-by: Jeuk Kim <jeuk20.kim@samsung.com> -- Jeuk Kim <jeuk20.kim@samsung.com>
© 2016 - 2026 Red Hat, Inc.