From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Andrey Albershteyn <aalbersh@kernel.org>,
Damien Le Moal <dlemoal@kernel.org>,
Carlos Maiolino <cem@kernel.org>,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH 5/5] libfrog: enable cached report zones
Date: Tue, 27 Jan 2026 21:10:02 -0800 [thread overview]
Message-ID: <20260128051002.GP5945@frogsfrogsfrogs> (raw)
In-Reply-To: <20260128043318.522432-6-hch@lst.de>
On Wed, Jan 28, 2026 at 05:32:59AM +0100, Christoph Hellwig wrote:
> Modify the function xfrog_report_zones() to default to always trying
> first a cached report zones using the BLKREPORTZONEV2 ioctl.
> If the kernel does not support BLKREPORTZONEV2, fall back to the
> (slower) regular report zones BLKREPORTZONE ioctl.
>
> TO enable this feature even if xfsprogs is compiled on a system where
> linux/blkzoned.h does not define BLKREPORTZONEV2, this ioctl is defined
> in libfrog/zones.h, together with the BLK_ZONE_REP_CACHED flag and the
> BLK_ZONE_COND_ACTIVE zone condition.
>
> Since a cached report zone always return the condition
> BLK_ZONE_COND_ACTIVE for any zone that is implicitly open, explicitly
> open or closed, the function xfs_zone_validate_seq() is modified to
> handle this new condition as being equivalent to the implicit open,
> explicit open or closed conditions.
>
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> [hch: don't try cached reporting again if not supported]
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks fine to me, so
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> include/platform_defs.h | 6 ++++++
> libfrog/zones.c | 22 +++++++++++++++++++++-
> 2 files changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/include/platform_defs.h b/include/platform_defs.h
> index 1a9f401fc11c..09129e0f22dc 100644
> --- a/include/platform_defs.h
> +++ b/include/platform_defs.h
> @@ -312,6 +312,12 @@ struct kvec {
> * Local definitions for the new cached report zones added in Linux 6.19 in case
> * the system <linux/blkzoned.h> doesn't provide them yet.
> */
> +#ifndef BLKREPORTZONEV2
> +#define BLKREPORTZONEV2 _IOWR(0x12, 142, struct blk_zone_report)
> +#endif
> +#ifndef BLK_ZONE_REP_CACHED
> +#define BLK_ZONE_REP_CACHED (1U << 31)
> +#endif
> #ifndef BLK_ZONE_COND_ACTIVE
> #define BLK_ZONE_COND_ACTIVE 0xff
> #endif
> diff --git a/libfrog/zones.c b/libfrog/zones.c
> index 2276c56bec9c..c088d3240545 100644
> --- a/libfrog/zones.c
> +++ b/libfrog/zones.c
> @@ -3,12 +3,15 @@
> * Copyright (c) 2025, Western Digital Corporation or its affiliates.
> */
> #include "platform_defs.h"
> +#include "atomic.h"
> #include "libfrog/zones.h"
> #include <sys/ioctl.h>
>
> /* random size that allows efficient processing */
> #define ZONES_PER_REPORT 16384
>
> +static atomic_t cached_reporting_disabled;
> +
> struct xfrog_zone_report *
> xfrog_report_zones(
> int fd,
> @@ -24,10 +27,27 @@ _("Failed to allocate memory for reporting zones."));
> }
> }
>
> + /*
> + * Try cached report zones first. If this fails, fallback to the regular
> + * (slower) report zones.
> + */
> rep->rep.sector = sector;
> rep->rep.nr_zones = ZONES_PER_REPORT;
>
> - if (ioctl(fd, BLKREPORTZONE, &rep->rep)) {
> + if (atomic_read(&cached_reporting_disabled))
> + goto uncached;
> +
> + rep->rep.flags = BLK_ZONE_REP_CACHED;
> + if (ioctl(fd, BLKREPORTZONEV2, &rep->rep)) {
> + atomic_inc(&cached_reporting_disabled);
> + goto uncached;
> + }
> +
> + return rep;
> +
> +uncached:
> + rep->rep.flags = 0;
> + if (ioctl(fd, BLKREPORTZONE, rep)) {
> fprintf(stderr, "%s %s\n",
> _("ioctl(BLKREPORTZONE) failed:\n"),
> strerror(-errno));
> --
> 2.47.3
>
>
prev parent reply other threads:[~2026-01-28 5:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 4:32 enable cached zone report v5 Christoph Hellwig
2026-01-28 4:32 ` [PATCH 1/5] include blkzoned.h in platform_defs.h Christoph Hellwig
2026-01-28 5:11 ` Darrick J. Wong
2026-01-28 5:58 ` Damien Le Moal
2026-01-28 4:32 ` [PATCH 2/5] xfs: use blkdev_report_zones_cached() Christoph Hellwig
2026-01-28 4:32 ` [PATCH 3/5] mkfs: remove unnecessary return value affectation Christoph Hellwig
2026-01-28 4:32 ` [PATCH 4/5] libfrog: lift common zone reporting code from mkfs and repair Christoph Hellwig
2026-01-28 5:09 ` Darrick J. Wong
2026-01-28 4:32 ` [PATCH 5/5] libfrog: enable cached report zones Christoph Hellwig
2026-01-28 5:10 ` Darrick J. Wong [this message]
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=20260128051002.GP5945@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@kernel.org \
--cc=cem@kernel.org \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=linux-xfs@vger.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