Re: [PATCH] scsi_set_host_offline (resend)

Mike Anderson
2003-04-01T02:48:06Z

Oliver Neukum [oliver@neukum.org] wrote:
> Am Samstag, 29. M?rz 2003 22:54 schrieb James Bottomley:
> > On Sat, 2003-03-29 at 14:53, Matthew Dharm wrote:
> > > My understanding was that I couldn't call set_device_offline with the
> > > host lock held, which is a problem because I need the host lock to
> > > traverse the device list.
> >
> > The solution we're talking about here is from the user level hotplug
> > scripts. Once we get the remove-single-device fixed, you simply use the
> > device hot unplug script to traverse the attached SCSI devices, clean up
> > the user land (kill processes, unmount filesystems etc.) and then blow
> > the devices away. After the host has no devices, you should simply be
> > able to trigger a host removal from within your driver.
>
> It seems you are still trying this overcomplicated going through
> user space and back thing.
> There's no benefit at all in this. If you make this work you can just
> as well make a straightforward thing work. Which will not be a nightmare
> to make work right under all circumstances.

Matthew / James I believe I am out of sync with how much is being done
by userspace and how much is being done in the kernel. I believed there
was always userspace action to umount / close devices.

Matthew I know in the previous mail you wrote a numbered list of steps.
I believe item #2 should have called scsi_set_host_offline or
scsi_set_device_offline. Item #6 would only happen if scsi_remove_host
was called sometime prior.

I wrote the following text on the interface I thought we had / where
trying to complete. I would like to add to this so that we possibly
could archive an interface contract between the LLDD and scsi-mid.

2.5 SCSI host register interfaces (scsi_add_host / scsi_remove_host)

1. LLDD call graph standard

(PROBE)
LLDD Mid Sysfs
scsi_register -->
scsi_set_device --> (depreciated)
scsi_add_host ---+
|
scsi_sysfs_add_host --> device_register (shost)
scsi_scan_host (i)-> device_register (sdev)

(REMOVE)
LLDD Mid Sysfs
scsi_remove_host ---+
|
scsi_sysfs_remove_host --> device_unregister (shost)
scsi_forget_host (i)-> device_unregister (sdev)

(hotplug "remove" events for shost and sdev where generated by
device_unregister call).

(sdev device ref cnt == 0)
koject_cleanup
|
scsi_device_release

(shost device ref cnt == 0)
koject_cleanup
|
+-- scsi_host_release
|
shost->hostt->release

2. LLDD call graph offline event

(OFFLINE single device)
LLDD Mid Sysfs
scsi_set_device_offline --+
|
scsi_eh_scmd_add

Note: Do we need hotplug events here or wait until remove???

(OFFLINE host)
LLDD Mid Sysfs
scsi_set_host_offline --+
|
scsi_set_device_offline

(REMOVE)
Same as above.

TODO (1):
scsi_add_host scans the host and when outstanding patches are applied
the scsi_host struct device will have a ref count of 1+N where N is the
number of struct scsi_device's found off the host. In turn each struct
scsi_device struct device will have a ref count of 1+N where N is the
number of upper drivers bound or the number of opens (this may not be
correct for sometime as we do not have an option for the multiple bind
sg issue).

TODO (2):
We need a common method to stop gets to a struct device post a certain
barrier. In the short term scsi could add a scsi_host flag to stop scan
adds, but cannot effect sysfs gets.

TODO (3):
When outstanding patches are applied scsi_remove_host will cause a
device_unregister to be called on all child nodes (sdevs) of scsi_host
and scsi_host (these unregisters will generate hot plug "remove" events)
once the scsi_device ref cnt goes to zero scsi_device_release is called
and once scsi_host ref cnt goes to zero scsi_host_release is called.

-andmike
--
Michael Anderson
andmike@us.ibm.com