public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: linux-xfs@vger.kernel.org, Andrey Albershteyn <aalbersh@kernel.org>
Cc: "Darrick J . Wong" <djwong@kernel.org>,
	Christoph Hellwig <hch@lst.de>, Carlos Maiolino <cem@kernel.org>
Subject: [PATCH v3 4/6] mkfs: use xfrog_report_zones()
Date: Sat, 20 Dec 2025 11:53:24 +0900	[thread overview]
Message-ID: <20251220025326.209196-5-dlemoal@kernel.org> (raw)
In-Reply-To: <20251220025326.209196-1-dlemoal@kernel.org>

Use the function xfrog_report_zones() to obtain zone information from
a zoned device instead of directly issuing a BLKREPORTZONE ioctl.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 mkfs/xfs_mkfs.c | 35 +++++++++--------------------------
 1 file changed, 9 insertions(+), 26 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 550fc011b614..ac7ad0661805 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -6,7 +6,6 @@
 #include "libfrog/util.h"
 #include "libxfs.h"
 #include <ctype.h>
-#include <linux/blkzoned.h>
 #include "libxfs/xfs_zones.h"
 #include "xfs_multidisk.h"
 #include "libxcmd.h"
@@ -15,6 +14,7 @@
 #include "libfrog/crc32cselftest.h"
 #include "libfrog/dahashselftest.h"
 #include "libfrog/fsproperties.h"
+#include "libfrog/zones.h"
 #include "proto.h"
 #include <ini.h>
 
@@ -2566,20 +2566,16 @@ struct zone_topology {
 	struct zone_info	log;
 };
 
-/* random size that allows efficient processing */
-#define ZONES_PER_IOCTL			16384
-
 static void
 report_zones(
 	const char		*name,
 	struct zone_info	*zi)
 {
-	struct blk_zone_report	*rep;
+	struct blk_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;
 
@@ -2606,31 +2602,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);
+		free(rep);
+		rep = xfrog_report_zones(fd, sector);
+		if (!rep)
 			exit(1);
-		}
+
 		if (!rep->nr_zones)
 			break;
 
+		zones = (struct blk_zone *)(rep + 1);
 		for (i = 0; i < rep->nr_zones; i++) {
 			if (n >= zi->nr_zones)
 				break;
-- 
2.52.0


  parent reply	other threads:[~2025-12-20  2:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-20  2:53 [PATCH v3 0/6] Enable cached zone report Damien Le Moal
2025-12-20  2:53 ` [PATCH v3 1/6] libxfs: add missing forward declaration in xfs_zones.h Damien Le Moal
2026-01-06 16:16   ` Darrick J. Wong
2026-01-07  6:20   ` Christoph Hellwig
2025-12-20  2:53 ` [PATCH v3 2/6] mkfs: remove unnecessary return value affectation Damien Le Moal
2026-01-06 16:17   ` Darrick J. Wong
2026-01-07  6:20   ` Christoph Hellwig
2025-12-20  2:53 ` [PATCH v3 3/6] libfrog: introduce xfrog_report_zones Damien Le Moal
2026-01-06 16:29   ` Darrick J. Wong
2025-12-20  2:53 ` Damien Le Moal [this message]
2026-01-06 16:31   ` [PATCH v3 4/6] mkfs: use xfrog_report_zones() Darrick J. Wong
2025-12-20  2:53 ` [PATCH v3 5/6] repair: " Damien Le Moal
2025-12-20  2:53 ` [PATCH v3 6/6] libfrog: enable cached report zones Damien Le Moal
2026-01-06 16:34   ` Darrick J. Wong
2026-01-07  6:22   ` Christoph Hellwig

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=20251220025326.209196-5-dlemoal@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=aalbersh@kernel.org \
    --cc=cem@kernel.org \
    --cc=djwong@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