Enable cached zone report
v2 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. 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(-)
Signature · 1 line
2.52.0
PATCH v2 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 v2 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 <0 && errno ==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 v2 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 <0 && errno ==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 4 lines · Damien Le Moal
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?
Quoted 6 lines
Darrick,
It may be cleaner to have a common report zones helper instead of repating the same ioctl pattern in
mkfs/xfs_mkfs.candrepair/zoned.c. However, I am not sure where to place such helper. In libxfs/ or in libfrog/ ? Please advise.
libfrog/, please.
--D
Quoted 21 lines
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 zonelibxfs/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
Quoted 9 lines · Darrick J. Wong
Quoted 4 lines · Damien Le Moal
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_ACTIVEif the kernel headers are from 6.18?
Quoted 8 lines
Quoted 6 lines
Darrick,
It may be cleaner to have a common report zones helper instead of repating the same ioctl pattern in
mkfs/xfs_mkfs.candrepair/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
Quoted 24 lines
--D
Quoted 21 lines
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 zonelibxfs/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
Quoted 8 lines · Darrick J. Wong
Quoted 4 lines · Damien Le Moal
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_ACTIVEif 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 ?
Quoted 9 lines
Quoted 7 lines
Darrick,
It may be cleaner to have a common report zones helper instead of repating the same ioctl pattern in
mkfs/xfs_mkfs.candrepair/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 ?
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 7 lines · Damien Le Moal
Quoted 6 lines · Darrick J. Wong
Quoted 4 lines · Damien Le Moal
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.
Quoted 5 lines
Quoted 2 lines
Just out of curiosity, do you see any xfsprogs build problems with
BLK_ZONE_COND_ACTIVEif 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_ACTIVEdefined). 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.
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Darrick,
It may be cleaner to have a common report zones helper instead of repating the same ioctl pattern in
mkfs/xfs_mkfs.candrepair/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.cis OK ?
Yep.
--D
Quoted 3 lines
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 11 lines · Darrick J. Wong
Quoted 10 lines · Damien Le Moal
Quoted 8 lines · Darrick J. Wong
Quoted 4 lines · Damien Le Moal
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_ACTIVEif the kernel headers are from 6.18?
Quoted 8 lines
Quoted 2 lines
Nope, I do not, at least not with my Fedora 6.17.12 headers (which do not have
BLK_ZONE_COND_ACTIVEdefined). Do you see any problem ?I see it, but only if I
./tools/libxfs-applythe 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=a448911c20ec0d3482361b2287266abd76d9f979that 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.
Quoted 20 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Darrick,
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
It may be cleaner to have a common report zones helper instead of repating the same ioctl pattern in
mkfs/xfs_mkfs.candrepair/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.cis OK ?Yep.
--D
Quoted 3 lines
Signature · 2 lines
Damien Le Moal Western Digital Research
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 11 lines · Darrick J. Wong
Quoted 10 lines · Damien Le Moal
Quoted 8 lines · Darrick J. Wong
Quoted 4 lines · Damien Le Moal
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_ACTIVEif the kernel headers are from 6.18?
Quoted 8 lines
Quoted 2 lines
Nope, I do not, at least not with my Fedora 6.17.12 headers (which do not have
BLK_ZONE_COND_ACTIVEdefined). Do you see any problem ?I see it, but only if I
./tools/libxfs-applythe 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=a448911c20ec0d3482361b2287266abd76d9f979that 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.
Signature · 2 lines
Damien Le Moal Western Digital Research