Commit 4ae61c68 authored by Douglas Gilbert's avatar Douglas Gilbert Committed by Martin K. Petersen

scsi: core: add scsi_io_completion_reprep helper

Since the action "reprep" is called from two places, rather than repeat the
code, make a new scsi_io_completion helper with "reprep" as its suffix.
Signed-off-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent da32baea
...@@ -761,6 +761,20 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result) ...@@ -761,6 +761,20 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result)
} }
} }
/* Helper for scsi_io_completion() when "reprep" action required. */
static void scsi_io_completion_reprep(struct scsi_cmnd *cmd,
struct request_queue *q)
{
/* A new command will be prepared and issued. */
if (q->mq_ops) {
scsi_mq_requeue_cmd(cmd);
} else {
/* Unprep request and put it back at head of the queue. */
scsi_release_buffers(cmd);
scsi_requeue_command(q, cmd);
}
}
/* Helper for scsi_io_completion() when special action required. */ /* Helper for scsi_io_completion() when special action required. */
static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result) static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
{ {
...@@ -906,15 +920,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result) ...@@ -906,15 +920,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
return; return;
/*FALLTHRU*/ /*FALLTHRU*/
case ACTION_REPREP: case ACTION_REPREP:
/* Unprep the request and put it back at the head of the queue. scsi_io_completion_reprep(cmd, q);
* A new command will be prepared and issued.
*/
if (q->mq_ops) {
scsi_mq_requeue_cmd(cmd);
} else {
scsi_release_buffers(cmd);
scsi_requeue_command(q, cmd);
}
break; break;
case ACTION_RETRY: case ACTION_RETRY:
/* Retry the same command immediately */ /* Retry the same command immediately */
...@@ -1091,20 +1097,9 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) ...@@ -1091,20 +1097,9 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
* If there had been no error, but we have leftover bytes in the * If there had been no error, but we have leftover bytes in the
* requeues just queue the command up again. * requeues just queue the command up again.
*/ */
if (result == 0) { if (result == 0)
/* scsi_io_completion_reprep(cmd, q);
* Unprep the request and put it back at the head of the else
* queue. A new command will be prepared and issued.
* This block is the same as case ACTION_REPREP in
* scsi_io_completion_action() above.
*/
if (q->mq_ops) {
scsi_mq_requeue_cmd(cmd);
} else {
scsi_release_buffers(cmd);
scsi_requeue_command(q, cmd);
}
} else
scsi_io_completion_action(cmd, result); scsi_io_completion_action(cmd, result);
} }
......
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