From: Damien Le Moal <dlemoal@kernel.org>
To: Shashank Mohan Jain <jain.sm@gmail.com>, Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@lst.de>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Hannes Reinecke <hare@suse.de>,
Chaitanya Kulkarni <kch@nvidia.com>,
"Martin K. Petersen" <mkp@kernel.org>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] block: only use the cached zone report if BLK_ZONE_REP_CACHED is set
Date: Mon, 12 Oct 2026 13:27:18 +0200 [thread overview]
Message-ID: <87b3cf42-ae12-40dc-9d84-4bb8b7acac83@kernel.org> (raw)
In-Reply-To: <20261011154018.48913-2-jain.sm@gmail.com>
On 2026/10/11 17:40, Shashank Mohan Jain wrote:
> BLKREPORTZONEV2 takes the flags field of struct blk_zone_report as an
> input. With BLK_ZONE_REP_CACHED the report is built from the zone
> information cached by the block layer. Without it, BLKREPORTZONEV2 is
> documented to behave like BLKREPORTZONE and to get the report from the
> device: this is what the changelog of the commit that added the ioctl
> and the comments in include/uapi/linux/blkzoned.h say.
>
> blkdev_report_zones_ioctl() only uses the flag to validate the input
> and calls blkdev_report_zones_cached() for every BLKREPORTZONEV2
> request. A caller that passes flags == 0 gets the cached report, in
> which implicitly open, explicitly open and closed zones all have the
> condition BLK_ZONE_COND_ACTIVE, and an explicitly opened empty zone is
> reported as empty.
>
> Example with a zoned null_blk device (10 MiB, 4 MiB zones) after
> BLKOPENZONE on zone 0, and a write of 8 sectors to zone 1 followed by
> BLKCLOSEZONE:
>
> BLKREPORTZONE: zone 0 cond 0x3 (EXP_OPEN)
> zone 1 cond 0x4 (CLOSED)
> BLKREPORTZONEV2, flags 0: zone 0 cond 0x1 (EMPTY)
> zone 1 cond 0xff (ACTIVE)
>
> The uapi header marks BLKREPORTZONE as deprecated in favour of
> BLKREPORTZONEV2. A program that follows this and does not ask for
> cached information can no longer tell open zones from closed ones, and
> is handed BLK_ZONE_COND_ACTIVE, which is only defined for the cached
> report.
>
> Use the cached report only when BLK_ZONE_REP_CACHED is set and the
> device has a cached report; otherwise, and whenever the flag is not
> set, get the report from the device with blkdev_report_zones(). Guard
> the cached path with blkdev_has_cached_report_zones() so the redundant
> call is avoided when there is no cached report: in that case
> blkdev_report_zones_cached() already falls back to a device report, so
> the observable behaviour is unchanged. blkdev_has_cached_report_zones()
> is defined lower in the file, so move it, with its comment, above
> blkdev_report_zones_ioctl().
>
> Tested with zoned null_blk devices in qemu: a program that compares
> the reports of BLKREPORTZONE and BLKREPORTZONEV2 with flags 0 after
> the sequence above finds the differences before this change and none
> with it. The report with BLK_ZONE_REP_CACHED is unchanged.
>
> Fixes: b30ffcdc0c15 ("block: introduce BLKREPORTZONESV2 ioctl")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Shashank Mohan Jain <jain.sm@gmail.com>
Looks good.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-10-12 11:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 15:40 [PATCH v2 0/2] block: two fixes for the zone report ioctls Shashank Mohan Jain
2026-10-11 15:40 ` [PATCH v2 1/2] block: only use the cached zone report if BLK_ZONE_REP_CACHED is set Shashank Mohan Jain
2026-10-12 11:27 ` Damien Le Moal [this message]
2026-10-11 15:40 ` [PATCH v2 2/2] block: fix the length of a smaller last zone in blkdev_get_zone_info() Shashank Mohan Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87b3cf42-ae12-40dc-9d84-4bb8b7acac83@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jain.sm@gmail.com \
--cc=johannes.thumshirn@wdc.com \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkp@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®