From: "Darrick J. Wong" <djwong@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: linux-xfs@vger.kernel.org,
Andrey Albershteyn <aalbersh@kernel.org>,
Christoph Hellwig <hch@lst.de>, Carlos Maiolino <cem@kernel.org>
Subject: Re: [PATCH v3 3/6] libfrog: introduce xfrog_report_zones
Date: Tue, 6 Jan 2026 08:29:50 -0800 [thread overview]
Message-ID: <20260106162950.GD191501@frogsfrogsfrogs> (raw)
In-Reply-To: <20251220025326.209196-4-dlemoal@kernel.org>
On Sat, Dec 20, 2025 at 11:53:23AM +0900, Damien Le Moal wrote:
> 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.
>
> xfrog_report_zones() allocates and returns a struct blk_zone_report
> structure. It is the responsibility of the caller to free this
> structure after use.
>
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
> libfrog/Makefile | 6 ++++--
> libfrog/zones.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> libfrog/zones.h | 13 +++++++++++++
> 3 files changed, 59 insertions(+), 2 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..0187edce5fa4
> --- /dev/null
> +++ b/libfrog/zones.c
> @@ -0,0 +1,42 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2025, Western Digital Corporation or its affiliates.
> + */
> +#include "platform_defs.h"
> +#include "zones.h"
Nit:
#include "libfrog/zones.h"
to make it more obvious that we're looking for the libfrog version (on
the off chance /usr/include ever end up with a zones.h).
> +#include <sys/ioctl.h>
> +
> +/* random size that allows efficient processing */
> +#define ZONES_PER_REPORT 16384
> +
> +struct blk_zone_report *
> +xfrog_report_zones(
> + int fd,
> + uint64_t sector)
> +{
> + struct blk_zone_report *rep;
> + size_t rep_size;
> + int ret;
> +
> + rep_size = sizeof(struct blk_zone_report) +
> + sizeof(struct blk_zone) * ZONES_PER_REPORT;
> + rep = calloc(1, rep_size);
> + if (!rep) {
> + fprintf(stderr,
> +_("Failed to allocate memory for reporting zones.\n"));
> + return NULL;
> + }
> +
> + rep->sector = sector;
> + rep->nr_zones = ZONES_PER_REPORT;
> +
> + ret = ioctl(fd, BLKREPORTZONE, rep);
> + if (ret) {
> + fprintf(stderr,
> +_("ioctl(BLKREPORTZONE) failed: %d!\n"), -errno);
Note that eventually gcc & friends will start warning about non-constant
formatting strings because i18n catalogue attacks are a thing now.
<start rant>
aka the Rigellian translation pack maps that string to "Hork fubzzz %s
%s %s %s" and now fprintf walks right off the varargs list and kaboom.
Annoyingly this makes output even worse because the canonical form of
that becomes this monstrosity:
fprintf(stderr, "%s: %s\n", _("BLKREPORTZONE failed"),
strerror(-errno));
This also fails because the Rigellians use jack-o-lantern emoji to
separate fields instead of colon-space so I don't know what to do :P
<end rant>
That said, xfsprogs is full of potential i18n catalogue attacks so if
Andrey's cool with it, then I'll go along with it.
(Though I'll at least try to remember not to type out the familiar old
way even though I've been doing it for 30 years.)
> + free(rep);
> + return NULL;
> + }
> +
> + return rep;
The logic in here looks good, though.
> +}
> diff --git a/libfrog/zones.h b/libfrog/zones.h
> new file mode 100644
> index 000000000000..66df7a426a27
> --- /dev/null
> +++ b/libfrog/zones.h
> @@ -0,0 +1,13 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2025, Western Digital Corporation or its affiliates.
> + */
> +#ifndef __LIBFROG_ZONE_H__
> +#define __LIBFROG_ZONE_H__
> +
> +#include <stdint.h>
> +#include <linux/blkzoned.h>
Don't put includes in header files, please. uint64_t should be covered
by platform_defs.h and you can just have a forward declaration of struct
blk_zone_report.
--D
> +
> +struct blk_zone_report *xfrog_report_zones(int fd, uint64_t sector);
> +
> +#endif /* __LIBFROG_ZONE_H__ */
> --
> 2.52.0
>
>
next prev parent reply other threads:[~2026-01-06 16:29 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 [this message]
2025-12-20 2:53 ` [PATCH v3 4/6] mkfs: use xfrog_report_zones() Damien Le Moal
2026-01-06 16:31 ` 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=20260106162950.GD191501@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