On Mon, Sep 07, 2026 at 01:07:38PM +0200, Niklas Cassel wrote:
> Deriving the zone that an offset belongs to is open coded in five places,
> in two files, as a division of the offset by BlockLimits.zone_size.
> 
> The zone size of a zoned device is always a power of two. Linux requires
> that of every zoned device it accepts, in blk_revalidate_disk_zones() and
> in each of the drivers that report one, and qcow2 rejects an image whose
> header says otherwise. So the division is a shift, and the shift is worth
> deriving once rather than at every use: record it in BlockLimits as
> zone_size_bits, next to the size it comes from, and assert the property
> that it relies on where it is computed.
> 
> Add bdrv_zone_index() and use it. No functional change; the count of zones
> that a management operation spans stays a division, since it is a length
> rather than an offset.
> 
> Reviewed-by: Damien Le Moal <[email protected]>
> Signed-off-by: Niklas Cassel <[email protected]>
> ---
>  block/file-posix.c               |  8 ++++----
>  block/io.c                       | 12 ++++++++++++
>  hw/block/virtio-blk.c            |  2 +-
>  include/block/block-io.h         |  2 ++
>  include/block/block_int-common.h |  7 +++++++
>  5 files changed, 26 insertions(+), 5 deletions(-)

Reviewed-by: Stefan Hajnoczi <[email protected]>

Attachment: signature.asc
Description: PGP signature

Reply via email to