Skip to contentSkip to conversation

blk-mq: end the request if getting a keyslot fails

PATCH New Eric Biggers 1 participant 1 message Nov 10

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-mq: end the request if getting a keyslot fails

From: Josef Bacik <[email protected]>

commit e67cb6ed40e7f45912b63d7d575f18dfd2ebc98a upstream.

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")

[ Backport to 6.6.y: dropped the part related to
bio_zone_write_plugging(), which doesn't exist on this branch. ]

---
 block/blk-mq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
block/blk-mq.c +1 -3
index e3fb9222c5ee0..130f4fea9f9c2 100644
@@ -3069,9 +3069,7 @@ void blk_mq_submit_bio(struct bio *bio)
 
 	ret = blk_crypto_rq_get_keyslot(rq);
 	if (ret != BLK_STS_OK) {
-		bio->bi_status = ret;
-		bio_endio(bio);
-		blk_mq_free_request(rq);
+		blk_mq_end_request(rq, ret);
 		return;
 	}
 

base-commit: 5139929c698c273e07cb0635732f6a918a7b8e78

Signature · 1 line
2.56.0