From: Christoph Hellwig <hch@lst.de>
To: linux-scsi@vger.kernel.org
Subject: [PATCH 6/8] scsi: move more requeue handling into scsi_requeue_command
Date: Sun, 7 Sep 2014 09:31:07 -0700 [thread overview]
Message-ID: <1410107469-896-7-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1410107469-896-1-git-send-email-hch@lst.de>
Move a bit code out of scsi_io_completion and into scsi_requeue_command
in preparation for further refactoring.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/scsi/scsi_lib.c | 85 ++++++++++++++++++++++---------------------------
1 file changed, 38 insertions(+), 47 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index c398343..2221bf1 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -506,42 +506,6 @@ void scsi_requeue_run_queue(struct work_struct *work)
scsi_run_queue(q);
}
-/*
- * Function: scsi_requeue_command()
- *
- * Purpose: Handle post-processing of completed commands.
- *
- * Arguments: q - queue to operate on
- * cmd - command that may need to be requeued.
- *
- * Returns: Nothing
- *
- * Notes: After command completion, there may be blocks left
- * over which weren't finished by the previous command
- * this can be for a number of reasons - the main one is
- * I/O errors in the middle of the request, in which case
- * we need to request the blocks that come after the bad
- * sector.
- * Notes: Upon return, cmd is a stale pointer.
- */
-static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
-{
- struct scsi_device *sdev = cmd->device;
- struct request *req = cmd->request;
- unsigned long flags;
-
- spin_lock_irqsave(q->queue_lock, flags);
- blk_unprep_request(req);
- req->special = NULL;
- scsi_put_command(cmd);
- blk_requeue_request(q, req);
- spin_unlock_irqrestore(q->queue_lock, flags);
-
- scsi_run_queue(q);
-
- put_device(&sdev->sdev_gendev);
-}
-
void scsi_run_host_queues(struct Scsi_Host *shost)
{
struct scsi_device *sdev;
@@ -647,6 +611,43 @@ static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
}
}
+/**
+ * scsi_requeue_command - requeue a command from the I/O completion path.
+ * @cmd : command that needs to be requeued
+ *
+ * After command completion, there may be blocks left over which weren't
+ * finished by the previous command this can be for a number of reasons -
+ * the main one is I/O errors in the middle of the request, in which case
+ * we need to request the blocks that come after the bad sector.
+ */
+static void scsi_requeue_command(struct scsi_cmnd *cmd)
+{
+ struct request *req = cmd->request;
+ struct request_queue *q = req->q;
+
+ scsi_free_sgtables(cmd);
+
+ if (q->mq_ops) {
+ cmd->request->cmd_flags &= ~REQ_DONTPREP;
+ scsi_mq_uninit_cmd(cmd);
+ scsi_mq_requeue_cmd(cmd);
+ } else {
+ struct scsi_device *sdev = cmd->device;
+ unsigned long flags;
+
+ spin_lock_irqsave(q->queue_lock, flags);
+ blk_unprep_request(req);
+ req->special = NULL;
+ scsi_put_command(cmd);
+ blk_requeue_request(q, req);
+ spin_unlock_irqrestore(q->queue_lock, flags);
+
+ scsi_run_queue(q);
+
+ put_device(&sdev->sdev_gendev);
+ }
+}
+
static bool scsi_end_request(struct request *req, int error,
unsigned int bytes, unsigned int bidi_bytes)
{
@@ -773,7 +774,6 @@ static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
{
int result = cmd->result;
- struct request_queue *q = cmd->device->request_queue;
struct request *req = cmd->request;
int error = 0;
struct scsi_sense_hdr sshdr;
@@ -995,16 +995,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
/*FALLTHRU*/
case ACTION_REPREP:
requeue:
- /* Unprep the request and put it back at the head of the queue.
- * A new command will be prepared and issued.
- */
- scsi_free_sgtables(cmd);
- if (q->mq_ops) {
- cmd->request->cmd_flags &= ~REQ_DONTPREP;
- scsi_mq_uninit_cmd(cmd);
- scsi_mq_requeue_cmd(cmd);
- } else
- scsi_requeue_command(q, cmd);
+ scsi_requeue_command(cmd);
break;
case ACTION_RETRY:
/* Retry the same command immediately */
--
1.9.1
next prev parent reply other threads:[~2014-09-07 16:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-07 16:31 I/O path cleanup Christoph Hellwig
2014-09-07 16:31 ` [PATCH 1/8] scsi: don't use scsi_next_command in scsi_reset_provider Christoph Hellwig
2014-10-01 12:03 ` Bart Van Assche
2014-09-07 16:31 ` [PATCH 2/8] scsi: remove scsi_next_command Christoph Hellwig
2014-10-01 12:06 ` Bart Van Assche
2014-09-07 16:31 ` [PATCH 3/8] scsi: clean up S/G table freeing Christoph Hellwig
2014-10-01 12:22 ` Bart Van Assche
2014-10-01 21:05 ` Christoph Hellwig
2014-09-07 16:31 ` [PATCH 4/8] scsi: stop passing a gfp_mask argument down the command setup path Christoph Hellwig
2014-10-01 12:28 ` Bart Van Assche
2014-09-07 16:31 ` [PATCH 5/8] scsi: move scsi_dispatch_cmd to scsi_lib.c Christoph Hellwig
2014-10-01 12:30 ` Bart Van Assche
2014-09-07 16:31 ` Christoph Hellwig [this message]
2014-10-01 12:33 ` [PATCH 6/8] scsi: move more requeue handling into scsi_requeue_command Bart Van Assche
2014-09-07 16:31 ` [PATCH 7/8] scsi: split error handling slow path out of scsi_io_completion Christoph Hellwig
2014-10-01 12:46 ` Bart Van Assche
2014-09-07 16:31 ` [PATCH 8/8] scsi: merge scsi_finish_command and scsi_io_completion Christoph Hellwig
2014-10-01 12:55 ` Bart Van Assche
2014-09-08 7:22 ` I/O path cleanup Bart Van Assche
2014-09-08 15:13 ` Christoph Hellwig
2014-09-30 13:31 ` Bart Van Assche
2014-09-30 13:43 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410107469-896-7-git-send-email-hch@lst.de \
--to=hch@lst.de \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.