Pārlūkot izejas kodu

[scsi] Cope with targets that send multiple CHECK CONDITIONS at power-on

Some targets send a spurious CHECK CONDITION message in response to
the first SCSI command.  We issue (and ignore the status of) an
arbitary harmless SCSI command (a READ CAPACITY (10)) in order to draw
out this response.

The Solaris Comstar target seems to send more than one spurious CHECK
CONDITION response.  Attempt up to SCSI_MAX_DUMMY_READ_CAP dummy READ
CAPACITY (10) commands before assuming that error responses are
meaningful.

Problem reported by Kristof Van Doorsselaere <kvandoor@aserver.com>
and Shiva Shankar <802.11e@gmail.com>.
tags/v0.9.7
Michael Brown 16 gadus atpakaļ
vecāks
revīzija
b111bdfb00
1 mainītis faili ar 19 papildinājumiem un 5 dzēšanām
  1. 19
    5
      src/drivers/block/scsi.c

+ 19
- 5
src/drivers/block/scsi.c Parādīt failu

@@ -29,6 +29,13 @@
29 29
  *
30 30
  */
31 31
 
32
+/** Maximum number of dummy "read capacity (10)" operations
33
+ *
34
+ * These are issued at connection setup to draw out various useless
35
+ * power-on messages.
36
+ */
37
+#define SCSI_MAX_DUMMY_READ_CAP 10
38
+
32 39
 static inline __attribute__ (( always_inline )) struct scsi_device *
33 40
 block_to_scsi ( struct block_device *blockdev ) {
34 41
 	return container_of ( blockdev, struct scsi_device, blockdev );
@@ -250,14 +257,21 @@ static struct block_device_operations scsi_operations_10 = {
250 257
  * CAPACITY call to determine the block size and total device size.
251 258
  */
252 259
 int init_scsidev ( struct scsi_device *scsi ) {
260
+	unsigned int i;
253 261
 	int rc;
254 262
 
255
-	/* Issue a theoretically extraneous READ CAPACITY (10)
256
-	 * command, solely in order to draw out the "CHECK CONDITION
257
-	 * (power-on occurred)" that some dumb targets insist on
258
-	 * sending as an error at start of day.
263
+	/* Issue some theoretically extraneous READ CAPACITY (10)
264
+	 * commands, solely in order to draw out the "CHECK CONDITION
265
+	 * (power-on occurred)", "CHECK CONDITION (reported LUNs data
266
+	 * has changed)" etc. that some dumb targets insist on sending
267
+	 * as an error at start of day.  The precise command that we
268
+	 * use is unimportant; we just need to provide the target with
269
+	 * an opportunity to send its responses.
259 270
 	 */
260
-	scsi_read_capacity_10 ( &scsi->blockdev );
271
+	for ( i = 0 ; i < SCSI_MAX_DUMMY_READ_CAP ; i++ ) {
272
+		if ( ( rc = scsi_read_capacity_10 ( &scsi->blockdev ) ) == 0 )
273
+			break;
274
+	}
261 275
 
262 276
 	/* Try READ CAPACITY (10), which is a mandatory command, first. */
263 277
 	scsi->blockdev.op = &scsi_operations_10;

Notiek ielāde…
Atcelt
Saglabāt