summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@sandisk.com>2016-10-28 17:19:37 -0700
committerJens Axboe <axboe@fb.com>2016-11-02 12:50:19 -0600
commitfd00144301d64f1742541a3c5e64cd1c51f39c55 (patch)
tree51ef593c5beb15b66ba36b3eaac027369441d16f /block
parent5d1b25c1ecabb37f8eb58c8e9dd74f77f703e5d9 (diff)
downloadlinux-fd00144301d64f1742541a3c5e64cd1c51f39c55.tar.bz2
blk-mq: Introduce blk_mq_queue_stopped()
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@sandisk.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r--block/blk-mq.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 2864e191cc86..28bf667bfe09 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -944,6 +944,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 (blk_mq_hctx_stopped(hctx))
+ 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);