Commit 74b7ae5f authored by Damien Le Moal's avatar Damien Le Moal Committed by Jens Axboe

block: Fix zone write plug initialization from blk_revalidate_zone_cb()

When revalidating the zones of a zoned block device,
blk_revalidate_zone_cb() must allocate a zone write plug for any
sequential write required zone that is not empty nor full. However, the
current code tests the latter case by comparing the zone write pointer
offset to the zone size instead of the zone capacity. Furthermore,
disk_get_and_lock_zone_wplug() is called with a sector argument equal to
the zone start instead of the current zone write pointer position.
This commit fixes both issues by calling disk_get_and_lock_zone_wplug()
for a zone that is not empty and with a write pointer offset lower than
the zone capacity and use the zone capacity sector as the sector
argument for disk_get_and_lock_zone_wplug().

Fixes: dd291d77 ("block: Introduce zone write plugging")
Signed-off-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20240501110907.96950-4-dlemoal@kernel.orgSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 6b7593b5
...@@ -1664,10 +1664,11 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx, ...@@ -1664,10 +1664,11 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
* empty nor full. So make sure we have a zone write plug for * empty nor full. So make sure we have a zone write plug for
* such zone if the device has a zone write plug hash table. * such zone if the device has a zone write plug hash table.
*/ */
if (!disk->zone_wplugs_hash)
break;
wp_offset = blk_zone_wp_offset(zone); wp_offset = blk_zone_wp_offset(zone);
if (disk->zone_wplugs_hash && if (wp_offset && wp_offset < zone->capacity) {
wp_offset && wp_offset < zone_sectors) { zwplug = disk_get_and_lock_zone_wplug(disk, zone->wp,
zwplug = disk_get_and_lock_zone_wplug(disk, zone->start,
GFP_NOIO, &flags); GFP_NOIO, &flags);
if (!zwplug) if (!zwplug)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment