Skip to content

Commit

Permalink
block: Improve blk_zone_write_plug_bio_merged()
Browse files Browse the repository at this point in the history
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 <[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 096bc7e commit c4c3ffd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions block/blk-zoned.c
Original file line number Diff line number Diff line change
Expand Up @@ -885,11 +885,16 @@ void blk_zone_write_plug_bio_merged(struct bio *bio)
bio_set_flag(bio, BIO_ZONE_WRITE_PLUGGING);

/*
* Increase the plug reference count and advance the zone write
* pointer offset.
* Get a reference on the zone write plug of the target zone and advance
* the zone write pointer offset. Given that this is a merge, we already
* have at least one request and one BIO referencing the zone write
* plug. So this should not fail.
*/
zwplug = disk_get_zone_wplug(bio->bi_bdev->bd_disk,
bio->bi_iter.bi_sector);
if (WARN_ON_ONCE(!zwplug))
return;

spin_lock_irqsave(&zwplug->lock, flags);
zwplug->wp_offset += bio_sectors(bio);
spin_unlock_irqrestore(&zwplug->lock, flags);
Expand Down

0 comments on commit c4c3ffd

Please sign in to comment.