linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Handling erroneous READ CAPACITY response in sd.c
@ 2004-10-15 19:19 Alan Stern
  2004-10-19 20:58 ` Luben Tuikov
  0 siblings, 1 reply; 28+ messages in thread
From: Alan Stern @ 2004-10-15 19:19 UTC (permalink / raw)
  To: James Bottomley; +Cc: SCSI development list

A number of USB mass storage devices incorrectly return the total number 
of blocks rather than the largest block number in response to READ 
CAPACITY.  They then go on to compound the problem by not returning 
"Logical block address out of range" sense when asked to read the "last" 
block; instead they mess up the protocol and don't send any status phase 
information.

The usb-storage driver has been dealing with this by adding blacklist 
entries for these devices, but this isn't a very good solution.  After 
all, it's not a transport problem -- and it's not a good idea for a 
low-level driver to change the data being sent by a device.

Instead the adjustment should be made in sd.c, in the sd_read_capacity() 
routine.  One possibility is to have a SCSI blacklist flag for the bad 
devices.  A better choice might be to correct the mistake at runtime.  
Using the heuristic that the total number of blocks is almost always even 
(as far as I know it is _always_ even for USB disk-like devices), we could 
try to read the last block whenever READ CAPACITY reports an odd number of 
blocks.  If the read fails then we would know to decrement the number.

Does either of these sound like a good idea?  And if the second choice 
sounds better, is there anyone who could help me to write such a patch?

Alan Stern


^ permalink raw reply	[flat|nested] 28+ messages in thread
[parent not found: <417AFDA5.5080806@micro.ee.nthu.edu.tw>]
[parent not found: <417F6412.90000@micro.ee.nthu.edu.tw>]

end of thread, other threads:[~2004-11-08 22:08 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-15 19:19 Handling erroneous READ CAPACITY response in sd.c Alan Stern
2004-10-19 20:58 ` Luben Tuikov
2004-10-19 21:52   ` Alan Stern
2004-10-20 12:40     ` Luben Tuikov
2004-10-20 15:48       ` Alan Stern
2004-10-24 12:34         ` Eero Volotinen
2004-10-25 19:41           ` Alan Stern
2004-10-25 20:27             ` Luben Tuikov
2004-10-25 20:08           ` Luben Tuikov
     [not found]             ` <417D6123.4060902@ping-viini.org>
2004-10-25 20:55               ` Luben Tuikov
2004-11-05 16:18       ` Alan Stern
2004-11-05 18:06         ` Matthew Dharm
2004-11-05 18:34           ` Alan Stern
2004-11-05 18:44           ` [usb-storage] " Andries Brouwer
2004-11-05 21:38             ` Alan Stern
2004-11-05 21:59               ` Andries Brouwer
2004-11-08 18:55         ` Luben Tuikov
2004-11-08 21:03           ` Alan Stern
2004-11-08 21:35             ` Luben Tuikov
2004-11-08 22:04             ` Matthew Dharm
2004-11-08 22:08               ` Alan Stern
2004-10-20 13:28     ` Luben Tuikov
     [not found] <417AFDA5.5080806@micro.ee.nthu.edu.tw>
2004-10-24 17:11 ` Alan Stern
2004-10-25 21:54   ` Darsen
2004-10-26 14:43     ` Alan Stern
     [not found] <417F6412.90000@micro.ee.nthu.edu.tw>
2004-10-27 19:11 ` Alan Stern
2004-10-29 14:22   ` Darsen
2004-10-29 16:46     ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).