Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] blk-mq: add helper function to test hctx inactive
@ 2020-10-14 12:56 Xianting Tian
  0 siblings, 0 replies; only message in thread
From: Xianting Tian @ 2020-10-14 12:56 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, Xianting Tian

Introduce helper function blk_mq_hctx_inactive() to test
BLK_MQ_S_INACTIVE as we already done for BLK_MQ_S_STOPPED.

Signed-off-by: Xianting Tian <tian.xianting@h3c.com>
---
 block/blk-mq-tag.c | 2 +-
 block/blk-mq.h     | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 32d82e23b..3119572bc 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -153,7 +153,7 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data)
 	 * Give up this allocation if the hctx is inactive.  The caller will
 	 * retry on an active hctx.
 	 */
-	if (unlikely(test_bit(BLK_MQ_S_INACTIVE, &data->hctx->state))) {
+	if (unlikely(blk_mq_hctx_inactive(data->hctx))) {
 		blk_mq_put_tag(tags, data->ctx, tag + tag_offset);
 		return BLK_MQ_NO_TAG;
 	}
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 863a2f334..9813269c2 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -171,6 +171,11 @@ static inline bool blk_mq_hctx_stopped(struct blk_mq_hw_ctx *hctx)
 	return test_bit(BLK_MQ_S_STOPPED, &hctx->state);
 }
 
+static inline bool blk_mq_hctx_inactive(struct blk_mq_hw_ctx *hctx)
+{
+	return test_bit(BLK_MQ_S_INACTIVE, &hctx->state);
+}
+
 static inline bool blk_mq_hw_queue_mapped(struct blk_mq_hw_ctx *hctx)
 {
 	return hctx->nr_ctx && hctx->tags;
-- 
2.17.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14 12:56 [PATCH] blk-mq: add helper function to test hctx inactive Xianting Tian

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org
	public-inbox-index linux-block

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git