public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: James Bottomley <James.Bottomley@steeleye.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	Mike Anderson <andmike@us.ibm.com>, Andrew Morton <akpm@osdl.org>,
	greg@kroah.com, Jens Axboe <axboe@suse.de>,
	linux-usb-devel@lists.sourceforge.net,
	SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Re: [linux-usb-devel] Re: bug 2400
Date: Sun, 04 Apr 2004 20:54:57 -0700	[thread overview]
Message-ID: <4070D891.9040409@pacbell.net> (raw)
In-Reply-To: <1081104161.2112.34.camel@mulgrave>

James Bottomley wrote:
> So you dispute this assertion in the email you quoted above:
> 
>>>Since we cannot solve that
>>>race, there's no reason to try to solve the "some parts of the kernel
>>>know but others don't" part of the race.
> 
> 
> On what basis?  This, I think, is the core of the differences between

On the basis of faulty assumptions embedded therein.  Notably
"cannot solve that race" (I elaborate below on exactly how that
information _is_ passed along from USB, which is specifically
what you said "cannot" be solved) ... so also the conclusion
that there's "no reason to try" fixing things.


> us.  I don't see why an asynchronous event should proceed up the stack
> in an orderly synchronised manner.

Some such events don't; but this isn't one of them.  And the
reason it _does_ is to make sure drivers can always prevent
oopsing on device unplug ... and to help eliminate HCD-specific
behaviors from the equation.  (There were a lot of those in 2.4,
which made robust device unplugging rather hard to achieve.)


> It goes like this:
> 
> - Initially, only the device knows, so commands outstanding time out

Well, hardware timeouts or other protocol faults will happen
when the device doesn't respond to I/O from the host.  Those
will be reported in the usual way.  When they happen in other
contexts, such faults may be recoverable ... there's no way
yet to know that these particular ones won't be.


That ends when khubd gets notified, by the hub, that the device
is gone.  At which point (a) the USB device gets marked as gone,
so that usbcore will reject further requests with -ESHUTDOWN,
(b) all pending I/Os are canceled with -ESHUTDOWN status, and
except for UHCI, (c) HCDs force those the URBs back to drivers,
as part of cleaning up the remaining hardware state.

At that point, usbcore and the HCD are all but done with the
device, and the only question is when the memory associated
with the usb_interface and usb_device objects gets its last
reference dropped, so the memory gets freed.  The current UHCI
answer may surprise some drivers, even though the 2.4 stack
could do the same thing.  The time from (a) to (c) will usually
be tens of milliseconds, at most; average time before khubd
notices will be around 1/8 second.


Then (d) for each driver bound to an interface on that device,
the USB disconnect() method is called.  Driver responsibility
is to drop all those interface and device references ASAP.

Plus, in the typical case where drivers are using implicit
refcounts to claim interface/device handles, never issuing
requests using them after the disconnect() returns, since that
releases the implicit reference acquired during probe().


> - Then, the USB driver knows, so it errors incoming commands (and
> presumably returns with error any outstanding untimed out ones)

I don't think any single point (a)-(d) matches that
description.  As soon as it gets -ESHUTDOWN it "knows",
even before (d), for example ... though it's more
natural to wait till (d) before starting to clean up
the device state.


> - Then, SCSI knows, so we forbid user I/O

SCSI knows by the fact that the host was unregistered in (d),
rarely more than ~300 msec after physical disconnect.

The problem here was that the "forbid" is borked.  Maybe not
in SCSI (there are other layers involved), but oopsably.


> The point is, that any I/O after disconnection gets an error ... the
> error just comes from different places as the knowledge propagates
> upwards.

Which directly follows from what I said ... USB propagates
that knowledge in carefully defined ways.   Other layers can
do the same, although clearly state associated with open file
descriptors needs to use a slightly different strategy.  And
that strategy is what Alan's original comment was about.

- Dave


  reply	other threads:[~2004-04-05  3:55 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-01 21:15 bug 2400 Andrew Morton
2004-04-01 21:52 ` Matt Gulick
2004-04-01 22:08   ` Andrew Morton
2004-04-01 22:48     ` Matt Gulick
2004-04-01 22:40   ` James Bottomley
2004-04-01 22:53     ` Matt Gulick
2004-04-01 23:07 ` Matthew Dharm
2004-04-01 23:32 ` James Bottomley
2004-04-02  0:29   ` Steven Dake
2004-04-02  8:43   ` Mike Anderson
2004-04-02 15:57     ` James Bottomley
2004-04-02 16:45       ` Mike Anderson
2004-04-02 17:05         ` James Bottomley
2004-04-02 17:44           ` Mike Anderson
2004-04-02 18:13             ` James Bottomley
2004-04-02 23:40               ` Mike Anderson
2004-04-03  0:25                 ` James Bottomley
2004-04-04  1:40                   ` Alan Stern
2004-04-04 15:23                     ` James Bottomley
2004-04-04 16:46                       ` Alan Stern
2004-04-04 17:04                         ` James Bottomley
2004-04-05  3:17                           ` Alan Stern
2004-04-05 14:59                             ` Mike Anderson
2004-04-05 21:27                             ` James Bottomley
2004-04-06 14:00                               ` Alan Stern
2004-04-05 22:10                             ` Patrick Mansfield
2004-04-06 14:10                               ` Alan Stern
2004-04-08 14:09                               ` Alan Stern
2004-04-08 16:24                                 ` Matt Gulick
2004-04-08 18:33                                   ` Alan Stern
2004-04-08 19:44                                     ` Matt Gulick
2004-04-05 13:30                           ` [linux-usb-devel] " Oliver Neukum
2004-04-04 18:16                       ` David Brownell
2004-04-04 18:42                         ` James Bottomley
2004-04-05  3:54                           ` David Brownell [this message]
2004-04-05 21:44                             ` James Bottomley
2004-04-05 23:23                               ` [linux-usb-devel] " David Brownell
2004-04-06  1:19                                 ` James Bottomley
2004-04-06  6:52                                   ` Oliver Neukum
2004-04-06 14:03                                     ` James Bottomley
2004-04-07  9:19                                       ` Oliver.Neukum
2004-04-06 15:10                                   ` David Brownell
2004-04-06 15:47                                     ` James Bottomley
2004-04-06 16:16                                       ` David Brownell
2004-04-06 16:55                                       ` Alan Stern
2004-04-06 17:13                                         ` James Bottomley
2004-04-02 23:36   ` James Bottomley
2004-04-03  0:11     ` Mike Anderson
2004-04-03  0:16       ` James Bottomley
2004-04-05  4:33     ` Patrick Mansfield
2004-04-05 14:09       ` James Bottomley
2004-04-05 21:07       ` James Bottomley
2004-04-06  9:22         ` Jens Axboe
2004-04-06 13:56           ` James Bottomley
2004-04-06 14:04             ` Jens Axboe
2004-04-06 14:09               ` James Bottomley
2004-04-08 23:06         ` Greg KH
2004-04-09 11:28           ` James Bottomley
2004-04-05 14:03     ` Jens Axboe
2004-04-05 21:08       ` James Bottomley
2004-04-06  9:22         ` Jens Axboe

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=4070D891.9040409@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=James.Bottomley@steeleye.com \
    --cc=akpm@osdl.org \
    --cc=andmike@us.ibm.com \
    --cc=axboe@suse.de \
    --cc=greg@kroah.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox