aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd.h
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/sd.h
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/sd.h')
-rw-r--r--drivers/scsi/sd.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 4163f2910e3d..f703f4827b6f 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -20,6 +20,7 @@
20 */ 20 */
21#define SD_MAX_RETRIES 5 21#define SD_MAX_RETRIES 5
22#define SD_PASSTHROUGH_RETRIES 1 22#define SD_PASSTHROUGH_RETRIES 1
23#define SD_MAX_MEDIUM_TIMEOUTS 2
23 24
24/* 25/*
25 * Size of the initial data buffer for mode and read capacity data 26 * Size of the initial data buffer for mode and read capacity data
@@ -59,6 +60,8 @@ struct scsi_disk {
59 u32 unmap_alignment; 60 u32 unmap_alignment;
60 u32 index; 61 u32 index;
61 unsigned int physical_block_size; 62 unsigned int physical_block_size;
63 unsigned int max_medium_access_timeouts;
64 unsigned int medium_access_timed_out;
62 u8 media_present; 65 u8 media_present;
63 u8 write_prot; 66 u8 write_prot;
64 u8 protection_type;/* Data Integrity Field */ 67 u8 protection_type;/* Data Integrity Field */
@@ -88,6 +91,38 @@ static inline struct scsi_disk *scsi_disk(struct gendisk *disk)
88 (sdsk)->disk->disk_name, ##a) : \ 91 (sdsk)->disk->disk_name, ##a) : \
89 sdev_printk(prefix, (sdsk)->device, fmt, ##a) 92 sdev_printk(prefix, (sdsk)->device, fmt, ##a)
90 93
94static inline int scsi_medium_access_command(struct scsi_cmnd *scmd)
95{
96 switch (scmd->cmnd[0]) {
97 case READ_6:
98 case READ_10:
99 case READ_12:
100 case READ_16:
101 case SYNCHRONIZE_CACHE:
102 case VERIFY:
103 case VERIFY_12:
104 case VERIFY_16:
105 case WRITE_6:
106 case WRITE_10:
107 case WRITE_12:
108 case WRITE_16:
109 case WRITE_SAME:
110 case WRITE_SAME_16:
111 case UNMAP:
112 return 1;
113 case VARIABLE_LENGTH_CMD:
114 switch (scmd->cmnd[9]) {
115 case READ_32:
116 case VERIFY_32:
117 case WRITE_32:
118 case WRITE_SAME_32:
119 return 1;
120 }
121 }
122
123 return 0;
124}
125
91/* 126/*
92 * A DIF-capable target device can be formatted with different 127 * A DIF-capable target device can be formatted with different
93 * protection schemes. Currently 0 through 3 are defined: 128 * protection schemes. Currently 0 through 3 are defined: