public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* SCSI eats error from flush failure during hot plug
@ 2014-06-05 23:52 Steven Haber
  2014-06-07 19:29 ` James Bottomley
  2014-06-26 15:02 ` Christoph Hellwig
  0 siblings, 2 replies; 24+ messages in thread
From: Steven Haber @ 2014-06-05 23:52 UTC (permalink / raw)
  To: linux-scsi

Hello,

I am testing ATA device durability during hot unplug. I have a power
fault test suite that has turned up issues with the fsync->SCSI->ATA
codepath. If a device is unplugged while an fsync is in progress, ATA
returns a flush error to the SCSI driver but scsi_io_completion()
seems to disregard it. fsync() returns no error, which should mean
that the write was durably flushed to disk. I expect fsync() to return
EIO or something similar when the flush isn't acked by the device.

When the failure occurs, the SCSI sense key is set to ABORTED_COMMAND.
However, scsi_end_command() is called without any of the sense context
and scsi_io_completion() returns early without checking sense at all.

This commit may be related:
d6b0c53723753fc0cfda63f56735b225c43e1e9a
(http://git.opencores.org/?a=commitdiff&p=linux&h=d6b0c53723753fc0cfda63f56735b225c43e1e9a)

The following patch fixes the issue, but it's a hack. I only have a
vague understanding of Linux drivers, so I'm looking for advice on how
to make this fix better and get it upstream.

Thanks!

Steven Haber
Qumulo, Inc.





diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 9db097a..789af39 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -822,40 +822,44 @@ void scsi_io_completion(struct scsi_cmnd *cmd,
unsigned int good_bytes)
  /*
  * Recovered errors need reporting, but they're always treated
  * as success, so fiddle the result code here.  For BLOCK_PC
  * we already took a copy of the original into rq->errors which
  * is what gets returned to the user
  */
  if (sense_valid && (sshdr.sense_key == RECOVERED_ERROR)) {
  /* if ATA PASS-THROUGH INFORMATION AVAILABLE skip
  * print since caller wants ATA registers. Only occurs on
  * SCSI ATA PASS_THROUGH commands when CK_COND=1
  */
  if ((sshdr.asc == 0x0) && (sshdr.ascq == 0x1d))
  ;
  else if (!(req->cmd_flags & REQ_QUIET))
  scsi_print_sense("", cmd);
  result = 0;
  /* BLOCK_PC may have set error */
  error = 0;
  }

+ if (sense_valid && (sshdr.sense_key == ABORTED_COMMAND) &&
+    good_bytes == 0)
+ error = (sshdr.asc == 0x10) ? -EILSEQ : -EIO;
+
  /*
  * A number of bytes were successfully read.  If there
  * are leftovers and there is some kind of error
  * (result != 0), retry the rest.
  */
  if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL)
  return;

  error = __scsi_error_from_host_byte(cmd, result);

  if (host_byte(result) == DID_RESET) {
  /* Third party bus reset or reset for error recovery
  * reasons.  Just retry the command and see what
  * happens.
  */
  action = ACTION_RETRY;
  } else if (sense_valid && !sense_deferred) {
  switch (sshdr.sense_key) {
  case UNIT_ATTENTION:
  if (cmd->device->removable) {

^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2014-07-17 15:27 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-05 23:52 SCSI eats error from flush failure during hot plug Steven Haber
2014-06-07 19:29 ` James Bottomley
2014-06-09 17:21   ` Steven Haber
2014-06-09 17:29     ` James Bottomley
2014-06-11 13:37       ` Christoph Hellwig
2014-06-19 18:05         ` James Bottomley
2014-06-25 13:13           ` Christoph Hellwig
2014-06-26 14:02             ` James Bottomley
2014-06-26 15:00               ` Christoph Hellwig
2014-06-26 15:04                 ` James Bottomley
2014-06-26 15:08                   ` Christoph Hellwig
2014-06-26 18:52                     ` James Bottomley
2014-06-27  7:53                       ` Christoph Hellwig
2014-06-26 15:02 ` Christoph Hellwig
2014-06-26 18:13   ` Steven Haber
2014-06-26 18:52   ` James Bottomley
2014-06-27  7:55     ` Christoph Hellwig
     [not found]       ` <CAPK7rjdpxAALA-oLZJ3wDBPc3kr5Nw4jLALLxEaT0zSiAOD+wg@mail.gmail.com>
2014-06-30 18:45         ` Steven Haber
2014-07-01  8:15           ` Christoph Hellwig
2014-07-03 16:57             ` Steven Haber
2014-07-03 17:18               ` Christoph Hellwig
2014-07-09 22:38                 ` James Bottomley
2014-07-10  7:44                   ` Christoph Hellwig
2014-07-17 15:27                   ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox