From: bart.vanassche@sandisk.com (Bart Van Assche)
Subject: [PATCH v2 1/7] blk-mq: Introduce blk_mq_queue_stopped()
Date: Wed, 28 Sep 2016 16:57:55 -0700 [thread overview]
Message-ID: <26c7db22-bac8-6d8c-ba6e-3cbf0cec3368@sandisk.com> (raw)
In-Reply-To: <f153ee47-e599-c333-92b0-d5da475012f3@sandisk.com>
The function blk_queue_stopped() allows to test whether or not a
traditional request queue has been stopped. Introduce a helper
function that allows block drivers to query easily whether or not
one or more hardware contexts of a blk-mq queue have been stopped.
Signed-off-by: Bart Van Assche <bart.vanassche at sandisk.com>
Reviewed-by: Hannes Reinecke <hare at suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
Cc: Christoph Hellwig <hch at lst.de>
---
block/blk-mq.c | 20 ++++++++++++++++++++
include/linux/blk-mq.h | 1 +
2 files changed, 21 insertions(+)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index dc5f47f..d8c45de 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -950,6 +950,26 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool async)
}
EXPORT_SYMBOL(blk_mq_run_hw_queues);
+/**
+ * blk_mq_queue_stopped() - check whether one or more hctxs have been stopped
+ * @q: request queue.
+ *
+ * The caller is responsible for serializing this function against
+ * blk_mq_{start,stop}_hw_queue().
+ */
+bool blk_mq_queue_stopped(struct request_queue *q)
+{
+ struct blk_mq_hw_ctx *hctx;
+ int i;
+
+ queue_for_each_hw_ctx(q, hctx, i)
+ if (test_bit(BLK_MQ_S_STOPPED, &hctx->state))
+ return true;
+
+ return false;
+}
+EXPORT_SYMBOL(blk_mq_queue_stopped);
+
void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx)
{
cancel_work(&hctx->run_work);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 5daa0ef..368c460d 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -233,6 +233,7 @@ void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs
void blk_mq_abort_requeue_list(struct request_queue *q);
void blk_mq_complete_request(struct request *rq, int error);
+bool blk_mq_queue_stopped(struct request_queue *q);
void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx);
void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx);
void blk_mq_stop_hw_queues(struct request_queue *q);
--
2.10.0
next prev parent reply other threads:[~2016-09-28 23:57 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-28 23:57 [PATCH v2 0/7] Introduce blk_quiesce_queue() and blk_resume_queue() Bart Van Assche
2016-09-28 23:57 ` Bart Van Assche [this message]
2016-10-05 17:50 ` [PATCH v2 1/7] blk-mq: Introduce blk_mq_queue_stopped() Sagi Grimberg
2016-10-11 16:40 ` Christoph Hellwig
2016-09-28 23:59 ` [PATCH v2 4/7] blk-mq: Introduce blk_quiesce_queue() and blk_resume_queue() Bart Van Assche
2016-09-29 5:52 ` Hannes Reinecke
2016-09-29 21:51 ` Ming Lei
2016-09-30 15:55 ` Bart Van Assche
2016-10-01 22:56 ` Ming Lei
2016-10-05 4:16 ` Bart Van Assche
2016-10-05 4:32 ` Ming Lei
2016-10-05 14:46 ` Bart Van Assche
2016-10-05 16:11 ` Ming Lei
2016-10-05 18:14 ` Sagi Grimberg
2016-10-05 19:05 ` Bart Van Assche
2016-10-05 19:10 ` Sagi Grimberg
2016-10-05 21:08 ` Bart Van Assche
2016-10-05 22:49 ` Ming Lei
2016-10-05 23:00 ` Bart Van Assche
2016-09-29 0:00 ` [PATCH v2 5/7] dm: Fix a race condition related to stopping and starting queues Bart Van Assche
2016-09-29 0:01 ` [PATCH v2 6/7] SRP transport: Port srp_wait_for_queuecommand() to scsi-mq Bart Van Assche
2016-09-29 5:54 ` Hannes Reinecke
2016-10-05 17:38 ` Sagi Grimberg
2016-10-05 21:51 ` Bart Van Assche
2016-10-11 16:44 ` Christoph Hellwig
2016-09-29 0:01 ` [PATCH v2 7/7] [RFC] nvme: Fix a race condition Bart Van Assche
2016-10-05 17:40 ` Sagi Grimberg
2016-10-11 16:46 ` Christoph Hellwig
2016-10-12 0:41 ` Bart Van Assche
2016-09-29 0:02 ` [PATCH v2 2/7] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Bart Van Assche
2016-09-29 0:02 ` [PATCH v2 3/7] [RFC] nvme: " Bart Van Assche
2016-10-05 17:43 ` Sagi Grimberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=26c7db22-bac8-6d8c-ba6e-3cbf0cec3368@sandisk.com \
--to=bart.vanassche@sandisk.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox