aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-02-16 09:16:13 -0500
committerChristoph Hellwig <hch@lst.de>2014-07-25 17:16:13 -0400
commitf6d47e74fcb2814225e429c94355ad1c551daffb (patch)
treecf592468f080cee6793106bef06fbfb000e6abb2
parent2ccbb00808465338b57c39f38c0b1e7ce69e2bb1 (diff)
scsi: unwind blk_end_request_all and blk_end_request_err calls
Replace the calls to the various blk_end_request variants with opencode equivalents. Blk-mq is using a model that gives the driver control between the bio updates and the actual completion, and making the old code follow that same model allows us to keep the code more similar for both paths. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Webb Scales <webbnh@hp.com> Acked-by: Jens Axboe <axboe@kernel.dk> Tested-by: Bart Van Assche <bvanassche@acm.org> Tested-by: Robert Elliott <elliott@hp.com>
-rw-r--r--drivers/scsi/scsi_lib.c61
1 files changed, 42 insertions, 19 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index a643353584b5..8723abeb018e 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -621,6 +621,37 @@ static void scsi_release_bidi_buffers(struct scsi_cmnd *cmd)
621 cmd->request->next_rq->special = NULL; 621 cmd->request->next_rq->special = NULL;
622} 622}
623 623
624static bool scsi_end_request(struct request *req, int error,
625 unsigned int bytes, unsigned int bidi_bytes)
626{
627 struct scsi_cmnd *cmd = req->special;
628 struct scsi_device *sdev = cmd->device;
629 struct request_queue *q = sdev->request_queue;
630 unsigned long flags;
631
632
633 if (blk_update_request(req, error, bytes))
634 return true;
635
636 /* Bidi request must be completed as a whole */
637 if (unlikely(bidi_bytes) &&
638 blk_update_request(req->next_rq, error, bidi_bytes))
639 return true;
640
641 if (blk_queue_add_random(q))
642 add_disk_randomness(req->rq_disk);
643
644 spin_lock_irqsave(q->queue_lock, flags);
645 blk_finish_request(req, error);
646 spin_unlock_irqrestore(q->queue_lock, flags);
647
648 if (bidi_bytes)
649 scsi_release_bidi_buffers(cmd);
650 scsi_release_buffers(cmd);
651 scsi_next_command(cmd);
652 return false;
653}
654
624/** 655/**
625 * __scsi_error_from_host_byte - translate SCSI error code into errno 656 * __scsi_error_from_host_byte - translate SCSI error code into errno
626 * @cmd: SCSI command (unused) 657 * @cmd: SCSI command (unused)
@@ -693,7 +724,7 @@ static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
693 * be put back on the queue and retried using the same 724 * be put back on the queue and retried using the same
694 * command as before, possibly after a delay. 725 * command as before, possibly after a delay.
695 * 726 *
696 * c) We can call blk_end_request() with -EIO to fail 727 * c) We can call scsi_end_request() with -EIO to fail
697 * the remainder of the request. 728 * the remainder of the request.
698 */ 729 */
699void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) 730void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
@@ -744,13 +775,9 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
744 * both sides at once. 775 * both sides at once.
745 */ 776 */
746 req->next_rq->resid_len = scsi_in(cmd)->resid; 777 req->next_rq->resid_len = scsi_in(cmd)->resid;
747 778 if (scsi_end_request(req, 0, blk_rq_bytes(req),
748 scsi_release_buffers(cmd); 779 blk_rq_bytes(req->next_rq)))
749 scsi_release_bidi_buffers(cmd); 780 BUG();
750
751 blk_end_request_all(req, 0);
752
753 scsi_next_command(cmd);
754 return; 781 return;
755 } 782 }
756 } else if (blk_rq_bytes(req) == 0 && result && !sense_deferred) { 783 } else if (blk_rq_bytes(req) == 0 && result && !sense_deferred) {
@@ -797,15 +824,16 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
797 /* 824 /*
798 * If we finished all bytes in the request we are done now. 825 * If we finished all bytes in the request we are done now.
799 */ 826 */
800 if (!blk_end_request(req, error, good_bytes)) 827 if (!scsi_end_request(req, error, good_bytes, 0))
801 goto next_command; 828 return;
802 829
803 /* 830 /*
804 * Kill remainder if no retrys. 831 * Kill remainder if no retrys.
805 */ 832 */
806 if (error && scsi_noretry_cmd(cmd)) { 833 if (error && scsi_noretry_cmd(cmd)) {
807 blk_end_request_all(req, error); 834 if (scsi_end_request(req, error, blk_rq_bytes(req), 0))
808 goto next_command; 835 BUG();
836 return;
809 } 837 }
810 838
811 /* 839 /*
@@ -919,8 +947,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
919 scsi_print_sense("", cmd); 947 scsi_print_sense("", cmd);
920 scsi_print_command(cmd); 948 scsi_print_command(cmd);
921 } 949 }
922 if (!blk_end_request_err(req, error)) 950 if (!scsi_end_request(req, error, blk_rq_err_bytes(req), 0))
923 goto next_command; 951 return;
924 /*FALLTHRU*/ 952 /*FALLTHRU*/
925 case ACTION_REPREP: 953 case ACTION_REPREP:
926 requeue: 954 requeue:
@@ -939,11 +967,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
939 __scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY, 0); 967 __scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY, 0);
940 break; 968 break;
941 } 969 }
942 return;
943
944next_command:
945 scsi_release_buffers(cmd);
946 scsi_next_command(cmd);
947} 970}
948 971
949static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, 972static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb,