Skip to content

Commit 95febeb

Browse files
committed
block: fix missing queue put in error path
If we fail the submission queue checks, we don't put the queue afterwards. This can cause various issues like stalls on scheduler switch or failure to remove the device, or like in the original bug report, timeout waiting for the device on reboot/restart. While in there, fix a few whitespace discrepancies in the surrounding code. Link: https://bugzilla.kernel.org/show_bug.cgi?id=215039 Fixes: b637108 ("blk-mq: fix filesystem I/O request allocation") Reported-and-tested-by: Stephen Smith <[email protected]> Reviewed-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 94c4b4f commit 95febeb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

block/blk-mq.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,8 +2543,7 @@ static struct request *blk_mq_get_new_requests(struct request_queue *q,
25432543
return NULL;
25442544
}
25452545

2546-
static inline bool blk_mq_can_use_cached_rq(struct request *rq,
2547-
struct bio *bio)
2546+
static inline bool blk_mq_can_use_cached_rq(struct request *rq, struct bio *bio)
25482547
{
25492548
if (blk_mq_get_hctx_type(bio->bi_opf) != rq->mq_hctx->type)
25502549
return false;
@@ -2565,7 +2564,6 @@ static inline struct request *blk_mq_get_request(struct request_queue *q,
25652564
bool checked = false;
25662565

25672566
if (plug) {
2568-
25692567
rq = rq_list_peek(&plug->cached_rq);
25702568
if (rq && rq->q == q) {
25712569
if (unlikely(!submit_bio_checks(bio)))
@@ -2587,12 +2585,14 @@ static inline struct request *blk_mq_get_request(struct request_queue *q,
25872585
fallback:
25882586
if (unlikely(bio_queue_enter(bio)))
25892587
return NULL;
2590-
if (!checked && !submit_bio_checks(bio))
2591-
return NULL;
2588+
if (unlikely(!checked && !submit_bio_checks(bio)))
2589+
goto out_put;
25922590
rq = blk_mq_get_new_requests(q, plug, bio, nsegs, same_queue_rq);
2593-
if (!rq)
2594-
blk_queue_exit(q);
2595-
return rq;
2591+
if (rq)
2592+
return rq;
2593+
out_put:
2594+
blk_queue_exit(q);
2595+
return NULL;
25962596
}
25972597

25982598
/**

0 commit comments

Comments
 (0)