diff options
-rw-r--r-- | drivers/scsi/constants.c | 41 | ||||
-rw-r--r-- | drivers/scsi/scsi.c | 43 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 13 | ||||
-rw-r--r-- | drivers/scsi/scsi_logging.h | 1 | ||||
-rw-r--r-- | include/scsi/scsi_dbg.h | 3 |
5 files changed, 57 insertions, 44 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 2893464129b5..0cf43f6e464b 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c | |||
@@ -1440,19 +1440,54 @@ const char *scsi_driverbyte_string(int result) | |||
1440 | } | 1440 | } |
1441 | EXPORT_SYMBOL(scsi_driverbyte_string); | 1441 | EXPORT_SYMBOL(scsi_driverbyte_string); |
1442 | 1442 | ||
1443 | void scsi_print_result(struct scsi_cmnd *cmd) | 1443 | #ifdef CONFIG_SCSI_CONSTANTS |
1444 | #define scsi_mlreturn_name(result) { result, #result } | ||
1445 | static const struct value_name_pair scsi_mlreturn_arr[] = { | ||
1446 | scsi_mlreturn_name(NEEDS_RETRY), | ||
1447 | scsi_mlreturn_name(SUCCESS), | ||
1448 | scsi_mlreturn_name(FAILED), | ||
1449 | scsi_mlreturn_name(QUEUED), | ||
1450 | scsi_mlreturn_name(SOFT_ERROR), | ||
1451 | scsi_mlreturn_name(ADD_TO_MLQUEUE), | ||
1452 | scsi_mlreturn_name(TIMEOUT_ERROR), | ||
1453 | scsi_mlreturn_name(SCSI_RETURN_NOT_HANDLED), | ||
1454 | scsi_mlreturn_name(FAST_IO_FAIL) | ||
1455 | }; | ||
1456 | #endif | ||
1457 | |||
1458 | const char *scsi_mlreturn_string(int result) | ||
1459 | { | ||
1460 | #ifdef CONFIG_SCSI_CONSTANTS | ||
1461 | const struct value_name_pair *arr = scsi_mlreturn_arr; | ||
1462 | int k; | ||
1463 | |||
1464 | for (k = 0; k < ARRAY_SIZE(scsi_mlreturn_arr); ++k, ++arr) { | ||
1465 | if (result == arr->value) | ||
1466 | return arr->name; | ||
1467 | } | ||
1468 | #endif | ||
1469 | return NULL; | ||
1470 | } | ||
1471 | EXPORT_SYMBOL(scsi_mlreturn_string); | ||
1472 | |||
1473 | void scsi_print_result(struct scsi_cmnd *cmd, const char *msg, int disposition) | ||
1444 | { | 1474 | { |
1475 | const char *mlret_string = scsi_mlreturn_string(disposition); | ||
1445 | const char *hb_string = scsi_hostbyte_string(cmd->result); | 1476 | const char *hb_string = scsi_hostbyte_string(cmd->result); |
1446 | const char *db_string = scsi_driverbyte_string(cmd->result); | 1477 | const char *db_string = scsi_driverbyte_string(cmd->result); |
1447 | 1478 | ||
1448 | if (hb_string || db_string) | 1479 | if (hb_string || db_string) |
1449 | scmd_printk(KERN_INFO, cmd, | 1480 | scmd_printk(KERN_INFO, cmd, |
1450 | "Result: hostbyte=%s driverbyte=%s", | 1481 | "%s%s Result: hostbyte=%s driverbyte=%s", |
1482 | msg ? msg : "", | ||
1483 | mlret_string ? mlret_string : "UNKNOWN", | ||
1451 | hb_string ? hb_string : "invalid", | 1484 | hb_string ? hb_string : "invalid", |
1452 | db_string ? db_string : "invalid"); | 1485 | db_string ? db_string : "invalid"); |
1453 | else | 1486 | else |
1454 | scmd_printk(KERN_INFO, cmd, | 1487 | scmd_printk(KERN_INFO, cmd, |
1455 | "Result: hostbyte=0x%02x driverbyte=0x%02x", | 1488 | "%s%s Result: hostbyte=0x%02x driverbyte=0x%02x", |
1489 | msg ? msg : "", | ||
1490 | mlret_string ? mlret_string : "UNKNOWN", | ||
1456 | host_byte(cmd->result), driver_byte(cmd->result)); | 1491 | host_byte(cmd->result), driver_byte(cmd->result)); |
1457 | } | 1492 | } |
1458 | EXPORT_SYMBOL(scsi_print_result); | 1493 | EXPORT_SYMBOL(scsi_print_result); |
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 32eaac03cf4e..bc52bbd97381 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -527,9 +527,9 @@ void scsi_log_send(struct scsi_cmnd *cmd) | |||
527 | * | 527 | * |
528 | * 1: nothing (match completion) | 528 | * 1: nothing (match completion) |
529 | * | 529 | * |
530 | * 2: log opcode + command of all commands | 530 | * 2: log opcode + command of all commands + cmd address |
531 | * | 531 | * |
532 | * 3: same as 2 plus dump cmd address | 532 | * 3: same as 2 |
533 | * | 533 | * |
534 | * 4: same as 3 plus dump extra junk | 534 | * 4: same as 3 plus dump extra junk |
535 | */ | 535 | */ |
@@ -537,10 +537,8 @@ void scsi_log_send(struct scsi_cmnd *cmd) | |||
537 | level = SCSI_LOG_LEVEL(SCSI_LOG_MLQUEUE_SHIFT, | 537 | level = SCSI_LOG_LEVEL(SCSI_LOG_MLQUEUE_SHIFT, |
538 | SCSI_LOG_MLQUEUE_BITS); | 538 | SCSI_LOG_MLQUEUE_BITS); |
539 | if (level > 1) { | 539 | if (level > 1) { |
540 | scmd_printk(KERN_INFO, cmd, "Send: "); | 540 | scmd_printk(KERN_INFO, cmd, |
541 | if (level > 2) | 541 | "Send: scmd 0x%p\n", cmd); |
542 | printk("0x%p ", cmd); | ||
543 | printk("\n"); | ||
544 | scsi_print_command(cmd); | 542 | scsi_print_command(cmd); |
545 | if (level > 3) { | 543 | if (level > 3) { |
546 | printk(KERN_INFO "buffer = 0x%p, bufflen = %d," | 544 | printk(KERN_INFO "buffer = 0x%p, bufflen = %d," |
@@ -565,7 +563,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) | |||
565 | * | 563 | * |
566 | * 2: same as 1 but for all command completions. | 564 | * 2: same as 1 but for all command completions. |
567 | * | 565 | * |
568 | * 3: same as 2 plus dump cmd address | 566 | * 3: same as 2 |
569 | * | 567 | * |
570 | * 4: same as 3 plus dump extra junk | 568 | * 4: same as 3 plus dump extra junk |
571 | */ | 569 | */ |
@@ -574,36 +572,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) | |||
574 | SCSI_LOG_MLCOMPLETE_BITS); | 572 | SCSI_LOG_MLCOMPLETE_BITS); |
575 | if (((level > 0) && (cmd->result || disposition != SUCCESS)) || | 573 | if (((level > 0) && (cmd->result || disposition != SUCCESS)) || |
576 | (level > 1)) { | 574 | (level > 1)) { |
577 | scmd_printk(KERN_INFO, cmd, "Done: "); | 575 | scsi_print_result(cmd, "Done: ", disposition); |
578 | if (level > 2) | ||
579 | printk("0x%p ", cmd); | ||
580 | /* | ||
581 | * Dump truncated values, so we usually fit within | ||
582 | * 80 chars. | ||
583 | */ | ||
584 | switch (disposition) { | ||
585 | case SUCCESS: | ||
586 | printk("SUCCESS\n"); | ||
587 | break; | ||
588 | case NEEDS_RETRY: | ||
589 | printk("RETRY\n"); | ||
590 | break; | ||
591 | case ADD_TO_MLQUEUE: | ||
592 | printk("MLQUEUE\n"); | ||
593 | break; | ||
594 | case FAILED: | ||
595 | printk("FAILED\n"); | ||
596 | break; | ||
597 | case TIMEOUT_ERROR: | ||
598 | /* | ||
599 | * If called via scsi_times_out. | ||
600 | */ | ||
601 | printk("TIMEOUT\n"); | ||
602 | break; | ||
603 | default: | ||
604 | printk("UNKNOWN\n"); | ||
605 | } | ||
606 | scsi_print_result(cmd); | ||
607 | scsi_print_command(cmd); | 576 | scsi_print_command(cmd); |
608 | if (status_byte(cmd->result) & CHECK_CONDITION) | 577 | if (status_byte(cmd->result) & CHECK_CONDITION) |
609 | scsi_print_sense(cmd); | 578 | scsi_print_sense(cmd); |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 30f51c11a279..26a57faf885b 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -832,7 +832,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
832 | int error = 0; | 832 | int error = 0; |
833 | struct scsi_sense_hdr sshdr; | 833 | struct scsi_sense_hdr sshdr; |
834 | bool sense_valid = false; | 834 | bool sense_valid = false; |
835 | int sense_deferred = 0; | 835 | int sense_deferred = 0, level = 0; |
836 | enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY, | 836 | enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY, |
837 | ACTION_DELAYED_RETRY} action; | 837 | ACTION_DELAYED_RETRY} action; |
838 | unsigned long wait_for = (cmd->allowed + 1) * req->timeout; | 838 | unsigned long wait_for = (cmd->allowed + 1) * req->timeout; |
@@ -1038,8 +1038,15 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
1038 | switch (action) { | 1038 | switch (action) { |
1039 | case ACTION_FAIL: | 1039 | case ACTION_FAIL: |
1040 | /* Give up and fail the remainder of the request */ | 1040 | /* Give up and fail the remainder of the request */ |
1041 | if (!(req->cmd_flags & REQ_QUIET)) { | 1041 | if (unlikely(scsi_logging_level)) |
1042 | scsi_print_result(cmd); | 1042 | level = SCSI_LOG_LEVEL(SCSI_LOG_MLQUEUE_SHIFT, |
1043 | SCSI_LOG_MLQUEUE_BITS); | ||
1044 | /* | ||
1045 | * if logging is enabled the failure will be printed | ||
1046 | * in scsi_log_completion(), so avoid duplicate messages | ||
1047 | */ | ||
1048 | if (!level && !(req->cmd_flags & REQ_QUIET)) { | ||
1049 | scsi_print_result(cmd, NULL, FAILED); | ||
1043 | if (driver_byte(result) & DRIVER_SENSE) | 1050 | if (driver_byte(result) & DRIVER_SENSE) |
1044 | scsi_print_sense(cmd); | 1051 | scsi_print_sense(cmd); |
1045 | scsi_print_command(cmd); | 1052 | scsi_print_command(cmd); |
diff --git a/drivers/scsi/scsi_logging.h b/drivers/scsi/scsi_logging.h index 1f65139e14f8..7fe64a847143 100644 --- a/drivers/scsi/scsi_logging.h +++ b/drivers/scsi/scsi_logging.h | |||
@@ -51,6 +51,7 @@ do { \ | |||
51 | } while (0); \ | 51 | } while (0); \ |
52 | } while (0) | 52 | } while (0) |
53 | #else | 53 | #else |
54 | #define SCSI_LOG_LEVEL(SHIFT, BITS) 0 | ||
54 | #define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD) | 55 | #define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD) |
55 | #endif /* CONFIG_SCSI_LOGGING */ | 56 | #endif /* CONFIG_SCSI_LOGGING */ |
56 | 57 | ||
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h index f41a86bc1a8f..7982795df595 100644 --- a/include/scsi/scsi_dbg.h +++ b/include/scsi/scsi_dbg.h | |||
@@ -17,9 +17,10 @@ extern void scsi_print_sense(const struct scsi_cmnd *); | |||
17 | extern void __scsi_print_sense(const struct scsi_device *, const char *name, | 17 | extern void __scsi_print_sense(const struct scsi_device *, const char *name, |
18 | const unsigned char *sense_buffer, | 18 | const unsigned char *sense_buffer, |
19 | int sense_len); | 19 | int sense_len); |
20 | extern void scsi_print_result(struct scsi_cmnd *); | 20 | extern void scsi_print_result(struct scsi_cmnd *, const char *, int); |
21 | extern const char *scsi_hostbyte_string(int); | 21 | extern const char *scsi_hostbyte_string(int); |
22 | extern const char *scsi_driverbyte_string(int); | 22 | extern const char *scsi_driverbyte_string(int); |
23 | extern const char *scsi_mlreturn_string(int); | ||
23 | extern const char *scsi_sense_key_string(unsigned char); | 24 | extern const char *scsi_sense_key_string(unsigned char); |
24 | extern const char *scsi_extd_sense_format(unsigned char, unsigned char, | 25 | extern const char *scsi_extd_sense_format(unsigned char, unsigned char, |
25 | const char **); | 26 | const char **); |