linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Anderson <andmike@linux.vnet.ibm.com>
To: linux-scsi@vger.kernel.org
Subject: [PATCH] scsi: zero scsi cmd result in scsi_init_cmd_errh
Date: Tue, 26 Jan 2010 12:57:32 -0800	[thread overview]
Message-ID: <20100126205532.24221.74180.stgit@desktop-andmike.beaverton.ibm.com> (raw)

This patch zeros the command result in scsi_init_cmd_errh to ensure that
the scsi command result is zero prior to starting the command as the
command could have previously had a non-zero result if the command has
been requeued. In a timeout case that exhausts retries this previous
non-zero result value can lead to incorrect final status not being set to
timeout in scsi_eh_flush_done_q which may lead to incorrect status being
conveyed to command originator or others viewing the result field.

Signed-off-by: Mike Anderson <andmike@linux.vnet.ibm.com>
---

Debug:
Added a debug flag to track result being dirty (DRIVER_RES_DIRTY). Set and
checked for dirty flag already set in scsi_queue_insert.

On timeout case received:
kernel: [42236.341626] scsi_queue_insert: Cmd ffff8800379ab080, result dirty 9


 drivers/scsi/scsi_lib.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index d892768..25e5a6c 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -295,6 +295,7 @@ static void scsi_init_cmd_errh(struct scsi_cmnd *cmd)
 	memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 	if (cmd->cmd_len == 0)
 		cmd->cmd_len = scsi_command_size(cmd->cmnd);
+	cmd->result = 0;
 }
 
 void scsi_device_unbusy(struct scsi_device *sdev)


                 reply	other threads:[~2010-01-26 20:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20100126205532.24221.74180.stgit@desktop-andmike.beaverton.ibm.com \
    --to=andmike@linux.vnet.ibm.com \
    --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).