All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] stale residual returned on write following BUSY retry
@ 2007-09-17 22:11 Michael Reed
  0 siblings, 0 replies; only message in thread
From: Michael Reed @ 2007-09-17 22:11 UTC (permalink / raw)
  To: linux-scsi; +Cc: Jeremy Higdon, Kevan Rehm, James Bottomley

[-- Attachment #1: Type: text/plain, Size: 990 bytes --]

A BUSY status returned on a write request results in a stale residual
being returned when the write ultimately successfully completes.

This can be reproduced as follows:

1) issue immediate mode rewind to scsi tape drive
2) issue write request

The tape drive returns busy.  The low level driver detects underrun and
sets the residual into the scsi command.  The low level driver responds
with (DID_OK << 16) | scsi_status.  scsi_status is 8, hence
status_byte(result) == 4, i.e., BUSY.

scsi_softirq_done() calls scsi_decide_disposition() which returns
ADD_TO_MLQUEUE.  scsi_softirq_done() then calls scsi_queue_insert()
which, on the way to resubmitting the request to the driver, calls
scsi_init_cmd_errh().

The attached patch modifies scsi_init_cmd_errh() to clear the resid
field.  This prevents a "stale" residual from being returned when the
scsi command finally completes without a BUSY status.

This patch applies to 2.6.23-rc6-git7.

Signed-off-by: Michael Reed <mdr@sgi.com>



[-- Attachment #2: residual.patch --]
[-- Type: text/x-patch, Size: 467 bytes --]

--- linux-2.6.23-rc6-git7.orig/drivers/scsi/scsi_lib.c	2007-09-17 14:02:03.000000000 -0700
+++ linux-2.6.23-rc6-git7/drivers/scsi/scsi_lib.c	2007-09-17 14:05:51.000000000 -0700
@@ -443,6 +443,7 @@ EXPORT_SYMBOL_GPL(scsi_execute_async);
 static void scsi_init_cmd_errh(struct scsi_cmnd *cmd)
 {
 	cmd->serial_number = 0;
+	cmd->resid = 0;
 	memset(cmd->sense_buffer, 0, sizeof cmd->sense_buffer);
 	if (cmd->cmd_len == 0)
 		cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-09-17 22:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-17 22:11 [PATCH 1/1] stale residual returned on write following BUSY retry Michael Reed

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.