All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Antonio Ospite <ospite@studenti.unina.it>,
	USB list <linux-usb@vger.kernel.org>,
	Boaz Harrosh <bharrosh@panasas.com>,
	Alan Jenkins <alan-jenkins@tuffmail.co.uk>,
	Hans de Goede <j.w.r.degoede@hhs.nl>,
	SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] Fix handling of failed requests in scsi_io_completion
Date: Sat, 20 Sep 2008 00:31:50 +0000	[thread overview]
Message-ID: <1221870710.3428.25.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0809191152200.2429-100000@iolanthe.rowland.org>

On Fri, 2008-09-19 at 11:53 -0400, Alan Stern wrote:
> On Fri, 19 Sep 2008, Antonio Ospite wrote:
> 
> > On Fri, 5 Sep 2008 15:35:13 -0400 (EDT)
> > Alan Stern <stern@rowland.harvard.edu> wrote:
> > 
> > > On Wed, 27 Aug 2008, Alan Stern wrote:
> > > 
> > > > This patch (as1133) fixes a bug in the interaction between
> > > > scsi_end_request() and scsi_io_completion().  The bug was triggered by
> > > > recent changes to accomodate USB drives can't access their last few
> > > > sectors using multi-sector transfers (the so-called last_sector_bug
> > > > flag).
> > > > 
> > > > The bug shows up when a multi-sector I/O request has been broken up
> > > > into single-sector commands.  If one of those commands gets an error,
> > > > the remainder of the request never gets completed.  This is because
> > > > the "bytes" value passed to scsi_end_request() is completely wrong; it
> > > > is the transfer size of the current command, not the total transfer
> > > > size of the request.
> > > 
> > > There hasn't been any reply to this patch submission.  For reference,
> > > the original message is at
> > > 
> > > 	http://marc.info/?l=linux-scsi&m=121986305201166&w=2
> > > 
> > > Has it been accepted, rejected, or did it fall through the cracks?
> > > 
> > > Alan Stern
> > >
> > 
> > Hi again,
> > 
> > anything new about this patch? Alan, I'll keep reminding about it from
> > time to time, until it is accepted or rejected.
> 
> All I can tell you is that I asked James Bottomley at the Linux Kernel
> Summit, and he said he has been too busy to look at it but it's got an
> "!" on his to-do list.

OK, I looked at it.  Sorry about the delay; I wanted to audit the users
to make sure we didn't over complete.  There's lots more than just the
last sector bug that relies on partial completions doing request
chunking.  I don't like your bytes == 0 micro optimisation, but other
than that, it looks fine.

However, there's too much code movement in this for a bug fix that has
to go into a late -rc and the stable series.  I think the patch below
represents the smallest and simplest (and thus least error prone) fix,
doesn't it (the rest can go into scsi-misc as an enhancement)?

With regard to what the mid-layer is doing, for the error cases where we
send enough bytes to complete the request fully, I think the requeue
looks superfluous (it's never going to get into that code in
scsi_end_request), The other strange bit is that I can't find any error
cases where we don't complete everything ... i.e. the partial complete
and requeue never applies, so we should probably just be using
end_dequeued_request().  I also think we could junk scsi_end_request()
in faviour of blk_end_request and do the blk_noretry_request() check
inline in scsi_io_completion, after we try to complete but before we
might retry.

James

---

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ff5d56b..62307bd 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -852,7 +852,7 @@ static void scsi_end_bidi_request(struct scsi_cmnd *cmd)
 void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 {
 	int result = cmd->result;
-	int this_count = scsi_bufflen(cmd);
+	int this_count;
 	struct request_queue *q = cmd->device->request_queue;
 	struct request *req = cmd->request;
 	int error = 0;
@@ -908,6 +908,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 	 */
 	if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL)
 		return;
+	this_count = blk_rq_bytes(req);
 
 	/* good_bytes = 0, or (inclusive) there were leftovers and
 	 * result = 0, so scsi_end_request couldn't retry.



  reply	other threads:[~2008-09-20 15:17 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-11 17:03 BUG in handling of last_sector_bug flag Alan Stern
     [not found] ` <Pine.LNX.4.44L0.0808111209100.2142-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-08-12  9:08   ` Alan Jenkins
     [not found]     ` <48A15318.30600-cCz0Lq7MMjm9FHfhHBbuYA@public.gmane.org>
2008-08-12 15:24       ` Alan Stern
     [not found]         ` <Pine.LNX.4.44L0.0808121120130.2248-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-08-12 16:33           ` Boaz Harrosh
     [not found]             ` <48A1BB71.5050905-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-08-12 21:00               ` Alan Stern
2008-08-13 11:13                 ` Boaz Harrosh
     [not found]                   ` <48A2C1F5.6000708-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-08-13 14:50                     ` Alan Stern
     [not found]                       ` <Pine.LNX.4.44L0.0808131036310.2455-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-08-13 16:37                         ` Boaz Harrosh
     [not found]                           ` <48A30DC7.8070501-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-08-13 16:45                             ` Boaz Harrosh
2008-08-13 19:17                           ` Alan Stern
2008-08-14 19:41                           ` Alan Stern
     [not found]                             ` <Pine.LNX.4.44L0.0808141535350.2148-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-08-15  8:31                               ` Alan Jenkins
2008-08-15 17:43                             ` Antonio Ospite
2008-08-26 21:13                             ` Antonio Ospite
     [not found]                               ` <20080826231301.aac6f0e5.ospite-aNJ+ML1ZbiP93QAQaVx+gl6hYfS7NtTn@public.gmane.org>
2008-08-27 14:21                                 ` Alan Stern
2008-08-27 14:33                                   ` James Bottomley
2008-08-27 15:54                                     ` Alan Stern
     [not found]                                     ` <1219847626.3292.17.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-08-27 18:50                                       ` [PATCH] Fix handling of failed requests in scsi_io_completion Alan Stern
2008-09-05 19:35                                         ` Alan Stern
     [not found]                                           ` <Pine.LNX.4.44L0.0809051533280.4482-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-09-19  7:17                                             ` Antonio Ospite
     [not found]                                               ` <20080919091748.9438726b.ospite-aNJ+ML1ZbiP93QAQaVx+gl6hYfS7NtTn@public.gmane.org>
2008-09-19 15:53                                                 ` Alan Stern
2008-09-20  0:31                                                   ` James Bottomley [this message]
2008-09-20 17:06                                                     ` Alan Stern
     [not found]                                                       ` <Pine.LNX.4.44L0.0809201241160.13839-100000-pYrvlCTfrz9XsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-09-20 17:55                                                         ` James Bottomley
2008-09-20 20:49                                                           ` Alan Stern
2008-09-20 21:09                                                             ` James Bottomley
2008-09-21 12:55                                                               ` Boaz Harrosh
     [not found]                                                                 ` <48D64459.2010802-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2008-09-21 19:57                                                                   ` James Bottomley
     [not found]                                                               ` <1221944955.3152.58.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-09-21 16:30                                                                 ` Alan Stern
     [not found]                                                                   ` <Pine.LNX.4.44L0.0809211201470.1154-100000-pYrvlCTfrz9XsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-09-21 19:59                                                                     ` James Bottomley
     [not found]                                                                       ` <1222027177.3152.121.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-09-21 21:03                                                                         ` Alan Stern
2008-09-22  7:24                                                                           ` 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=1221870710.3428.25.camel@localhost.localdomain \
    --to=james.bottomley@hansenpartnership.com \
    --cc=alan-jenkins@tuffmail.co.uk \
    --cc=bharrosh@panasas.com \
    --cc=j.w.r.degoede@hhs.nl \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=ospite@studenti.unina.it \
    --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 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.