* [PATCH v2 0/3] Enable cached zone report
@ 2025-12-19 9:38 Damien Le Moal
2025-12-19 9:38 ` [PATCH v2 1/3] libxfs: define BLKREPORTZONEV2 if the kernel does not provide it Damien Le Moal
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Damien Le Moal @ 2025-12-19 9:38 UTC (permalink / raw)
To: linux-xfs, Andrey Albershteyn, Darrick J . Wong
Cc: Christoph Hellwig, Carlos Maiolino
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. This was co-developped with
Christoph.
Darrick,
It may be cleaner to have a common report zones helper instead of
repating the same ioctl pattern in mkfs/xfs_mkfs.c and repair/zoned.c.
However, I am not sure where to place such helper. In libxfs/ or in
libfrog/ ? Please advise.
Thanks !
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 (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(-)
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/3] libxfs: define BLKREPORTZONEV2 if the kernel does not provide it
2025-12-19 9:38 [PATCH v2 0/3] Enable cached zone report Damien Le Moal
@ 2025-12-19 9:38 ` Damien Le Moal
2025-12-19 9:38 ` [PATCH v2 2/3] mkfs: use cached report zone Damien Le Moal
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Damien Le Moal @ 2025-12-19 9:38 UTC (permalink / raw)
To: linux-xfs, Andrey Albershteyn, Darrick J . Wong
Cc: Christoph Hellwig, Carlos Maiolino
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.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
[hch: split from a larger patch]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
libxfs/topology.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/libxfs/topology.h b/libxfs/topology.h
index f0ca65f3576e..a6e69353f9a0 100644
--- a/libxfs/topology.h
+++ b/libxfs/topology.h
@@ -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__ */
--
2.52.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/3] mkfs: use cached report zone
2025-12-19 9:38 [PATCH v2 0/3] Enable cached zone report Damien Le Moal
2025-12-19 9:38 ` [PATCH v2 1/3] libxfs: define BLKREPORTZONEV2 if the kernel does not provide it Damien Le Moal
@ 2025-12-19 9:38 ` Damien Le Moal
2025-12-19 9:38 ` [PATCH v2 3/3] repair: " Damien Le Moal
2025-12-19 23:56 ` [PATCH v2 0/3] Enable cached zone report Darrick J. Wong
3 siblings, 0 replies; 10+ messages in thread
From: Damien Le Moal @ 2025-12-19 9:38 UTC (permalink / raw)
To: linux-xfs, Andrey Albershteyn, Darrick J . Wong
Cc: Christoph Hellwig, Carlos Maiolino
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.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
[hch: split out BLKREPORTZONEV2 and BLK_ZONE_REP_CACHED definition into
another patch]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
mkfs/xfs_mkfs.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index bc6a28b63c24..59c673532ad6 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -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 < 0 && errno == ENOTTY) {
+ rep->flags = 0;
+ ret = ioctl(fd, BLKREPORTZONE, rep);
+ }
if (ret) {
fprintf(stderr,
_("ioctl(BLKREPORTZONE) failed: %d!\n"), -errno);
--
2.52.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/3] repair: use cached report zone
2025-12-19 9:38 [PATCH v2 0/3] Enable cached zone report Damien Le Moal
2025-12-19 9:38 ` [PATCH v2 1/3] libxfs: define BLKREPORTZONEV2 if the kernel does not provide it Damien Le Moal
2025-12-19 9:38 ` [PATCH v2 2/3] mkfs: use cached report zone Damien Le Moal
@ 2025-12-19 9:38 ` Damien Le Moal
2025-12-19 23:56 ` [PATCH v2 0/3] Enable cached zone report Darrick J. Wong
3 siblings, 0 replies; 10+ messages in thread
From: Damien Le Moal @ 2025-12-19 9:38 UTC (permalink / raw)
To: linux-xfs, Andrey Albershteyn, Darrick J . Wong
Cc: Christoph Hellwig, Carlos Maiolino
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.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
repair/zoned.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/repair/zoned.c b/repair/zoned.c
index 206b0158f95f..1e4891c483ee 100644
--- a/repair/zoned.c
+++ b/repair/zoned.c
@@ -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 < 0 && errno == ENOTTY) {
+ rep->flags = 0;
+ ret = ioctl(fd, BLKREPORTZONE, rep);
+ }
if (ret) {
do_error(_("ioctl(BLKREPORTZONE) failed: %d!\n"), ret);
goto out_free;
--
2.52.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] Enable cached zone report
2025-12-19 9:38 [PATCH v2 0/3] Enable cached zone report Damien Le Moal
` (2 preceding siblings ...)
2025-12-19 9:38 ` [PATCH v2 3/3] repair: " Damien Le Moal
@ 2025-12-19 23:56 ` Darrick J. Wong
2025-12-19 23:59 ` Darrick J. Wong
2025-12-20 0:00 ` Damien Le Moal
3 siblings, 2 replies; 10+ messages in thread
From: Darrick J. Wong @ 2025-12-19 23:56 UTC (permalink / raw)
To: Damien Le Moal
Cc: linux-xfs, Andrey Albershteyn, Christoph Hellwig, Carlos Maiolino
On Fri, Dec 19, 2025 at 06:38:07PM +0900, Damien Le Moal 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. This was co-developped with
> Christoph.
Just out of curiosity, do you see any xfsprogs build problems with
BLK_ZONE_COND_ACTIVE if the kernel headers are from 6.18?
> Darrick,
>
> It may be cleaner to have a common report zones helper instead of
> repating the same ioctl pattern in mkfs/xfs_mkfs.c and repair/zoned.c.
> However, I am not sure where to place such helper. In libxfs/ or in
> libfrog/ ? Please advise.
libfrog/, please.
--D
> Thanks !
>
> 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 (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(-)
>
> --
> 2.52.0
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] Enable cached zone report
2025-12-19 23:56 ` [PATCH v2 0/3] Enable cached zone report Darrick J. Wong
@ 2025-12-19 23:59 ` Darrick J. Wong
2025-12-20 0:00 ` Damien Le Moal
1 sibling, 0 replies; 10+ messages in thread
From: Darrick J. Wong @ 2025-12-19 23:59 UTC (permalink / raw)
To: Damien Le Moal
Cc: linux-xfs, Andrey Albershteyn, Christoph Hellwig, Carlos Maiolino
On Fri, Dec 19, 2025 at 03:56:02PM -0800, Darrick J. Wong wrote:
> On Fri, Dec 19, 2025 at 06:38:07PM +0900, Damien Le Moal 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. This was co-developped with
> > Christoph.
>
> Just out of curiosity, do you see any xfsprogs build problems with
> BLK_ZONE_COND_ACTIVE if the kernel headers are from 6.18?
>
> > Darrick,
> >
> > It may be cleaner to have a common report zones helper instead of
> > repating the same ioctl pattern in mkfs/xfs_mkfs.c and repair/zoned.c.
> > However, I am not sure where to place such helper. In libxfs/ or in
> > libfrog/ ? Please advise.
>
> libfrog/, please.
and since I hit [send] without providing a reason, I'll request a
do-over:
libfrog/, please. That's where we stuff all the support code, ioctl
wrappers, and data structures for xfsprogs nowadays. It's better than
cluttering up libxfs/.
--D
> --D
>
> > Thanks !
> >
> > 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 (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(-)
> >
> > --
> > 2.52.0
> >
> >
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] Enable cached zone report
2025-12-19 23:56 ` [PATCH v2 0/3] Enable cached zone report Darrick J. Wong
2025-12-19 23:59 ` Darrick J. Wong
@ 2025-12-20 0:00 ` Damien Le Moal
2025-12-20 1:54 ` Darrick J. Wong
1 sibling, 1 reply; 10+ messages in thread
From: Damien Le Moal @ 2025-12-20 0:00 UTC (permalink / raw)
To: Darrick J. Wong
Cc: linux-xfs, Andrey Albershteyn, Christoph Hellwig, Carlos Maiolino
On 12/20/25 08:56, Darrick J. Wong wrote:
> On Fri, Dec 19, 2025 at 06:38:07PM +0900, Damien Le Moal 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. This was co-developped with
>> Christoph.
>
> Just out of curiosity, do you see any xfsprogs build problems with
> BLK_ZONE_COND_ACTIVE if the kernel headers are from 6.18?
Nope, I do not, at least not with my Fedora 6.17.12 headers (which do not have
BLK_ZONE_COND_ACTIVE defined). Do you see any problem ?
>
>> Darrick,
>>
>> It may be cleaner to have a common report zones helper instead of
>> repating the same ioctl pattern in mkfs/xfs_mkfs.c and repair/zoned.c.
>> However, I am not sure where to place such helper. In libxfs/ or in
>> libfrog/ ? Please advise.
>
> libfrog/, please.
OK. Will add a helper there then. libfrog/zone.c is OK ?
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] Enable cached zone report
2025-12-20 0:00 ` Damien Le Moal
@ 2025-12-20 1:54 ` Darrick J. Wong
2025-12-20 2:22 ` Damien Le Moal
2025-12-20 2:59 ` Damien Le Moal
0 siblings, 2 replies; 10+ messages in thread
From: Darrick J. Wong @ 2025-12-20 1:54 UTC (permalink / raw)
To: Damien Le Moal
Cc: linux-xfs, Andrey Albershteyn, Christoph Hellwig, Carlos Maiolino
On Sat, Dec 20, 2025 at 09:00:10AM +0900, Damien Le Moal wrote:
> On 12/20/25 08:56, Darrick J. Wong wrote:
> > On Fri, Dec 19, 2025 at 06:38:07PM +0900, Damien Le Moal 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. This was co-developped with
> >> Christoph.
> >
> > Just out of curiosity, do you see any xfsprogs build problems with
> > BLK_ZONE_COND_ACTIVE if the kernel headers are from 6.18?
>
> Nope, I do not, at least not with my Fedora 6.17.12 headers (which do not have
> BLK_ZONE_COND_ACTIVE defined). Do you see any problem ?
I see it, but only if I ./tools/libxfs-apply the 6.19-rc libxfs/ changes
to the xfsprogs codebase first. I came up with an ugly workaround:
https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfsprogs-dev.git/commit/?h=libxfs-6.19-sync&id=a448911c20ec0d3482361b2287266abd76d9f979
that sloppily #defines it if it doesn't exist.
> >
> >> Darrick,
> >>
> >> It may be cleaner to have a common report zones helper instead of
> >> repating the same ioctl pattern in mkfs/xfs_mkfs.c and repair/zoned.c.
> >> However, I am not sure where to place such helper. In libxfs/ or in
> >> libfrog/ ? Please advise.
> >
> > libfrog/, please.
>
> OK. Will add a helper there then. libfrog/zone.c is OK ?
Yep.
--D
> --
> Damien Le Moal
> Western Digital Research
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] Enable cached zone report
2025-12-20 1:54 ` Darrick J. Wong
@ 2025-12-20 2:22 ` Damien Le Moal
2025-12-20 2:59 ` Damien Le Moal
1 sibling, 0 replies; 10+ messages in thread
From: Damien Le Moal @ 2025-12-20 2:22 UTC (permalink / raw)
To: Darrick J. Wong
Cc: linux-xfs, Andrey Albershteyn, Christoph Hellwig, Carlos Maiolino
On 12/20/25 10:54, Darrick J. Wong wrote:
> On Sat, Dec 20, 2025 at 09:00:10AM +0900, Damien Le Moal wrote:
>> On 12/20/25 08:56, Darrick J. Wong wrote:
>>> On Fri, Dec 19, 2025 at 06:38:07PM +0900, Damien Le Moal 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. This was co-developped with
>>>> Christoph.
>>>
>>> Just out of curiosity, do you see any xfsprogs build problems with
>>> BLK_ZONE_COND_ACTIVE if the kernel headers are from 6.18?
>>
>> Nope, I do not, at least not with my Fedora 6.17.12 headers (which do not have
>> BLK_ZONE_COND_ACTIVE defined). Do you see any problem ?
>
> I see it, but only if I ./tools/libxfs-apply the 6.19-rc libxfs/ changes
> to the xfsprogs codebase first. I came up with an ugly workaround:
> https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfsprogs-dev.git/commit/?h=libxfs-6.19-sync&id=a448911c20ec0d3482361b2287266abd76d9f979
>
> that sloppily #defines it if it doesn't exist.
Arg. Of course ! I do not see the issue because cached zone report is not
supported on my setup where it is not defined.
OK. Adding that definition to libfrog/zones.h (new file). This defines the new
helper xfrog_report_zones(). Or should that go into libxfs ?
Or maybe libxfs/xfs_zones.h should include libfrog/zones.h.
>
>>>
>>>> Darrick,
>>>>
>>>> It may be cleaner to have a common report zones helper instead of
>>>> repating the same ioctl pattern in mkfs/xfs_mkfs.c and repair/zoned.c.
>>>> However, I am not sure where to place such helper. In libxfs/ or in
>>>> libfrog/ ? Please advise.
>>>
>>> libfrog/, please.
>>
>> OK. Will add a helper there then. libfrog/zone.c is OK ?
>
> Yep.
>
> --D
>
>> --
>> Damien Le Moal
>> Western Digital Research
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] Enable cached zone report
2025-12-20 1:54 ` Darrick J. Wong
2025-12-20 2:22 ` Damien Le Moal
@ 2025-12-20 2:59 ` Damien Le Moal
1 sibling, 0 replies; 10+ messages in thread
From: Damien Le Moal @ 2025-12-20 2:59 UTC (permalink / raw)
To: Darrick J. Wong
Cc: linux-xfs, Andrey Albershteyn, Christoph Hellwig, Carlos Maiolino
On 12/20/25 10:54, Darrick J. Wong wrote:
> On Sat, Dec 20, 2025 at 09:00:10AM +0900, Damien Le Moal wrote:
>> On 12/20/25 08:56, Darrick J. Wong wrote:
>>> On Fri, Dec 19, 2025 at 06:38:07PM +0900, Damien Le Moal 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. This was co-developped with
>>>> Christoph.
>>>
>>> Just out of curiosity, do you see any xfsprogs build problems with
>>> BLK_ZONE_COND_ACTIVE if the kernel headers are from 6.18?
>>
>> Nope, I do not, at least not with my Fedora 6.17.12 headers (which do not have
>> BLK_ZONE_COND_ACTIVE defined). Do you see any problem ?
>
> I see it, but only if I ./tools/libxfs-apply the 6.19-rc libxfs/ changes
> to the xfsprogs codebase first. I came up with an ugly workaround:
> https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfsprogs-dev.git/commit/?h=libxfs-6.19-sync&id=a448911c20ec0d3482361b2287266abd76d9f979
>
> that sloppily #defines it if it doesn't exist.
I addressed this in the v3 series I just posted. Much cleaner I think with the
common xfrog_report_zones() helper.
I am not used to xfsprogs code style though, so please review !
Cheers.
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-12-20 2:59 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-19 9:38 [PATCH v2 0/3] Enable cached zone report Damien Le Moal
2025-12-19 9:38 ` [PATCH v2 1/3] libxfs: define BLKREPORTZONEV2 if the kernel does not provide it Damien Le Moal
2025-12-19 9:38 ` [PATCH v2 2/3] mkfs: use cached report zone Damien Le Moal
2025-12-19 9:38 ` [PATCH v2 3/3] repair: " Damien Le Moal
2025-12-19 23:56 ` [PATCH v2 0/3] Enable cached zone report Darrick J. Wong
2025-12-19 23:59 ` Darrick J. Wong
2025-12-20 0:00 ` Damien Le Moal
2025-12-20 1:54 ` Darrick J. Wong
2025-12-20 2:22 ` Damien Le Moal
2025-12-20 2:59 ` 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