Enable cached zone report
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
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.
--- libxfs/topology.h | 8 ++++++++ 1 file changed, 8 insertions(+)
libxfs/topology.h +8 -0
@@ -46,4 +46,12 @@ extern intcheck_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
PATCH 2/3 mkfs: use cached report zone
In reply to Damien Le MoalUse 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
@@ -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
PATCH 3/3 repair: use cached report zone
In reply to Damien Le MoalUse 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
@@ -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
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