From: Christoph Hellwig <hch@lst.de>
Date: Mon, 5 Oct 2020 08:41:23 +0000 (+0200)
Subject: scsi: core: Move command size detection out of the fast path
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2ceda20f0a99a74a82b78870f3b3e5fa93087a7f;p=linux.git

scsi: core: Move command size detection out of the fast path

We only need to detect the command size for ioctl request from userspace,
which is limited to the passthrough path.  Move the check there instead of
doing it for all queuecommand invocations.

Link: https://lore.kernel.org/r/20201005084130.143273-4-hch@lst.de
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index b515560eaf020..b0bd15f534671 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1181,6 +1181,8 @@ static blk_status_t scsi_setup_scsi_cmnd(struct scsi_device *sdev,
 	}
 
 	cmd->cmd_len = scsi_req(req)->cmd_len;
+	if (cmd->cmd_len == 0)
+		cmd->cmd_len = scsi_command_size(cmd->cmnd);
 	cmd->cmnd = scsi_req(req)->cmd;
 	cmd->transfersize = blk_rq_bytes(req);
 	cmd->allowed = scsi_req(req)->retries;
@@ -1694,8 +1696,6 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
 
 	scsi_set_resid(cmd, 0);
 	memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
-	if (cmd->cmd_len == 0)
-		cmd->cmd_len = scsi_command_size(cmd->cmnd);
 	cmd->scsi_done = scsi_mq_done;
 
 	reason = scsi_dispatch_cmd(cmd);