public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH 09/10] scsi: remove scsi_setup_cmnd and scsi_setup_fs_cmnd
Date: Mon,  5 Oct 2020 10:41:29 +0200	[thread overview]
Message-ID: <20201005084130.143273-10-hch@lst.de> (raw)
In-Reply-To: <20201005084130.143273-1-hch@lst.de>

Move this trivial functionality into scsi_prepare_cmd instead of
splitting it over multiple small functions, and update the comments
to better document passthrough commands as the special case.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/scsi_lib.c | 50 ++++++++++++++---------------------------
 1 file changed, 17 insertions(+), 33 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index c65ecb99c6994b..f7b88d8cf975d5 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1175,38 +1175,6 @@ static blk_status_t scsi_setup_scsi_cmnd(struct scsi_device *sdev,
 	return BLK_STS_OK;
 }
 
-/*
- * Setup a normal block command.  These are simple request from filesystems
- * that still need to be translated to SCSI CDBs from the ULD.
- */
-static blk_status_t scsi_setup_fs_cmnd(struct scsi_device *sdev,
-		struct request *req)
-{
-	struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
-
-	if (unlikely(sdev->handler && sdev->handler->prep_fn)) {
-		blk_status_t ret = sdev->handler->prep_fn(sdev, req);
-		if (ret != BLK_STS_OK)
-			return ret;
-	}
-
-	cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
-	memset(cmd->cmnd, 0, BLK_MAX_CDB);
-	return scsi_cmd_to_driver(cmd)->init_command(cmd);
-}
-
-static blk_status_t scsi_setup_cmnd(struct scsi_device *sdev,
-		struct request *req)
-{
-	struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
-
-	cmd->sc_data_direction = rq_dma_dir(req);
-
-	if (blk_rq_is_scsi(req))
-		return scsi_setup_scsi_cmnd(sdev, req);
-	return scsi_setup_fs_cmnd(sdev, req);
-}
-
 static blk_status_t
 scsi_device_state_check(struct scsi_device *sdev, struct request *req)
 {
@@ -1568,6 +1536,7 @@ static blk_status_t scsi_prepare_cmd(struct request *req)
 	cmd->request = req;
 	cmd->tag = req->tag;
 	cmd->prot_op = SCSI_PROT_NORMAL;
+	cmd->sc_data_direction = rq_dma_dir(req);
 
 	sg = (void *)cmd + sizeof(struct scsi_cmnd) + shost->hostt->cmd_size;
 	cmd->sdb.table.sgl = sg;
@@ -1581,7 +1550,22 @@ static blk_status_t scsi_prepare_cmd(struct request *req)
 
 	blk_mq_start_request(req);
 
-	return scsi_setup_cmnd(sdev, req);
+	/*
+	 * Special handling for passthrough commands, which don't go to the ULP
+	 * at all:
+	 */
+	if (blk_rq_is_scsi(req))
+		return scsi_setup_scsi_cmnd(sdev, req);
+
+	if (sdev->handler && sdev->handler->prep_fn) {
+		blk_status_t ret = sdev->handler->prep_fn(sdev, req);
+		if (ret != BLK_STS_OK)
+			return ret;
+	}
+
+	cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
+	memset(cmd->cmnd, 0, BLK_MAX_CDB);
+	return scsi_cmd_to_driver(cmd)->init_command(cmd);
 }
 
 static void scsi_mq_done(struct scsi_cmnd *cmd)
-- 
2.28.0


  parent reply	other threads:[~2020-10-05  8:41 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-05  8:41 misc I/O submission cleanups Christoph Hellwig
2020-10-05  8:41 ` [PATCH 01/10] scsi: don't export scsi_device_from_queue Christoph Hellwig
2020-10-05  9:00   ` Hannes Reinecke
2020-10-13 22:42   ` Martin K. Petersen
2020-10-05  8:41 ` [PATCH 02/10] scsi: remove scsi_init_cmd_errh Christoph Hellwig
2020-10-05  9:01   ` Hannes Reinecke
2020-10-05  8:41 ` [PATCH 03/10] scsi: move command size detection out of the fast path Christoph Hellwig
2020-10-05  9:02   ` Hannes Reinecke
2020-10-05  8:41 ` [PATCH 04/10] scsi: simplify varlen CDB length checking Christoph Hellwig
2020-10-05  9:03   ` Hannes Reinecke
2020-10-05 16:06   ` Bart Van Assche
2020-10-07  2:36     ` Martin K. Petersen
2020-10-05  8:41 ` [PATCH 05/10] scsi: use rq_dma_dir in scsi_setup_cmnd Christoph Hellwig
2020-10-05  9:04   ` Hannes Reinecke
2020-10-05  8:41 ` [PATCH 06/10] scsi: rename scsi_prep_state_check to scsi_device_state_check Christoph Hellwig
2020-10-05  9:04   ` Hannes Reinecke
2020-10-05  8:41 ` [PATCH 07/10] scsi: rename scsi_mq_prep_fn to scsi_prepare_cmd Christoph Hellwig
2020-10-05  9:05   ` Hannes Reinecke
2020-10-05  8:41 ` [PATCH 08/10] scsi: cleanup allocation and freeing of sgtables Christoph Hellwig
2020-10-06  5:49   ` Hannes Reinecke
2020-10-05  8:41 ` Christoph Hellwig [this message]
2020-10-05  8:41 ` [PATCH 10/10] scsi: only start the request just before dispatching Christoph Hellwig
2020-10-05 16:11   ` Bart Van Assche
2020-10-07  2:37 ` misc I/O submission cleanups Martin K. Petersen
2020-10-08 16:39 ` Qian Cai

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=20201005084130.143273-10-hch@lst.de \
    --to=hch@lst.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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