public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* BUG in handling of last_sector_bug flag
@ 2008-08-11 17:03 Alan Stern
       [not found] ` <Pine.LNX.4.44L0.0808111209100.2142-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
  0 siblings, 1 reply; 32+ messages in thread
From: Alan Stern @ 2008-08-11 17:03 UTC (permalink / raw)
  To: James Bottomley, Hans de Goede, Alan Jenkins
  Cc: SCSI development list, USB list, Antonio Ospite

Antonio reported a problem in

	http://marc.info/?l=linux-usb&m=121802760208717&w=2

and I have traced it to a bad interaction between the last_sector_bug 
flag in sd.c and error reporting in the midlayer.

The last_sector_bug flag is set for devices which can't handle 
multi-sector accesses at the end of the medium.  It causes such 
accesses to be broken up into multiple single-sector accesses.  For 
example, a read request for the last 8 sectors of a drive would be 
turned into eight read requests, each for a single sector.

The problem arises when one of those single-sector requests fails with
an I/O error.  In the example above, the total length of the original
request was 4096 bytes.  But scsi_io_completion() is called with 
good_bytes = 0 and this_count gets set to 512, the number of bytes in 
the failed command.

At the end of the function, scsi_end_request() is called with error =
-EIO, bytes = 512, and requeue = 0.  This results in a call to

	blk_end_request(req, -EIO, 512);

and the remainder of the request is left hanging out to dry.  It never 
is requeued, it never completes, and the caller hangs.

This suggests that we need to change the call to scsi_end_request() at 
the end of scsi_io_completion().  If result is nonzero then nothing 
will be requeued, so this_count should be replaced with the total 
number of bytes remaining in the request.  Does that sound reasonable?

If anyone would like to recreate the conditions leading to this 
problem, there's a description of how to do it in this email:

	http://marc.info/?l=linux-kernel&m=121805565105096&w=2

Alan Stern

--
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

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2008-09-22  7:24 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox