From: Boaz Harrosh <bharrosh@panasas.com>
To: "James Bottomley" <James.Bottomley@SteelEye.com>,
"Christoph Hellwig" <hch@lst.de>,
"\"Jürgen E. Fischer\"" <fischer@norbit.de>,
"FUJITA Tomonori" <fujita.tomonori@lab.ntt.co.jp>,
linux-scsi <linux-scsi@vger.kernel.org>
Subject: [patch 2/4] aha152x.c - Clean Reset path
Date: Thu, 12 Jul 2007 12:55:21 +0300 [thread overview]
Message-ID: <4695FA89.4010105@panasas.com> (raw)
In-Reply-To: <4695F76F.5000305@panasas.com>
What Reset code was doing: Save command's important/dangerous
Info on stack. NULL those members from scsi_cmnd.
Issue a Reset. wait for it to finish than restore members
and return.
What I do is save or NULL nothing. But use the "resetting"
hint in aha152x_internal_queue() to NULL out working members
and leave struct scsi_cmnd alone.
(Actually the Reset path never touches any of these working
members but it looks safer this way, just in case.)
The indentation in aha152x_internal_queue() is wrong at
this stage but it will be eliminated in last patch, and
for now it is easier for review.
---
drivers/scsi/aha152x.c | 23 +++++++++--------------
1 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 29253f9..ea57ecd 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1022,6 +1022,14 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
SCp.buffer : next buffer
SCp.buffers_residual : left buffers in list
SCp.phase : current state of the command */
+
+ if(phase & resetting) {
+ SCpnt->SCp.ptr = NULL;
+ SCpnt->SCp.this_residual = 0;
+ SCpnt->resid = 0;
+ SCpnt->SCp.buffer = NULL;
+ SCpnt->SCp.buffers_residual = 0;
+ } else {
if (SCpnt->use_sg) {
SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->request_buffer;
SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer);
@@ -1033,6 +1041,7 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
SCpnt->SCp.buffer = NULL;
SCpnt->SCp.buffers_residual = 0;
}
+ }
DO_LOCK(flags);
@@ -1149,10 +1158,6 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
struct Scsi_Host *shpnt = SCpnt->device->host;
DECLARE_COMPLETION(done);
int ret, issued, disconnected;
- unsigned char old_cmd_len = SCpnt->cmd_len;
- unsigned short old_use_sg = SCpnt->use_sg;
- void *old_buffer = SCpnt->request_buffer;
- unsigned old_bufflen = SCpnt->request_bufflen;
unsigned long flags;
unsigned long timeleft;
@@ -1173,11 +1178,6 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
disconnected = issued && remove_SC(&DISCONNECTED_SC, SCpnt);
DO_UNLOCK(flags);
- SCpnt->cmd_len = 0;
- SCpnt->use_sg = 0;
- SCpnt->request_buffer = NULL;
- SCpnt->request_bufflen = 0;
-
aha152x_internal_queue(SCpnt, &done, resetting, reset_done);
timeleft = wait_for_completion_timeout(&done, 100*HZ);
@@ -1188,11 +1188,6 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
DO_UNLOCK(flags);
}
- SCpnt->cmd_len = old_cmd_len;
- SCpnt->use_sg = old_use_sg;
- SCpnt->request_buffer = old_buffer;
- SCpnt->request_bufflen = old_bufflen;
-
DO_LOCK(flags);
if(SCpnt->SCp.phase & resetted) {
--
1.5.2.2.249.g45fd
next prev parent reply other threads:[~2007-07-12 9:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-12 9:42 [patch 0/4] aha152x.c - Cleanup, need help in testing and auditing Boaz Harrosh
2007-07-12 9:49 ` [patch 1/4] aha152x.c - Preliminary fixes and some comments Boaz Harrosh
2007-07-12 9:55 ` Boaz Harrosh [this message]
2007-07-12 10:05 ` [patch 3/4] aha152x.c - Fix check_condition code-path Boaz Harrosh
2007-07-12 10:09 ` [patch 4/4] aha152x.c - use data accessors and !use_sg cleanup Boaz Harrosh
2007-07-12 13:17 ` [patch 0/4] aha152x.c - Cleanup, need help in testing and auditing Boaz Harrosh
2007-07-12 20:57 ` Randy Dunlap
2007-07-16 9:22 ` Boaz Harrosh
2007-07-16 9:35 ` Christoph Hellwig
2007-07-18 0:16 ` Randy Dunlap
2007-07-18 9:29 ` Boaz Harrosh
2007-07-18 12:39 ` Boaz Harrosh
2007-07-18 17:33 ` Randy Dunlap
2007-07-18 21:58 ` Randy Dunlap
2007-07-19 2:43 ` Randy Dunlap
2007-07-19 3:03 ` Randy Dunlap
2007-07-19 13:04 ` Boaz Harrosh
2007-07-19 15:37 ` Randy Dunlap
2007-07-19 15:57 ` Boaz Harrosh
2007-07-19 17:49 ` Randy Dunlap
2007-07-24 10:12 ` Boaz Harrosh
2007-07-24 16:17 ` Randy Dunlap
2007-08-16 5:22 ` Randy Dunlap
2007-08-16 14:39 ` James Bottomley
2007-08-16 17:20 ` Randy Dunlap
2007-08-16 17:18 ` James Bottomley
2007-08-17 19:59 ` Randy Dunlap
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=4695FA89.4010105@panasas.com \
--to=bharrosh@panasas.com \
--cc=James.Bottomley@SteelEye.com \
--cc=fischer@norbit.de \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=hch@lst.de \
--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;
as well as URLs for NNTP newsgroup(s).