Skip to contentSkip to conversation

Fix sense handling in __scsi_execute()

PATCH In review Bart Van Assche 1 participant 2 messages Jan 23, 2019 – Jan 24, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix sense handling in __scsi_execute()

Since blk_execute_rq() no longer allocates a sense buffer and no longer initializes the sense pointer the callers of blk_execute_rq() have to do initialize the sense pointer. Hence this patch that initializes rq->sense and that removes a superfluous memcpy() statement.

Cc Christoph Hellwig <[email protected]>
Cc Douglas Gilbert <[email protected]>
Cc <[email protected]> # v4.11+
Fixes 82ed4db499b8 ("block: split scsi_request out of struct request")
---
 drivers/scsi/scsi_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/scsi_lib.c +1 -2
index 4feba3b5aff1..8b9f4b1bca35 100644
@@ -271,6 +271,7 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 	rq->cmd_len = COMMAND_SIZE(cmd[0]);
 	memcpy(rq->cmd, cmd, rq->cmd_len);
 	rq->retries = retries;
+	rq->sense = sense;
 	req->timeout = timeout;
 	req->cmd_flags |= flags;
 	req->rq_flags |= rq_flags | RQF_QUIET;
@@ -291,8 +292,6 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 
 	if (resid)
 		*resid = rq->resid_len;
-	if (sense && rq->sense_len)
-		memcpy(sense, rq->sense, SCSI_SENSE_BUFFERSIZE);
 	if (sshdr)
 		scsi_normalize_sense(rq->sense, rq->sense_len, sshdr);
 	ret = rq->result;
Signature · 1 line
2.20.1.321.g9e740568ce-goog
#1 lore raw
Quoted 21 lines · Bart Van Assche

Since blk_execute_rq() no longer allocates a sense buffer and no longer initializes the sense pointer the callers of blk_execute_rq() have to do initialize the sense pointer. Hence this patch that initializes rq->sense and that removes a superfluous memcpy() statement.

Cc Christoph Hellwig <[email protected]>>Cc: Douglas Gilbert <[email protected]>>Cc: <[email protected]>#v4.11+-
Fixes 82ed4db499b8 ("block: split scsi_request out of struct request"

drivers/scsi/scsi_lib.c |3 +---

1 file changed, 1 insertion(+-), 2 deletions(-)
drivers/scsi/scsi_lib.c +1 -1
index 4feba3b5aff1..8b9f4b1bca35 100644
--- a/drivers/scsi/scsi_lib.c
+-+-+- b/drivers/scsi/scsi_lib.c

@@-271,6 +-271,7 @@int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,

	rq->cmd_len =COMMAND_SIZE(cmd[0];> 	memcpy(rq->cmd, cmd, rq->cmd_len);> 	rq->retries =retries;>+-	rq->sense =sense;> 	req->timeout =timeout;> 	req->cmd_flags |=flags;> 	req->rq_flags |=rq_flags |RQF_QUIET;>@@-291,8 +-292,6 @@int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,

	if (resid)
		*resid =rq->resid_len;>-	if (sense &&rq->sense_len)
drivers/scsi/scsi_lib.c +0 -1
-		memcpy(sense, rq->sense, SCSI_SENSE_BUFFERSIZE);> 	if (sshdr)
Quoted 1 line
		scsi_normalize_sense(rq->sense, rq->sense_len, sshdr);> 	ret =rq->result;

Please ignore this patch - I just realized that this is not the right way to fix the issue I ran into.

Bart.