Skip to contentSkip to conversation

Enable cached zone report

PATCH Superseded Damien Le Moal 1 participant 5 messages Dec 19, 2025

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Enable cached zone report

Enable cached zone report to speed up mkfs and repair. Cached zone report support was introduced in the kernel with version 6.19-rc1. This was co-developped with Christoph.

Damien Le Moal (3):
libxfs: define BLKREPORTZONEV2 if the kernel does not provide it
mkfs: use cached report zone
repair: use cached report zone

 libxfs/topology.h | 8 ++++++++
 mkfs/xfs_mkfs.c   | 7 ++++++-
 repair/zoned.c    | 7 ++++++-
 3 files changed, 20 insertions(+), 2 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/3 libxfs: define BLKREPORTZONEV2 if the kernel does not provide it

Define the BLKREPORTZONEV2 ioctl and the BLK_ZONE_REP_CACHED flag if the kernel blkzoned.h header file does not provide these, to allow faster zone reporting in mkfs and repair.

[hch: split from a larger patch]
---
 libxfs/topology.h | 8 ++++++++
 1 file changed, 8 insertions(+)
libxfs/topology.h +8 -0
index f0ca65f3576e..a6e69353f9a0 100644
@@ -46,4 +46,12 @@ extern int
 check_overwrite(
 	const char	*device);
 
+/*
+ * Cached report ioctl (/usr/include/linux/blkzoned.h)
+ */
+#ifndef BLKREPORTZONEV2
+#define BLKREPORTZONEV2		_IOWR(0x12, 142, struct blk_zone_report)
+#define BLK_ZONE_REP_CACHED	(1U << 31)
+#endif
+
 #endif	/* __LIBXFS_TOPOLOGY_H__ */
Signature · 1 line
2.52.0
#2 lore raw

PATCH 2/3 mkfs: use cached report zone

In reply to Damien Le Moal

Use BLKREPORTZONEV2 ioctl with the BLK_ZONE_REP_CACHED flag set to speed up zone reports. If this fails, fallback to the legacy BLKREPORTZONE ioctl() which is slower as it uses the device to get the zone report.

[hch: split out BLKREPORTZONEV2 and BLK_ZONE_REP_CACHED definition into another patch]

---
 mkfs/xfs_mkfs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
mkfs/xfs_mkfs.c +6 -1
index bc6a28b63c24..7088823b3f54 100644
@@ -2623,8 +2623,13 @@ _("Failed to allocate memory for zone reporting.\n"));
 		memset(rep, 0, rep_size);
 		rep->sector = sector;
 		rep->nr_zones = ZONES_PER_IOCTL;
+		rep->flags = BLK_ZONE_REP_CACHED;
 
-		ret = ioctl(fd, BLKREPORTZONE, rep);
+		ret = ioctl(fd, BLKREPORTZONEV2, rep);
+		if (ret == -ENOTTY) {
+			rep->flags = 0;
+			ret = ioctl(fd, BLKREPORTZONE, rep);
+		}
 		if (ret) {
 			fprintf(stderr,
 _("ioctl(BLKREPORTZONE) failed: %d!\n"), -errno);
Signature · 1 line
2.52.0
#3 lore raw

PATCH 3/3 repair: use cached report zone

In reply to Damien Le Moal

Use BLKREPORTZONEV2 ioctl with the BLK_ZONE_REP_CACHED flag set to speed up zone reports. If this fails, fallback to the legacy BLKREPORTZONE ioctl() which is slower as it uses the device to get the zone report.

---
 repair/zoned.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
repair/zoned.c +6 -1
index 206b0158f95f..84018a104208 100644
@@ -82,8 +82,13 @@ check_zones(
 		memset(rep, 0, rep_size);
 		rep->sector = sector;
 		rep->nr_zones = ZONES_PER_IOCTL;
+		rep->flags = BLK_ZONE_REP_CACHED;
 
-		ret = ioctl(fd, BLKREPORTZONE, rep);
+		ret = ioctl(fd, BLKREPORTZONEV2, rep);
+		if (ret == -ENOTTY) {
+			rep->flags = 0;
+			ret = ioctl(fd, BLKREPORTZONE, rep);
+		}
 		if (ret) {
 			do_error(_("ioctl(BLKREPORTZONE) failed: %d!\n"), ret);
 			goto out_free;
Signature · 1 line
2.52.0
#4 lore raw
In reply to Damien Le Moal
Quoted 9 lines · Damien Le Moal

Enable cached zone report to speed up mkfs and repair. Cached zone report support was introduced in the kernel with version 6.19-rc1. This was co-developped with Christoph.

Damien Le Moal (3):
libxfs: define BLKREPORTZONEV2 if the kernel does not provide it
mkfs: use cached report zone
repair: use cached report zone

Quoted 5 lines
 libxfs/topology.h | 8 ++++++++
 mkfs/xfs_mkfs.c   | 7 ++++++-
 repair/zoned.c    | 7 ++++++-
 3 files changed, 20 insertions(+), 2 deletions(-)

Please disregard this version. I botched the patches and they breaks mkfs & repair on kernels that do not have cached zone report. Resending a v2.

Signature · 2 lines
Damien Le Moal
Western Digital Research