From: Matthew Wilcox <matthew@wil.cx>
To: Boaz Harrosh <bharrosh@panasas.com>
Cc: James Bottomley <James.Bottomley@suse.de>,
Alan Stern <stern@rowland.harvard.edu>,
Mike Christie <michaelc@cs.wisc.edu>,
Hannes Reinecke <hare@suse.de>,
linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH 3/3] scsi_lib: Collapse scsi_end_request into only user
Date: Mon, 4 Jan 2010 06:23:38 -0700 [thread overview]
Message-ID: <20100104132338.GA9882@parisc-linux.org> (raw)
In-Reply-To: <4B41DC42.1090706@panasas.com>
On Mon, Jan 04, 2010 at 02:17:06PM +0200, Boaz Harrosh wrote:
> Embedding scsi_end_request() into scsi_io_completion actually simplifies the
> code and makes it clearer what's going on.
I'm not entirely convinced about that -- scsi_io_completion is currently
over 200 lines long and needs to be made shorter, not longer. That said,
I see no reason that the current factoring of scsi_io_completion() makes
sense; pushing the decoding of the sense key into a separate function
looks like a more profitable idea. It would also let you do without
the nasty gotos you add in this patch.
> There is absolutely no functional and/or side effects changes after this patch.
>
> Patch was inspired by Alan Stern.
>
> CC: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
> ---
> drivers/scsi/scsi_lib.c | 90 +++++++++++-----------------------------------
> 1 files changed, 22 insertions(+), 68 deletions(-)
>
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 8d8b4eb..326b228 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -512,66 +512,6 @@ void scsi_run_host_queues(struct Scsi_Host *shost)
> scsi_run_queue(sdev->request_queue);
> }
>
> -/*
> - * Function: scsi_end_request()
> - *
> - * Purpose: Post-processing of completed commands (usually invoked at end
> - * of upper level post-processing and scsi_io_completion).
> - *
> - * Arguments: cmd - command that is complete.
> - * error - 0 if I/O indicates success, < 0 for I/O error.
> - * bytes - number of bytes of completed I/O
> - * requeue - indicates whether we should requeue leftovers.
> - *
> - * Lock status: Assumed that lock is not held upon entry.
> - *
> - * Returns: cmd if requeue required, NULL otherwise.
> - *
> - * Notes: This is called for block device requests in order to
> - * mark some number of sectors as complete.
> - *
> - * We are guaranteeing that the request queue will be goosed
> - * at some point during this call.
> - * Notes: If cmd was requeued, upon return it will be a stale pointer.
> - */
> -static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error,
> - int bytes, int requeue)
> -{
> - struct request *req = cmd->request;
> -
> - /*
> - * If there are blocks left over at the end, set up the command
> - * to queue the remainder of them.
> - */
> - if (blk_end_request(req, error, bytes)) {
> - /* kill remainder if no retrys */
> - if (error && scsi_noretry_cmd(cmd))
> - blk_end_request_all(req, error);
> - else {
> - if (requeue) {
> - /*
> - * Bleah. Leftovers again. Stick the
> - * leftovers in the front of the
> - * queue, and goose the queue again.
> - */
> - scsi_release_buffers(cmd);
> - scsi_requeue_command(cmd);
> - cmd = NULL;
> - }
> - return cmd;
> - }
> - }
> -
> - cmd->request = NULL;
> - /*
> - * This will goose the queue request function at the end, so we don't
> - * need to worry about launching another command.
> - */
> - scsi_release_buffers(cmd);
> - scsi_next_command(cmd);
> - return NULL;
> -}
> -
> static inline unsigned int scsi_sgtable_index(unsigned short nents)
> {
> unsigned int index;
> @@ -704,7 +644,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
> struct scsi_sense_hdr sshdr;
> int sense_valid = 0;
> int sense_deferred = 0;
> - enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY,
> + enum {ACTION_FAIL, ACTION_REPREP, ACTION_NEXT_CMND, ACTION_RETRY,
> ACTION_DELAYED_RETRY} action;
> char *description = NULL;
>
> @@ -773,13 +713,22 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
> error = 0;
> }
>
> - /*
> - * A number of bytes were successfully read. If there
> - * are leftovers and there is some kind of error
> - * (result != 0), retry the rest.
> - */
> - if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL)
> - return;
> + if (!blk_end_request(req, error, good_bytes)) {
> + cmd->request = NULL;
> + action = ACTION_NEXT_CMND;
> + goto do_action;
> + }
> +
> + if (error && scsi_noretry_cmd(cmd)) {
> + /* kill remainder if no retrys */
> + blk_end_request_all(req, error);
> + cmd->request = NULL;
> + action = ACTION_NEXT_CMND;
> + goto do_action;
> + } else if (result == 0) {
> + action = ACTION_REPREP;
> + goto do_action;
> + }
>
> error = -EIO;
>
> @@ -878,6 +827,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
> action = ACTION_FAIL;
> }
>
> +do_action:
> switch (action) {
> case ACTION_FAIL:
> /* Give up and fail the remainder of the request */
> @@ -896,6 +846,10 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
> else
> scsi_next_command(cmd);
> break;
> + case ACTION_NEXT_CMND:
> + scsi_release_buffers(cmd);
> + scsi_next_command(cmd);
> + break;
> case ACTION_REPREP:
> /* Unprep the request and put it back at the head of the queue.
> * A new command will be prepared and issued.
> --
> 1.6.6
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
next prev parent reply other threads:[~2010-01-04 13:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-04 12:11 [PATCHSET 0/3] little bit of love to scsi_io_completion Boaz Harrosh
2010-01-04 12:13 ` [PATCH 1/3] scsi_lib: request_queue is only needed inside scsi_requeue_command Boaz Harrosh
2010-01-04 12:15 ` [PATCH 2/3] scsi_lib: Remove that __scsi_release_buffers contraption Boaz Harrosh
2010-01-04 12:17 ` [PATCH 3/3] scsi_lib: Collapse scsi_end_request into only user Boaz Harrosh
2010-01-04 13:23 ` Matthew Wilcox [this message]
2010-01-04 13:56 ` Boaz Harrosh
2010-01-04 14:07 ` [PATCH 3/3 version 2] " Boaz Harrosh
2010-01-04 14:12 ` Boaz Harrosh
2010-01-04 18:23 ` Alan Stern
2010-01-05 7:27 ` Boaz Harrosh
2010-01-05 7:53 ` [PATCH 3/3 version 3] " Boaz Harrosh
2010-01-05 8:49 ` Boaz Harrosh
2010-01-05 9:07 ` [PATCH 3/3 version 4] " Boaz Harrosh
2010-01-05 15:20 ` Alan Stern
2010-01-05 16:23 ` Boaz Harrosh
2010-01-05 16:33 ` Alan Stern
-- strict thread matches above, loose matches on Subject: below --
2010-11-08 15:02 [PATCH 0/3] scsi_lib: Some love to scsi_lib Boaz Harrosh
2010-11-08 15:15 ` [PATCH 3/3] scsi_lib: Collapse scsi_end_request into only user Boaz Harrosh
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=20100104132338.GA9882@parisc-linux.org \
--to=matthew@wil.cx \
--cc=James.Bottomley@suse.de \
--cc=bharrosh@panasas.com \
--cc=hare@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=michaelc@cs.wisc.edu \
--cc=stern@rowland.harvard.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox