block: two fixes for the zone report ioctls
Subsystems (2)
cover block: two fixes for the zone report ioctls
Two problems in the zone report code added in v6.19:
- BLKREPORTZONEV2 does not look at BLK_ZONE_REP_CACHED and returns the cached report also when the flag is not set (patch 1).
- blkdev_get_zone_info() gives a smaller last zone the length of a full zone, so the cached report describes a zone that ends behind the end of the device (patch 2).
Both were found by reading the code and then confirmed with zoned null_blk devices in qemu (x86_64). The test program opens one zone explicitly, writes to a second zone and closes it, and compares the reports of BLKREPORTZONE, BLKREPORTZONEV2 with flags 0 and BLKREPORTZONEV2 with BLK_ZONE_REP_CACHED. On mainline it finds both problems. With patch 1 only the length of the last zone in the cached report is left, and with both patches there is no difference apart from the zone conditions and the write pointer of conventional zones in the cached report, which are as documented.
For patch 1 there is a choice between the code and the documentation. The changelog of b30ffcdc0c15 and the comments in the uapi header both say that without BLK_ZONE_REP_CACHED the report comes from the device, and BLKREPORTZONE is marked as deprecated in favour of the new ioctl, so I changed the code. If the cached report is meant to be the only mode of BLKREPORTZONEV2, the header needs to say so instead.
The series is based on mainline (a5ebb76233b7, v7.3-rc6+). Patch 1 applies to next-20261009 as is. Patch 2 needs its context adjusted there, because blkdev_get_zone_info() tests the zone type instead of the zone condition in for-7.4/block.
Shashank Mohan Jain (2):
block: only use the cached zone report if BLK_ZONE_REP_CACHED is set
block: fix the length of a smaller last zone in blkdev_get_zone_info()
block/blk-zoned.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
base-commit: a5ebb76233b79db01e82e061173cb73c6d2b5c6b
Signature · 1 line
2.43.0
PATCH 1/2 block: only use the cached zone report if BLK_ZONE_REP_CACHED is set
BLKREPORTZONEV2 takes the flags field of struct blk_zone_report as an input. With BLK_ZONE_REP_CACHED the report is built from the zone information cached by the block layer. Without it, BLKREPORTZONEV2 is documented to behave like BLKREPORTZONE and to get the report from the
device: this is what the changelog of the commit that added the ioctl and the comments in include/uapi/linux/blkzoned.h say.
blkdev_report_zones_ioctl() only uses the flag to validate the input and calls blkdev_report_zones_cached() for every BLKREPORTZONEV2 request. A caller that passes flags == 0 gets the cached report, in which implicitly open, explicitly open and closed zones all have the condition BLK_ZONE_COND_ACTIVE, and an explicitly opened empty zone is reported as empty.
Example with a zoned null_blk device (10 MiB, 4 MiB zones) after BLKOPENZONE on zone 0, and a write of 8 sectors to zone 1 followed by BLKCLOSEZONE:
BLKREPORTZONE: zone 0 cond 0x3 (EXP_OPEN)
zone 1 cond 0x4 (CLOSED)
BLKREPORTZONEV2, flags 0: zone 0 cond 0x1 (EMPTY)
zone 1 cond 0xff (ACTIVE)The uapi header marks BLKREPORTZONE as deprecated in favour of BLKREPORTZONEV2. A program that follows this and does not ask for cached information can no longer tell open zones from closed ones, and is handed BLK_ZONE_COND_ACTIVE, which is only defined for the cached report.
Call blkdev_report_zones_cached() only if BLK_ZONE_REP_CACHED is set, and blkdev_report_zones() otherwise.
Tested with zoned null_blk devices in qemu: a program that compares the reports of BLKREPORTZONE and BLKREPORTZONEV2 with flags 0 after the sequence above finds the differences before this change and none with it. The report with BLK_ZONE_REP_CACHED is unchanged.
---
Prepared with Claude Code (Anthropic), model Claude Opus 5.5 (claude-opus-5-5).
block/blk-zoned.c | 7 +++++++ 1 file changed, 7 insertions(+)
block/blk-zoned.c +7 -0
@@ -400,6 +400,13 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,case BLKREPORTZONEV2 :if (rep.flags & ~BLK_ZONE_REPV2_INPUT_FLAGS )return -EINVAL ; +if (!(rep.flags &BLK_ZONE_REP_CACHED )) { + ret =blkdev_report_zones (bdev, rep.sector, + rep.nr_zones, + blkdev_copy_zone_to_user, + &args); +break ; + } ret =blkdev_report_zones_cached (bdev, rep.sector, rep.nr_zones, blkdev_copy_zone_to_user, &args);break ;
Signature · 1 line
2.43.0
Damien Le Moal
maintainerRe: [PATCH 1/2] block: only use the cached zone report if BLK_ZONE_REP_CACHED is set
Quoted 55 lines · Shashank Mohan Jain
BLKREPORTZONEV2 takes the flags field of struct
blk_zone_reportas an input. WithBLK_ZONE_REP_CACHEDthe report is built from the zone information cached by the block layer. Without it, BLKREPORTZONEV2 is documented to behave like BLKREPORTZONE and to get the report from the
device: this is what the changelog of the commit that added the ioctl and the comments ininclude/uapi/linux/blkzoned.hsay.
blkdev_report_zones_ioctl()only uses the flag to validate the input and callsblkdev_report_zones_cached()for every BLKREPORTZONEV2 request. A caller that passes flags == 0 gets the cached report, in which implicitly open, explicitly open and closed zones all have the conditionBLK_ZONE_COND_ACTIVE, and an explicitly opened empty zone is reported as empty.Example with a zoned
null_blkdevice (10 MiB, 4 MiB zones) after BLKOPENZONE on zone 0, and a write of 8 sectors to zone 1 followed by BLKCLOSEZONE:BLKREPORTZONE: zone 0 cond
0x3(EXP_OPEN)zone 1 cond 0x4 (CLOSED) BLKREPORTZONEV2, flags 0: zone 0 cond 0x1 (EMPTY) zone 1 cond 0xff (ACTIVE)The uapi header marks BLKREPORTZONE as deprecated in favour of BLKREPORTZONEV2. A program that follows this and does not ask for cached information can no longer tell open zones from closed ones, and is handed
BLK_ZONE_COND_ACTIVE, which is only defined for the cached report.Call
blkdev_report_zones_cached()only ifBLK_ZONE_REP_CACHEDis set, andblkdev_report_zones()otherwise.Tested with zoned
null_blkdevices in qemu: a program that compares the reports of BLKREPORTZONE and BLKREPORTZONEV2 with flags 0 after the sequence above finds the differences before this change and none with it. The report withBLK_ZONE_REP_CACHEDis unchanged.Fixes b30ffcdc0c15 ("block: introduce BLKREPORTZONESV2 ioctl")Assisted-by LLMSigned-off-by Shashank Mohan Jain <[email protected]>---
Prepared with Claude Code (Anthropic), model Claude Opus 5.5 (claude-opus-5-5).block/blk-zoned.c | 7 +++++++ 1 file changed, 7 insertions(+)block/blk-zoned.c +0
-0@@ -400,6 +400,13 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,case BLKREPORTZONEV2 :if (rep.flags & ~BLK_ZONE_REPV2_INPUT_FLAGS )
block/blk-zoned.c int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd, · line 411
Quoted 10 lines
block/blk-zoned.c +7
-0return -EINVAL ; +if (!(rep.flags &BLK_ZONE_REP_CACHED )) { + ret =blkdev_report_zones (bdev, rep.sector, + rep.nr_zones, + blkdev_copy_zone_to_user, + &args); +break ; + } ret =blkdev_report_zones_cached (bdev, rep.sector, rep.nr_zones, blkdev_copy_zone_to_user, &args);
Can you reverse this if to be "if (rep.flags & BLK_ZONE_REP_CACHED) {" and to call blkdev_report_zones_cached if the condition is true? That would be a lot more logical.
Also, the condition should probably be:
if ((rep.flags & BLK_ZONE_REP_CACHED) && blkdev_has_cached_report_zones(bdev))
to be more efficient and avoid a call to blkdev_report_zones_cached() which will turn into a regular device report zones.
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 1/2] block: only use the cached zone report if BLK_ZONE_REP_CACHED is set
Quoted 4 lines · Damien Le Moal
Can you reverse this if to be "if (rep.flags &
BLK_ZONE_REP_CACHED) {" ... Also, the condition should probably be:if ((rep.flags & BLK_ZONE_REP_CACHED) && blkdev_has_cached_report_zones(bdev))
Reworked exactly as suggested and reposted as v2:
https://lore.kernel.org/all/[email protected]/
blkdev_has_cached_report_zones() is now used from the ioctl, so I moved it (with its comment) above blkdev_report_zones_ioctl(). Patch 2 is unchanged and carries your Reviewed-by. Retested on zoned null_blk.
Thanks,
Shashank
Quoted 84 lines · Damien Le Moal
Quoted 55 lines · Shashank Mohan Jain
BLKREPORTZONEV2 takes the flags field of struct
blk_zone_reportas an input. WithBLK_ZONE_REP_CACHEDthe report is built from the zone information cached by the block layer. Without it, BLKREPORTZONEV2 is documented to behave like BLKREPORTZONE and to get the report from the
device: this is what the changelog of the commit that added the ioctl and the comments ininclude/uapi/linux/blkzoned.hsay.
blkdev_report_zones_ioctl()only uses the flag to validate the input and callsblkdev_report_zones_cached()for every BLKREPORTZONEV2 request. A caller that passes flags == 0 gets the cached report, in which implicitly open, explicitly open and closed zones all have the conditionBLK_ZONE_COND_ACTIVE, and an explicitly opened empty zone is reported as empty.Example with a zoned
null_blkdevice (10 MiB, 4 MiB zones) after BLKOPENZONE on zone 0, and a write of 8 sectors to zone 1 followed by BLKCLOSEZONE:BLKREPORTZONE: zone 0 cond
0x3(EXP_OPEN)zone 1 cond 0x4 (CLOSED) BLKREPORTZONEV2, flags 0: zone 0 cond 0x1 (EMPTY) zone 1 cond 0xff (ACTIVE)The uapi header marks BLKREPORTZONE as deprecated in favour of BLKREPORTZONEV2. A program that follows this and does not ask for cached information can no longer tell open zones from closed ones, and is handed
BLK_ZONE_COND_ACTIVE, which is only defined for the cached report.Call
blkdev_report_zones_cached()only ifBLK_ZONE_REP_CACHEDis set, andblkdev_report_zones()otherwise.Tested with zoned
null_blkdevices in qemu: a program that compares the reports of BLKREPORTZONE and BLKREPORTZONEV2 with flags 0 after the sequence above finds the differences before this change and none with it. The report withBLK_ZONE_REP_CACHEDis unchanged.Fixes b30ffcdc0c15 ("block: introduce BLKREPORTZONESV2 ioctl")Assisted-by LLMSigned-off-by Shashank Mohan Jain <[email protected]>---
Prepared with Claude Code (Anthropic), model Claude Opus 5.5 (claude-opus-5-5).block/blk-zoned.c | 7 +++++++ 1 file changed, 7 insertions(+)block/blk-zoned.c +0
-0@@ -400,6 +400,13 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,case BLKREPORTZONEV2 :if (rep.flags & ~BLK_ZONE_REPV2_INPUT_FLAGS )block/blk-zoned.c int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd, · line 411
Quoted 10 lines
block/blk-zoned.c +7
-0return -EINVAL ; +if (!(rep.flags &BLK_ZONE_REP_CACHED )) { + ret =blkdev_report_zones (bdev, rep.sector, + rep.nr_zones, + blkdev_copy_zone_to_user, + &args); +break ; + } ret =blkdev_report_zones_cached (bdev, rep.sector, rep.nr_zones, blkdev_copy_zone_to_user, &args);Can you reverse this if to be "if (rep.flags &
BLK_ZONE_REP_CACHED) {" and to callblkdev_report_zones_cachedif the condition is true? That would be a lot more logical.Also, the condition should probably be:
if ((rep.flags & BLK_ZONE_REP_CACHED) && blkdev_has_cached_report_zones(bdev))to be more efficient and avoid a call to
blkdev_report_zones_cached()which will turn into a regular device report zones.--
Damien Le Moal
Western Digital Research
Re: [PATCH 1/2] block: only use the cached zone report if BLK_ZONE_REP_CACHED is set
In reply to Damien Le MoalQuoted 4 lines · Damien Le Moal
Can you reverse this if to be "if (rep.flags &
BLK_ZONE_REP_CACHED) {" ... Also, the condition should probably be:if ((rep.flags & BLK_ZONE_REP_CACHED) && blkdev_has_cached_report_zones(bdev))
Reworked exactly as suggested and reposted as v2:
https://lore.kernel.org/all/[email protected]/
blkdev_has_cached_report_zones() is now used from the ioctl, so I moved it (with its comment) above blkdev_report_zones_ioctl(). Patch 2 is unchanged and carries your Reviewed-by. Retested on zoned null_blk.
Thanks,
Shashank
PATCH 2/2 block: fix the length of a smaller last zone in blkdev_get_zone_info()
In reply to Shashank Mohan Jainblkdev_get_zone_info() sets the length of every zone to the zone size of the device. The last zone of a zoned block device may be smaller than the others: blk_revalidate_zone_cb() accepts that and remembers the capacity of that zone in disk->last_zone_capacity. For such a zone the length reported from the cached information is too large, and start + len is beyond the end of the device. A conventional last zone is also given the capacity of a full zone.
Example with a zoned null_blk device of 10 MiB (20480 sectors) with 4 MiB zones, last zone:
BLKREPORTZONE: start 16384 len 4096 capacity 4096
BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED: start 16384 len 8192 capacity 4096
Limit the length to what is left of the device. disk_zone_is_last() still recognises the last zone, as start + len is then equal to the capacity of the device. The capacity of a conventional zone is equal to its length, which blk_revalidate_conv_zone() checks, so use the length there.
Tested with zoned null_blk devices in qemu (all zones sequential, and two conventional zones followed by sequential ones, both with a smaller last zone): the start, length and capacity of all zones in the cached report are the same as in the report from the device with this change. null_blk cannot create a device with a conventional last zone, so that case is not tested.
---
Prepared with Claude Code (Anthropic), model Claude Opus 5.5 (claude-opus-5-5).
block/blk-zoned.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/blk-zoned.c +2 -2
@@ -971,7 +971,7 @@ int blkdev_get_zone_info(struct block_device *bdev, sector_t sector,rcu_read_unlock (); zone->start = sector; - zone->len = zone_sectors; + zone->len =min (zone_sectors,get_capacity (disk) - sector);/* * If this is a conventional zone, we do not have a zone write plug and
@@ -979,7 +979,7 @@ int blkdev_get_zone_info(struct block_device *bdev, sector_t sector,*/ if (zone->cond ==BLK_ZONE_COND_NOT_WP ) { zone->type =BLK_ZONE_TYPE_CONVENTIONAL ; - zone->capacity = zone_sectors; + zone->capacity = zone->len; zone->wp =ULLONG_MAX ;return 0 ; }
Signature · 1 line
2.43.0
Re: [PATCH 2/2] block: fix the length of a smaller last zone in blkdev_get_zone_info()
Quoted 28 lines · Shashank Mohan Jain
blkdev_get_zone_info()sets the length of every zone to the zone size of the device. The last zone of a zoned block device may be smaller than the others:blk_revalidate_zone_cb()accepts that and remembers the capacity of that zone indisk->last_zone_capacity. For such a zone the length reported from the cached information is too large, and start + len is beyond the end of the device. A conventional last zone is also given the capacity of a full zone.Example with a zoned
null_blkdevice of 10 MiB (20480 sectors) with 4 MiB zones, last zone:BLKREPORTZONE: start 16384 len 4096 capacity 4096
BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED: start 16384 len 8192 capacity 4096Limit the length to what is left of the device.
disk_zone_is_last()still recognises the last zone, as start + len is then equal to the capacity of the device. The capacity of a conventional zone is equal to its length, whichblk_revalidate_conv_zone()checks, so use the length there.Tested with zoned
null_blkdevices in qemu (all zones sequential, and two conventional zones followed by sequential ones, both with a smaller last zone): the start, length and capacity of all zones in the cached report are the same as in the report from the device with this change.null_blkcannot create a device with a conventional last zone, so that case is not tested.
Quoted 4 lines
Fixes f2284eec5053 ("block: introduce blkdev_get_zone_info()")Assisted-by LLMSigned-off-by Shashank Mohan Jain <[email protected]>
Doh! Good catch.
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 2/2] block: fix the length of a smaller last zone in blkdev_get_zone_info()
In reply to Shashank Mohan JainQuoted 8 lines · Shashank Mohan Jain
blkdev_get_zone_info()sets the length of every zone to the zone size of the device. The last zone of a zoned block device may be smaller than the others:blk_revalidate_zone_cb()accepts that and remembers the capacity of that zone indisk->last_zone_capacity. For such a zone the length reported from the cached information is too large, and start + len is beyond the end of the device. A conventional last zone is also given the capacity of a full zone.
Quoted 6 lines
Example with a zoned
null_blkdevice of 10 MiB (20480 sectors) with 4 MiB zones, last zone:BLKREPORTZONE: start 16384 len 4096 capacity 4096
BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED: start 16384 len 8192 capacity 4096
Can you add this to blktests as a reproducer?
The patch looks good:
Re: [PATCH 2/2] block: fix the length of a smaller last zone in blkdev_get_zone_info()
Quoted 1 line · Christoph Hellwig
Can you add this to blktests as a reproducer?
Will do. I'll send a blktests test under tests/zbd/ that sets up a zoned null_blk device with a smaller last zone and checks that BLKREPORTZONEV2 without BLK_ZONE_REP_CACHED matches BLKREPORTZONE, and that the cached report's last-zone length does not extend past the device. I'll post it to the blktests project separately and reference this series.
Thanks,
Shashank
Quoted 23 lines · Christoph Hellwig
Quoted 8 lines · Shashank Mohan Jain
blkdev_get_zone_info()sets the length of every zone to the zone size of the device. The last zone of a zoned block device may be smaller than the others:blk_revalidate_zone_cb()accepts that and remembers the capacity of that zone indisk->last_zone_capacity. For such a zone the length reported from the cached information is too large, and start + len is beyond the end of the device. A conventional last zone is also given the capacity of a full zone.Quoted 6 lines
Example with a zoned
null_blkdevice of 10 MiB (20480 sectors) with 4 MiB zones, last zone:BLKREPORTZONE: start 16384 len 4096 capacity 4096
BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED: start 16384 len 8192 capacity 4096Can you add this to blktests as a reproducer?
The patch looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Damien Le Moal
maintainerRe: [PATCH 2/2] block: fix the length of a smaller last zone in blkdev_get_zone_info()
Quoted 8 lines · shashank Jain
Quoted 1 line · Christoph Hellwig
Can you add this to blktests as a reproducer?
Will do. I'll send a blktests test under tests/zbd/ that sets up a zoned
null_blkdevice with a smaller last zone and checks that BLKREPORTZONEV2 withoutBLK_ZONE_REP_CACHEDmatches BLKREPORTZONE, and that the cached report's last-zone length does not extend past the device. I'll post it to the blktests project separately and reference this series.
How do you plan to issue a BLK_ZONE_REP_CACHED report? "blkzone report" does not have that yet. I am planning to send a patch for it.
Quoted 28 lines
Thanks,
ShashankQuoted 23 lines · Christoph Hellwig
Quoted 8 lines · Shashank Mohan Jain
blkdev_get_zone_info()sets the length of every zone to the zone size of the device. The last zone of a zoned block device may be smaller than the others:blk_revalidate_zone_cb()accepts that and remembers the capacity of that zone indisk->last_zone_capacity. For such a zone the length reported from the cached information is too large, and start + len is beyond the end of the device. A conventional last zone is also given the capacity of a full zone.Quoted 6 lines
Example with a zoned
null_blkdevice of 10 MiB (20480 sectors) with 4 MiB zones, last zone:BLKREPORTZONE: start 16384 len 4096 capacity 4096
BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED: start 16384 len 8192 capacity 4096Can you add this to blktests as a reproducer?
The patch looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 2/2] block: fix the length of a smaller last zone in blkdev_get_zone_info()
Quoted 2 lines · Damien Le Moal
How do you plan to issue a
BLK_ZONE_REP_CACHEDreport? "blkzone report" does not have that yet. I am planning to send a patch for it.
Good point. Two options, and I am happy to follow your preference:
- Use "blkzone report" with the cached flag once your util-linux patch lands - that matches the existing zbd tests and avoids a bundled tool. I would hold the blktests submission until it is available.
- Or carry a small C helper in the blktests src/ directory that issues BLKREPORTZONEV2 with BLK_ZONE_REP_CACHED directly, so the test is self-contained and does not depend on the util-linux version.
I lean towards the first, to match the zbd conventions and your blkzone work; tell me which you prefer and I will align the test with it.
Thanks,
Shashank
Quoted 47 lines · Damien Le Moal
Quoted 8 lines · shashank Jain
Quoted 1 line · Christoph Hellwig
Can you add this to blktests as a reproducer?
Will do. I'll send a blktests test under tests/zbd/ that sets up a zoned
null_blkdevice with a smaller last zone and checks that BLKREPORTZONEV2 withoutBLK_ZONE_REP_CACHEDmatches BLKREPORTZONE, and that the cached report's last-zone length does not extend past the device. I'll post it to the blktests project separately and reference this series.How do you plan to issue a
BLK_ZONE_REP_CACHEDreport? "blkzone report" does not have that yet. I am planning to send a patch for it.Quoted 28 lines
Thanks,
ShashankQuoted 23 lines · Christoph Hellwig
Quoted 8 lines · Shashank Mohan Jain
blkdev_get_zone_info()sets the length of every zone to the zone size of the device. The last zone of a zoned block device may be smaller than the others:blk_revalidate_zone_cb()accepts that and remembers the capacity of that zone indisk->last_zone_capacity. For such a zone the length reported from the cached information is too large, and start + len is beyond the end of the device. A conventional last zone is also given the capacity of a full zone.Quoted 6 lines
Example with a zoned
null_blkdevice of 10 MiB (20480 sectors) with 4 MiB zones, last zone:BLKREPORTZONE: start 16384 len 4096 capacity 4096
BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED: start 16384 len 8192 capacity 4096Can you add this to blktests as a reproducer?
The patch looks good:
Reviewed-by Christoph Hellwig <[email protected]>--
Damien Le Moal
Western Digital Research
Damien Le Moal
maintainerRe: [PATCH 2/2] block: fix the length of a smaller last zone in blkdev_get_zone_info()
Quoted 9 lines · shashank Jain
Quoted 2 lines · Damien Le Moal
How do you plan to issue a
BLK_ZONE_REP_CACHEDreport? "blkzone report" does not have that yet. I am planning to send a patch for it.Good point. Two options, and I am happy to follow your preference:
- Use "blkzone report" with the cached flag once your util-linux patch lands - that matches the existing zbd tests and avoids a bundled tool. I would hold the blktests submission until it is available.
We should leave "blkzone report" to get the device report as before, to avoid breaking anything for user with the "active" condition being returned. I was thinking on adding a "--cached" option to control the use of BLK_ZONE_REP_CACHED.
If you want to take on such patch, go ahead. CC me on it and I will review. The patches I need to send to add depop support will take some more time.
Quoted 58 lines
- Or carry a small C helper in the blktests src/ directory that issues BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHEDdirectly, so the test is self-contained and does not depend on the util-linux version.I lean towards the first, to match the zbd conventions and your blkzone work; tell me which you prefer and I will align the test with it.
Thanks,
ShashankQuoted 47 lines · Damien Le Moal
Quoted 8 lines · shashank Jain
Quoted 1 line · Christoph Hellwig
Can you add this to blktests as a reproducer?
Will do. I'll send a blktests test under tests/zbd/ that sets up a zoned
null_blkdevice with a smaller last zone and checks that BLKREPORTZONEV2 withoutBLK_ZONE_REP_CACHEDmatches BLKREPORTZONE, and that the cached report's last-zone length does not extend past the device. I'll post it to the blktests project separately and reference this series.How do you plan to issue a
BLK_ZONE_REP_CACHEDreport? "blkzone report" does not have that yet. I am planning to send a patch for it.Quoted 28 lines
Thanks,
ShashankQuoted 23 lines · Christoph Hellwig
Quoted 8 lines · Shashank Mohan Jain
blkdev_get_zone_info()sets the length of every zone to the zone size of the device. The last zone of a zoned block device may be smaller than the others:blk_revalidate_zone_cb()accepts that and remembers the capacity of that zone indisk->last_zone_capacity. For such a zone the length reported from the cached information is too large, and start + len is beyond the end of the device. A conventional last zone is also given the capacity of a full zone.Quoted 6 lines
Example with a zoned
null_blkdevice of 10 MiB (20480 sectors) with 4 MiB zones, last zone:BLKREPORTZONE: start 16384 len 4096 capacity 4096
BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED: start 16384 len 8192 capacity 4096Can you add this to blktests as a reproducer?
The patch looks good:
Reviewed-by Christoph Hellwig <[email protected]>--
Damien Le Moal
Western Digital Research
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 2/2] block: fix the length of a smaller last zone in blkdev_get_zone_info()
Quoted 3 lines · Damien Le Moal
I was thinking on adding a "--cached" option to control the use of
BLK_ZONE_REP_CACHED.
If you want to take on such patch, go ahead. CC me on it and I will review.
Thanks - yes, I will take it: a "--cached" option to "blkzone report" that selects BLKREPORTZONEV2 with BLK_ZONE_REP_CACHED, leaving the default report via the device (BLKREPORTZONE) unchanged. I will post it to util-linux and CC you. The blktests reproducer will then use "blkzone report --cached" rather than a bundled helper.
Thanks,
Shashank
Quoted 83 lines · Damien Le Moal
Quoted 9 lines · shashank Jain
Quoted 2 lines · Damien Le Moal
How do you plan to issue a
BLK_ZONE_REP_CACHEDreport? "blkzone report" does not have that yet. I am planning to send a patch for it.Good point. Two options, and I am happy to follow your preference:
- Use "blkzone report" with the cached flag once your util-linux patch lands - that matches the existing zbd tests and avoids a bundled tool. I would hold the blktests submission until it is available.
We should leave "blkzone report" to get the device report as before, to avoid breaking anything for user with the "active" condition being returned. I was thinking on adding a "--cached" option to control the use of
BLK_ZONE_REP_CACHED.If you want to take on such patch, go ahead. CC me on it and I will review. The patches I need to send to add depop support will take some more time.
Quoted 4 lines
- Or carry a small C helper in the blktests src/ directory that issues BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHEDdirectly, so the test is self-contained and does not depend on the util-linux version.Quoted 54 lines
I lean towards the first, to match the zbd conventions and your blkzone work; tell me which you prefer and I will align the test with it.
Thanks,
ShashankQuoted 47 lines · Damien Le Moal
Quoted 8 lines · shashank Jain
Quoted 1 line · Christoph Hellwig
Can you add this to blktests as a reproducer?
Will do. I'll send a blktests test under tests/zbd/ that sets up a zoned
null_blkdevice with a smaller last zone and checks that BLKREPORTZONEV2 withoutBLK_ZONE_REP_CACHEDmatches BLKREPORTZONE, and that the cached report's last-zone length does not extend past the device. I'll post it to the blktests project separately and reference this series.How do you plan to issue a
BLK_ZONE_REP_CACHEDreport? "blkzone report" does not have that yet. I am planning to send a patch for it.Quoted 28 lines
Thanks,
ShashankQuoted 23 lines · Christoph Hellwig
Quoted 8 lines · Shashank Mohan Jain
blkdev_get_zone_info()sets the length of every zone to the zone size of the device. The last zone of a zoned block device may be smaller than the others:blk_revalidate_zone_cb()accepts that and remembers the capacity of that zone indisk->last_zone_capacity. For such a zone the length reported from the cached information is too large, and start + len is beyond the end of the device. A conventional last zone is also given the capacity of a full zone.Quoted 6 lines
Example with a zoned
null_blkdevice of 10 MiB (20480 sectors) with 4 MiB zones, last zone:BLKREPORTZONE: start 16384 len 4096 capacity 4096
BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED: start 16384 len 8192 capacity 4096Can you add this to blktests as a reproducer?
The patch looks good:
Reviewed-by Christoph Hellwig <[email protected]>--
Damien Le Moal
Western Digital Research--
Damien Le Moal
Western Digital Research
Damien Le Moal
maintainerRe: [PATCH 2/2] block: fix the length of a smaller last zone in blkdev_get_zone_info()
Quoted 10 lines · shashank Jain
Quoted 3 lines · Damien Le Moal
I was thinking on adding a "--cached" option to control the use of
BLK_ZONE_REP_CACHED.
If you want to take on such patch, go ahead. CC me on it and I will review.Thanks - yes, I will take it: a "--cached" option to "blkzone report" that selects BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED, leaving the default report via the device (BLKREPORTZONE) unchanged. I will post it to util-linux and CC you. The blktests reproducer will then use "blkzone report --cached" rather than a bundled helper.
Maybe add a prep patch that defaults to BLKREPORTZONEV2 (without BLK_ZONE_REP_CACHED) if BLKREPORTZONEV2 is defined.
And a second patch that adds the --cached option for BLK_ZONE_REP_CACHED.
Quoted 88 lines
Thanks,
ShashankQuoted 83 lines · Damien Le Moal
Quoted 9 lines · shashank Jain
Quoted 2 lines · Damien Le Moal
How do you plan to issue a
BLK_ZONE_REP_CACHEDreport? "blkzone report" does not have that yet. I am planning to send a patch for it.Good point. Two options, and I am happy to follow your preference:
- Use "blkzone report" with the cached flag once your util-linux patch lands - that matches the existing zbd tests and avoids a bundled tool. I would hold the blktests submission until it is available.
We should leave "blkzone report" to get the device report as before, to avoid breaking anything for user with the "active" condition being returned. I was thinking on adding a "--cached" option to control the use of
BLK_ZONE_REP_CACHED.If you want to take on such patch, go ahead. CC me on it and I will review. The patches I need to send to add depop support will take some more time.
Quoted 4 lines
- Or carry a small C helper in the blktests src/ directory that issues BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHEDdirectly, so the test is self-contained and does not depend on the util-linux version.Quoted 54 lines
I lean towards the first, to match the zbd conventions and your blkzone work; tell me which you prefer and I will align the test with it.
Thanks,
ShashankQuoted 47 lines · Damien Le Moal
Quoted 8 lines · shashank Jain
Quoted 1 line · Christoph Hellwig
Can you add this to blktests as a reproducer?
Will do. I'll send a blktests test under tests/zbd/ that sets up a zoned
null_blkdevice with a smaller last zone and checks that BLKREPORTZONEV2 withoutBLK_ZONE_REP_CACHEDmatches BLKREPORTZONE, and that the cached report's last-zone length does not extend past the device. I'll post it to the blktests project separately and reference this series.How do you plan to issue a
BLK_ZONE_REP_CACHEDreport? "blkzone report" does not have that yet. I am planning to send a patch for it.Quoted 28 lines
Thanks,
ShashankQuoted 23 lines · Christoph Hellwig
Quoted 8 lines · Shashank Mohan Jain
blkdev_get_zone_info()sets the length of every zone to the zone size of the device. The last zone of a zoned block device may be smaller than the others:blk_revalidate_zone_cb()accepts that and remembers the capacity of that zone indisk->last_zone_capacity. For such a zone the length reported from the cached information is too large, and start + len is beyond the end of the device. A conventional last zone is also given the capacity of a full zone.Quoted 6 lines
Example with a zoned
null_blkdevice of 10 MiB (20480 sectors) with 4 MiB zones, last zone:BLKREPORTZONE: start 16384 len 4096 capacity 4096
BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED: start 16384 len 8192 capacity 4096Can you add this to blktests as a reproducer?
The patch looks good:
Reviewed-by Christoph Hellwig <[email protected]>--
Damien Le Moal
Western Digital Research--
Damien Le Moal
Western Digital Research
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 2/2] block: fix the length of a smaller last zone in blkdev_get_zone_info()
Quoted 3 lines · Damien Le Moal
Maybe add a prep patch that defaults to BLKREPORTZONEV2 (without
BLK_ZONE_REP_CACHED) if BLKREPORTZONEV2 is defined.
And a second patch that adds the --cached option forBLK_ZONE_REP_CACHED.
Will do - a 2-patch series: 1/2 makes "blkzone report" use BLKREPORTZONEV2 (without BLK_ZONE_REP_CACHED) when the ioctl is defined in the headers, keeping the current device-report behaviour; 2/2 adds "--cached" for BLK_ZONE_REP_CACHED. I will CC you.
Thanks,
Shashank
Quoted 111 lines · Damien Le Moal
Quoted 10 lines · shashank Jain
Quoted 3 lines · Damien Le Moal
I was thinking on adding a "--cached" option to control the use of
BLK_ZONE_REP_CACHED.
If you want to take on such patch, go ahead. CC me on it and I will review.Thanks - yes, I will take it: a "--cached" option to "blkzone report" that selects BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED, leaving the default report via the device (BLKREPORTZONE) unchanged. I will post it to util-linux and CC you. The blktests reproducer will then use "blkzone report --cached" rather than a bundled helper.Maybe add a prep patch that defaults to BLKREPORTZONEV2 (without
BLK_ZONE_REP_CACHED) if BLKREPORTZONEV2 is defined.And a second patch that adds the --cached option for
BLK_ZONE_REP_CACHED.Quoted 88 lines
Thanks,
ShashankQuoted 83 lines · Damien Le Moal
Quoted 9 lines · shashank Jain
Quoted 2 lines · Damien Le Moal
How do you plan to issue a
BLK_ZONE_REP_CACHEDreport? "blkzone report" does not have that yet. I am planning to send a patch for it.Good point. Two options, and I am happy to follow your preference:
- Use "blkzone report" with the cached flag once your util-linux patch lands - that matches the existing zbd tests and avoids a bundled tool. I would hold the blktests submission until it is available.
We should leave "blkzone report" to get the device report as before, to avoid breaking anything for user with the "active" condition being returned. I was thinking on adding a "--cached" option to control the use of
BLK_ZONE_REP_CACHED.If you want to take on such patch, go ahead. CC me on it and I will review. The patches I need to send to add depop support will take some more time.
Quoted 4 lines
- Or carry a small C helper in the blktests src/ directory that issues BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHEDdirectly, so the test is self-contained and does not depend on the util-linux version.Quoted 54 lines
I lean towards the first, to match the zbd conventions and your blkzone work; tell me which you prefer and I will align the test with it.
Thanks,
ShashankQuoted 47 lines · Damien Le Moal
Quoted 8 lines · shashank Jain
Quoted 1 line · Christoph Hellwig
Can you add this to blktests as a reproducer?
Will do. I'll send a blktests test under tests/zbd/ that sets up a zoned
null_blkdevice with a smaller last zone and checks that BLKREPORTZONEV2 withoutBLK_ZONE_REP_CACHEDmatches BLKREPORTZONE, and that the cached report's last-zone length does not extend past the device. I'll post it to the blktests project separately and reference this series.How do you plan to issue a
BLK_ZONE_REP_CACHEDreport? "blkzone report" does not have that yet. I am planning to send a patch for it.Quoted 28 lines
Thanks,
ShashankQuoted 23 lines · Christoph Hellwig
Quoted 8 lines · Shashank Mohan Jain
blkdev_get_zone_info()sets the length of every zone to the zone size of the device. The last zone of a zoned block device may be smaller than the others:blk_revalidate_zone_cb()accepts that and remembers the capacity of that zone indisk->last_zone_capacity. For such a zone the length reported from the cached information is too large, and start + len is beyond the end of the device. A conventional last zone is also given the capacity of a full zone.Quoted 6 lines
Example with a zoned
null_blkdevice of 10 MiB (20480 sectors) with 4 MiB zones, last zone:BLKREPORTZONE: start 16384 len 4096 capacity 4096
BLKREPORTZONEV2 with
BLK_ZONE_REP_CACHED: start 16384 len 8192 capacity 4096Can you add this to blktests as a reproducer?
The patch looks good:
Reviewed-by Christoph Hellwig <[email protected]>--
Damien Le Moal
Western Digital Research--
Damien Le Moal
Western Digital Research--
Damien Le Moal
Western Digital Research
Damien Le Moal
maintainerRe: [PATCH 2/2] block: fix the length of a smaller last zone in blkdev_get_zone_info()
In reply to shashank JainQuoted 13 lines · shashank Jain
Quoted 2 lines · Damien Le Moal
How do you plan to issue a
BLK_ZONE_REP_CACHEDreport? "blkzone report" does not have that yet. I am planning to send a patch for it.Good point. Two options, and I am happy to follow your preference:
- Use "blkzone report" with the cached flag once your util-linux patch lands - that matches the existing zbd tests and avoids a bundled tool. I would hold the blktests submission until it is available.
- Or carry a small C helper in the blktests src/ directory that issues BLKREPORTZONEV2 withBLK_ZONE_REP_CACHEDdirectly, so the test is self-contained and does not depend on the util-linux version.
Quoted 2 lines
I lean towards the first, to match the zbd conventions and your blkzone work; tell me which you prefer and I will align the test with it.
Yes, let's avoid the small helper. Having access to the cached report with blkzone will be useful for many things anyway, and the patch should be easy.
Signature · 2 lines
Damien Le Moal Western Digital Research