Linux block layer
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: axboe@kernek.dk
Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: [PATCH 4/6] scsi: simplify scsi_execute_req_flags
Date: Tue, 14 Feb 2017 20:15:58 +0100	[thread overview]
Message-ID: <20170214191600.17480-5-hch@lst.de> (raw)
In-Reply-To: <20170214191600.17480-1-hch@lst.de>

Add a sshdr argument to __scsi_execute so that we can decode the sense
data directly into the sense header instead of needing a copy of it.

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

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 227a77869e13..35b43a8f1bfa 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -215,8 +215,9 @@ void scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
 
 static int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 		 int data_direction, void *buffer, unsigned bufflen,
-		 unsigned char *sense, int timeout, int retries, u64 flags,
-		 req_flags_t rq_flags, int *resid)
+		 unsigned char *sense, struct scsi_sense_hdr *sshdr,
+		 int timeout, int retries, u64 flags, req_flags_t rq_flags,
+		 int *resid)
 {
 	struct request *req;
 	struct scsi_request *rq;
@@ -259,6 +260,8 @@ static int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 		*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 = req->errors;
  out:
 	blk_put_request(req);
@@ -288,7 +291,7 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 		 int *resid)
 {
 	return __scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense,
-			timeout, retries, flags, 0, resid);
+			NULL, timeout, retries, flags, 0, resid);
 }
 EXPORT_SYMBOL(scsi_execute);
 
@@ -297,21 +300,9 @@ int scsi_execute_req_flags(struct scsi_device *sdev, const unsigned char *cmd,
 		     struct scsi_sense_hdr *sshdr, int timeout, int retries,
 		     int *resid, u64 flags, req_flags_t rq_flags)
 {
-	char *sense = NULL;
-	int result;
-	
-	if (sshdr) {
-		sense = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_NOIO);
-		if (!sense)
-			return DRIVER_ERROR << 24;
-	}
-	result = __scsi_execute(sdev, cmd, data_direction, buffer, bufflen,
-			      sense, timeout, retries, flags, rq_flags, resid);
-	if (sshdr)
-		scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, sshdr);
-
-	kfree(sense);
-	return result;
+	return __scsi_execute(sdev, cmd, data_direction, buffer, bufflen,
+			      NULL, sshdr, timeout, retries, flags, rq_flags,
+			      resid);
 }
 EXPORT_SYMBOL(scsi_execute_req_flags);
 
-- 
2.11.0

  parent reply	other threads:[~2017-02-14 19:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-14 19:15 sense handling improvements Christoph Hellwig
2017-02-14 19:15 ` [PATCH 1/6] scsi: always zero sshdr in scsi_normalize_sense Christoph Hellwig
2017-02-15  7:59   ` Hannes Reinecke
2017-02-14 19:15 ` [PATCH 2/6] sd: improve TUR handling in sd_check_events Christoph Hellwig
2017-02-15  8:00   ` Hannes Reinecke
2017-02-14 19:15 ` [PATCH 3/6] scsi: make the sense header argument to scsi_test_unit_ready mandatory Christoph Hellwig
2017-02-14 19:15 ` Christoph Hellwig [this message]
2017-02-14 19:15 ` [PATCH 5/6] scsi: merge __scsi_execute into scsi_execute Christoph Hellwig
2017-02-14 19:16 ` [PATCH 6/6] scsi: remove scsi_execute_req_flags Christoph Hellwig
2017-02-15  8:19 ` sense handling improvements Hannes Reinecke
2017-02-15 15:04   ` Christoph Hellwig
2017-02-15 15:30     ` Bart Van Assche
2017-02-16  3:42 ` Martin K. Petersen
2017-02-16 14:33   ` Christoph Hellwig
2017-02-22  7:19   ` Christoph Hellwig
2017-02-22 13:52     ` Martin K. Petersen
2017-02-23  0:51     ` Martin K. Petersen
2017-02-23  9:49       ` Christoph Hellwig
2017-02-23 14:28         ` Martin K. Petersen
2017-02-23 14:31           ` Christoph Hellwig

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=20170214191600.17480-5-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernek.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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