Skip to content

Commit c4c3ffd

Browse files
damien-lemoalaxboe
authored andcommitted
block: Improve blk_zone_write_plug_bio_merged()
Improve blk_zone_write_plug_bio_merged() to check that we succefully get a reference on the zone write plug of the merged BIO, as expected since for a merge we already have at least one request and one BIO referencing the zone write plug. Comments in this function are also improved to better explain the references to the BIO zone write plug. 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-11-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 096bc7e commit c4c3ffd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

block/blk-zoned.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,11 +885,16 @@ void blk_zone_write_plug_bio_merged(struct bio *bio)
885885
bio_set_flag(bio, BIO_ZONE_WRITE_PLUGGING);
886886

887887
/*
888-
* Increase the plug reference count and advance the zone write
889-
* pointer offset.
888+
* Get a reference on the zone write plug of the target zone and advance
889+
* the zone write pointer offset. Given that this is a merge, we already
890+
* have at least one request and one BIO referencing the zone write
891+
* plug. So this should not fail.
890892
*/
891893
zwplug = disk_get_zone_wplug(bio->bi_bdev->bd_disk,
892894
bio->bi_iter.bi_sector);
895+
if (WARN_ON_ONCE(!zwplug))
896+
return;
897+
893898
spin_lock_irqsave(&zwplug->lock, flags);
894899
zwplug->wp_offset += bio_sectors(bio);
895900
spin_unlock_irqrestore(&zwplug->lock, flags);

0 commit comments

Comments
 (0)