Enable cached zone report
v3 cover Enable cached zone report
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.
Patch 1 and 2 are a couple of simple fixes/cleanups.
Patch 3 intorduces the new xfrog_report_zones() helper function, which is used in patch 4 and 5 for mkfs and repair respectively. Finally, patch 6 modifies xfrog_report_zones() to enable cached report zones.
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 (6):
libxfs: add missing forward declaration in xfs_zones.h
mkfs: remove unnecessary return value affectation
libfrog: introduce xfrog_report_zones
mkfs: use xfrog_report_zones()
repair: use xfrog_report_zones()
libfrog: enable cached report zones
libfrog/Makefile | 6 ++++-- libfrog/zones.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ libfrog/zones.h | 22 ++++++++++++++++++++ libxfs/xfs_zones.c | 3 ++- libxfs/xfs_zones.h | 1 + mkfs/xfs_mkfs.c | 39 +++++++++-------------------------- repair/zoned.c | 29 ++++++++------------------ 7 files changed, 98 insertions(+), 53 deletions(-) create mode 100644 libfrog/zones.c create mode 100644 libfrog/zones.h
Signature · 1 line
2.52.0
PATCH v3 1/6 libxfs: add missing forward declaration in xfs_zones.h
Add the missing forward declaration for struct blk_zone in xfs_zones.h. This avoids headaches with the order of header file inclusion to avoid compilation errors.
--- libxfs/xfs_zones.h | 1 + 1 file changed, 1 insertion(+)
libxfs/xfs_zones.h +1 -0
@@ -2,6 +2,7 @@#ifndef _LIBXFS_ZONES_H#define _LIBXFS_ZONES_H +struct blk_zone ;struct xfs_rtgroup ;/*
Signature · 1 line
2.52.0
Re: [PATCH v3 1/6] libxfs: add missing forward declaration in xfs_zones.h
Quoted 8 lines · Damien Le Moal
Add the missing forward declaration for struct
blk_zoneinxfs_zones.h. This avoids headaches with the order of header file inclusion to avoid compilation errors.Fixes 48ccc2459039 ("xfs: parse and validate hardware zone information")Signed-off-by Damien Le Moal <[email protected]>--- libxfs/xfs_zones.h | 1 +
We don't normally merge changes to xfsprogs' libxfs that haven't already gone into the kernel libxfs. If Andrey's ok with this then I am too.
(alternate suggestion: can the forward declaration go in platform_defs.h?)
--D
Quoted 18 lines
1 file changed, 1 insertion(+)libxfs/xfs_zones.h +1
-0@@ -2,6 +2,7 @@#ifndef _LIBXFS_ZONES_H#define _LIBXFS_ZONES_H +struct blk_zone ;struct xfs_rtgroup ;/* Signature · 1 line
2.52.0
Re: [PATCH v3 1/6] libxfs: add missing forward declaration in xfs_zones.h
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Add the missing forward declaration for struct
blk_zoneinxfs_zones.h. This avoids headaches with the order of header file inclusion to avoid compilation errors.Fixes 48ccc2459039 ("xfs: parse and validate hardware zone information")Signed-off-by Damien Le Moal <[email protected]>
This needs to go into the kernel first. And yes, I can't blame new contributors for not knowing what files are shared..
PATCH v3 2/6 mkfs: remove unnecessary return value affectation
In reply to Damien Le MoalThe 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.
--- mkfs/xfs_mkfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
mkfs/xfs_mkfs.c +1 -3
@@ -2589,10 +2589,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;
Signature · 1 line
2.52.0
Re: [PATCH v3 2/6] mkfs: remove unnecessary return value affectation
Quoted 6 lines · Damien Le Moal
The function
report_zones()inmkfs/xfs_mkfs.cis a void function. So there is no need to set the variable ret to-EIObefore returning iffstat()fails.Fixes 2e5a737a61d3 ("xfs_mkfs: support creating file system with zoned RT devices")Signed-off-by Damien Le Moal <[email protected]>
LGTM,
--D
Quoted 24 lines
--- mkfs/xfs_mkfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)mkfs/xfs_mkfs.c +1
-3@@ -2589,10 +2589,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;Signature · 1 line
2.52.0
Re: [PATCH v3 2/6] mkfs: remove unnecessary return value affectation
In reply to Damien Le MoalLooks good:
PATCH v3 3/6 libfrog: introduce xfrog_report_zones
In reply to Damien Le MoalDefine 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.
--- 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
libfrog/Makefile +4 -2
@@ -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
libfrog/zones.c new file +42 -0
42 lines not on this page · raw message
libfrog/zones.h new file +13 -0
@@ -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> + +struct blk_zone_report *xfrog_report_zones (int fd,uint64_t sector); + +#endif /* __LIBFROG_ZONE_H__ */
Signature · 1 line
2.52.0
Re: [PATCH v3 3/6] libfrog: introduce xfrog_report_zones
Quoted 47 lines · Damien Le Moal
Define the new helper function
xfrog_report_zones()to report zones of a zoned block device. This function is implemented in the new filelibfrog/zones.cand defined in the header filelibfrog/zones.h.
xfrog_report_zones()allocates and returns a structblk_zone_reportstructure. It is the responsibility of the caller to free this structure after use.Signed-off-by Damien Le Moal <[email protected]>--- 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.hlibfrog/Makefile +4
-2@@ -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.pylibfrog/zones.c new file +0
-0
libfrog/zones.c line 6
Quoted 6 lines
libfrog/zones.c new file +6
-0@@ -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).
Quoted 20 lines
libfrog/zones.c new file +20
-0+#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" ));
libfrog/zones.c line 36
Quoted 10 lines
libfrog/zones.c new file +10
-0+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.)
libfrog/zones.c line 41
Quoted 5 lines
libfrog/zones.c new file +5
-0+free (rep); +return NULL ; + } + +return rep;
The logic in here looks good, though.
Quoted 7 lines
libfrog/zones.c new file +1
-0+}libfrog/zones.h new file +0
-0
libfrog/zones.h line 9
Quoted 9 lines
libfrog/zones.h new file +9
-0@@ -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
Quoted 8 lines
libfrog/zones.h new file +4
-0+ +struct blk_zone_report *xfrog_report_zones (int fd,uint64_t sector); + +#endif /* __LIBFROG_ZONE_H__ */ Signature · 1 line
2.52.0
PATCH v3 4/6 mkfs: use xfrog_report_zones()
In reply to Damien Le MoalUse the function xfrog_report_zones() to obtain zone information from a zoned device instead of directly issuing a BLKREPORTZONE ioctl.
--- mkfs/xfs_mkfs.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-)
mkfs/xfs_mkfs.c +9 -26
@@ -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 ;
Signature · 1 line
2.52.0
Re: [PATCH v3 4/6] mkfs: use xfrog_report_zones()
Quoted 68 lines · Damien Le Moal
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 <[email protected]>--- mkfs/xfs_mkfs.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-)mkfs/xfs_mkfs.c +4
-17@@ -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;
mkfs/xfs_mkfs.c report_zones( · line 2609
Quoted 10 lines
mkfs/xfs_mkfs.c +2
-8-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);
Now that I see the actual usage patterns I wonder if this would be more efficient if you had a separate allocator function to avoid repeatedly freeing and re-allocating the buffer?
Also this could be combined with the previous patch since you're really just hoisting code from mkfs to libfrog.
--D
Quoted 15 lines
mkfs/xfs_mkfs.c +3
-1+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 ;Signature · 1 line
2.52.0
PATCH v3 5/6 repair: use xfrog_report_zones()
In reply to Damien Le MoalUse the function xfrog_report_zones() to obtain zones information from a zoned device instead of directly issuing a BLKREPORTZONE ioctl.
--- repair/zoned.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-)
repair/zoned.c +8 -21
@@ -3,7 +3,7 @@* Copyright (c) 2024 Christoph Hellwig. */ #include <ctype.h> -#include <linux/blkzoned.h> +#include "libfrog/zones.h" #include "libxfs_priv.h" #include "libxfs.h" #include "xfs_zones.h"
@@ -51,8 +51,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 blk_zone_report *rep =NULL ;unsigned int i, n =0 ;if (ioctl (fd,BLKGETSIZE64 , &device_size))
@@ -67,30 +66,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 ; +free (rep); + rep =xfrog_report_zones (fd, sector); +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)break ; + zones = (struct blk_zone *)(rep +1 );for (i =0 ; i < rep->nr_zones; i++) {if (n >= mp->m_sb.sb_rgcount)break ;
Signature · 1 line
2.52.0
PATCH v3 6/6 libfrog: enable cached report zones
In reply to Damien Le MoalModify 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.
--- libfrog/zones.c | 11 ++++++++++- libfrog/zones.h | 9 +++++++++ libxfs/xfs_zones.c | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-)
libfrog/zones.c +10 -1
@@ -27,10 +27,19 @@ _("Failed to allocate memory for reporting zones.\n"));return NULL ; } +/* +* Try cached report zones first. If this fails, fallback to the regular +* (slower) report zones. +*/ rep->sector = sector; rep->nr_zones =ZONES_PER_REPORT ; + 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);
libfrog/zones.h +9 -0
@@ -8,6 +8,15 @@#include <stdint.h> #include <linux/blkzoned.h> +/* +* 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) +#define BLK_ZONE_COND_ACTIVE 0xff +#endif +struct blk_zone_report *xfrog_report_zones (int fd,uint64_t sector);#endif /* __LIBFROG_ZONE_H__ */
libxfs/xfs_zones.c +2 -1
@@ -3,7 +3,7 @@* Copyright (c) 2023-2025 Christoph Hellwig. * Copyright (c) 2024-2025, Western Digital Corporation or its affiliates. */ -#include <linux/blkzoned.h> +#include <libfrog/zones.h> #include "libxfs_priv.h" #include "xfs.h" #include "xfs_fs.h"
@@ -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);
Signature · 1 line
2.52.0
Re: [PATCH v3 6/6] libfrog: enable cached report zones
Quoted 53 lines · Damien Le Moal
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.hdoes not define BLKREPORTZONEV2, this ioctl is defined inlibfrog/zones.h, together with theBLK_ZONE_REP_CACHEDflag and theBLK_ZONE_COND_ACTIVEzone condition.Since a cached report zone always return the condition
BLK_ZONE_COND_ACTIVEfor any zone that is implicitly open, explicitly open or closed, the functionxfs_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 <[email protected]>--- libfrog/zones.c | 11 ++++++++++- libfrog/zones.h | 9 +++++++++ libxfs/xfs_zones.c | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-)libfrog/zones.c +10
-1@@ -27,10 +27,19 @@ _("Failed to allocate memory for reporting zones.\n"));return NULL ; } +/* +* Try cached report zones first. If this fails, fallback to the regular +* (slower) report zones. +*/ rep->sector = sector; rep->nr_zones =ZONES_PER_REPORT ; + 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);libfrog/zones.h +0
-0
libfrog/zones.h line 17
Quoted 10 lines
libfrog/zones.h +7
-0@@ -8,6 +8,15 @@#include <stdint.h> #include <linux/blkzoned.h> +/* +* 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) +#define BLK_ZONE_COND_ACTIVE 0xff
Of these three definitions, only BLK_ZONE_COND_ACTIVE is actually used outside of libfrog/zones.c, right? I suggest defining BLKREPORTZONEV2 and BLK_ZONE_REP_CACHED there instead of zones.h to reduce the number of symbols floating around.
(The rest of the code changes look ok to me)
--D
Quoted 30 lines
libfrog/zones.h +2
-0+#endif +struct blk_zone_report *xfrog_report_zones (int fd,uint64_t sector);#endif /* __LIBFROG_ZONE_H__ */ libxfs/xfs_zones.c +2
-1@@ -3,7 +3,7 @@* Copyright (c) 2023-2025 Christoph Hellwig. * Copyright (c) 2024-2025, Western Digital Corporation or its affiliates. */ -#include <linux/blkzoned.h> +#include <libfrog/zones.h> #include "libxfs_priv.h" #include "xfs.h" #include "xfs_fs.h" @@ -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);Signature · 1 line
2.52.0
Re: [PATCH v3 6/6] libfrog: enable cached report zones
In reply to Damien Le Moallibxfs/xfs_zones.c
Quoted 4 lines · Damien Le Moal
libxfs/xfs_zones.c +0
-0
This file is shared with the kernel, so we'll need to get the changes from a libxfs sync as well.
libxfs/xfs_zones.c line 6
Quoted 6 lines
libxfs/xfs_zones.c +1
-1@@ -3,7 +3,7 @@* Copyright (c) 2023-2025 Christoph Hellwig. * Copyright (c) 2024-2025, Western Digital Corporation or its affiliates. */ -#include <linux/blkzoned.h> +#include <libfrog/zones.h>
.. and we'll need this include to be hidden in the xfsprogs-wide headers.