Skip to content

Commit c9c8aea

Browse files
damien-lemoalaxboe
authored andcommitted
block: Simplify zone write plug BIO abort
When BIOs plugged in a zone write plug are aborted, blk_zone_wplug_bio_io_error() clears the BIO BIO_ZONE_WRITE_PLUGGING flag so that bio_io_error(bio) does not end up calling blk_zone_write_plug_bio_endio() and we thus need to manually drop the reference on the zone write plug held by the aborted BIO. Move the call to disk_put_zone_wplug() that is alwasy following the call to blk_zone_wplug_bio_io_error() inside that function to simplify the code. 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-14-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b5a64ec commit c9c8aea

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

block/blk-zoned.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -634,12 +634,14 @@ static struct blk_zone_wplug *disk_get_and_lock_zone_wplug(struct gendisk *disk,
634634
return zwplug;
635635
}
636636

637-
static inline void blk_zone_wplug_bio_io_error(struct bio *bio)
637+
static inline void blk_zone_wplug_bio_io_error(struct blk_zone_wplug *zwplug,
638+
struct bio *bio)
638639
{
639-
struct request_queue *q = bio->bi_bdev->bd_disk->queue;
640+
struct request_queue *q = zwplug->disk->queue;
640641

641642
bio_clear_flag(bio, BIO_ZONE_WRITE_PLUGGING);
642643
bio_io_error(bio);
644+
disk_put_zone_wplug(zwplug);
643645
blk_queue_exit(q);
644646
}
645647

@@ -650,10 +652,8 @@ static void disk_zone_wplug_abort(struct blk_zone_wplug *zwplug)
650652
{
651653
struct bio *bio;
652654

653-
while ((bio = bio_list_pop(&zwplug->bio_list))) {
654-
blk_zone_wplug_bio_io_error(bio);
655-
disk_put_zone_wplug(zwplug);
656-
}
655+
while ((bio = bio_list_pop(&zwplug->bio_list)))
656+
blk_zone_wplug_bio_io_error(zwplug, bio);
657657
}
658658

659659
/*
@@ -673,8 +673,7 @@ static void disk_zone_wplug_abort_unaligned(struct gendisk *disk,
673673
if (wp_offset >= zone_capacity ||
674674
(bio_op(bio) != REQ_OP_ZONE_APPEND &&
675675
bio_offset_from_zone_start(bio) != wp_offset)) {
676-
blk_zone_wplug_bio_io_error(bio);
677-
disk_put_zone_wplug(zwplug);
676+
blk_zone_wplug_bio_io_error(zwplug, bio);
678677
continue;
679678
}
680679

0 commit comments

Comments
 (0)