sd: medium access timeout counter fails to reset
authorDavid Jeffery <djeffery@redhat.com>
Thu, 10 Apr 2014 15:08:30 +0000 (11:08 -0400)
committerChristoph Hellwig <hch@lst.de>
Mon, 19 May 2014 10:54:21 +0000 (12:54 +0200)
commit2a863ba8f6f5d72e4905a91c6281d575809fed5b
treecc06e265d04ba36a8115e878e4f64bf0ce1c6a58
parentac61d19559349e205dad7b5122b281419aa74a82
sd: medium access timeout counter fails to reset

There is an error with the medium access timeout feature of the sd driver. The
sdkp->medium_access_timed_out value is reset to zero in sd_done() in the wrong
place.  Currently it is reset to zero only when a command returns sense data.
This can result in cases where the medium access check falsely triggers from
timed out commands which are hours or days apart.

For example, an I/O command times out and is aborted.  It then retries and
succeeds.  But with no sense data generated and returned, the
medium_access_timed_out value is not reset.  If no sd command returns sense
data, then the next command to time out (however far in time from the first
failure) will trigger the medium access timeout and put the device offline.

The resetting of sdkp->medium_access_timed_out should occur before the check
for sense data.

To reproduce using scsi_debug, use SCSI_DEBUG_OPT_TIMEOUT or
SCSI_DEBUG_OPT_MAC_TIMEOUT to force an I/O command to timeout.  Then, remove
the opt value so the I/O will succeed on retry.  Perform more I/O as desired.
Finally, repeat the process to make a new I/O command time out.  Without the
patch, the device will be marked offline even though many I/O commands have
succeeded between the 2 instances of timed out commands.

Signed-off-by: David Jeffery <djeffery@redhat.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/scsi/sd.c
This page took 0.025316 seconds and 5 git commands to generate.