Commit d0d3bbf9 authored by Christoph Hellwig's avatar Christoph Hellwig

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarWebb Scales <webbnh@hp.com>
Acked-by: default avatarJens Axboe <axboe@kernel.dk>
Tested-by: default avatarBart Van Assche <bvanassche@acm.org>
Tested-by: default avatarRobert Elliott <elliott@hp.com>
parent de3e8bf3
...@@ -645,9 +645,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) ...@@ -645,9 +645,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
* returns an immediate error upwards, and signals * returns an immediate error upwards, and signals
* that the device is no longer present */ * that the device is no longer present */
cmd->result = DID_NO_CONNECT << 16; cmd->result = DID_NO_CONNECT << 16;
scsi_done(cmd); goto done;
/* return 0 (because the command has been processed) */
goto out;
} }
/* Check to see if the scsi lld made this device blocked. */ /* Check to see if the scsi lld made this device blocked. */
...@@ -659,17 +657,9 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) ...@@ -659,17 +657,9 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
* occur until the device transitions out of the * occur until the device transitions out of the
* suspend state. * suspend state.
*/ */
scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY);
SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd,
"queuecommand : device blocked\n")); "queuecommand : device blocked\n"));
return SCSI_MLQUEUE_DEVICE_BUSY;
/*
* NOTE: rtn is still zero here because we don't need the
* queue to be plugged on return (it's already stopped)
*/
goto out;
} }
/* /*
...@@ -693,20 +683,19 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) ...@@ -693,20 +683,19 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
"cdb_size=%d host->max_cmd_len=%d\n", "cdb_size=%d host->max_cmd_len=%d\n",
cmd->cmd_len, cmd->device->host->max_cmd_len)); cmd->cmd_len, cmd->device->host->max_cmd_len));
cmd->result = (DID_ABORT << 16); cmd->result = (DID_ABORT << 16);
goto done;
scsi_done(cmd);
goto out;
} }
if (unlikely(host->shost_state == SHOST_DEL)) { if (unlikely(host->shost_state == SHOST_DEL)) {
cmd->result = (DID_NO_CONNECT << 16); cmd->result = (DID_NO_CONNECT << 16);
scsi_done(cmd); goto done;
} else {
trace_scsi_dispatch_cmd_start(cmd);
cmd->scsi_done = scsi_done;
rtn = host->hostt->queuecommand(host, cmd);
} }
trace_scsi_dispatch_cmd_start(cmd);
cmd->scsi_done = scsi_done;
rtn = host->hostt->queuecommand(host, cmd);
if (rtn) { if (rtn) {
trace_scsi_dispatch_cmd_error(cmd, rtn); trace_scsi_dispatch_cmd_error(cmd, rtn);
if (rtn != SCSI_MLQUEUE_DEVICE_BUSY && if (rtn != SCSI_MLQUEUE_DEVICE_BUSY &&
...@@ -715,12 +704,12 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) ...@@ -715,12 +704,12 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd,
"queuecommand : request rejected\n")); "queuecommand : request rejected\n"));
scsi_queue_insert(cmd, rtn);
} }
out:
return rtn; return rtn;
done:
scsi_done(cmd);
return 0;
} }
/** /**
......
...@@ -1557,9 +1557,12 @@ static void scsi_request_fn(struct request_queue *q) ...@@ -1557,9 +1557,12 @@ static void scsi_request_fn(struct request_queue *q)
* Dispatch the command to the low-level driver. * Dispatch the command to the low-level driver.
*/ */
rtn = scsi_dispatch_cmd(cmd); rtn = scsi_dispatch_cmd(cmd);
spin_lock_irq(q->queue_lock); if (rtn) {
if (rtn) scsi_queue_insert(cmd, rtn);
spin_lock_irq(q->queue_lock);
goto out_delay; goto out_delay;
}
spin_lock_irq(q->queue_lock);
} }
return; return;
...@@ -1579,7 +1582,7 @@ static void scsi_request_fn(struct request_queue *q) ...@@ -1579,7 +1582,7 @@ static void scsi_request_fn(struct request_queue *q)
blk_requeue_request(q, req); blk_requeue_request(q, req);
sdev->device_busy--; sdev->device_busy--;
out_delay: out_delay:
if (sdev->device_busy == 0) if (sdev->device_busy == 0 && !scsi_device_blocked(sdev))
blk_delay_queue(q, SCSI_QUEUE_DELAY); blk_delay_queue(q, SCSI_QUEUE_DELAY);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment