public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Re: USB storage problems on OHCI..
@ 2003-09-22 18:55 Andries.Brouwer
  2003-09-22 19:28 ` [linux-usb-devel] " James Bottomley
  0 siblings, 1 reply; 49+ messages in thread
From: Andries.Brouwer @ 2003-09-22 18:55 UTC (permalink / raw)
  To: patmans, torvalds
  Cc: Andries.Brouwer, david-b, greg, hch, linux-scsi, linux-usb-devel,
	mdharm-usb, stern

> Basically, Andries Brouwer's strategy of making sd.c more conservative has
> been a very successful one in the past. Why not continue on that?

% I would be interested in hearing what Andries has to say. ...
% The variety of ways in which these things fail is truly amazing.

Yes.

We have just seen this for keyboards: keypresses work, modifier key
releases work, and as soon as one assumes anything more there turn
out to be keyboards that fail.

Similarly, USB storage devices tend to fail whatever one tries,
and only systematically work if one does precisely what Windows
does. For SCSI disks things are not nearly as bad - there are
only a few manufacturers and they mostly produce quality stuff.

This means that carefully reading the SCSI standard is a useful
activity if one writes for SCSI disks. But for USB storage it
is more productive to trace the commands the various flavours
of Windows send.

(Yes, I am willing to collect whatever people send me, and put up
a web page describing the Windows way of addressing USB storage.)

So, I agree with Linus (and with myself :-)) - in the absence of
precise knowledge about the device and about its Windows drivers
all that is left is being as conservative as possible.
And I agree with Alan - even though being careful is a very good idea,
it does not help in all cases.

There are some general things we can do - for CF cards and the like
we probably do not want to read the cache type - USB is hot pluggable,
so it should not be necessary to send a flush cache command at shutdown.
Today I see

        if (sdkp->media_present) {
                sd_read_capacity(sdkp, disk->disk_name, sreq, buffer);
                if (sdp->removable)
                        sd_read_write_protect_flag(sdkp, disk->disk_name,
                                        sreq, buffer);
                sd_read_cache_type(sdkp, disk->disk_name, sreq, buffer);
        }

and I suppose we could skip sd_read_cache_type() in the
hot-pluggable case - a flag that USB storage could set.

Andries


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

^ permalink raw reply	[flat|nested] 49+ messages in thread
* Re: [linux-usb-devel] Re: USB storage problems on OHCI..
@ 2003-09-22 19:56 Andries.Brouwer
  2003-09-22 20:48 ` Alan Stern
                   ` (2 more replies)
  0 siblings, 3 replies; 49+ messages in thread
From: Andries.Brouwer @ 2003-09-22 19:56 UTC (permalink / raw)
  To: Andries.Brouwer, James.Bottomley
  Cc: david-b, greg, hch, linux-scsi, linux-usb-devel, mdharm-usb,
	patmans, stern, torvalds

    From James.Bottomley@SteelEye.com  Mon Sep 22 21:29:06 2003

    On Mon, 2003-09-22 at 13:55, Andries.Brouwer@cwi.nl wrote:
    >         if (sdkp->media_present) {
    >                 sd_read_capacity(sdkp, disk->disk_name, sreq, buffer);
    >                 if (sdp->removable)
    >                         sd_read_write_protect_flag(sdkp, disk->disk_name,
    >                                         sreq, buffer);
    >                 sd_read_cache_type(sdkp, disk->disk_name, sreq, buffer);
    >         }
    > 
    > and I suppose we could skip sd_read_cache_type() in the
    > hot-pluggable case - a flag that USB storage could set.

    what about just having a conservative mode for sd?  This could still
    internally be a set of flags, just one single way of clearing them all
    from slave configure.  For the most conservative setting, we could
    probably dump spin up, read write protect, and read cache type.

Maybe.

[By the way - reading Write Protect is meaningful and works,
for my Smart Media card readers.]

I have seen proposals around here for flags that are far too specific
(like "do not ask for mode page 8"). If we go to that level of detail
then we'll soon have fifty flags.
Black lists, and flags that describe various ways of being broken
are a bad idea in my opinion. I will not deny that they may be needed
in some cases, but they are never the preferred solution.

Also "conservative mode" sounds like a flag that describes some
way of being broken.

On the other hand "hot-pluggable" describes a positive asset,
and if we can conclude from that that it is unnecessary to ask
for mode page 8 then we achieve the same effect in a positive way.


There is another comment here.
A scsi device declares its level of scsi compliance.
Most USB storage devices are not very scsi compliant at all,
and report 0 there.
To everybody's surprise USB storage does

        US_DEBUGP("Fixing INQUIRY data to show SCSI rev 2 - was %d\n",
                  data_ptr[2] & 7);

        /* Change the SCSI revision number */
        data_ptr[2] = (data_ptr[2] & ~7) | 2;

It claims that the device is SCSI-2 compliant, even when the
device itself does not make that claim at all.


Suppose that we stop changing this compliance level.
Then getting SCSI-1 or no compliance level could be a
"conservative mode" flag.

[Of course this was done for a reason - USB storage was written
assuming the SCSI layer given. If we stop changing the SCSI level
that may require changes in the SCSI code. Probably Matt remembers
what the problems were.]

Andries

^ permalink raw reply	[flat|nested] 49+ messages in thread
* Re: [linux-usb-devel] Re: USB storage problems on OHCI..
@ 2003-09-22 22:55 Pat LaVarre
  2003-09-29 14:54 ` Pat LaVarre
  0 siblings, 1 reply; 49+ messages in thread
From: Pat LaVarre @ 2003-09-22 22:55 UTC (permalink / raw)
  To: linux-scsi, linux-usb-devel
  Cc: torvalds, mdharm-scsi, stern, hch, james.bottomley,
	andries.brouwer


> From: Linus Torvalds <torvalds () osdl ! org>
> Date: 2003-09-22 19:55:30
> ...
> How about just trusting the size ...
> and capping it at 20?

Besides dramatic overestimates of mode sense additional length, I've
also seen the off-by-one slight overestimate and the high-byte-zeroed
dramatic underestimate.

> General MODE SENSE stuff is in:
> http://www.t10.org/ftp/t10/drafts/spc3/spc3r15.pdf

Yes, but t10 mmc often quietly contradicts & overrides t10 spc for pdt
x05 dvd/cd and for atapi pdt x00 hdd/rmb.  For t10 newbies wanting to
fetch the bleeding edge, latest final draft, oldest still available,
etc. I sometimes recommend the index:

http://www.t10.org/scsi-3.htm

> > A scsi device declares its level of scsi compliance.
> ...
> From: Matthew Dharm <mdharm-scsi () one-eyed-alien ! net>
> Date: 2003-09-22 20:51:59
> ...
> reporting of 0, 1, 2, or something random ...
> appears ... unrelated to the capabilities of the device ...

The pernicious idea of zeroing the scsi revision in byte 2 of op x12
inquiry forms part of how mmc quietly redefines spc.  Misapplying the
sff precursor of the pdt x05 mmc spec to pdt x00 devices is part of how
msft whql qualified atapi pdt x00 devices for sale thru oem's in the
late 1990's.

> > > > From: Alan Stern <stern () rowland ! harvard ! edu>
> > > > Date: 2003-09-22 14:25:28
> > > > ...
> > > > many, many USB storage devices.  
> > > > They just don't handle MODE-SENSE page 8 correctly.
> > >
> > > From: Linus Torvalds <torvalds () osdl ! org>
> > > Date: 2003-09-22 16:09:47
> > > ...
> > > How about just making the sd.c layer more robust? 
> >
> > From: Alan Stern <stern () rowland ! harvard ! edu>
> > Date: 2003-09-22 16:42:52
> > ...
> > variety of ways ... fail ... truly amazing.
>
> From:  Christoph Hellwig <hch () infradead ! org>
> Date: 2003-09-22 17:21:42
> ...
> for those usb-storage devices where ...
> nothing that isn't excercised by the windows drivers
> has the slightest chance of working..

In the sd world, usb hdd/rmb (pdt x00) may handle specifically the mode
sense of page 8 that win sends.

For usb bInterfaceSubClass = x06 TransparentScsi that cdb might be:
x 1A 00:08:00 18 00

For usb bInterfaceSubClass != x06 TransparentScsi that cdb might be:
x 5A 00 08:00:00:00 00 00:1C 00

usb dvd/cd (pdt x05) sell into the sr/ide-cd world instead, of course.

Tell me we care to hear specifically what some win sends to some of my
usb hdd/rmb, and I'll go collect a few sample usb bus traces.  I do NOT
know that the above cdb's are correct.  Those are just my guesses,
summing up little clues from years of messing around near here.  I hear
in particular that win 9x/me differs from win 2k/xp near hear.

> Subject:  Re: [linux-usb-devel] Re: USB storage problems on OHCI..
> From: Linus Torvalds <torvalds () osdl ! org>
> Date: 2003-09-22 17:41:47
> ...
> is it saner to try to read just the bytes we need
> (3 bytes: page code, page size and the cache bits),
> or the full 20 bytes?

I thought "everyone knew" sanest was to always fetch header + block
descriptors + whole pages?

Trouble is, that's a circular definition in that the host can't know
whether the device will volunteer an optional block descriptor or not. 
mmc says shall not, spc says maybe not but should.

We only have to care if we have to know how many Data bytes to expect to
copy In.

> From: Andries.Brouwer () cwi ! nl
> Date: 2003-09-22 18:55:22
> ...
> Similarly, USB storage devices tend to ...
> only systematically work
> if one does precisely what Windows does.

Yes, what ain't tested don't work.

> USB is hot pluggable,
> so it should not be necessary
> to send a flush cache command at shutdown.

Who has tested this rule?  I know I've seen ata hdd lose data in
response to a pin 1 reset issued without op x35 sync cache.  I've heard
same of dvd.  And loss of bus power can kill any write cache in a drive,
of course.

> From: James Bottomley <James.Bottomley () steeleye ! com>
> Date: 2003-09-22 17:55:09 ...
> ...
> I think we could try 4 bytes

We know that isn't talk like windows.  msdn.microsoft.com tells us the
win 2k kernel crashes if a root-privileged app asks for just the 4 byte
header from devices for which Win translates to x5A MODE_SENSE_10 from
x1A MODE_SENSE  Because the win 2k kernel crashes so reliably, we can
confidently guess no working win 2k apps talk that way.

> From: James Bottomley <James.Bottomley () steeleye ! com>
> Date: 2003-09-22 19:28:56
> ...
> sd? ... the most conservative ..., we could probably
> dump spin up, read write protect, and read cache type ...

Aye, although in sr/ide-cd we have a default of not writable to overcome
somehow.

Pat LaVarre




^ permalink raw reply	[flat|nested] 49+ messages in thread
* Re: [linux-usb-devel] Re: USB storage problems on OHCI..
@ 2003-09-22 23:07 Andries.Brouwer
  0 siblings, 0 replies; 49+ messages in thread
From: Andries.Brouwer @ 2003-09-22 23:07 UTC (permalink / raw)
  To: linux-scsi, linux-usb-devel, p.lavarre
  Cc: andries.brouwer, hch, james.bottomley, mdharm-scsi, stern,
	torvalds

> Tell me we care to hear specifically what some win sends to some of my
> usb hdd/rmb, and I'll go collect a few sample usb bus traces.

I'll collect and publish.
(Change the subject line to "USB storage traces" or so.)
Must have some old traces somewhere myself too.

Andries

^ permalink raw reply	[flat|nested] 49+ messages in thread
* Re: [linux-usb-devel] Re: USB storage problems on OHCI..
@ 2003-09-23 14:37 Andries.Brouwer
  2003-09-23 14:51 ` James Bottomley
  2003-09-23 15:46 ` Linus Torvalds
  0 siblings, 2 replies; 49+ messages in thread
From: Andries.Brouwer @ 2003-09-23 14:37 UTC (permalink / raw)
  To: Andries.Brouwer, James.Bottomley
  Cc: david-b, greg, hch, linux-scsi, linux-usb-devel, mdharm-usb,
	patmans, stern, torvalds

    From James.Bottomley@SteelEye.com  Tue Sep 23 16:05:21 2003

    > Also "conservative mode" sounds like a flag that describes some
    > way of being broken.
    > 
    > On the other hand "hot-pluggable" describes a positive asset,
    > and if we can conclude from that that it is unnecessary to ask
    > for mode page 8 then we achieve the same effect in a positive way.

    I disagree on this one.  hot-pluggable sounds like it should be set for
    ever hotplug device (currently that would include firewire, which may be
    iffy, and Fibre Channel, which has our highest level of SCSI compliance
    and would definitely be wrong).

Why would it be wrong?

    The design goal is that this flag makes sd assume as little SCSI
    standards compliance as it can get away with while still operating the
    device.

No, the design goal of "hot-pluggable" is that it indicates that
the device can disappear any moment. Nothing at all about SCSI
compliance.

Pulling out a device while it is actively reading or writing
will probably break something. But if a device is hot-pluggable
it should be OK to pull it out when it has been inactive for
a second or so.

But if that is really true, then it should not be necessary
to send the device any "synchronise cache" commands when we
shut down.

And if no such commands will be sent anyway, then we need not ask
the device about its type of cache.

And if we do not ask, then we need not worry whether the device
is sufficiently compliant to answer such a question.

Andries

^ permalink raw reply	[flat|nested] 49+ messages in thread
* Re: Re: USB storage problems on OHCI..
  2003-09-23 14:51 ` James Bottomley
@ 2003-09-23 15:23 Alan Stern
  2003-09-24 14:10 ` [linux-usb-devel] " James Bottomley
  -1 siblings, 1 reply; 49+ messages in thread
From: Alan Stern @ 2003-09-23 15:23 UTC (permalink / raw)
  To: James Bottomley
  Cc: Andries.Brouwer, david-b, greg, hch, SCSI Mailing List,
	linux-usb-devel, mdharm-usb, Patrick Mansfield, Linus Torvalds

On 23 Sep 2003, James Bottomley wrote:

> On Tue, 2003-09-23 at 09:37, Andries.Brouwer@cwi.nl wrote:
> 
> > Pulling out a device while it is actively reading or writing
> > will probably break something. But if a device is hot-pluggable
> > it should be OK to pull it out when it has been inactive for
> > a second or so.
> > 
> > But if that is really true, then it should not be necessary
> > to send the device any "synchronise cache" commands when we
> > shut down.
> 
> For a FC array, suprise unplug would be caveat emptor (possibly because
> fibre connection transience is going to cause it to come back), but
> notified unplug would still want to flush the cache on the assumption
> the next action might be to power down the array.

Is there any way to notify the system that you are about to unplug a 
drive?  It seems to me that the best approach is to flush the cache on an 
unmount.  People naturally assume that it's safe to unplug a device once 
it has been unmounted, and they also realize that it's unsafe to unplug a 
device containing a mounted filesystem.

That doesn't address the problem of raw device access, but perhaps 
whatever ioctl is used by blockdev --flushbufs can also flush the cache.

Is there any harm in sending a SYNCHRONIZE command to a device that
doesn't need it (write-through cache)?  Maybe doing that is less dangerous 
than trying to read mode-sense page 8 on these buggy USB devices.  
(Although I'm not aware of anyone who has tried the experiment.)

Alan Stern



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

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

end of thread, other threads:[~2003-10-03 21:37 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20030922004943.E32009@one-eyed-alien.net>
2003-09-22 14:25 ` [linux-usb-devel] Re: USB storage problems on OHCI Alan Stern
2003-09-22 14:31   ` Christoph Hellwig
2003-09-22 15:11     ` Christoph Hellwig
2003-09-22 15:49       ` Patrick Mansfield
2003-09-22 16:09         ` [linux-usb-devel] " Linus Torvalds
2003-09-22 16:42           ` Alan Stern
2003-09-22 17:23           ` Patrick Mansfield
2003-09-22 17:41             ` [linux-usb-devel] " Linus Torvalds
2003-09-22 17:55               ` James Bottomley
2003-09-22 19:55                 ` [linux-usb-devel] " Linus Torvalds
2003-09-23 17:47                   ` Ruud Linders
2003-09-23 18:16                     ` Linus Torvalds
2003-09-24 16:40                       ` Ruud Linders
2003-09-24 16:53                         ` Linus Torvalds
2003-09-26 18:43                           ` Alan Stern
2003-10-03 14:18                             ` Alan Stern
2003-10-03 15:05                               ` James Bottomley
2003-10-03 21:35                                 ` Patrick Mansfield
2003-09-22 18:46           ` Alan Cox
2003-09-22 16:37         ` [linux-usb-devel] " Christoph Hellwig
2003-09-22 16:44           ` Patrick Mansfield
2003-09-22 17:21             ` Christoph Hellwig
2003-09-22 19:01               ` Alan Stern
2003-09-22 15:50       ` Alan Stern
2003-09-22 15:58         ` Patrick Mansfield
2003-09-22 16:36           ` [linux-usb-devel] " Alan Stern
2003-09-22 16:38         ` Christoph Hellwig
2003-09-22 15:29   ` [linux-usb-devel] " Linus Torvalds
2003-09-22 16:22     ` David Brownell
2003-09-22 16:31       ` [linux-usb-devel] " Linus Torvalds
2003-09-22 17:13         ` David Brownell
2003-09-22 17:29           ` Linus Torvalds
2003-09-22 17:49             ` [linux-usb-devel] " David Brownell
2003-09-22 18:40               ` Linus Torvalds
2003-09-22 19:14                 ` Alan Stern
2003-09-22 16:58       ` [linux-usb-devel] " Martin Diehl
2003-09-22 17:19         ` David Brownell
2003-09-22 18:55 Andries.Brouwer
2003-09-22 19:28 ` [linux-usb-devel] " James Bottomley
  -- strict thread matches above, loose matches on Subject: below --
2003-09-22 19:56 Andries.Brouwer
2003-09-22 20:48 ` Alan Stern
2003-09-22 20:51 ` Matthew Dharm
2003-09-23 14:04 ` James Bottomley
2003-09-22 22:55 Pat LaVarre
2003-09-29 14:54 ` Pat LaVarre
2003-09-22 23:07 Andries.Brouwer
2003-09-23 14:37 Andries.Brouwer
2003-09-23 14:51 ` James Bottomley
2003-09-23 15:46 ` Linus Torvalds
2003-09-23 15:23 Alan Stern
2003-09-24 14:10 ` [linux-usb-devel] " James Bottomley

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