linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>, Sagi Grimberg <sagig@mellanox.com>,
	Sebastian Parschauer <sebastian.riemer@profitbricks.com>,
	Robert Elliott <Elliott@hp.com>,
	Ming Lei <ming.lei@canonical.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	linux-rdma <linux-rdma@vger.kernel.org>
Subject: [PATCH v2 02/12] blk-mq: Add blk_mq_unique_tag()
Date: Tue, 07 Oct 2014 15:03:15 +0200	[thread overview]
Message-ID: <5433E493.9030304@acm.org> (raw)
In-Reply-To: <5433E43D.3010107@acm.org>

The queuecommand() callback functions in SCSI low-level drivers
need to know which hardware context has been selected by the
block layer. Since this information is not available in the
request structure, and since passing the hctx pointer directly to
the queuecommand callback function would require modification of
all SCSI LLDs, add a function to the block layer that allows to
query the hardware context index.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@canonical.com>
Cc: Sagi Grimberg <sagig@mellanox.com>
---
 block/blk-mq-tag.c     | 27 +++++++++++++++++++++++++++
 block/blk-mq.c         |  2 ++
 include/linux/blk-mq.h | 22 ++++++++++++++++++++++
 3 files changed, 51 insertions(+)

diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 88d512f..2c63a2b 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -592,6 +592,33 @@ int blk_mq_tag_update_depth(struct blk_mq_tags *tags, unsigned int tdepth)
 	return 0;
 }
 
+/**
+ * blk_mq_unique_tag() - return a tag that is unique queue-wide
+ * @rq: request for which to compute a unique tag
+ *
+ * The tag field in struct request is unique per hardware queue but not over
+ * all hardware queues. Hence this function that returns a tag with the
+ * hardware context index in the upper bits and the per hardware queue tag in
+ * the lower bits.
+ *
+ * Note: When called for a request that queued on a non-multiqueue request
+ * queue, the hardware context index is set to zero.
+ */
+u32 blk_mq_unique_tag(struct request *rq)
+{
+	struct request_queue *q = rq->q;
+	struct blk_mq_hw_ctx *hctx;
+	int hwq = 0;
+
+	if (q->mq_ops) {
+		hctx = q->mq_ops->map_queue(q, rq->mq_ctx->cpu);
+		hwq = hctx->queue_num;
+	}
+
+	return blk_mq_build_unique_tag(hwq, rq->tag);
+}
+EXPORT_SYMBOL(blk_mq_unique_tag);
+
 ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page)
 {
 	char *orig_page = page;
diff --git a/block/blk-mq.c b/block/blk-mq.c
index df8e1e0..bf1959c 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2018,6 +2018,8 @@ static int blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set)
  */
 int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
 {
+	BUILD_BUG_ON(BLK_MQ_MAX_DEPTH > 1 << BLK_MQ_UNIQUE_TAG_BITS);
+
 	if (!set->nr_hw_queues)
 		return -EINVAL;
 	if (!set->queue_depth)
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index eac4f31..6050a23 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -167,6 +167,28 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw,
 		gfp_t gfp, bool reserved);
 struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag);
 
+enum {
+	BLK_MQ_UNIQUE_TAG_BITS = 16,
+	BLK_MQ_UNIQUE_TAG_MASK = (1 << BLK_MQ_UNIQUE_TAG_BITS) - 1,
+};
+
+u32 blk_mq_unique_tag(struct request *rq);
+
+static inline u32 blk_mq_build_unique_tag(int hwq, int tag)
+{
+	return (hwq << BLK_MQ_UNIQUE_TAG_BITS) | (tag & BLK_MQ_UNIQUE_TAG_MASK);
+}
+
+static inline u16 blk_mq_unique_tag_to_hwq(u32 unique_tag)
+{
+	return unique_tag >> BLK_MQ_UNIQUE_TAG_BITS;
+}
+
+static inline u16 blk_mq_unique_tag_to_tag(u32 unique_tag)
+{
+	return unique_tag & BLK_MQ_UNIQUE_TAG_MASK;
+}
+
 struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_index);
 struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int, int);
 
-- 
1.8.4.5


  reply	other threads:[~2014-10-07 13:03 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-07 13:01 [PATCH v2 0/12] IB/srp: Add multichannel support Bart Van Assche
2014-10-07 13:03 ` Bart Van Assche [this message]
2014-10-11 11:08   ` [PATCH v2 02/12] blk-mq: Add blk_mq_unique_tag() Christoph Hellwig
2014-10-13  9:21     ` Bart Van Assche
     [not found]       ` <543B99B2.1010307-HInyCGIudOg@public.gmane.org>
2014-10-13 10:15         ` Christoph Hellwig
2014-10-19 16:14           ` Sagi Grimberg
     [not found]   ` <5433E493.9030304-HInyCGIudOg@public.gmane.org>
2014-10-28  1:55     ` Martin K. Petersen
2014-10-07 13:04 ` [PATCH v2 04/12] scsi_tcq.h: Add support for multiple hardware queues Bart Van Assche
2014-10-19 16:12   ` Sagi Grimberg
     [not found]     ` <5443E2DF.1040605-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-10-20 12:01       ` Bart Van Assche
     [not found]         ` <5444F995.5080407-HInyCGIudOg@public.gmane.org>
2014-10-21  8:49           ` Christoph Hellwig
2014-10-21  8:59             ` Sagi Grimberg
2014-10-28  2:06   ` Martin K. Petersen
     [not found] ` <5433E43D.3010107-HInyCGIudOg@public.gmane.org>
2014-10-07 13:02   ` [PATCH v2 01/12] blk-mq: Use all available " Bart Van Assche
2014-10-07 14:37     ` Jens Axboe
     [not found]       ` <5433FA8F.3050100-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2014-10-08 13:21         ` Bart Van Assche
     [not found]           ` <54353A74.7040406-HInyCGIudOg@public.gmane.org>
2014-10-11 11:11             ` Christoph Hellwig
     [not found]               ` <20141011111114.GB9593-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-10-13  9:45                 ` Bart Van Assche
     [not found]                   ` <543B9F47.2090204-HInyCGIudOg@public.gmane.org>
2014-10-17 13:20                     ` Christoph Hellwig
     [not found]                       ` <20141017132053.GF16538-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-10-17 14:11                         ` Sagi Grimberg
2014-10-07 13:03   ` [PATCH v2 03/12] scsi-mq: Add support for multiple " Bart Van Assche
     [not found]     ` <5433E4AB.8030306-HInyCGIudOg@public.gmane.org>
2014-10-19 15:54       ` Sagi Grimberg
2014-10-28  2:01       ` Martin K. Petersen
2014-10-29 12:22         ` Bart Van Assche
2014-10-29 12:27           ` Bart Van Assche
     [not found]             ` <5450DD49.6090108-HInyCGIudOg@public.gmane.org>
2014-10-30  0:53               ` Martin K. Petersen
2014-10-07 13:04   ` [PATCH v2 05/12] IB/srp: Move ib_destroy_cm_id() call into srp_free_ch_ib() Bart Van Assche
2014-10-07 13:04   ` [PATCH v2 06/12] IB/srp: Remove stale connection retry mechanism Bart Van Assche
2014-10-07 13:05   ` [PATCH v2 09/12] IB/srp: Separate target and channel variables Bart Van Assche
2014-10-19 16:48     ` Sagi Grimberg
2014-10-07 13:06   ` [PATCH v2 11/12] IB/srp: Eliminate free_reqs list Bart Van Assche
     [not found]     ` <5433E56E.6010600-HInyCGIudOg@public.gmane.org>
2014-10-17 10:59       ` Christoph Hellwig
     [not found]         ` <20141017105939.GB7819-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-10-19 16:59           ` Sagi Grimberg
2014-10-20 11:47           ` Bart Van Assche
2014-10-21  8:49             ` Christoph Hellwig
2014-10-07 13:05 ` [PATCH v2 07/12] IB/srp: Avoid that I/O hangs due to a cable pull during LUN scanning Bart Van Assche
2014-10-19 16:27   ` Sagi Grimberg
     [not found]     ` <5443E66F.7050901-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-10-20 12:15       ` Bart Van Assche
2014-10-21  8:50         ` Christoph Hellwig
2014-10-07 13:05 ` [PATCH v2 08/12] IB/srp: Introduce two new srp_target_port member variables Bart Van Assche
2014-10-19 16:30   ` Sagi Grimberg
2014-10-07 13:06 ` [PATCH v2 10/12] IB/srp: Use block layer tags Bart Van Assche
     [not found]   ` <5433E557.3010505-HInyCGIudOg@public.gmane.org>
2014-10-17 10:58     ` Christoph Hellwig
     [not found]       ` <20141017105858.GA7819-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-10-20 11:44         ` Bart Van Assche
2014-10-22 22:03     ` Elliott, Robert (Server Storage)
     [not found]       ` <94D0CD8314A33A4D9D801C0FE68B4029593212E0-wwDBVnaDRpYSZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
2014-10-23  7:16         ` Bart Van Assche
2014-10-23 17:43           ` Webb Scales
     [not found]             ` <54493E5A.7050803-VXdhtT5mjnY@public.gmane.org>
2014-10-24  6:45               ` Bart Van Assche
     [not found]                 ` <5449F571.7080308-HInyCGIudOg@public.gmane.org>
2014-10-24 15:40                   ` Webb Scales
2014-10-23  8:47       ` Christoph Hellwig
2014-10-24  4:43         ` Elliott, Robert (Server Storage)
2014-10-24  6:45           ` Christoph Hellwig
     [not found]             ` <20141024064514.GA15654-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-10-31 17:34               ` Hannes Reinecke
2014-11-03  7:52             ` Kashyap Desai
2014-11-03  8:25               ` Christoph Hellwig
2014-10-07 13:07 ` [PATCH v2 12/12] IB/srp: Add multichannel support Bart Van Assche
2014-10-17 11:01   ` EH action after scsi_remove_host, was: " Christoph Hellwig
2014-10-20 13:53     ` Bart Van Assche
2014-10-21  8:51       ` Christoph Hellwig
2014-10-17 11:06   ` Christoph Hellwig
     [not found]     ` <20141017110627.GD7819-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-10-20 11:57       ` Bart Van Assche
2014-10-21  8:49         ` Christoph Hellwig
     [not found]   ` <5433E585.607-HInyCGIudOg@public.gmane.org>
2014-10-19 17:36     ` Sagi Grimberg
2014-10-20 12:56       ` Bart Van Assche
     [not found]         ` <54450690.709-HInyCGIudOg@public.gmane.org>
2014-10-21  9:10           ` Sagi Grimberg
     [not found]             ` <544622FE.5040906-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-10-28 18:32               ` Sagi Grimberg
     [not found]                 ` <544FE13A.60807-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-10-29 10:52                   ` Bart Van Assche
2014-10-30 14:19                     ` Sagi Grimberg
2014-10-30 14:36                       ` Bart Van Assche
     [not found]                         ` <54524D08.4040203-HInyCGIudOg@public.gmane.org>
2014-10-30 15:06                           ` Sagi Grimberg
     [not found]                             ` <545253E3.7000009-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-10-30 15:19                               ` Bart Van Assche
     [not found]                                 ` <545256E5.9010501-HInyCGIudOg@public.gmane.org>
2014-10-30 17:33                                   ` Sagi Grimberg
2014-10-31  9:19                                     ` Bart Van Assche
     [not found]                                       ` <5453541D.7040206-HInyCGIudOg@public.gmane.org>
2014-11-02 13:03                                         ` Sagi Grimberg
2014-11-03  1:46                                           ` Elliott, Robert (Server Storage)
2014-11-04 11:46                                             ` Bart Van Assche
     [not found]                                               ` <5458BC8B.40202-HInyCGIudOg@public.gmane.org>
2014-11-04 12:15                                                 ` Sagi Grimberg
     [not found]                                                   ` <5458C344.2040109-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-11-05  4:57                                                     ` Elliott, Robert (Server Storage)
     [not found]                                                       ` <94D0CD8314A33A4D9D801C0FE68B40295937104F-2m9nI20wMFwSZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
2014-11-05 11:22                                                         ` Sagi Grimberg
2014-10-21  9:14     ` Sagi Grimberg
2014-10-29 12:36       ` Bart Van Assche
2014-10-30 14:22         ` 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=5433E493.9030304@acm.org \
    --to=bvanassche@acm.org \
    --cc=Elliott@hp.com \
    --cc=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=ming.lei@canonical.com \
    --cc=sagig@mellanox.com \
    --cc=sebastian.riemer@profitbricks.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;
as well as URLs for NNTP newsgroup(s).