diff options
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r-- | drivers/scsi/scsi_lib.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 4cf902efbdbf..f44ab801119b 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -634,7 +634,7 @@ void scsi_run_host_queues(struct Scsi_Host *shost) | |||
634 | * of upper level post-processing and scsi_io_completion). | 634 | * of upper level post-processing and scsi_io_completion). |
635 | * | 635 | * |
636 | * Arguments: cmd - command that is complete. | 636 | * Arguments: cmd - command that is complete. |
637 | * uptodate - 1 if I/O indicates success, <= 0 for I/O error. | 637 | * error - 0 if I/O indicates success, < 0 for I/O error. |
638 | * bytes - number of bytes of completed I/O | 638 | * bytes - number of bytes of completed I/O |
639 | * requeue - indicates whether we should requeue leftovers. | 639 | * requeue - indicates whether we should requeue leftovers. |
640 | * | 640 | * |
@@ -649,26 +649,25 @@ void scsi_run_host_queues(struct Scsi_Host *shost) | |||
649 | * at some point during this call. | 649 | * at some point during this call. |
650 | * Notes: If cmd was requeued, upon return it will be a stale pointer. | 650 | * Notes: If cmd was requeued, upon return it will be a stale pointer. |
651 | */ | 651 | */ |
652 | static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate, | 652 | static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error, |
653 | int bytes, int requeue) | 653 | int bytes, int requeue) |
654 | { | 654 | { |
655 | struct request_queue *q = cmd->device->request_queue; | 655 | struct request_queue *q = cmd->device->request_queue; |
656 | struct request *req = cmd->request; | 656 | struct request *req = cmd->request; |
657 | unsigned long flags; | ||
658 | 657 | ||
659 | /* | 658 | /* |
660 | * If there are blocks left over at the end, set up the command | 659 | * If there are blocks left over at the end, set up the command |
661 | * to queue the remainder of them. | 660 | * to queue the remainder of them. |
662 | */ | 661 | */ |
663 | if (end_that_request_chunk(req, uptodate, bytes)) { | 662 | if (blk_end_request(req, error, bytes)) { |
664 | int leftover = (req->hard_nr_sectors << 9); | 663 | int leftover = (req->hard_nr_sectors << 9); |
665 | 664 | ||
666 | if (blk_pc_request(req)) | 665 | if (blk_pc_request(req)) |
667 | leftover = req->data_len; | 666 | leftover = req->data_len; |
668 | 667 | ||
669 | /* kill remainder if no retrys */ | 668 | /* kill remainder if no retrys */ |
670 | if (!uptodate && blk_noretry_request(req)) | 669 | if (error && blk_noretry_request(req)) |
671 | end_that_request_chunk(req, 0, leftover); | 670 | blk_end_request(req, error, leftover); |
672 | else { | 671 | else { |
673 | if (requeue) { | 672 | if (requeue) { |
674 | /* | 673 | /* |
@@ -683,14 +682,6 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate, | |||
683 | } | 682 | } |
684 | } | 683 | } |
685 | 684 | ||
686 | add_disk_randomness(req->rq_disk); | ||
687 | |||
688 | spin_lock_irqsave(q->queue_lock, flags); | ||
689 | if (blk_rq_tagged(req)) | ||
690 | blk_queue_end_tag(q, req); | ||
691 | end_that_request_last(req, uptodate); | ||
692 | spin_unlock_irqrestore(q->queue_lock, flags); | ||
693 | |||
694 | /* | 685 | /* |
695 | * This will goose the queue request function at the end, so we don't | 686 | * This will goose the queue request function at the end, so we don't |
696 | * need to worry about launching another command. | 687 | * need to worry about launching another command. |
@@ -987,7 +978,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
987 | * are leftovers and there is some kind of error | 978 | * are leftovers and there is some kind of error |
988 | * (result != 0), retry the rest. | 979 | * (result != 0), retry the rest. |
989 | */ | 980 | */ |
990 | if (scsi_end_request(cmd, 1, good_bytes, result == 0) == NULL) | 981 | if (scsi_end_request(cmd, 0, good_bytes, result == 0) == NULL) |
991 | return; | 982 | return; |
992 | 983 | ||
993 | /* good_bytes = 0, or (inclusive) there were leftovers and | 984 | /* good_bytes = 0, or (inclusive) there were leftovers and |
@@ -1001,7 +992,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
1001 | * and quietly refuse further access. | 992 | * and quietly refuse further access. |
1002 | */ | 993 | */ |
1003 | cmd->device->changed = 1; | 994 | cmd->device->changed = 1; |
1004 | scsi_end_request(cmd, 0, this_count, 1); | 995 | scsi_end_request(cmd, -EIO, this_count, 1); |
1005 | return; | 996 | return; |
1006 | } else { | 997 | } else { |
1007 | /* Must have been a power glitch, or a | 998 | /* Must have been a power glitch, or a |
@@ -1033,7 +1024,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
1033 | scsi_requeue_command(q, cmd); | 1024 | scsi_requeue_command(q, cmd); |
1034 | return; | 1025 | return; |
1035 | } else { | 1026 | } else { |
1036 | scsi_end_request(cmd, 0, this_count, 1); | 1027 | scsi_end_request(cmd, -EIO, this_count, 1); |
1037 | return; | 1028 | return; |
1038 | } | 1029 | } |
1039 | break; | 1030 | break; |
@@ -1061,7 +1052,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
1061 | "Device not ready", | 1052 | "Device not ready", |
1062 | &sshdr); | 1053 | &sshdr); |
1063 | 1054 | ||
1064 | scsi_end_request(cmd, 0, this_count, 1); | 1055 | scsi_end_request(cmd, -EIO, this_count, 1); |
1065 | return; | 1056 | return; |
1066 | case VOLUME_OVERFLOW: | 1057 | case VOLUME_OVERFLOW: |
1067 | if (!(req->cmd_flags & REQ_QUIET)) { | 1058 | if (!(req->cmd_flags & REQ_QUIET)) { |
@@ -1071,7 +1062,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
1071 | scsi_print_sense("", cmd); | 1062 | scsi_print_sense("", cmd); |
1072 | } | 1063 | } |
1073 | /* See SSC3rXX or current. */ | 1064 | /* See SSC3rXX or current. */ |
1074 | scsi_end_request(cmd, 0, this_count, 1); | 1065 | scsi_end_request(cmd, -EIO, this_count, 1); |
1075 | return; | 1066 | return; |
1076 | default: | 1067 | default: |
1077 | break; | 1068 | break; |
@@ -1092,7 +1083,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
1092 | scsi_print_sense("", cmd); | 1083 | scsi_print_sense("", cmd); |
1093 | } | 1084 | } |
1094 | } | 1085 | } |
1095 | scsi_end_request(cmd, 0, this_count, !result); | 1086 | scsi_end_request(cmd, -EIO, this_count, !result); |
1096 | } | 1087 | } |
1097 | 1088 | ||
1098 | /* | 1089 | /* |