diff mbox series

[v2] blk-mq: use BLK_MQ_NO_TAG for no tag

Message ID 20200826020651.9856-1-tian.xianting@h3c.com (mailing list archive)
State New, archived
Headers show
Series [v2] blk-mq: use BLK_MQ_NO_TAG for no tag | expand

Commit Message

Tianxianting Aug. 26, 2020, 2:06 a.m. UTC
Replace various magic -1 constants for tags with BLK_MQ_NO_TAG.
And move the definition of BLK_MQ_NO_TAG from 'block/blk-mq-tag.h'
to 'include/linux/blk-mq.h'

Signed-off-by: Xianting Tian <tian.xianting@h3c.com>
---
 block/blk-core.c       | 4 ++--
 block/blk-mq-sched.c   | 2 +-
 block/blk-mq-tag.h     | 6 ------
 include/linux/blk-mq.h | 8 +++++++-
 4 files changed, 10 insertions(+), 10 deletions(-)

Comments

Ming Lei Aug. 26, 2020, 4:29 a.m. UTC | #1
On Wed, Aug 26, 2020 at 10:06:51AM +0800, Xianting Tian wrote:
> Replace various magic -1 constants for tags with BLK_MQ_NO_TAG.
> And move the definition of BLK_MQ_NO_TAG from 'block/blk-mq-tag.h'
> to 'include/linux/blk-mq.h'

All three symbols are supposed for block core internal code only, so
looks you shouldn't move them to public header.


Thanks, 
Ming
Tianxianting Aug. 26, 2020, 6:02 a.m. UTC | #2
Hi Ming Lei
Thanks for your quick comment.
As the function request_to_qc_t() in 'include/linux/blk-mq.h ' used the magic '-1',
Seems it is hard to replace it with BLK_MQ_NO_TAG :(

-----Original Message-----
From: Ming Lei [mailto:ming.lei@redhat.com] 
Sent: Wednesday, August 26, 2020 12:29 PM
To: tianxianting (RD) <tian.xianting@h3c.com>
Cc: axboe@kernel.dk; linux-block@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [v2] blk-mq: use BLK_MQ_NO_TAG for no tag

On Wed, Aug 26, 2020 at 10:06:51AM +0800, Xianting Tian wrote:
> Replace various magic -1 constants for tags with BLK_MQ_NO_TAG.
> And move the definition of BLK_MQ_NO_TAG from 'block/blk-mq-tag.h'
> to 'include/linux/blk-mq.h'

All three symbols are supposed for block core internal code only, so looks you shouldn't move them to public header.


Thanks,
Ming
diff mbox series

Patch

diff --git a/block/blk-core.c b/block/blk-core.c
index d9d632639..c7eaf7504 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -116,8 +116,8 @@  void blk_rq_init(struct request_queue *q, struct request *rq)
 	rq->__sector = (sector_t) -1;
 	INIT_HLIST_NODE(&rq->hash);
 	RB_CLEAR_NODE(&rq->rb_node);
-	rq->tag = -1;
-	rq->internal_tag = -1;
+	rq->tag = BLK_MQ_NO_TAG;
+	rq->internal_tag = BLK_MQ_NO_TAG;
 	rq->start_time_ns = ktime_get_ns();
 	rq->part = NULL;
 	refcount_set(&rq->ref, 1);
diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index a19cdf159..439481f59 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -522,7 +522,7 @@  void blk_mq_sched_insert_request(struct request *rq, bool at_head,
 		goto run;
 	}
 
-	WARN_ON(e && (rq->tag != -1));
+	WARN_ON(e && (rq->tag != BLK_MQ_NO_TAG));
 
 	if (blk_mq_sched_bypass_insert(hctx, !!e, rq)) {
 		/*
diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h
index b1acac518..8fc48aa72 100644
--- a/block/blk-mq-tag.h
+++ b/block/blk-mq-tag.h
@@ -45,12 +45,6 @@  static inline struct sbq_wait_state *bt_wait_ptr(struct sbitmap_queue *bt,
 	return sbq_wait_ptr(bt, &hctx->wait_index);
 }
 
-enum {
-	BLK_MQ_NO_TAG		= -1U,
-	BLK_MQ_TAG_MIN		= 1,
-	BLK_MQ_TAG_MAX		= BLK_MQ_NO_TAG - 1,
-};
-
 extern bool __blk_mq_tag_busy(struct blk_mq_hw_ctx *);
 extern void __blk_mq_tag_idle(struct blk_mq_hw_ctx *);
 
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 9d2d5ad36..2499d8aae 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -209,6 +209,12 @@  enum hctx_type {
 	HCTX_MAX_TYPES,
 };
 
+enum {
+	BLK_MQ_NO_TAG		= -1U,
+	BLK_MQ_TAG_MIN		= 1,
+	BLK_MQ_TAG_MAX		= BLK_MQ_NO_TAG - 1,
+};
+
 /**
  * struct blk_mq_tag_set - tag set that can be shared between request queues
  * @map:	   One or more ctx -> hctx mappings. One map exists for each
@@ -569,7 +575,7 @@  static inline void *blk_mq_rq_to_pdu(struct request *rq)
 static inline blk_qc_t request_to_qc_t(struct blk_mq_hw_ctx *hctx,
 		struct request *rq)
 {
-	if (rq->tag != -1)
+	if (rq->tag != BLK_MQ_NO_TAG)
 		return rq->tag | (hctx->queue_num << BLK_QC_T_SHIFT);
 
 	return rq->internal_tag | (hctx->queue_num << BLK_QC_T_SHIFT) |