[PATCH v3 0/6] Support for Zoned UFS

Daejun Park posted 6 patches 3 days, 14 hours ago
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(-)
[PATCH v3 0/6] Support for Zoned UFS
Posted by Daejun Park 3 days, 14 hours ago
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>
Re: [PATCH v3 0/6] Support for Zoned UFS
Posted by Jeuk Kim 1 day, 11 hours ago
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>