* [PATCH v2] blk-mq: end the request if getting a keyslot fails
@ 2026-10-29 20:01 Eric Biggers
2026-11-03 10:21 ` Christoph Hellwig
2026-11-03 14:31 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Eric Biggers @ 2026-10-29 20:01 UTC (permalink / raw)
To: linux-block, Jens Axboe
Cc: Christoph Hellwig, Josef Bacik, stable, Eric Biggers
From: Josef Bacik <josef@toxicpanda.com>
When blk_crypto_rq_get_keyslot() fails, blk_mq_submit_bio() ends the bio
by hand and frees the request. By then blk_mq_bio_to_request() has done
the IO accounting, which blk_mq_free_request() doesn't undo, so the
in_flight counter never drops and iostat shows a device that is 100%
busy. If the bio went through zone write plugging the zone stays plugged
as well, and every later write to it waits forever.
Use blk_mq_end_request() like the dispatch path does for a request the
driver rejected, after marking it for zone write plugging.
Move the call to blk_zone_write_plug_init_request() before
blk_crypto_rq_get_keyslot() so that it doesn't need to be duplicated.
It doesn't depend on the keyslot.
Fixes: 99dc422335d8 ("block: support to account io_ticks precisely")
Fixes: dd291d77cc90 ("block: Introduce zone write plugging")
Cc: stable@vger.kernel.org
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
v2:
- Moved the call to blk_zone_write_plug_init_request()
- Updated Fixes to list the commits that actually introduced the bugs
- Added Cc stable
- Sent as standalone patch
block/blk-mq.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 8d687b338d6d7..379c679b04138 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3199,16 +3199,15 @@ void blk_mq_submit_bio(struct bio *bio)
blk_mq_bio_to_request(rq, bio, nr_segs);
+ if (bio_zone_write_plugging(bio))
+ blk_zone_write_plug_init_request(rq);
+
ret = blk_crypto_rq_get_keyslot(rq);
if (ret != BLK_STS_OK) {
- bio_endio_status(bio, ret);
- blk_mq_free_request(rq);
+ blk_mq_end_request(rq, ret);
return;
}
- if (bio_zone_write_plugging(bio))
- blk_zone_write_plug_init_request(rq);
-
if (op_is_flush(bio->bi_opf) && blk_insert_flush(rq))
return;
base-commit: 4dd16e31135ea8437a720222df34e8745f385d6d
--
2.56.0.317.g454f8302e1-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] blk-mq: end the request if getting a keyslot fails
2026-10-29 20:01 [PATCH v2] blk-mq: end the request if getting a keyslot fails Eric Biggers
@ 2026-11-03 10:21 ` Christoph Hellwig
2026-11-03 14:31 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-11-03 10:21 UTC (permalink / raw)
To: Eric Biggers
Cc: linux-block, Jens Axboe, Christoph Hellwig, Josef Bacik, stable
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] blk-mq: end the request if getting a keyslot fails
2026-10-29 20:01 [PATCH v2] blk-mq: end the request if getting a keyslot fails Eric Biggers
2026-11-03 10:21 ` Christoph Hellwig
@ 2026-11-03 14:31 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2026-11-03 14:31 UTC (permalink / raw)
To: linux-block, Eric Biggers; +Cc: Christoph Hellwig, Josef Bacik, stable
On Thu, 29 Oct 2026 20:01:10 +0000, Eric Biggers wrote:
> When blk_crypto_rq_get_keyslot() fails, blk_mq_submit_bio() ends the bio
> by hand and frees the request. By then blk_mq_bio_to_request() has done
> the IO accounting, which blk_mq_free_request() doesn't undo, so the
> in_flight counter never drops and iostat shows a device that is 100%
> busy. If the bio went through zone write plugging the zone stays plugged
> as well, and every later write to it waits forever.
>
> [...]
Applied, thanks!
[1/1] blk-mq: end the request if getting a keyslot fails
commit: e67cb6ed40e7f45912b63d7d575f18dfd2ebc98a
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-03 14:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-29 20:01 [PATCH v2] blk-mq: end the request if getting a keyslot fails Eric Biggers
2026-11-03 10:21 ` Christoph Hellwig
2026-11-03 14:31 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox