Browse Source

[scsi] Improve SCSI debugging

tags/v0.9.8
Michael Brown 15 years ago
parent
commit
acfd7cc609
1 changed files with 26 additions and 9 deletions
  1. 26
    9
      src/drivers/block/scsi.c

+ 26
- 9
src/drivers/block/scsi.c View File

55
 			  struct scsi_command *command ) {
55
 			  struct scsi_command *command ) {
56
 	int rc;
56
 	int rc;
57
 
57
 
58
+	DBGC2 ( scsi, "SCSI %p " SCSI_CDB_FORMAT "\n",
59
+		scsi, SCSI_CDB_DATA ( command->cdb ) );
60
+
58
 	/* Clear sense response code before issuing command */
61
 	/* Clear sense response code before issuing command */
59
 	command->sense_response = 0;
62
 	command->sense_response = 0;
60
 
63
 
64
 	/* Issue SCSI command */
67
 	/* Issue SCSI command */
65
 	if ( ( rc = scsi->command ( scsi, command ) ) != 0 ) {
68
 	if ( ( rc = scsi->command ( scsi, command ) ) != 0 ) {
66
 		/* Something went wrong with the issuing mechanism */
69
 		/* Something went wrong with the issuing mechanism */
67
-		DBG ( "SCSI %p " SCSI_CDB_FORMAT " err %s\n",
68
-		      scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) );
70
+		DBGC ( scsi, "SCSI %p " SCSI_CDB_FORMAT " err %s\n",
71
+		       scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) );
69
 		return rc;
72
 		return rc;
70
 	}
73
 	}
71
 
74
 
74
 		step();
77
 		step();
75
 	if ( ( rc = command->rc ) != 0 ) {
78
 	if ( ( rc = command->rc ) != 0 ) {
76
 		/* Something went wrong with the command execution */
79
 		/* Something went wrong with the command execution */
77
-		DBG ( "SCSI %p " SCSI_CDB_FORMAT " err %s\n",
78
-		      scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) );
80
+		DBGC ( scsi, "SCSI %p " SCSI_CDB_FORMAT " err %s\n",
81
+		       scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) );
79
 		return rc;
82
 		return rc;
80
 	}
83
 	}
81
 
84
 
82
 	/* Check for SCSI errors */
85
 	/* Check for SCSI errors */
83
 	if ( command->status != 0 ) {
86
 	if ( command->status != 0 ) {
84
-		DBG ( "SCSI %p " SCSI_CDB_FORMAT " status %02x sense %02x\n",
85
-		      scsi, SCSI_CDB_DATA ( command->cdb ),
86
-		      command->status, command->sense_response );
87
+		DBGC ( scsi, "SCSI %p " SCSI_CDB_FORMAT " status %02x sense "
88
+		       "%02x\n", scsi, SCSI_CDB_DATA ( command->cdb ),
89
+		       command->status, command->sense_response );
87
 		return -EIO;
90
 		return -EIO;
88
 	}
91
 	}
89
 
92
 
285
 	for ( i = 0 ; i < SCSI_MAX_DUMMY_READ_CAP ; i++ ) {
288
 	for ( i = 0 ; i < SCSI_MAX_DUMMY_READ_CAP ; i++ ) {
286
 		if ( ( rc = scsi_read_capacity_10 ( &scsi->blockdev ) ) == 0 )
289
 		if ( ( rc = scsi_read_capacity_10 ( &scsi->blockdev ) ) == 0 )
287
 			break;
290
 			break;
291
+		DBGC ( scsi, "SCSI %p ignoring start-of-day error (#%d)\n",
292
+		       scsi, ( i + 1 ) );
288
 	}
293
 	}
289
 
294
 
290
 	/* Try READ CAPACITY (10), which is a mandatory command, first. */
295
 	/* Try READ CAPACITY (10), which is a mandatory command, first. */
291
 	scsi->blockdev.op = &scsi_operations_10;
296
 	scsi->blockdev.op = &scsi_operations_10;
292
-	if ( ( rc = scsi_read_capacity_10 ( &scsi->blockdev ) ) != 0 )
297
+	if ( ( rc = scsi_read_capacity_10 ( &scsi->blockdev ) ) != 0 ) {
298
+		DBGC ( scsi, "SCSI %p could not READ CAPACITY (10): %s\n",
299
+		       scsi, strerror ( rc ) );
293
 		return rc;
300
 		return rc;
301
+	}
294
 
302
 
295
 	/* If capacity range was exceeded (i.e. capacity.lba was
303
 	/* If capacity range was exceeded (i.e. capacity.lba was
296
 	 * 0xffffffff, meaning that blockdev->blocks is now zero), use
304
 	 * 0xffffffff, meaning that blockdev->blocks is now zero), use
299
 	 */
307
 	 */
300
 	if ( scsi->blockdev.blocks == 0 ) {
308
 	if ( scsi->blockdev.blocks == 0 ) {
301
 		scsi->blockdev.op = &scsi_operations_16;
309
 		scsi->blockdev.op = &scsi_operations_16;
302
-		if ( ( rc = scsi_read_capacity_16 ( &scsi->blockdev ) ) != 0 )
310
+		if ( ( rc = scsi_read_capacity_16 ( &scsi->blockdev ) ) != 0 ){
311
+			DBGC ( scsi, "SCSI %p could not READ CAPACITY (16): "
312
+			       "%s\n", scsi, strerror ( rc ) );
303
 			return rc;
313
 			return rc;
314
+		}
304
 	}
315
 	}
305
 
316
 
317
+	DBGC ( scsi, "SCSI %p using READ/WRITE (%d) commands\n", scsi,
318
+	       ( ( scsi->blockdev.op == &scsi_operations_10 ) ? 10 : 16 ) );
319
+	DBGC ( scsi, "SCSI %p capacity is %ld MB (%#llx blocks)\n", scsi,
320
+	       ( ( unsigned long ) ( scsi->blockdev.blocks >> 11 ) ),
321
+	       scsi->blockdev.blocks );
322
+
306
 	return 0;
323
 	return 0;
307
 }
324
 }

Loading…
Cancel
Save