All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
To: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
Cc: Alan Jenkins
	<alan-jenkins-cCz0Lq7MMjm9FHfhHBbuYA@public.gmane.org>,
	James Bottomley
	<James.Bottomley-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>,
	Hans de Goede <j.w.r.degoede-fbo2DhPpy/Q@public.gmane.org>,
	SCSI development list
	<linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	USB list <linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Antonio Ospite
	<ospite-aNJ+ML1ZbiP93QAQaVx+gl6hYfS7NtTn@public.gmane.org>
Subject: Re: BUG in handling of last_sector_bug flag
Date: Wed, 13 Aug 2008 19:37:27 +0300	[thread overview]
Message-ID: <48A30DC7.8070501@panasas.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0808131036310.2455-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>

Alan Stern wrote:
> On Wed, 13 Aug 2008, Boaz Harrosh wrote:
> 
>> But now that I stared at the code harder. Current code is a complete bug.
>> the: "this_count = scsi_bufflen()" Has nothing to do with anything. 
>> Maybe it was meant to be: "this_count = scsi_bufflen() - good_bytes"
>> That is the count left over after the first complete. But after we
>> have completed good_bytes, the second complete is never scsi_bufflen().
>> (It used to work because most of the times it is bigger then the reminder
>> but then we can just use: "this_count = ~0")
>>
>> Also what you did is not enough. What if the error is one of the known cases
>> above, where the "complete and return" is inside the case. They will hang also. 
>> Here is what I think should be:
>>
>> ---
>> git diff --stat -p drivers/scsi/
>>  drivers/scsi/scsi_lib.c |    7 +++----
>>  1 files changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
>> index ff5d56b..36995e5 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;
>> @@ -909,9 +909,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
>>  	if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL)
>>  		return;
>>  
>> -	/* good_bytes = 0, or (inclusive) there were leftovers and
>> -	 * result = 0, so scsi_end_request couldn't retry.
>> -	 */
>> +	this_count = blk_rq_bytes(req);
>> +
>>  	if (sense_valid && !sense_deferred) {
>>  		switch (sshdr.sense_key) {
>>  		case UNIT_ATTENTION:
> 
> Is this really right?  Consider the subcases that follow.  For example, 
> in the UNIT ATTENTION case we have
> 
> 			scsi_end_request(cmd, -EIO, this_count, 1);
> 
> With this_count equal to blk_rq_bytes(req), there will be no leftovers 
> and so nothing will be requeued.  Shouldn't it really be
> 
> 			scsi_end_request(cmd, -EIO, 0, 1);
> 
> The same holds for all the other places scsi_end_request() is called 
> with requeue equal to 1, including the final call (if result == 0).  
> This suggests that this_count should be eliminated entirely and each 
> of those calls be replaced by either
> 
> 			goto retry;
> or
> 			goto fail;
> 
> together with:
> 
>  retry:
> 	scsi_end_request(cmd, -EIO, 0, 1);
> 	return;
>  fail:
> 	scsi_end_request(cmd, -EIO, blk_rq_bytes(req), 0);
> 	return;
> 

OK Yes, you are absolutely right. Please send a proposal and we'll 
stare at it for a while.

One thing I don't like is the now blk_end_request(req, -EIO, bytes=0)
inside scsi_end_request(). What's the point of calling that with 0 bytes?
Maybe fix that too.

> Alan Stern
> 
> PS: In my copy of the code, scsi_end_request() doesn't use
> blk_rq_bytes().  Has this been updated in the SCSI development tree?
> 

No it does not. I was just commenting on the new code. If you fix up
scsi_end_request() you should fix this too.

Thanks for doing this. This is a long outstanding nagging bug. It was
encountered before.

Boaz
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2008-08-13 16:37 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 [this message]
     [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
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=48A30DC7.8070501@panasas.com \
    --to=bharrosh-c4p08nqkorlbdgjk7y7tuq@public.gmane.org \
    --cc=James.Bottomley-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org \
    --cc=alan-jenkins-cCz0Lq7MMjm9FHfhHBbuYA@public.gmane.org \
    --cc=j.w.r.degoede-fbo2DhPpy/Q@public.gmane.org \
    --cc=linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ospite-aNJ+ML1ZbiP93QAQaVx+gl6hYfS7NtTn@public.gmane.org \
    --cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.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.