Skip to contentSkip to conversation

blk-mq: add helper function to test hctx inactive

PATCH New Xianting Tian 1 participant 1 message Oct 14, 2020 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-mq: add helper function to test hctx inactive

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

---
 block/blk-mq-tag.c | 2 +-
 block/blk-mq.h     | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
block/blk-mq-tag.c +1 -1
index 32d82e23b..3119572bc 100644
@@ -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;
 	}
block/blk-mq.h +5 -0
index 863a2f334..9813269c2 100644
@@ -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;
Signature · 1 line
2.17.1