[PATCH v2 0/2] block: two fixes for the zone report ioctls
From: Shashank Mohan Jain
Date: Sun Oct 11 2026 - 12:16:47 EST
Two problems in the zone report code added in v6.19:
- BLKREPORTZONEV2 does not look at BLK_ZONE_REP_CACHED and returns the
cached report also when the flag is not set (patch 1).
- blkdev_get_zone_info() gives a smaller last zone the length of a
full zone, so the cached report describes a zone that ends behind
the end of the device (patch 2).
Both were found by reading the code and then confirmed with zoned
null_blk devices in qemu (x86_64). The test program opens one zone
explicitly, writes to a second zone and closes it, and compares the
reports of BLKREPORTZONE, BLKREPORTZONEV2 with flags 0 and
BLKREPORTZONEV2 with BLK_ZONE_REP_CACHED. On mainline it finds both
problems. With both patches BLKREPORTZONEV2 with flags 0 returns the
same device report as BLKREPORTZONE, and the cached report describes
the smaller last zone with its real length.
For patch 1 there is a choice between the code and the documentation.
The changelog of b30ffcdc0c15 and the comments in the uapi header both
say that without BLK_ZONE_REP_CACHED the report comes from the device,
and BLKREPORTZONE is marked as deprecated in favour of the new ioctl,
so I changed the code. If the cached report is meant to be the only
mode of BLKREPORTZONEV2, the header needs to say so instead.
Changes since v1:
- patch 1: rewrite the BLKREPORTZONEV2 case to the positive form
suggested by Damien Le Moal: take the cached report only when
BLK_ZONE_REP_CACHED is set and blkdev_has_cached_report_zones() is
true, and call blkdev_report_zones() in every other case. This drops
the redundant blkdev_report_zones_cached() call for the no-cache
case, where it would only fall back to a device report anyway, so
the observable behaviour is unchanged.
- patch 1: blkdev_has_cached_report_zones() is now used from
blkdev_report_zones_ioctl(), so move it, with its comment, above
that function rather than add a forward declaration.
- patch 1: adjust the changelog to describe the new form.
- patch 2 is unchanged; it keeps Damien Le Moal's Reviewed-by from v1.
- retested on zoned null_blk in qemu (see below).
The series is based on mainline (a5ebb76233b7, v7.3-rc6+), where both
patches apply. Patch 1 also applies to linux-next (next-20261009).
Patch 2 needs its context adjusted on linux-next / for-7.4/block,
because blkdev_get_zone_info() there tests the zone type instead of
the zone condition; I can rebase it onto that tree if you prefer to
take the series there.
Shashank Mohan Jain (2):
block: only use the cached zone report if BLK_ZONE_REP_CACHED is set
block: fix the length of a smaller last zone in blkdev_get_zone_info()
block/blk-zoned.c | 41 ++++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
base-commit: a5ebb76233b79db01e82e061173cb73c6d2b5c6b
--
2.43.0