public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* enable cached zone report v4
@ 2026-01-09 16:22 Christoph Hellwig
  2026-01-09 16:22 ` [PATCH 1/4] xfs: use blkdev_report_zones_cached() Christoph Hellwig
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Christoph Hellwig @ 2026-01-09 16:22 UTC (permalink / raw)
  To: Andrey Albershteyn
  Cc: Damien Le Moal, Darrick J . Wong, Carlos Maiolino, linux-xfs

Enable cached zone report to speed up mkfs and repair on a zoned block
device (e.g. an SMR disk). Cached zone report support was introduced in
the kernel with version 6.19-rc1.

Note: I've taken this series over from Damien as he's busy and it need
it as a base for further work.

Changes from v3:
 - reorder includes to not need the forward declaration in xfs_zones.h
 - use the libfrog/ for #include statements
 - fix the include guard in libfrog/zones.h
 - fix up i18n string mess
 - hide the new ioctl definition in libfrog/zones.c
 - don't add userspace includes to libxfs/xfs_zones.h
 - reuse the buffer for multiple report zone calls

Changes from v2:
 - Complete rework of the series to make the zone reporting code common
   in libfrog
 - Added patch 1 and 2 as small cleanups/improvements.

Changes from v1:
 - Fix erroneous handling of ioctl(BLKREPORTZONEV2) error to correctly
   fallback to the regular ioctl(BLKREPORTZONE) if the kernel does not
   support BLKREPORTZONEV2.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/4] xfs: use blkdev_report_zones_cached()
  2026-01-09 16:22 enable cached zone report v4 Christoph Hellwig
@ 2026-01-09 16:22 ` Christoph Hellwig
  2026-01-20 14:28   ` Andrey Albershteyn
  2026-01-09 16:22 ` [PATCH 2/4] mkfs: remove unnecessary return value affectation Christoph Hellwig
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2026-01-09 16:22 UTC (permalink / raw)
  To: Andrey Albershteyn
  Cc: Damien Le Moal, Darrick J . Wong, Carlos Maiolino, linux-xfs,
	Martin K. Petersen, Jens Axboe

From: Damien Le Moal <dlemoal@kernel.org>

Source kernel commit: e04ccfc28252f181ea8d469d834b48e7dece65b2

Modify xfs_mount_zones() to replace the call to blkdev_report_zones()
with blkdev_report_zones_cached() to speed-up mount operations.
Since this causes xfs_zone_validate_seq() to see zones with the
BLK_ZONE_COND_ACTIVE condition, this function is also modified to acept
this condition as valid.

With this change, mounting a freshly formatted large capacity (30 TB)
SMR HDD completes under 2s compared to over 4.7s before.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/platform_defs.h | 4 ++++
 libxfs/xfs_zones.c      | 1 +
 2 files changed, 5 insertions(+)

diff --git a/include/platform_defs.h b/include/platform_defs.h
index da966490b0f5..cfdaca642645 100644
--- a/include/platform_defs.h
+++ b/include/platform_defs.h
@@ -307,4 +307,8 @@ struct kvec {
 	size_t iov_len;
 };
 
+#ifndef BLK_ZONE_COND_ACTIVE /* added in Linux 6.19 */
+#define BLK_ZONE_COND_ACTIVE	0xff
+#endif
+
 #endif	/* __XFS_PLATFORM_DEFS_H__ */
diff --git a/libxfs/xfs_zones.c b/libxfs/xfs_zones.c
index 7a81d83f5b3e..99ae05ce7473 100644
--- a/libxfs/xfs_zones.c
+++ b/libxfs/xfs_zones.c
@@ -97,6 +97,7 @@ xfs_zone_validate_seq(
 	case BLK_ZONE_COND_IMP_OPEN:
 	case BLK_ZONE_COND_EXP_OPEN:
 	case BLK_ZONE_COND_CLOSED:
+	case BLK_ZONE_COND_ACTIVE:
 		return xfs_zone_validate_wp(zone, rtg, write_pointer);
 	case BLK_ZONE_COND_FULL:
 		return xfs_zone_validate_full(zone, rtg, write_pointer);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/4] mkfs: remove unnecessary return value affectation
  2026-01-09 16:22 enable cached zone report v4 Christoph Hellwig
  2026-01-09 16:22 ` [PATCH 1/4] xfs: use blkdev_report_zones_cached() Christoph Hellwig
@ 2026-01-09 16:22 ` Christoph Hellwig
  2026-01-09 16:22 ` [PATCH 3/4] libfrog: lift common zone reporting code from mkfs and repair Christoph Hellwig
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2026-01-09 16:22 UTC (permalink / raw)
  To: Andrey Albershteyn
  Cc: Damien Le Moal, Darrick J . Wong, Carlos Maiolino, linux-xfs

From: Damien Le Moal <dlemoal@kernel.org>

The function report_zones() in mkfs/xfs_mkfs.c is a void function. So
there is no need to set the variable ret to -EIO before returning if
fstat() fails.

Fixes: 2e5a737a61d3 ("xfs_mkfs: support creating file system with zoned RT devices")
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 mkfs/xfs_mkfs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index b34407725f76..215cff8db7b1 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2587,10 +2587,8 @@ report_zones(
 		exit(1);
 	}
 
-	if (fstat(fd, &st) < 0) {
-		ret = -EIO;
+	if (fstat(fd, &st) < 0)
 		goto out_close;
-	}
 	if (!S_ISBLK(st.st_mode))
 		goto out_close;
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/4] libfrog: lift common zone reporting code from mkfs and repair
  2026-01-09 16:22 enable cached zone report v4 Christoph Hellwig
  2026-01-09 16:22 ` [PATCH 1/4] xfs: use blkdev_report_zones_cached() Christoph Hellwig
  2026-01-09 16:22 ` [PATCH 2/4] mkfs: remove unnecessary return value affectation Christoph Hellwig
@ 2026-01-09 16:22 ` Christoph Hellwig
  2026-01-09 16:31   ` Darrick J. Wong
  2026-01-09 16:22 ` [PATCH 4/4] libfrog: enable cached report zones Christoph Hellwig
  2026-01-12 11:02 ` enable cached zone report v4 Damien Le Moal
  4 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2026-01-09 16:22 UTC (permalink / raw)
  To: Andrey Albershteyn
  Cc: Damien Le Moal, Darrick J . Wong, Carlos Maiolino, linux-xfs

From: Damien Le Moal <dlemoal@kernel.org>

Define the new helper function xfrog_report_zones() to report zones of
a zoned block device.  This function is implemented in the new file
libfrog/zones.c and defined in the header file libfrog/zones.h and
use it from mkfs and repair instead of the previous open coded versions.

xfrog_report_zones() allocates and returns a struct blk_zone_report
structure, which can be be reused by subsequent invocations.  It is the
responsibility of the caller to free this structure after use.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
[hch: refactored to allow buffer reuse]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 libfrog/Makefile |  6 ++++--
 libfrog/zones.c  | 39 +++++++++++++++++++++++++++++++++++++++
 libfrog/zones.h  | 18 ++++++++++++++++++
 mkfs/xfs_mkfs.c  | 41 ++++++++++++-----------------------------
 repair/zoned.c   | 35 +++++++++++------------------------
 5 files changed, 84 insertions(+), 55 deletions(-)
 create mode 100644 libfrog/zones.c
 create mode 100644 libfrog/zones.h

diff --git a/libfrog/Makefile b/libfrog/Makefile
index 268fa26638d7..9f405ffe3475 100644
--- a/libfrog/Makefile
+++ b/libfrog/Makefile
@@ -35,7 +35,8 @@ radix-tree.c \
 randbytes.c \
 scrub.c \
 util.c \
-workqueue.c
+workqueue.c \
+zones.c
 
 HFILES = \
 avl64.h \
@@ -65,7 +66,8 @@ radix-tree.h \
 randbytes.h \
 scrub.h \
 statx.h \
-workqueue.h
+workqueue.h \
+zones.h
 
 GETTEXT_PY = \
 	gettext.py
diff --git a/libfrog/zones.c b/libfrog/zones.c
new file mode 100644
index 000000000000..2276c56bec9c
--- /dev/null
+++ b/libfrog/zones.c
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2025, Western Digital Corporation or its affiliates.
+ */
+#include "platform_defs.h"
+#include "libfrog/zones.h"
+#include <sys/ioctl.h>
+
+/* random size that allows efficient processing */
+#define ZONES_PER_REPORT		16384
+
+struct xfrog_zone_report *
+xfrog_report_zones(
+	int			fd,
+	uint64_t		sector,
+	struct xfrog_zone_report *rep)
+{
+	if (!rep) {
+		rep = calloc(1, struct_size(rep, zones, ZONES_PER_REPORT));
+		if (!rep) {
+			fprintf(stderr, "%s\n",
+_("Failed to allocate memory for reporting zones."));
+			return NULL;
+		}
+	}
+
+	rep->rep.sector = sector;
+	rep->rep.nr_zones = ZONES_PER_REPORT;
+
+	if (ioctl(fd, BLKREPORTZONE, &rep->rep)) {
+		fprintf(stderr, "%s %s\n",
+_("ioctl(BLKREPORTZONE) failed:\n"),
+			strerror(-errno));
+		free(rep);
+		return NULL;
+	}
+
+	return rep;
+}
diff --git a/libfrog/zones.h b/libfrog/zones.h
new file mode 100644
index 000000000000..33c1da7ef192
--- /dev/null
+++ b/libfrog/zones.h
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2025, Western Digital Corporation or its affiliates.
+ */
+#ifndef __LIBFROG_ZONES_H__
+#define __LIBFROG_ZONES_H__
+
+#include <linux/blkzoned.h>
+
+struct xfrog_zone_report {
+	struct blk_zone_report	rep;
+	struct blk_zone		zones[];
+};
+
+struct xfrog_zone_report *
+xfrog_report_zones(int fd, uint64_t sector, struct xfrog_zone_report *rep);
+
+#endif /* __LIBFROG_ZONES_H__ */
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 215cff8db7b1..9c165f29c298 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -15,6 +15,7 @@
 #include "libfrog/crc32cselftest.h"
 #include "libfrog/dahashselftest.h"
 #include "libfrog/fsproperties.h"
+#include "libfrog/zones.h"
 #include "proto.h"
 #include <ini.h>
 
@@ -2542,9 +2543,6 @@ struct zone_topology {
 	struct zone_info	log;
 };
 
-/* random size that allows efficient processing */
-#define ZONES_PER_IOCTL			16384
-
 static void
 zone_validate_capacity(
 	struct zone_info	*zi,
@@ -2572,12 +2570,11 @@ report_zones(
 	const char		*name,
 	struct zone_info	*zi)
 {
-	struct blk_zone_report	*rep;
+	struct xfrog_zone_report *rep = NULL;
 	bool			found_seq = false;
-	int			fd, ret = 0;
+	int			fd;
 	uint64_t		device_size;
 	uint64_t		sector = 0;
-	size_t			rep_size;
 	unsigned int		i, n = 0;
 	struct stat		st;
 
@@ -2604,32 +2601,18 @@ report_zones(
 	zi->nr_zones = device_size / zi->zone_size;
 	zi->nr_conv_zones = 0;
 
-	rep_size = sizeof(struct blk_zone_report) +
-		   sizeof(struct blk_zone) * ZONES_PER_IOCTL;
-	rep = malloc(rep_size);
-	if (!rep) {
-		fprintf(stderr,
-_("Failed to allocate memory for zone reporting.\n"));
-		exit(1);
-	}
-
 	while (n < zi->nr_zones) {
-		struct blk_zone *zones = (struct blk_zone *)(rep + 1);
+		struct blk_zone *zones;
 
-		memset(rep, 0, rep_size);
-		rep->sector = sector;
-		rep->nr_zones = ZONES_PER_IOCTL;
-
-		ret = ioctl(fd, BLKREPORTZONE, rep);
-		if (ret) {
-			fprintf(stderr,
-_("ioctl(BLKREPORTZONE) failed: %d!\n"), -errno);
+		rep = xfrog_report_zones(fd, sector, rep);
+		if (!rep)
 			exit(1);
-		}
-		if (!rep->nr_zones)
+
+		if (!rep->rep.nr_zones)
 			break;
 
-		for (i = 0; i < rep->nr_zones; i++) {
+		zones = rep->zones;
+		for (i = 0; i < rep->rep.nr_zones; i++) {
 			if (n >= zi->nr_zones)
 				break;
 
@@ -2676,8 +2659,8 @@ _("Unknown zone type (0x%x) found.\n"), zones[i].type);
 
 			n++;
 		}
-		sector = zones[rep->nr_zones - 1].start +
-			 zones[rep->nr_zones - 1].len;
+		sector = zones[rep->rep.nr_zones - 1].start +
+			 zones[rep->rep.nr_zones - 1].len;
 	}
 
 	free(rep);
diff --git a/repair/zoned.c b/repair/zoned.c
index 206b0158f95f..5102d43e218d 100644
--- a/repair/zoned.c
+++ b/repair/zoned.c
@@ -7,6 +7,7 @@
 #include "libxfs_priv.h"
 #include "libxfs.h"
 #include "xfs_zones.h"
+#include "libfrog/zones.h"
 #include "err_protos.h"
 #include "zoned.h"
 
@@ -51,8 +52,7 @@ check_zones(
 	uint64_t		sector = XFS_FSB_TO_BB(mp, mp->m_sb.sb_rtstart);
 	unsigned int		zone_size, zone_capacity;
 	uint64_t		device_size;
-	size_t			rep_size;
-	struct blk_zone_report	*rep;
+	struct xfrog_zone_report *rep = NULL;
 	unsigned int		i, n = 0;
 
 	if (ioctl(fd, BLKGETSIZE64, &device_size))
@@ -67,31 +67,18 @@ check_zones(
 		return;
 	}
 
-	rep_size = sizeof(struct blk_zone_report) +
-		   sizeof(struct blk_zone) * ZONES_PER_IOCTL;
-	rep = malloc(rep_size);
-	if (!rep) {
-		do_warn(_("malloc failed for zone report\n"));
-		return;
-	}
-
 	while (n < mp->m_sb.sb_rgcount) {
-		struct blk_zone *zones = (struct blk_zone *)(rep + 1);
-		int ret;
+		struct blk_zone *zones;
 
-		memset(rep, 0, rep_size);
-		rep->sector = sector;
-		rep->nr_zones = ZONES_PER_IOCTL;
+		rep = xfrog_report_zones(fd, sector, rep);
+		if (!rep)
+			return;
 
-		ret = ioctl(fd, BLKREPORTZONE, rep);
-		if (ret) {
-			do_error(_("ioctl(BLKREPORTZONE) failed: %d!\n"), ret);
-			goto out_free;
-		}
-		if (!rep->nr_zones)
+		if (!rep->rep.nr_zones)
 			break;
 
-		for (i = 0; i < rep->nr_zones; i++) {
+		zones = rep->zones;
+		for (i = 0; i < rep->rep.nr_zones; i++) {
 			if (n >= mp->m_sb.sb_rgcount)
 				break;
 
@@ -130,8 +117,8 @@ _("Inconsistent zone capacity!\n"));
 			report_zones_cb(mp, &zones[i]);
 			n++;
 		}
-		sector = zones[rep->nr_zones - 1].start +
-			 zones[rep->nr_zones - 1].len;
+		sector = zones[rep->rep.nr_zones - 1].start +
+			 zones[rep->rep.nr_zones - 1].len;
 	}
 
 out_free:
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/4] libfrog: enable cached report zones
  2026-01-09 16:22 enable cached zone report v4 Christoph Hellwig
                   ` (2 preceding siblings ...)
  2026-01-09 16:22 ` [PATCH 3/4] libfrog: lift common zone reporting code from mkfs and repair Christoph Hellwig
@ 2026-01-09 16:22 ` Christoph Hellwig
  2026-01-09 16:32   ` Darrick J. Wong
  2026-01-12 11:02 ` enable cached zone report v4 Damien Le Moal
  4 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2026-01-09 16:22 UTC (permalink / raw)
  To: Andrey Albershteyn
  Cc: Damien Le Moal, Darrick J . Wong, Carlos Maiolino, linux-xfs

From: Damien Le Moal <dlemoal@kernel.org>

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>
---
 libfrog/zones.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/libfrog/zones.c b/libfrog/zones.c
index 2276c56bec9c..f1ef0b24c564 100644
--- a/libfrog/zones.c
+++ b/libfrog/zones.c
@@ -3,12 +3,24 @@
  * Copyright (c) 2025, Western Digital Corporation or its affiliates.
  */
 #include "platform_defs.h"
+#include "atomic.h"
 #include "libfrog/zones.h"
 #include <sys/ioctl.h>
 
+/*
+ * Cached report ioctl (/usr/include/linux/blkzoned.h).
+ * Add in Linux 6.19.
+ */
+#ifndef BLKREPORTZONEV2
+#define BLKREPORTZONEV2		_IOWR(0x12, 142, struct blk_zone_report)
+#define BLK_ZONE_REP_CACHED	(1U << 31)
+#endif /* BLKREPORTZONEV2 */
+
 /* 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 +36,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


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/4] libfrog: lift common zone reporting code from mkfs and repair
  2026-01-09 16:22 ` [PATCH 3/4] libfrog: lift common zone reporting code from mkfs and repair Christoph Hellwig
@ 2026-01-09 16:31   ` Darrick J. Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2026-01-09 16:31 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Andrey Albershteyn, Damien Le Moal, Carlos Maiolino, linux-xfs

On Fri, Jan 09, 2026 at 05:22:54PM +0100, Christoph Hellwig wrote:
> From: Damien Le Moal <dlemoal@kernel.org>
> 
> Define the new helper function xfrog_report_zones() to report zones of
> a zoned block device.  This function is implemented in the new file
> libfrog/zones.c and defined in the header file libfrog/zones.h and
> use it from mkfs and repair instead of the previous open coded versions.
> 
> xfrog_report_zones() allocates and returns a struct blk_zone_report
> structure, which can be be reused by subsequent invocations.  It is the
> responsibility of the caller to free this structure after use.
> 
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> [hch: refactored to allow buffer reuse]
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good now, thanx for avoiding the buffer reallocations
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  libfrog/Makefile |  6 ++++--
>  libfrog/zones.c  | 39 +++++++++++++++++++++++++++++++++++++++
>  libfrog/zones.h  | 18 ++++++++++++++++++
>  mkfs/xfs_mkfs.c  | 41 ++++++++++++-----------------------------
>  repair/zoned.c   | 35 +++++++++++------------------------
>  5 files changed, 84 insertions(+), 55 deletions(-)
>  create mode 100644 libfrog/zones.c
>  create mode 100644 libfrog/zones.h
> 
> diff --git a/libfrog/Makefile b/libfrog/Makefile
> index 268fa26638d7..9f405ffe3475 100644
> --- a/libfrog/Makefile
> +++ b/libfrog/Makefile
> @@ -35,7 +35,8 @@ radix-tree.c \
>  randbytes.c \
>  scrub.c \
>  util.c \
> -workqueue.c
> +workqueue.c \
> +zones.c
>  
>  HFILES = \
>  avl64.h \
> @@ -65,7 +66,8 @@ radix-tree.h \
>  randbytes.h \
>  scrub.h \
>  statx.h \
> -workqueue.h
> +workqueue.h \
> +zones.h
>  
>  GETTEXT_PY = \
>  	gettext.py
> diff --git a/libfrog/zones.c b/libfrog/zones.c
> new file mode 100644
> index 000000000000..2276c56bec9c
> --- /dev/null
> +++ b/libfrog/zones.c
> @@ -0,0 +1,39 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2025, Western Digital Corporation or its affiliates.
> + */
> +#include "platform_defs.h"
> +#include "libfrog/zones.h"
> +#include <sys/ioctl.h>
> +
> +/* random size that allows efficient processing */
> +#define ZONES_PER_REPORT		16384
> +
> +struct xfrog_zone_report *
> +xfrog_report_zones(
> +	int			fd,
> +	uint64_t		sector,
> +	struct xfrog_zone_report *rep)
> +{
> +	if (!rep) {
> +		rep = calloc(1, struct_size(rep, zones, ZONES_PER_REPORT));
> +		if (!rep) {
> +			fprintf(stderr, "%s\n",
> +_("Failed to allocate memory for reporting zones."));
> +			return NULL;
> +		}
> +	}
> +
> +	rep->rep.sector = sector;
> +	rep->rep.nr_zones = ZONES_PER_REPORT;
> +
> +	if (ioctl(fd, BLKREPORTZONE, &rep->rep)) {
> +		fprintf(stderr, "%s %s\n",
> +_("ioctl(BLKREPORTZONE) failed:\n"),
> +			strerror(-errno));
> +		free(rep);
> +		return NULL;
> +	}
> +
> +	return rep;
> +}
> diff --git a/libfrog/zones.h b/libfrog/zones.h
> new file mode 100644
> index 000000000000..33c1da7ef192
> --- /dev/null
> +++ b/libfrog/zones.h
> @@ -0,0 +1,18 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2025, Western Digital Corporation or its affiliates.
> + */
> +#ifndef __LIBFROG_ZONES_H__
> +#define __LIBFROG_ZONES_H__
> +
> +#include <linux/blkzoned.h>
> +
> +struct xfrog_zone_report {
> +	struct blk_zone_report	rep;
> +	struct blk_zone		zones[];
> +};
> +
> +struct xfrog_zone_report *
> +xfrog_report_zones(int fd, uint64_t sector, struct xfrog_zone_report *rep);
> +
> +#endif /* __LIBFROG_ZONES_H__ */
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 215cff8db7b1..9c165f29c298 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -15,6 +15,7 @@
>  #include "libfrog/crc32cselftest.h"
>  #include "libfrog/dahashselftest.h"
>  #include "libfrog/fsproperties.h"
> +#include "libfrog/zones.h"
>  #include "proto.h"
>  #include <ini.h>
>  
> @@ -2542,9 +2543,6 @@ struct zone_topology {
>  	struct zone_info	log;
>  };
>  
> -/* random size that allows efficient processing */
> -#define ZONES_PER_IOCTL			16384
> -
>  static void
>  zone_validate_capacity(
>  	struct zone_info	*zi,
> @@ -2572,12 +2570,11 @@ report_zones(
>  	const char		*name,
>  	struct zone_info	*zi)
>  {
> -	struct blk_zone_report	*rep;
> +	struct xfrog_zone_report *rep = NULL;
>  	bool			found_seq = false;
> -	int			fd, ret = 0;
> +	int			fd;
>  	uint64_t		device_size;
>  	uint64_t		sector = 0;
> -	size_t			rep_size;
>  	unsigned int		i, n = 0;
>  	struct stat		st;
>  
> @@ -2604,32 +2601,18 @@ report_zones(
>  	zi->nr_zones = device_size / zi->zone_size;
>  	zi->nr_conv_zones = 0;
>  
> -	rep_size = sizeof(struct blk_zone_report) +
> -		   sizeof(struct blk_zone) * ZONES_PER_IOCTL;
> -	rep = malloc(rep_size);
> -	if (!rep) {
> -		fprintf(stderr,
> -_("Failed to allocate memory for zone reporting.\n"));
> -		exit(1);
> -	}
> -
>  	while (n < zi->nr_zones) {
> -		struct blk_zone *zones = (struct blk_zone *)(rep + 1);
> +		struct blk_zone *zones;
>  
> -		memset(rep, 0, rep_size);
> -		rep->sector = sector;
> -		rep->nr_zones = ZONES_PER_IOCTL;
> -
> -		ret = ioctl(fd, BLKREPORTZONE, rep);
> -		if (ret) {
> -			fprintf(stderr,
> -_("ioctl(BLKREPORTZONE) failed: %d!\n"), -errno);
> +		rep = xfrog_report_zones(fd, sector, rep);
> +		if (!rep)
>  			exit(1);
> -		}
> -		if (!rep->nr_zones)
> +
> +		if (!rep->rep.nr_zones)
>  			break;
>  
> -		for (i = 0; i < rep->nr_zones; i++) {
> +		zones = rep->zones;
> +		for (i = 0; i < rep->rep.nr_zones; i++) {
>  			if (n >= zi->nr_zones)
>  				break;
>  
> @@ -2676,8 +2659,8 @@ _("Unknown zone type (0x%x) found.\n"), zones[i].type);
>  
>  			n++;
>  		}
> -		sector = zones[rep->nr_zones - 1].start +
> -			 zones[rep->nr_zones - 1].len;
> +		sector = zones[rep->rep.nr_zones - 1].start +
> +			 zones[rep->rep.nr_zones - 1].len;
>  	}
>  
>  	free(rep);
> diff --git a/repair/zoned.c b/repair/zoned.c
> index 206b0158f95f..5102d43e218d 100644
> --- a/repair/zoned.c
> +++ b/repair/zoned.c
> @@ -7,6 +7,7 @@
>  #include "libxfs_priv.h"
>  #include "libxfs.h"
>  #include "xfs_zones.h"
> +#include "libfrog/zones.h"
>  #include "err_protos.h"
>  #include "zoned.h"
>  
> @@ -51,8 +52,7 @@ check_zones(
>  	uint64_t		sector = XFS_FSB_TO_BB(mp, mp->m_sb.sb_rtstart);
>  	unsigned int		zone_size, zone_capacity;
>  	uint64_t		device_size;
> -	size_t			rep_size;
> -	struct blk_zone_report	*rep;
> +	struct xfrog_zone_report *rep = NULL;
>  	unsigned int		i, n = 0;
>  
>  	if (ioctl(fd, BLKGETSIZE64, &device_size))
> @@ -67,31 +67,18 @@ check_zones(
>  		return;
>  	}
>  
> -	rep_size = sizeof(struct blk_zone_report) +
> -		   sizeof(struct blk_zone) * ZONES_PER_IOCTL;
> -	rep = malloc(rep_size);
> -	if (!rep) {
> -		do_warn(_("malloc failed for zone report\n"));
> -		return;
> -	}
> -
>  	while (n < mp->m_sb.sb_rgcount) {
> -		struct blk_zone *zones = (struct blk_zone *)(rep + 1);
> -		int ret;
> +		struct blk_zone *zones;
>  
> -		memset(rep, 0, rep_size);
> -		rep->sector = sector;
> -		rep->nr_zones = ZONES_PER_IOCTL;
> +		rep = xfrog_report_zones(fd, sector, rep);
> +		if (!rep)
> +			return;
>  
> -		ret = ioctl(fd, BLKREPORTZONE, rep);
> -		if (ret) {
> -			do_error(_("ioctl(BLKREPORTZONE) failed: %d!\n"), ret);
> -			goto out_free;
> -		}
> -		if (!rep->nr_zones)
> +		if (!rep->rep.nr_zones)
>  			break;
>  
> -		for (i = 0; i < rep->nr_zones; i++) {
> +		zones = rep->zones;
> +		for (i = 0; i < rep->rep.nr_zones; i++) {
>  			if (n >= mp->m_sb.sb_rgcount)
>  				break;
>  
> @@ -130,8 +117,8 @@ _("Inconsistent zone capacity!\n"));
>  			report_zones_cb(mp, &zones[i]);
>  			n++;
>  		}
> -		sector = zones[rep->nr_zones - 1].start +
> -			 zones[rep->nr_zones - 1].len;
> +		sector = zones[rep->rep.nr_zones - 1].start +
> +			 zones[rep->rep.nr_zones - 1].len;
>  	}
>  
>  out_free:
> -- 
> 2.47.3
> 
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 4/4] libfrog: enable cached report zones
  2026-01-09 16:22 ` [PATCH 4/4] libfrog: enable cached report zones Christoph Hellwig
@ 2026-01-09 16:32   ` Darrick J. Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2026-01-09 16:32 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Andrey Albershteyn, Damien Le Moal, Carlos Maiolino, linux-xfs

On Fri, Jan 09, 2026 at 05:22:55PM +0100, Christoph Hellwig wrote:
> From: Damien Le Moal <dlemoal@kernel.org>
> 
> 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>

That's an amusing use of atomic_t :)
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  libfrog/zones.c | 31 ++++++++++++++++++++++++++++++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/libfrog/zones.c b/libfrog/zones.c
> index 2276c56bec9c..f1ef0b24c564 100644
> --- a/libfrog/zones.c
> +++ b/libfrog/zones.c
> @@ -3,12 +3,24 @@
>   * Copyright (c) 2025, Western Digital Corporation or its affiliates.
>   */
>  #include "platform_defs.h"
> +#include "atomic.h"
>  #include "libfrog/zones.h"
>  #include <sys/ioctl.h>
>  
> +/*
> + * Cached report ioctl (/usr/include/linux/blkzoned.h).
> + * Add in Linux 6.19.
> + */
> +#ifndef BLKREPORTZONEV2
> +#define BLKREPORTZONEV2		_IOWR(0x12, 142, struct blk_zone_report)
> +#define BLK_ZONE_REP_CACHED	(1U << 31)
> +#endif /* BLKREPORTZONEV2 */
> +
>  /* 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 +36,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
> 
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: enable cached zone report v4
  2026-01-09 16:22 enable cached zone report v4 Christoph Hellwig
                   ` (3 preceding siblings ...)
  2026-01-09 16:22 ` [PATCH 4/4] libfrog: enable cached report zones Christoph Hellwig
@ 2026-01-12 11:02 ` Damien Le Moal
  4 siblings, 0 replies; 16+ messages in thread
From: Damien Le Moal @ 2026-01-12 11:02 UTC (permalink / raw)
  To: Christoph Hellwig, Andrey Albershteyn
  Cc: Darrick J . Wong, Carlos Maiolino, linux-xfs

On 1/9/26 17:22, Christoph Hellwig wrote:
> Enable cached zone report to speed up mkfs and repair on a zoned block
> device (e.g. an SMR disk). Cached zone report support was introduced in
> the kernel with version 6.19-rc1.
> 
> Note: I've taken this series over from Damien as he's busy and it need
> it as a base for further work.

Thanks for doing this !

> 
> Changes from v3:
>  - reorder includes to not need the forward declaration in xfs_zones.h
>  - use the libfrog/ for #include statements
>  - fix the include guard in libfrog/zones.h
>  - fix up i18n string mess
>  - hide the new ioctl definition in libfrog/zones.c
>  - don't add userspace includes to libxfs/xfs_zones.h
>  - reuse the buffer for multiple report zone calls
> 
> Changes from v2:
>  - Complete rework of the series to make the zone reporting code common
>    in libfrog
>  - Added patch 1 and 2 as small cleanups/improvements.
> 
> Changes from v1:
>  - Fix erroneous handling of ioctl(BLKREPORTZONEV2) error to correctly
>    fallback to the regular ioctl(BLKREPORTZONE) if the kernel does not
>    support BLKREPORTZONEV2.
> 
> 


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/4] xfs: use blkdev_report_zones_cached()
  2026-01-09 16:22 ` [PATCH 1/4] xfs: use blkdev_report_zones_cached() Christoph Hellwig
@ 2026-01-20 14:28   ` Andrey Albershteyn
  2026-01-20 17:31     ` Darrick J. Wong
  0 siblings, 1 reply; 16+ messages in thread
From: Andrey Albershteyn @ 2026-01-20 14:28 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Andrey Albershteyn, Damien Le Moal, Darrick J . Wong,
	Carlos Maiolino, linux-xfs, Martin K. Petersen, Jens Axboe

On 2026-01-09 17:22:52, Christoph Hellwig wrote:
> From: Damien Le Moal <dlemoal@kernel.org>
> 
> Source kernel commit: e04ccfc28252f181ea8d469d834b48e7dece65b2
> 
> Modify xfs_mount_zones() to replace the call to blkdev_report_zones()
> with blkdev_report_zones_cached() to speed-up mount operations.
> Since this causes xfs_zone_validate_seq() to see zones with the
> BLK_ZONE_COND_ACTIVE condition, this function is also modified to acept
> this condition as valid.
> 
> With this change, mounting a freshly formatted large capacity (30 TB)
> SMR HDD completes under 2s compared to over 4.7s before.
> 
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  include/platform_defs.h | 4 ++++
>  libxfs/xfs_zones.c      | 1 +
>  2 files changed, 5 insertions(+)
> 
> diff --git a/include/platform_defs.h b/include/platform_defs.h
> index da966490b0f5..cfdaca642645 100644
> --- a/include/platform_defs.h
> +++ b/include/platform_defs.h
> @@ -307,4 +307,8 @@ struct kvec {
>  	size_t iov_len;
>  };
>  
> +#ifndef BLK_ZONE_COND_ACTIVE /* added in Linux 6.19 */
> +#define BLK_ZONE_COND_ACTIVE	0xff

hmm I think #ifndef doesn't work for enum member. Compiling against
linux 6.19-rc6: 

../include/platform_defs.h:311:33: error: expected identifier before numeric constant
  311 | #define BLK_ZONE_COND_ACTIVE    0xff
      |                                 ^~~~
/linux-headers-v6.19-rc6/include/linux/blkzoned.h:84:9: note: in expansion of macro ‘BLK_ZONE_COND_ACTIVE’
   84 |         BLK_ZONE_COND_ACTIVE    = 0xFF,
      |         ^~~~~~~~~~~~~~~~~~~~

-- 
- Andrey


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/4] xfs: use blkdev_report_zones_cached()
  2026-01-20 14:28   ` Andrey Albershteyn
@ 2026-01-20 17:31     ` Darrick J. Wong
  2026-01-21  6:49       ` Christoph Hellwig
  0 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2026-01-20 17:31 UTC (permalink / raw)
  To: Andrey Albershteyn
  Cc: Christoph Hellwig, Andrey Albershteyn, Damien Le Moal,
	Carlos Maiolino, linux-xfs, Martin K. Petersen, Jens Axboe

On Tue, Jan 20, 2026 at 03:28:29PM +0100, Andrey Albershteyn wrote:
> On 2026-01-09 17:22:52, Christoph Hellwig wrote:
> > From: Damien Le Moal <dlemoal@kernel.org>
> > 
> > Source kernel commit: e04ccfc28252f181ea8d469d834b48e7dece65b2
> > 
> > Modify xfs_mount_zones() to replace the call to blkdev_report_zones()
> > with blkdev_report_zones_cached() to speed-up mount operations.
> > Since this causes xfs_zone_validate_seq() to see zones with the
> > BLK_ZONE_COND_ACTIVE condition, this function is also modified to acept
> > this condition as valid.
> > 
> > With this change, mounting a freshly formatted large capacity (30 TB)
> > SMR HDD completes under 2s compared to over 4.7s before.
> > 
> > Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> > Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
> > Signed-off-by: Jens Axboe <axboe@kernel.dk>
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  include/platform_defs.h | 4 ++++
> >  libxfs/xfs_zones.c      | 1 +
> >  2 files changed, 5 insertions(+)
> > 
> > diff --git a/include/platform_defs.h b/include/platform_defs.h
> > index da966490b0f5..cfdaca642645 100644
> > --- a/include/platform_defs.h
> > +++ b/include/platform_defs.h
> > @@ -307,4 +307,8 @@ struct kvec {
> >  	size_t iov_len;
> >  };
> >  
> > +#ifndef BLK_ZONE_COND_ACTIVE /* added in Linux 6.19 */
> > +#define BLK_ZONE_COND_ACTIVE	0xff
> 
> hmm I think #ifndef doesn't work for enum member. Compiling against
> linux 6.19-rc6: 
> 
> ../include/platform_defs.h:311:33: error: expected identifier before numeric constant
>   311 | #define BLK_ZONE_COND_ACTIVE    0xff
>       |                                 ^~~~
> /linux-headers-v6.19-rc6/include/linux/blkzoned.h:84:9: note: in expansion of macro ‘BLK_ZONE_COND_ACTIVE’
>    84 |         BLK_ZONE_COND_ACTIVE    = 0xFF,
>       |         ^~~~~~~~~~~~~~~~~~~~

I hacked around this very crudely:
https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfsprogs-dev.git/commit/?h=djwong-wtf&id=d5d9b4bd2da95c7b9429112f1c1098a62f155270

Though I think one of hch's fix patches fixed that.  I cannot post a
lore link because the #@!%)*&!%!!! anubis b@%#%!!! is completely broken
and will not let me in.  But we did the review for the kernel-side fixes
within the last couple of weeks.

--D

> 
> -- 
> - Andrey
> 
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/4] xfs: use blkdev_report_zones_cached()
  2026-01-20 17:31     ` Darrick J. Wong
@ 2026-01-21  6:49       ` Christoph Hellwig
  2026-01-27 16:39         ` [PATCH] libfrog: adjust header order for BLK_ZONE_COND_ACTIVE #ifndef check Andrey Albershteyn
  0 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2026-01-21  6:49 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Andrey Albershteyn, Christoph Hellwig, Andrey Albershteyn,
	Damien Le Moal, Carlos Maiolino, linux-xfs, Martin K. Petersen,
	Jens Axboe

On Tue, Jan 20, 2026 at 09:31:19AM -0800, Darrick J. Wong wrote:
> > > +#ifndef BLK_ZONE_COND_ACTIVE /* added in Linux 6.19 */
> > > +#define BLK_ZONE_COND_ACTIVE	0xff
> > 
> > hmm I think #ifndef doesn't work for enum member. Compiling against
> > linux 6.19-rc6: 
> > 
> > ../include/platform_defs.h:311:33: error: expected identifier before numeric constant
> >   311 | #define BLK_ZONE_COND_ACTIVE    0xff
> >       |                                 ^~~~
> > /linux-headers-v6.19-rc6/include/linux/blkzoned.h:84:9: note: in expansion of macro ‘BLK_ZONE_COND_ACTIVE’
> >    84 |         BLK_ZONE_COND_ACTIVE    = 0xFF,
> >       |         ^~~~~~~~~~~~~~~~~~~~
> 
> I hacked around this very crudely:
> https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfsprogs-dev.git/commit/?h=djwong-wtf&id=d5d9b4bd2da95c7b9429112f1c1098a62f155270

Urgg.  That's why we should not use enums in uapi headers..

Damien, I guess we could do a:

#define BLK_ZONE_COND_ACTIVE	BLK_ZONE_COND_ACTIVE

as the usual trick to fix that in the blkzoned.h header, and given
that 6.19 hasn't been released still get it to Linus in time.

> Though I think one of hch's fix patches fixed that.  I cannot post a
> lore link because the #@!%)*&!%!!! anubis b@%#%!!! is completely broken
> and will not let me in.  But we did the review for the kernel-side fixes
> within the last couple of weeks.

I don't think I fixed it.  Not intentionally, and not unintentionally
in a way I'd actually understand at least :)


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] libfrog: adjust header order for BLK_ZONE_COND_ACTIVE #ifndef check
  2026-01-21  6:49       ` Christoph Hellwig
@ 2026-01-27 16:39         ` Andrey Albershteyn
  2026-01-27 16:43           ` Christoph Hellwig
  0 siblings, 1 reply; 16+ messages in thread
From: Andrey Albershteyn @ 2026-01-27 16:39 UTC (permalink / raw)
  To: hch, linux-xfs, dlemoal; +Cc: Andrey Albershteyn

Even after kernel fix via defining BLK_ZONE_COND_ACTIVE the compiler
is still failing on this with:

In file included from zones.c:5:
../include/platform_defs.h:311:33: error: expected identifier before numeric constant
  311 | #define BLK_ZONE_COND_ACTIVE    0xff
      |                                 ^~~~
/linux-headers-v6.19-rc7/include/linux/blkzoned.h:84:9: note: in expansion of macro ‘BLK_ZONE_COND_ACTIVE’
   84 |         BLK_ZONE_COND_ACTIVE    = 0xFF, /* added in Linux 6.19 */
      |         ^~~~~~~~~~~~~~~~~~~~
In file included from ../libfrog/zones.h:8,
                 from zones.c:7:
/linux-headers-v6.19-rc7/include/linux/blkzoned.h:85:9: warning: ‘BLK_ZONE_COND_ACTIVE’ redefined
   85 | #define BLK_ZONE_COND_ACTIVE    BLK_ZONE_COND_ACTIVE
      |         ^~~~~~~~~~~~~~~~~~~~
../include/platform_defs.h:311:9: note: this is the location of the previous definition
  311 | #define BLK_ZONE_COND_ACTIVE    0xff
      |         ^~~~~~~~~~~~~~~~~~~~

This is because of the order of #ifndef (in platform_defs.h) and #define
(in blkzoned.h). The platform_defs.h defines BLK_ZONE_COND_ACTIVE first
and this causes enum to fail and macro being redefined. Fix this by
including libfrog/zones.h first, which includes blkzoned.h. Add stdint.h for
uint64_t in xfrog_report_zones().

Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
 libfrog/zones.c | 2 +-
 libfrog/zones.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/libfrog/zones.c b/libfrog/zones.c
index f1ef0b24c564..68be7388172b 100644
--- a/libfrog/zones.c
+++ b/libfrog/zones.c
@@ -2,9 +2,9 @@
 /*
  * Copyright (c) 2025, Western Digital Corporation or its affiliates.
  */
+#include "libfrog/zones.h"
 #include "platform_defs.h"
 #include "atomic.h"
-#include "libfrog/zones.h"
 #include <sys/ioctl.h>
 
 /*
diff --git a/libfrog/zones.h b/libfrog/zones.h
index 33c1da7ef192..4cc4d15c4dab 100644
--- a/libfrog/zones.h
+++ b/libfrog/zones.h
@@ -6,6 +6,7 @@
 #define __LIBFROG_ZONES_H__
 
 #include <linux/blkzoned.h>
+#include <stdint.h>
 
 struct xfrog_zone_report {
 	struct blk_zone_report	rep;
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] libfrog: adjust header order for BLK_ZONE_COND_ACTIVE #ifndef check
  2026-01-27 16:39         ` [PATCH] libfrog: adjust header order for BLK_ZONE_COND_ACTIVE #ifndef check Andrey Albershteyn
@ 2026-01-27 16:43           ` Christoph Hellwig
  2026-01-27 16:55             ` Andrey Albershteyn
  0 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2026-01-27 16:43 UTC (permalink / raw)
  To: Andrey Albershteyn; +Cc: hch, linux-xfs, dlemoal

On Tue, Jan 27, 2026 at 05:39:29PM +0100, Andrey Albershteyn wrote:
> This is because of the order of #ifndef (in platform_defs.h) and #define
> (in blkzoned.h). The platform_defs.h defines BLK_ZONE_COND_ACTIVE first
> and this causes enum to fail and macro being redefined. Fix this by
> including libfrog/zones.h first, which includes blkzoned.h. Add stdint.h for
> uint64_t in xfrog_report_zones().

Thanks, this looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

please order this before the cached zone reporting series, or fold it in
to preserve bisectability.  Or should I resend the series with this
change included?


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] libfrog: adjust header order for BLK_ZONE_COND_ACTIVE #ifndef check
  2026-01-27 16:43           ` Christoph Hellwig
@ 2026-01-27 16:55             ` Andrey Albershteyn
  2026-01-27 16:59               ` Andrey Albershteyn
  0 siblings, 1 reply; 16+ messages in thread
From: Andrey Albershteyn @ 2026-01-27 16:55 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Andrey Albershteyn, linux-xfs, dlemoal

On 2026-01-27 17:43:09, Christoph Hellwig wrote:
> On Tue, Jan 27, 2026 at 05:39:29PM +0100, Andrey Albershteyn wrote:
> > This is because of the order of #ifndef (in platform_defs.h) and #define
> > (in blkzoned.h). The platform_defs.h defines BLK_ZONE_COND_ACTIVE first
> > and this causes enum to fail and macro being redefined. Fix this by
> > including libfrog/zones.h first, which includes blkzoned.h. Add stdint.h for
> > uint64_t in xfrog_report_zones().
> 
> Thanks, this looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Thanks!

> 
> please order this before the cached zone reporting series, or fold it in

I will apply it first

-- 
- Andrey


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] libfrog: adjust header order for BLK_ZONE_COND_ACTIVE #ifndef check
  2026-01-27 16:55             ` Andrey Albershteyn
@ 2026-01-27 16:59               ` Andrey Albershteyn
  2026-01-27 17:01                 ` Christoph Hellwig
  0 siblings, 1 reply; 16+ messages in thread
From: Andrey Albershteyn @ 2026-01-27 16:59 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Andrey Albershteyn, linux-xfs, dlemoal

On 2026-01-27 17:55:32, Andrey Albershteyn wrote:
> On 2026-01-27 17:43:09, Christoph Hellwig wrote:
> > On Tue, Jan 27, 2026 at 05:39:29PM +0100, Andrey Albershteyn wrote:
> > > This is because of the order of #ifndef (in platform_defs.h) and #define
> > > (in blkzoned.h). The platform_defs.h defines BLK_ZONE_COND_ACTIVE first
> > > and this causes enum to fail and macro being redefined. Fix this by
> > > including libfrog/zones.h first, which includes blkzoned.h. Add stdint.h for
> > > uint64_t in xfrog_report_zones().
> > 
> > Thanks, this looks good:
> > 
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> Thanks!
> 
> > 
> > please order this before the cached zone reporting series, or fold it in
> 
> I will apply it first

hmm, actually there's no this header to apply fix to, can you resend
it with this fix applied?

-- 
- Andrey


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] libfrog: adjust header order for BLK_ZONE_COND_ACTIVE #ifndef check
  2026-01-27 16:59               ` Andrey Albershteyn
@ 2026-01-27 17:01                 ` Christoph Hellwig
  0 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2026-01-27 17:01 UTC (permalink / raw)
  To: Andrey Albershteyn
  Cc: Christoph Hellwig, Andrey Albershteyn, linux-xfs, dlemoal

On Tue, Jan 27, 2026 at 05:59:14PM +0100, Andrey Albershteyn wrote:
> > I will apply it first
> 
> hmm, actually there's no this header to apply fix to, can you resend
> it with this fix applied?

Sure.


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-01-27 17:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-09 16:22 enable cached zone report v4 Christoph Hellwig
2026-01-09 16:22 ` [PATCH 1/4] xfs: use blkdev_report_zones_cached() Christoph Hellwig
2026-01-20 14:28   ` Andrey Albershteyn
2026-01-20 17:31     ` Darrick J. Wong
2026-01-21  6:49       ` Christoph Hellwig
2026-01-27 16:39         ` [PATCH] libfrog: adjust header order for BLK_ZONE_COND_ACTIVE #ifndef check Andrey Albershteyn
2026-01-27 16:43           ` Christoph Hellwig
2026-01-27 16:55             ` Andrey Albershteyn
2026-01-27 16:59               ` Andrey Albershteyn
2026-01-27 17:01                 ` Christoph Hellwig
2026-01-09 16:22 ` [PATCH 2/4] mkfs: remove unnecessary return value affectation Christoph Hellwig
2026-01-09 16:22 ` [PATCH 3/4] libfrog: lift common zone reporting code from mkfs and repair Christoph Hellwig
2026-01-09 16:31   ` Darrick J. Wong
2026-01-09 16:22 ` [PATCH 4/4] libfrog: enable cached report zones Christoph Hellwig
2026-01-09 16:32   ` Darrick J. Wong
2026-01-12 11:02 ` enable cached zone report v4 Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox