No need for two queue references. Signed-off-by: Christoph Hellwig <hch@xxxxxx> --- block/blk-mq.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index fc1df2a5969a0..6375ed55cdfa7 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -445,24 +445,22 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q, * Check if the hardware context is actually mapped to anything. * If not tell the caller that it should skip this queue. */ + ret = -EXDEV; alloc_data.hctx = q->queue_hw_ctx[hctx_idx]; - if (!blk_mq_hw_queue_mapped(alloc_data.hctx)) { - blk_queue_exit(q); - return ERR_PTR(-EXDEV); - } + if (!blk_mq_hw_queue_mapped(alloc_data.hctx)) + goto out_queue_exit; cpu = cpumask_first_and(alloc_data.hctx->cpumask, cpu_online_mask); alloc_data.ctx = __blk_mq_get_ctx(q, cpu); - blk_queue_enter_live(q); + ret = -EWOULDBLOCK; rq = blk_mq_get_request(q, NULL, &alloc_data); - blk_queue_exit(q); - - if (!rq) { - blk_queue_exit(q); - return ERR_PTR(-EWOULDBLOCK); - } + if (!rq) + goto out_queue_exit; return rq; +out_queue_exit: + blk_queue_exit(q); + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx); -- 2.26.1