diff options
author | Christoph Hellwig <hch@lst.de> | 2014-01-22 12:39:04 -0500 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-07-25 07:38:41 -0400 |
commit | d0d3bbf96ec21167e55a48ebb31912918a674e0d (patch) | |
tree | b769066fd453a715abe19726af185d478a4ba47a /drivers/scsi | |
parent | de3e8bf3315c9c7c7ffd2f9b2f299b4205feefb9 (diff) |
scsi: centralize command re-queueing in scsi_dispatch_fn
Make sure we only have the logic for requeing commands in one place.
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>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/scsi.c | 35 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 9 |
2 files changed, 18 insertions, 26 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 321f854947b4..2396e89dead0 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -645,9 +645,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
645 | * returns an immediate error upwards, and signals | 645 | * returns an immediate error upwards, and signals |
646 | * that the device is no longer present */ | 646 | * that the device is no longer present */ |
647 | cmd->result = DID_NO_CONNECT << 16; | 647 | cmd->result = DID_NO_CONNECT << 16; |
648 | scsi_done(cmd); | 648 | goto done; |
649 | /* return 0 (because the command has been processed) */ | ||
650 | goto out; | ||
651 | } | 649 | } |
652 | 650 | ||
653 | /* Check to see if the scsi lld made this device blocked. */ | 651 | /* Check to see if the scsi lld made this device blocked. */ |
@@ -659,17 +657,9 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
659 | * occur until the device transitions out of the | 657 | * occur until the device transitions out of the |
660 | * suspend state. | 658 | * suspend state. |
661 | */ | 659 | */ |
662 | |||
663 | scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY); | ||
664 | |||
665 | SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, | 660 | SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, |
666 | "queuecommand : device blocked\n")); | 661 | "queuecommand : device blocked\n")); |
667 | 662 | return SCSI_MLQUEUE_DEVICE_BUSY; | |
668 | /* | ||
669 | * NOTE: rtn is still zero here because we don't need the | ||
670 | * queue to be plugged on return (it's already stopped) | ||
671 | */ | ||
672 | goto out; | ||
673 | } | 663 | } |
674 | 664 | ||
675 | /* | 665 | /* |
@@ -693,20 +683,19 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
693 | "cdb_size=%d host->max_cmd_len=%d\n", | 683 | "cdb_size=%d host->max_cmd_len=%d\n", |
694 | cmd->cmd_len, cmd->device->host->max_cmd_len)); | 684 | cmd->cmd_len, cmd->device->host->max_cmd_len)); |
695 | cmd->result = (DID_ABORT << 16); | 685 | cmd->result = (DID_ABORT << 16); |
696 | 686 | goto done; | |
697 | scsi_done(cmd); | ||
698 | goto out; | ||
699 | } | 687 | } |
700 | 688 | ||
701 | if (unlikely(host->shost_state == SHOST_DEL)) { | 689 | if (unlikely(host->shost_state == SHOST_DEL)) { |
702 | cmd->result = (DID_NO_CONNECT << 16); | 690 | cmd->result = (DID_NO_CONNECT << 16); |
703 | scsi_done(cmd); | 691 | goto done; |
704 | } else { | 692 | |
705 | trace_scsi_dispatch_cmd_start(cmd); | ||
706 | cmd->scsi_done = scsi_done; | ||
707 | rtn = host->hostt->queuecommand(host, cmd); | ||
708 | } | 693 | } |
709 | 694 | ||
695 | trace_scsi_dispatch_cmd_start(cmd); | ||
696 | |||
697 | cmd->scsi_done = scsi_done; | ||
698 | rtn = host->hostt->queuecommand(host, cmd); | ||
710 | if (rtn) { | 699 | if (rtn) { |
711 | trace_scsi_dispatch_cmd_error(cmd, rtn); | 700 | trace_scsi_dispatch_cmd_error(cmd, rtn); |
712 | if (rtn != SCSI_MLQUEUE_DEVICE_BUSY && | 701 | if (rtn != SCSI_MLQUEUE_DEVICE_BUSY && |
@@ -715,12 +704,12 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
715 | 704 | ||
716 | SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, | 705 | SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, |
717 | "queuecommand : request rejected\n")); | 706 | "queuecommand : request rejected\n")); |
718 | |||
719 | scsi_queue_insert(cmd, rtn); | ||
720 | } | 707 | } |
721 | 708 | ||
722 | out: | ||
723 | return rtn; | 709 | return rtn; |
710 | done: | ||
711 | scsi_done(cmd); | ||
712 | return 0; | ||
724 | } | 713 | } |
725 | 714 | ||
726 | /** | 715 | /** |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3ac677c48168..bf7342748f32 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -1557,9 +1557,12 @@ static void scsi_request_fn(struct request_queue *q) | |||
1557 | * Dispatch the command to the low-level driver. | 1557 | * Dispatch the command to the low-level driver. |
1558 | */ | 1558 | */ |
1559 | rtn = scsi_dispatch_cmd(cmd); | 1559 | rtn = scsi_dispatch_cmd(cmd); |
1560 | spin_lock_irq(q->queue_lock); | 1560 | if (rtn) { |
1561 | if (rtn) | 1561 | scsi_queue_insert(cmd, rtn); |
1562 | spin_lock_irq(q->queue_lock); | ||
1562 | goto out_delay; | 1563 | goto out_delay; |
1564 | } | ||
1565 | spin_lock_irq(q->queue_lock); | ||
1563 | } | 1566 | } |
1564 | 1567 | ||
1565 | return; | 1568 | return; |
@@ -1579,7 +1582,7 @@ static void scsi_request_fn(struct request_queue *q) | |||
1579 | blk_requeue_request(q, req); | 1582 | blk_requeue_request(q, req); |
1580 | sdev->device_busy--; | 1583 | sdev->device_busy--; |
1581 | out_delay: | 1584 | out_delay: |
1582 | if (sdev->device_busy == 0) | 1585 | if (sdev->device_busy == 0 && !scsi_device_blocked(sdev)) |
1583 | blk_delay_queue(q, SCSI_QUEUE_DELAY); | 1586 | blk_delay_queue(q, SCSI_QUEUE_DELAY); |
1584 | } | 1587 | } |
1585 | 1588 | ||