From: Boaz Harrosh <bharrosh@panasas.com>
To: James Bottomley <James.Bottomley@SteelEye.com>,
FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
linux-scsi <linux-scsi@vger.kernel.org>,
Alan Stern <stern@rowland.harvard.edu>,
Greg
Cc: Christoph Hellwig <hch@infradead.org>
Subject: [PATCH 1/5] scsi_error: code cleanup before refactoring of scsi_send_eh_cmnd()
Date: Mon, 10 Sep 2007 17:21:10 +0300 [thread overview]
Message-ID: <46E552D6.9040003@panasas.com> (raw)
In-Reply-To: <46E5508B.7030108@panasas.com>
- regrouped variables for easier reviewing of next patch
- Support of cmnd==NULL in call to scsi_send_eh_cmnd()
- In the REQUEST_SENSE case set cmnd[4] to the size of
sense_buffer. It was previously set by caller but needed
to be in sync with sense_buffer size.
- Also save/restore resid of faild command.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
drivers/scsi/scsi_error.c | 37 +++++++++++++++++++++++--------------
1 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index c8e351f..0bcfbe5 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -611,17 +611,20 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
{
struct scsi_device *sdev = scmd->device;
struct Scsi_Host *shost = sdev->host;
- int old_result = scmd->result;
DECLARE_COMPLETION_ONSTACK(done);
unsigned long timeleft;
unsigned long flags;
- struct scatterlist sgl;
+
+ unsigned char old_cmd_len;
unsigned char old_cmnd[MAX_COMMAND_SIZE];
enum dma_data_direction old_data_direction;
- unsigned short old_use_sg;
- unsigned char old_cmd_len;
unsigned old_bufflen;
void *old_buffer;
+ unsigned short old_use_sg;
+ int old_resid;
+ int old_result;
+
+ struct scatterlist sgl;
int rtn;
/*
@@ -631,15 +634,20 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
* we will need to restore these values prior to running the actual
* command.
*/
- old_buffer = scmd->request_buffer;
- old_bufflen = scmd->request_bufflen;
+ old_cmd_len = scmd->cmd_len;
memcpy(old_cmnd, scmd->cmnd, sizeof(scmd->cmnd));
old_data_direction = scmd->sc_data_direction;
- old_cmd_len = scmd->cmd_len;
+ old_bufflen = scmd->request_bufflen;
+ old_buffer = scmd->request_buffer;
old_use_sg = scmd->use_sg;
+ old_resid = scmd->resid;
+ old_result = scmd->result;
- memset(scmd->cmnd, 0, sizeof(scmd->cmnd));
- memcpy(scmd->cmnd, cmnd, cmnd_size);
+ if (cmnd) {
+ memset(scmd->cmnd, 0, sizeof(scmd->cmnd));
+ memcpy(scmd->cmnd, cmnd, cmnd_size);
+ scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
+ }
if (copy_sense) {
sg_init_one(&sgl, scmd->sense_buffer,
@@ -649,6 +657,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
scmd->request_bufflen = sgl.length;
scmd->request_buffer = &sgl;
scmd->use_sg = 1;
+ scmd->cmnd[4] = sgl.length;
} else {
scmd->request_buffer = NULL;
scmd->request_bufflen = 0;
@@ -657,7 +666,6 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
}
scmd->underflow = 0;
- scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
if (sdev->scsi_level <= SCSI_2)
scmd->cmnd[1] = (scmd->cmnd[1] & 0x1f) |
@@ -716,12 +724,13 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
/*
* Restore original data
*/
- scmd->request_buffer = old_buffer;
- scmd->request_bufflen = old_bufflen;
+ scmd->cmd_len = old_cmd_len;
memcpy(scmd->cmnd, old_cmnd, sizeof(scmd->cmnd));
scmd->sc_data_direction = old_data_direction;
- scmd->cmd_len = old_cmd_len;
+ scmd->request_bufflen = old_bufflen;
+ scmd->request_buffer = old_buffer;
scmd->use_sg = old_use_sg;
+ scmd->resid = old_resid;
scmd->result = old_result;
return rtn;
}
@@ -738,7 +747,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
static int scsi_request_sense(struct scsi_cmnd *scmd)
{
static unsigned char generic_sense[6] =
- {REQUEST_SENSE, 0, 0, 0, 252, 0};
+ {REQUEST_SENSE, 0, 0, 0, 0, 0};
return scsi_send_eh_cmnd(scmd, generic_sense, 6, SENSE_TIMEOUT, 1);
}
--
1.5.3.1
next prev parent reply other threads:[~2007-09-10 14:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-10 14:11 [patchset 0/5] Refactoring scsi_error to facilitate in synchronous REQUEST_SENSE Boaz Harrosh
2007-09-10 14:21 ` Boaz Harrosh [this message]
2007-09-10 14:23 ` [PATCH 2/5] " Boaz Harrosh
2007-09-10 15:12 ` Christoph Hellwig
2007-09-10 15:19 ` Randy Dunlap
2007-09-10 14:25 ` [PATCH 3/5] usb: transport.c use scsi_eh API in REQUEST_SENSE execution Boaz Harrosh
2007-09-10 14:25 ` [PATCH 4/5] NCR5380: Use scsi_eh API for REQUEST_SENSE invocation Boaz Harrosh
2007-09-10 14:29 ` [PATCH 5/5] arm: fas216 " Boaz Harrosh
2007-09-10 15:58 ` [patchset 0/5] Refactoring scsi_error to facilitate in synchronous REQUEST_SENSE Alan Stern
2007-09-10 17:03 ` Matthew Dharm
2007-09-10 17:09 ` James Bottomley
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=46E552D6.9040003@panasas.com \
--to=bharrosh@panasas.com \
--cc=James.Bottomley@SteelEye.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=hch@infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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.