block: Hold a reference on zone write plugs to schedule submission
authorDamien Le Moal <dlemoal@kernel.org>
Wed, 1 May 2024 11:08:58 +0000 (20:08 +0900)
committerJens Axboe <axboe@kernel.dk>
Wed, 1 May 2024 14:08:43 +0000 (08:08 -0600)
commit9e78c38ab30b14c1d6a07c61d57ac5e2f12fa568
tree60eead573783a7860e77fb62d1840ae0fbaf2a71
parent19aad274c22b96fc4c0113d87cc8a083c87c467e
block: Hold a reference on zone write plugs to schedule submission

Since a zone write plug BIO work is a field of struct blk_zone_wplug, we
must ensure that a zone write plug is never freed when its BIO
submission work is queued or running. Do this by holding a reference on
the zone write plug when the submission work is scheduled for execution
with queue_work() and releasing the reference at the end of the
execution of the work function blk_zone_wplug_bio_work().
The helper function disk_zone_wplug_schedule_bio_work() is introduced to
get a reference on a zone write plug and queue its work. This helper is
used in disk_zone_wplug_unplug_bio() and disk_zone_wplug_handle_error().

Fixes: dd291d77cc90 ("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-6-dlemoal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-zoned.c