Skip to content

Commit 74b7ae5

Browse files
damien-lemoalaxboe
authored andcommitted
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: dd291d7 ("block: Introduce zone write plugging") Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20240501110907.96950-4-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 6b7593b commit 74b7ae5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

block/blk-zoned.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,10 +1664,11 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
16641664
* empty nor full. So make sure we have a zone write plug for
16651665
* such zone if the device has a zone write plug hash table.
16661666
*/
1667+
if (!disk->zone_wplugs_hash)
1668+
break;
16671669
wp_offset = blk_zone_wp_offset(zone);
1668-
if (disk->zone_wplugs_hash &&
1669-
wp_offset && wp_offset < zone_sectors) {
1670-
zwplug = disk_get_and_lock_zone_wplug(disk, zone->start,
1670+
if (wp_offset && wp_offset < zone->capacity) {
1671+
zwplug = disk_get_and_lock_zone_wplug(disk, zone->wp,
16711672
GFP_NOIO, &flags);
16721673
if (!zwplug)
16731674
return -ENOMEM;

0 commit comments

Comments
 (0)