diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-17 20:54:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-17 20:54:40 -0400 |
commit | c55d267de274d308927b60c3e740c1a826832317 (patch) | |
tree | 21b53a8c725d9f9650f60d94b349459d5b8dae10 /drivers/scsi/scsi_lib.c | |
parent | 61ef46fd45c3c62dc7c880a45dd2aa841b9af8fb (diff) | |
parent | bc898c97f7ba24def788d9f80786cf028a197122 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (170 commits)
[SCSI] scsi_dh_rdac: Add MD36xxf into device list
[SCSI] scsi_debug: add consecutive medium errors
[SCSI] libsas: fix ata list corruption issue
[SCSI] hpsa: export resettable host attribute
[SCSI] hpsa: move device attributes to avoid forward declarations
[SCSI] scsi_debug: Logical Block Provisioning (SBC3r26)
[SCSI] sd: Logical Block Provisioning update
[SCSI] Include protection operation in SCSI command trace
[SCSI] hpsa: fix incorrect PCI IDs and add two new ones (2nd try)
[SCSI] target: Fix volume size misreporting for volumes > 2TB
[SCSI] bnx2fc: Broadcom FCoE offload driver
[SCSI] fcoe: fix broken fcoe interface reset
[SCSI] fcoe: precedence bug in fcoe_filter_frames()
[SCSI] libfcoe: Remove stale fcoe-netdev entries
[SCSI] libfcoe: Move FCOE_MTU definition from fcoe.h to libfcoe.h
[SCSI] libfc: introduce __fc_fill_fc_hdr that accepts fc_hdr as an argument
[SCSI] fcoe, libfc: initialize EM anchors list and then update npiv EMs
[SCSI] Revert "[SCSI] libfc: fix exchange being deleted when the abort itself is timed out"
[SCSI] libfc: Fixing a memory leak when destroying an interface
[SCSI] megaraid_sas: Version and Changelog update
...
Fix up trivial conflicts due to whitespace differences in
drivers/scsi/libsas/{sas_ata.c,sas_scsi_host.c}
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r-- | drivers/scsi/scsi_lib.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index fb2bb35c62cb..2d63c8ad1442 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -667,6 +667,30 @@ void scsi_release_buffers(struct scsi_cmnd *cmd) | |||
667 | } | 667 | } |
668 | EXPORT_SYMBOL(scsi_release_buffers); | 668 | EXPORT_SYMBOL(scsi_release_buffers); |
669 | 669 | ||
670 | static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result) | ||
671 | { | ||
672 | int error = 0; | ||
673 | |||
674 | switch(host_byte(result)) { | ||
675 | case DID_TRANSPORT_FAILFAST: | ||
676 | error = -ENOLINK; | ||
677 | break; | ||
678 | case DID_TARGET_FAILURE: | ||
679 | cmd->result |= (DID_OK << 16); | ||
680 | error = -EREMOTEIO; | ||
681 | break; | ||
682 | case DID_NEXUS_FAILURE: | ||
683 | cmd->result |= (DID_OK << 16); | ||
684 | error = -EBADE; | ||
685 | break; | ||
686 | default: | ||
687 | error = -EIO; | ||
688 | break; | ||
689 | } | ||
690 | |||
691 | return error; | ||
692 | } | ||
693 | |||
670 | /* | 694 | /* |
671 | * Function: scsi_io_completion() | 695 | * Function: scsi_io_completion() |
672 | * | 696 | * |
@@ -737,7 +761,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
737 | req->sense_len = len; | 761 | req->sense_len = len; |
738 | } | 762 | } |
739 | if (!sense_deferred) | 763 | if (!sense_deferred) |
740 | error = -EIO; | 764 | error = __scsi_error_from_host_byte(cmd, result); |
741 | } | 765 | } |
742 | 766 | ||
743 | req->resid_len = scsi_get_resid(cmd); | 767 | req->resid_len = scsi_get_resid(cmd); |
@@ -796,7 +820,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
796 | if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL) | 820 | if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL) |
797 | return; | 821 | return; |
798 | 822 | ||
799 | error = -EIO; | 823 | error = __scsi_error_from_host_byte(cmd, result); |
800 | 824 | ||
801 | if (host_byte(result) == DID_RESET) { | 825 | if (host_byte(result) == DID_RESET) { |
802 | /* Third party bus reset or reset for error recovery | 826 | /* Third party bus reset or reset for error recovery |
@@ -843,6 +867,13 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
843 | description = "Host Data Integrity Failure"; | 867 | description = "Host Data Integrity Failure"; |
844 | action = ACTION_FAIL; | 868 | action = ACTION_FAIL; |
845 | error = -EILSEQ; | 869 | error = -EILSEQ; |
870 | /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */ | ||
871 | } else if ((sshdr.asc == 0x20 || sshdr.asc == 0x24) && | ||
872 | (cmd->cmnd[0] == UNMAP || | ||
873 | cmd->cmnd[0] == WRITE_SAME_16 || | ||
874 | cmd->cmnd[0] == WRITE_SAME)) { | ||
875 | description = "Discard failure"; | ||
876 | action = ACTION_FAIL; | ||
846 | } else | 877 | } else |
847 | action = ACTION_FAIL; | 878 | action = ACTION_FAIL; |
848 | break; | 879 | break; |
@@ -1038,6 +1069,7 @@ static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev, | |||
1038 | cmd->request = req; | 1069 | cmd->request = req; |
1039 | 1070 | ||
1040 | cmd->cmnd = req->cmd; | 1071 | cmd->cmnd = req->cmd; |
1072 | cmd->prot_op = SCSI_PROT_NORMAL; | ||
1041 | 1073 | ||
1042 | return cmd; | 1074 | return cmd; |
1043 | } | 1075 | } |