[PATCH v5 00/15] block: fix the zone write granularity and the zone append limit

Niklas Cassel posted 15 patches 1 week, 1 day ago
There is a newer version of this series
block/block-backend.c             |  11 +++
block/file-posix.c                |  59 +++++++-----
block/io.c                        |  79 ++++++++++++----
hw/block/block.c                  |  68 ++++++++++++++
hw/block/virtio-blk.c             | 146 ++++++++++++++++++++++++++----
include/block/block-io.h          |  14 +++
include/block/block_int-common.h  |  19 +++-
include/hw/block/block.h          |  14 +++
include/hw/virtio/virtio-blk.h    |   1 +
include/system/block-backend-io.h |   1 +
10 files changed, 349 insertions(+), 63 deletions(-)
[PATCH v5 00/15] block: fix the zone write granularity and the zone append limit
Posted by Niklas Cassel 1 week, 1 day ago
Hello Stefan, Kevin, and everyone else,

This series fixes how QEMU reports and enforces the two constraints that a
zoned device places on a write to a sequential zone: the write granularity,
and the largest zone append that it accepts. It also fixes two bugs in the
zone append emulation in file-posix, one of which a guest can reach.

Most of it is preparation for Sam Li's zoned qcow2 series. The first two
patches are taken directly from there, as they are unrelated to qcow2.

Neither of the two values that this series touches is derived from
BlockLimits any more, which was Stefan's objection to v4: the guest has
been told the value, so it is part of the migration stream, and a
destination host whose disks report something else breaks the guest. The
write granularity now comes from the logical and the physical block size,
the append limit from a property, and a backend that needs more than the
configuration can express is refused at realize. The conditions that hold
for every backend rather than for a particular one moved into the block
layer, where they also cover callers that are not a device model.

Changes since v4:
- Patch 4 is new: a helper to check if a zone is conventional. The device
  model tested that by reaching into bs->wps->wp[] and decoding the bit
  that the block layer encodes it in, which two patches here would have
  added two more instances of.
- Patch 5: derive the granularity from the logical and the physical block
  size rather than from BlockLimits. Document
  BlockLimits.write_granularity. Dropped Damien's Reviewed-by, as the
  derivation itself changed.
- Patch 7: also refuse a backend that needs a coarser granularity than the
  block sizes can express. Dropped Damien's Reviewed-by, as the patch
  gained a check.
- Patch 9 is new: reject an append larger than a zone. This is the bound
  that the device model gives up by no longer deriving its own limit.
- Patch 11: a max-append-sectors property rather than a value derived from
  the backend. It now precedes patch 12, which v4 had first; that way round
  left a commit that reported a zero limit to the guest.
- Patch 12: remove BlockLimits.max_append_sectors, rather than have
  file-posix report max_hw_transfer for it. Nothing reads the field once
  virtio-blk takes its limit from a property, and file-posix was its only
  writer. Damien, your Reviewed-by was for reporting max_hw_transfer, so I
  have dropped it.
- Patch 15 is new: the CoroutineIOCompletion cleanup.

Niklas Cassel (13):
  block: add a helper for the index of the zone an offset falls in
  block: add a helper to check if a zone is conventional
  hw/block: derive the zone write granularity from the block sizes
  virtio-blk: check the write granularity of writes to sequential zones
  hw/block: reject a zoned device that the block sizes cannot address
  block: reject zone appends that are not a multiple of the sector size
  block: reject a zone append that is larger than a zone
  file-posix: remove the zone append write granularity check
  virtio-blk: add a max-append-sectors property
  block: remove BlockLimits.max_append_sectors
  file-posix: reject a zone append past the device capacity
  file-posix: reject a zone append to a full or conventional zone
  block: do not use CoroutineIOCompletion to hold a return value

Sam Li (2):
  block: widen BlockLimits.zone_size to uint64_t
  virtio-blk: do not merge requests across a zone boundary

 block/block-backend.c             |  11 +++
 block/file-posix.c                |  59 +++++++-----
 block/io.c                        |  79 ++++++++++++----
 hw/block/block.c                  |  68 ++++++++++++++
 hw/block/virtio-blk.c             | 146 ++++++++++++++++++++++++++----
 include/block/block-io.h          |  14 +++
 include/block/block_int-common.h  |  19 +++-
 include/hw/block/block.h          |  14 +++
 include/hw/virtio/virtio-blk.h    |   1 +
 include/system/block-backend-io.h |   1 +
 10 files changed, 349 insertions(+), 63 deletions(-)


base-commit: 3b5d71cc3652fa7f5ecc449f05dae3ead2b718d7
-- 
2.55.0
Re: [PATCH v5 00/15] block: fix the zone write granularity and the zone append limit
Posted by Niklas Cassel 1 week, 1 day ago
On Fri, Sep 18, 2026 at 07:29:08PM +0200, Niklas Cassel wrote:
> Hello Stefan, Kevin, and everyone else,
> 
> This series fixes how QEMU reports and enforces the two constraints that a
> zoned device places on a write to a sequential zone: the write granularity,
> and the largest zone append that it accepts. It also fixes two bugs in the
> zone append emulation in file-posix, one of which a guest can reach.
> 
> Most of it is preparation for Sam Li's zoned qcow2 series. The first two
> patches are taken directly from there, as they are unrelated to qcow2.
> 
> Neither of the two values that this series touches is derived from
> BlockLimits any more, which was Stefan's objection to v4: the guest has
> been told the value, so it is part of the migration stream, and a
> destination host whose disks report something else breaks the guest. The
> write granularity now comes from the logical and the physical block size,
> the append limit from a property, and a backend that needs more than the
> configuration can express is refused at realize. The conditions that hold
> for every backend rather than for a particular one moved into the block
> layer, where they also cover callers that are not a device model.
> 
> Changes since v4:
> - Patch 4 is new: a helper to check if a zone is conventional. The device
>   model tested that by reaching into bs->wps->wp[] and decoding the bit
>   that the block layer encodes it in, which two patches here would have
>   added two more instances of.
> - Patch 5: derive the granularity from the logical and the physical block
>   size rather than from BlockLimits. Document
>   BlockLimits.write_granularity. Dropped Damien's Reviewed-by, as the
>   derivation itself changed.
> - Patch 7: also refuse a backend that needs a coarser granularity than the
>   block sizes can express. Dropped Damien's Reviewed-by, as the patch
>   gained a check.
> - Patch 9 is new: reject an append larger than a zone. This is the bound
>   that the device model gives up by no longer deriving its own limit.
> - Patch 11: a max-append-sectors property rather than a value derived from
>   the backend. It now precedes patch 12, which v4 had first; that way round
>   left a commit that reported a zero limit to the guest.
> - Patch 12: remove BlockLimits.max_append_sectors, rather than have
>   file-posix report max_hw_transfer for it. Nothing reads the field once
>   virtio-blk takes its limit from a property, and file-posix was its only
>   writer. Damien, your Reviewed-by was for reporting max_hw_transfer, so I
>   have dropped it.
> - Patch 15 is new: the CoroutineIOCompletion cleanup.

Stefan, it seems like my tooling failed to pick up your tags because they
were multipart messages.... I'm very sorry about that.

Patches that you have reviewed, and are supposed to have your R-b tag:
1, 2, 3, 6, 8, 10, 13, 14



Patches that you need to review - changed so much that I dropped tags:
7, 12

Patches that you need to review - patches that you had comments on:
5, 11

Patches that you need to review - patches that are new:
4, 9, 15



Kind regards,
Niklas