public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@steeleye.com>
To: Matthew Dharm <mdharm-scsi@one-eyed-alien.net>
Cc: Mike Anderson <andmike@us.ibm.com>,
	mochel@osdl.org, SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] scsi_set_host_offline (resend)
Date: 30 Mar 2003 10:23:10 -0600	[thread overview]
Message-ID: <1049041398.21704.1451.camel@mulgrave> (raw)
In-Reply-To: <20030329141512.B10565@one-eyed-alien.net>

On Sat, 2003-03-29 at 16:15, Matthew Dharm wrote:
> So, the sequence goes something like this:
> 
> (1) user removes device, causing disconnect() callback in USB system to be
> called
> 
> (2) usb-storage driver markes device as gone so as to make all commands
> fail immediately, but does nothing else
> 
> (3) hotplug script is notified of USB device removal, figures out that this
> is a usb-storage device (possibly a USB/SCSI bridge), and invokes the
> hot-unplug for SCSI for each SCSI device (after unmount, etc.)  NOTE: I
> don't know how hotplug is supposed to be able to identify the bridge case.

Ideally, yes.  The driver throwing the hotplug event is supposed to be
able to distinguish between device and bridge removal.

> (4) SCSI hot-unplugging offlines the device, then removes them.
> 
> (5) Someone notices that the dead virtual host has no devices left, and
> signals the usb-storage driver that it's safe to unregister?!??!

That's the (unimplemented in scsi) refcounting in the generic device
core.  In theory, once the struct device belonging to the host's
refcount decrements to zero (and you trigger this by doing a device_put
in the first usb remove), it calls the ->release() hook.  The code
plugged into this hook knows that the devices are gone, so does the
final USB cleanup (and the scsi host removal).

> (6) SCSI mid-layer does cleanup and notifies usb-storage when it is safe to
> free resources
> 
> (7) usb-storage destroys all structures and completes cleanup
> 
> I can see how this all works, except for step #5 -- how does usb-storage
> know that it's time to unregister?
> 
> This seems awfully complicated... usb -> usb-storage -> userspace -> scsi
> -> unknown -> usb-storage -> scsi -> usb-storage is the sequence of events.

Well, USB storage devices with filesystems on top are rather complex
things to clean up after.

> It also means that if the hotplug scripts don't do the job right, we can
> wind up with lots of dead virtual HBAs lying around.  Not fatal, I guess...
> but pretty bad.
> 
> Originally we had been talking about usb -> usb-storage -> scsi ->
> usb-storage as the sequence.  userspace never got involved except as a
> helper -- it was never in the critical path. This also put the
> responsibility for faking-out devices that had been detached but not yet
> logically removed in one central place -- with this model, each HBA is
> responsible for faking-out devices on it's own.

There's just too much specific knowledge to put into the kernel.  Even
if SCSI were to offline the device, who does something about the filesys
or other applications using it?  All you gain is moving one step closer
to the solution, not the solution itself.

The way to think about this, I think, is "what would we do if the user
asked nicely before removing the device" (i.e. requested device ejection
rather than forced it).  Then the above makes perfect sense because we
have to start at the top and move down.  Since requested ejection is the
model for things like hotplug PCI busses, I'm hoping someone else is
thinking about this.

As far as the state of play today, I'm not sure if the SCSI refcounting
is correct or not.  The SCSI list traversals are certainly racy and
unsafe, and we have no SCSI hotplug event.

This is probably because no-one who develops for SCSI has access to true
hotplug hardware.  However, we do have other uses for the hotplug
infrastructure (FC device addition/removal, even SES device handling),
we're just not entirely sure how to proceed.

James



  reply	other threads:[~2003-03-30 16:23 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-25 10:07 [PATCH] scsi_set_host_offline (resend) Mike Anderson
2003-03-25 17:37 ` James Bottomley
2003-03-25 18:45   ` Mike Anderson
2003-03-25 19:02     ` James Bottomley
2003-03-25 21:04       ` Patrick Mochel
2003-03-25 23:29       ` Mike Anderson
2003-03-27 15:42         ` James Bottomley
2003-03-29  0:31           ` Patrick Mansfield
2003-03-29  1:32           ` Matthew Dharm
2003-03-29  6:30             ` Mike Anderson
2003-03-29 14:43             ` James Bottomley
2003-03-29 19:04               ` Mike Anderson
2003-03-29 19:24                 ` Oliver Neukum
2003-03-29 20:53               ` Matthew Dharm
2003-03-29 21:54                 ` James Bottomley
2003-03-29 22:15                   ` Matthew Dharm
2003-03-30 16:23                     ` James Bottomley [this message]
2003-03-30 17:26                       ` Oliver Neukum
2003-04-09 20:30                         ` Luben Tuikov
2003-04-09 22:32                           ` Oliver Neukum
2003-04-09 22:59                             ` Luben Tuikov
2003-04-10  7:51                               ` Oliver Neukum
2003-04-17 22:29                                 ` Luben Tuikov
2003-03-30 18:21                       ` Matthew Dharm
2003-04-09 20:53                         ` Luben Tuikov
2003-03-29 22:50                   ` Oliver Neukum
2003-04-01  2:48                     ` Mike Anderson
2003-04-02  7:42                       ` Matthew Dharm
2003-04-03  2:05                         ` Mike Anderson

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=1049041398.21704.1451.camel@mulgrave \
    --to=james.bottomley@steeleye.com \
    --cc=andmike@us.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mdharm-scsi@one-eyed-alien.net \
    --cc=mochel@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox