Skip to content

Commit

Permalink
block: Fix zone write plug initialization from blk_revalidate_zone_cb()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
damien-lemoal authored and axboe committed May 1, 2024
1 parent 6b7593b commit 74b7ae5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions block/blk-zoned.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
* 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);
if (disk->zone_wplugs_hash &&
wp_offset && wp_offset < zone_sectors) {
zwplug = disk_get_and_lock_zone_wplug(disk, zone->start,
if (wp_offset && wp_offset < zone->capacity) {
zwplug = disk_get_and_lock_zone_wplug(disk, zone->wp,
GFP_NOIO, &flags);
if (!zwplug)
return -ENOMEM;
Expand Down

0 comments on commit 74b7ae5

Please sign in to comment.