All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Cc: linux-rdma <linux-rdma@vger.kernel.org>,
	Christoph Hellwig <hch@infradead.org>,
	Jens Axboe <axboe@kernel.dk>, Robert Elliott <Elliott@hp.com>,
	Ming Lei <ming.lei@canonical.com>
Subject: [PATCH 3/8] scsi-mq: Pass hctx to low-level SCSI drivers
Date: Fri, 19 Sep 2014 14:57:35 +0200	[thread overview]
Message-ID: <541C283F.8000800@acm.org> (raw)
In-Reply-To: <541C27BF.6070609@acm.org>

Low-level drivers (LLDs) need to know which hardware context has been
selected by the block layer. Hence pass this information to SCSI LLDs.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Cc: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/scsi.c      |  7 +++++--
 drivers/scsi/scsi_lib.c  |  4 ++--
 drivers/scsi/scsi_priv.h |  2 +-
 include/scsi/scsi_host.h | 14 ++++++++++++++
 4 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index d81f3cc..9bd4bd0 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -640,9 +640,10 @@ EXPORT_SYMBOL(scsi_cmd_get_serial);
  * Return: nonzero return request was rejected and device's queue needs to be
  * plugged.
  */
-int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
+int scsi_dispatch_cmd(struct blk_mq_hw_ctx *hctx, struct scsi_cmnd *cmd)
 {
 	struct Scsi_Host *host = cmd->device->host;
+	struct scsi_host_template *hostt = host->hostt;
 	int rtn = 0;
 
 	atomic_inc(&cmd->device->iorequest_cnt);
@@ -701,7 +702,9 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
 	}
 
 	trace_scsi_dispatch_cmd_start(cmd);
-	rtn = host->hostt->queuecommand(host, cmd);
+	rtn = hctx && hostt->mq_queuecommand ?
+		hostt->mq_queuecommand(hctx, cmd) :
+		hostt->queuecommand(host, cmd);
 	if (rtn) {
 		trace_scsi_dispatch_cmd_error(cmd, rtn);
 		if (rtn != SCSI_MLQUEUE_DEVICE_BUSY &&
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index b0b6117..6303648 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1747,7 +1747,7 @@ static void scsi_request_fn(struct request_queue *q)
 		 * Dispatch the command to the low-level driver.
 		 */
 		cmd->scsi_done = scsi_done;
-		rtn = scsi_dispatch_cmd(cmd);
+		rtn = scsi_dispatch_cmd(NULL, cmd);
 		if (rtn) {
 			scsi_queue_insert(cmd, rtn);
 			spin_lock_irq(q->queue_lock);
@@ -1889,7 +1889,7 @@ static int scsi_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req)
 	scsi_init_cmd_errh(cmd);
 	cmd->scsi_done = scsi_mq_done;
 
-	reason = scsi_dispatch_cmd(cmd);
+	reason = scsi_dispatch_cmd(hctx, cmd);
 	if (reason) {
 		scsi_set_blocked(cmd, reason);
 		ret = BLK_MQ_RQ_QUEUE_BUSY;
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 12b8e1b..f4115f6 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -29,7 +29,7 @@ extern int scsi_init_hosts(void);
 extern void scsi_exit_hosts(void);
 
 /* scsi.c */
-extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd);
+extern int scsi_dispatch_cmd(struct blk_mq_hw_ctx *hctx, struct scsi_cmnd *cmd);
 extern int scsi_setup_command_freelist(struct Scsi_Host *shost);
 extern void scsi_destroy_command_freelist(struct Scsi_Host *shost);
 #ifdef CONFIG_SCSI_LOGGING
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 0a867d9..c695f1c 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -133,6 +133,20 @@ struct scsi_host_template {
 	int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *);
 
 	/*
+	 * scsi-mq version of queuecommand(). Must be provided by LLDDs that
+	 * provide multiple hardware queues and that need to know on which
+	 * hardware context a command has been queued by the block layer.
+	 *
+	 * Note: even if an LLDD provides an mq_queuecommand callback function
+	 * it still has to provide a queuecommand callback function. The SCSI
+	 * error handler namely can invoke the queuecommand callback function
+	 * even if scsi-mq is enabled.
+	 *
+	 * STATUS: OPTIONAL
+	 */
+	int (* mq_queuecommand)(struct blk_mq_hw_ctx *hctx, struct scsi_cmnd *);
+
+	/*
 	 * This is an error handling strategy routine.  You don't need to
 	 * define one of these if you don't want to - there is a default
 	 * routine that is present that should work in most cases.  For those
-- 
1.8.4.5


  parent reply	other threads:[~2014-09-19 12:57 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-19 12:55 [PATCH RFC 0/8] IB/srp: Add multichannel support Bart Van Assche
2014-09-19 12:56 ` Bart Van Assche
2014-09-19 18:02   ` Sagi Grimberg
2014-09-19 12:57 ` [PATCH 2/8] scsi-mq: Add support for multiple hardware queues Bart Van Assche
     [not found]   ` <541C281E.9090206-HInyCGIudOg@public.gmane.org>
2014-09-19 18:05     ` Sagi Grimberg
2014-09-19 18:11       ` Christoph Hellwig
     [not found]       ` <CAF9gx6JfP2bGyMauB6LzepZP_vKEvrd-sPZc5CRuOrtgQ_UCSw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-26 11:08         ` Ming Lei
     [not found]           ` <CACVXFVMiYsW=dszQ6mE-o_L8fEDdkO59vJ5qeHKch5c33K_QXw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-26 14:02             ` Bart Van Assche
2014-09-19 12:57 ` Bart Van Assche [this message]
     [not found] ` <541C27BF.6070609-HInyCGIudOg@public.gmane.org>
2014-09-19 12:58   ` [PATCH 4/8] IB/srp: Move ib_destroy_cm_id() call into srp_free_ch_ib() Bart Van Assche
     [not found]     ` <541C285B.5010309-HInyCGIudOg@public.gmane.org>
2014-09-19 18:10       ` Sagi Grimberg
2014-09-19 12:58   ` [PATCH 5/8] IB/srp: Remove stale connection retry mechanism Bart Van Assche
2014-09-19 18:25     ` Sagi Grimberg
     [not found]     ` <541C287D.1050900-HInyCGIudOg@public.gmane.org>
2014-09-20 17:45       ` Or Gerlitz
     [not found]         ` <CAJ3xEMhPKiut4MwZH9F7-T0+u7B6XPuh-FTZpA=Xe4ViAj5UUQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-02 10:34           ` Bart Van Assche
     [not found]             ` <542D2A3C.2080009-HInyCGIudOg@public.gmane.org>
2014-10-03  8:51               ` Bart Van Assche
2014-09-19 13:00   ` [PATCH 8/8] IB/srp: Add multichannel support Bart Van Assche
     [not found]     ` <541C28E0.7010705-HInyCGIudOg@public.gmane.org>
2014-09-19 14:28       ` Ming Lei
     [not found]         ` <CACVXFVPzz37J-613NZCfPStUBxf0rLOtz71LJ07PpCxYg5nn+g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-19 15:21           ` Bart Van Assche
     [not found]             ` <541C49EC.6030404-HInyCGIudOg@public.gmane.org>
2014-09-19 15:27               ` Ming Lei
2014-09-19 15:35                 ` Bart Van Assche
2014-09-19 15:38                   ` Jens Axboe
2014-09-19 17:30                     ` Sagi Grimberg
2014-09-19 17:33                       ` Jens Axboe
2014-09-19 18:11                         ` Christoph Hellwig
     [not found]                     ` <541C4DF1.4090604-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2014-10-01 16:08                       ` Bart Van Assche
2014-10-01 16:54                         ` Jens Axboe
2014-10-01 21:14                           ` Christoph Hellwig
     [not found]                           ` <542C31C4.1020702-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2014-10-02 16:45                             ` Bart Van Assche
2014-10-02 16:55                               ` Jens Axboe
     [not found]                                 ` <542D8368.8080604-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2014-10-03 13:01                                   ` Bart Van Assche
2014-10-03 14:24                                     ` Jens Axboe
     [not found]                               ` <542D8143.3050305-HInyCGIudOg@public.gmane.org>
2014-10-02 17:30                                 ` Christoph Hellwig
2014-10-06 11:16                                   ` Bart Van Assche
     [not found]                                     ` <54327A21.6070202-HInyCGIudOg@public.gmane.org>
2014-10-10 20:16                                       ` Roland Dreier
2014-09-23 16:32     ` Sagi Grimberg
     [not found]       ` <5421A093.1070203-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-09-23 19:02         ` Bart Van Assche
2014-09-24 12:22           ` Sagi Grimberg
2014-09-24 13:13             ` Bart Van Assche
     [not found]               ` <5422C395.7090902-HInyCGIudOg@public.gmane.org>
2014-09-24 13:38                 ` Sagi Grimberg
     [not found]                   ` <5422C970.4050306-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-09-24 13:43                     ` Sagi Grimberg
2014-10-07 12:51         ` Bart Van Assche
     [not found]           ` <5433E1B5.1030103-HInyCGIudOg@public.gmane.org>
2014-10-13  8:17             ` Sagi Grimberg
     [not found]               ` <543B8AB0.1090704-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-10-13  8:52                 ` Bart Van Assche
2014-10-01 16:14   ` [PATCH RFC] scsi_tcq.h: Add support for multiple hardware queues Bart Van Assche
2014-09-19 12:59 ` [PATCH 6/8] IB/srp: Avoid that I/O hangs due to a cable pull during LUN scanning Bart Van Assche
2014-09-19 12:59 ` [PATCH 7/8] IB/srp: Separate target and channel variables Bart Van Assche
2014-09-19 18:47   ` Sagi Grimberg
     [not found]   ` <541C28C8.7000007-HInyCGIudOg@public.gmane.org>
2014-09-23 16:07     ` Sagi Grimberg
2014-09-23 20:00       ` Bart Van Assche
2014-09-19 18:31 ` [PATCH RFC 0/8] IB/srp: Add multichannel support Jens Axboe
2014-09-22 14:37 ` Christoph Hellwig
     [not found]   ` <20140922143731.GA15377-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-09-22 16:25     ` Bart Van Assche
2014-09-22 16:31       ` Jens Axboe
2014-09-22 16:39         ` Jens Axboe

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=541C283F.8000800@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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.