Thread (23 messages) 23 messages, 6 authors, 2019-05-03

[PATCH 1/5] blk mq: take ref to q when running it

STALE2709d

From: <hidden>
Date: 2016-05-25 07:54:59
Also in: linux-scsi
Subsystem: block layer, the rest · Maintainers: Jens Axboe, Linus Torvalds

From: Mike Christie <redacted>

If the __blk_mq_run_hw_queue is a result of a async run or retry
then we do not have a reference to the queue. At this time,
blk_cleanup_queue could begin tearing it down while the queue_rq
function is being run.

This patch just has us do a blk_queue_enter call.

Signed-off-by: Mike Christie <redacted>
---
 block/blk-mq.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 7df9c92..5958a02 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -738,8 +738,13 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
 
 	WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask));
 
-	if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state)))
+	if (blk_queue_enter(q, false)) {
+		blk_mq_run_hw_queue(hctx, true);
 		return;
+	}
+
+	if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state)))
+		goto exit_queue;
 
 	hctx->run++;
 
@@ -832,6 +837,9 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
 		 **/
 		blk_mq_run_hw_queue(hctx, true);
 	}
+
+exit_queue:
+	blk_queue_exit(q);
 }
 
 /*
-- 
2.7.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help