aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_debug.c
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2012-02-09 13:48:53 -0500
committerJames Bottomley <JBottomley@Parallels.com>2012-02-19 11:14:52 -0500
commit18a4d0a22ed6c54b67af7718c305cd010f09ddf8 (patch)
tree06e22a92290ff84b2c1d5abb09424493de384c4b /drivers/scsi/scsi_debug.c
parenta78e21dc5e9f896ecee5b1fbe189690dfcca38e1 (diff)
[SCSI] Handle disk devices which can not process medium access commands
We have experienced several devices which fail in a fashion we do not currently handle gracefully in SCSI. After a failure these devices will respond to the SCSI primary command set (INQUIRY, TEST UNIT READY, etc.) but any command accessing the storage medium will time out. The following patch adds an callback that can be used by upper level drivers to inspect the results of an error handling command. This in turn has been used to implement additional checking in the SCSI disk driver. If a medium access command fails twice but TEST UNIT READY succeeds both times in the subsequent error handling we will offline the device. The maximum number of failed commands required to take a device offline can be tweaked in sysfs. Also add a new error flag to scsi_debug which allows this scenario to be easily reproduced. [jejb: fix up integer parsing to use kstrtouint] Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/scsi_debug.c')
-rw-r--r--drivers/scsi/scsi_debug.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index d2fd0efca565..8917154d96c7 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -126,6 +126,7 @@ static const char * scsi_debug_version_date = "20100324";
126#define SCSI_DEBUG_OPT_TRANSPORT_ERR 16 126#define SCSI_DEBUG_OPT_TRANSPORT_ERR 16
127#define SCSI_DEBUG_OPT_DIF_ERR 32 127#define SCSI_DEBUG_OPT_DIF_ERR 32
128#define SCSI_DEBUG_OPT_DIX_ERR 64 128#define SCSI_DEBUG_OPT_DIX_ERR 64
129#define SCSI_DEBUG_OPT_MAC_TIMEOUT 128
129/* When "every_nth" > 0 then modulo "every_nth" commands: 130/* When "every_nth" > 0 then modulo "every_nth" commands:
130 * - a no response is simulated if SCSI_DEBUG_OPT_TIMEOUT is set 131 * - a no response is simulated if SCSI_DEBUG_OPT_TIMEOUT is set
131 * - a RECOVERED_ERROR is simulated on successful read and write 132 * - a RECOVERED_ERROR is simulated on successful read and write
@@ -3615,6 +3616,9 @@ int scsi_debug_queuecommand_lck(struct scsi_cmnd *SCpnt, done_funct_t done)
3615 scsi_debug_every_nth = -1; 3616 scsi_debug_every_nth = -1;
3616 if (SCSI_DEBUG_OPT_TIMEOUT & scsi_debug_opts) 3617 if (SCSI_DEBUG_OPT_TIMEOUT & scsi_debug_opts)
3617 return 0; /* ignore command causing timeout */ 3618 return 0; /* ignore command causing timeout */
3619 else if (SCSI_DEBUG_OPT_MAC_TIMEOUT & scsi_debug_opts &&
3620 scsi_medium_access_command(SCpnt))
3621 return 0; /* time out reads and writes */
3618 else if (SCSI_DEBUG_OPT_RECOVERED_ERR & scsi_debug_opts) 3622 else if (SCSI_DEBUG_OPT_RECOVERED_ERR & scsi_debug_opts)
3619 inj_recovered = 1; /* to reads and writes below */ 3623 inj_recovered = 1; /* to reads and writes below */
3620 else if (SCSI_DEBUG_OPT_TRANSPORT_ERR & scsi_debug_opts) 3624 else if (SCSI_DEBUG_OPT_TRANSPORT_ERR & scsi_debug_opts)