]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
block: fix zone write plugs refcount handling in disk_zone_wplug_schedule_bio_work()
authorDamien Le Moal <dlemoal@kernel.org>
Fri, 27 Feb 2026 13:19:45 +0000 (22:19 +0900)
committerJens Axboe <axboe@kernel.dk>
Mon, 9 Mar 2026 20:29:59 +0000 (14:29 -0600)
commit0a8b8af896e0ef83e188e1fe20f98f2bbb1c2459
tree21d8969c1d994903f217a376f81536003133eeb3
parentb7d4ffb510373cc6ecf16022dd0e510a023034fb
block: fix zone write plugs refcount handling in disk_zone_wplug_schedule_bio_work()

The function disk_zone_wplug_schedule_bio_work() always takes a
reference on the zone write plug of the BIO work being scheduled. This
ensures that the zone write plug cannot be freed while the BIO work is
being scheduled but has not run yet. However, this unconditional
reference taking is fragile since the reference taken is released by the
BIO work blk_zone_wplug_bio_work() function, which implies that there
always must be a 1:1 relation between the work being scheduled and the
work running.

Make sure to drop the reference taken when scheduling the BIO work if
the work is already scheduled, that is, when queue_work() returns false.

Fixes: 9e78c38ab30b ("block: Hold a reference on zone write plugs to schedule submission")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-zoned.c