Re: Suggestion for aiding debugging of host removal

Christoph Hellwig
2003-12-11T11:39:11Z

On Wed, Dec 10, 2003 at 11:48:28PM -0800, Mike Anderson wrote:
> > > I've got a question about host removal. Once scsi_remove_host() has
> > > returned, the host driver's module is free to unload from memory (assuming
> > > the module's reference count is 0, which it normally is). Hence it is a
> > > mistake to access the host template in any way after that time.
>
> Normally it would not be zero on the return from scsi_remove_host. It
> would not go to zero until scsi_host_put is called. If the scsi_host_put
> is the last ref then prior to the returning of the scsi_host_put
> scsi_host_dev_release would have been called. If it is not then there
> must of been a open on a device outstanding (which would keep a rmmod
> from being called, but would allow hotplug and unexpectged disconnects).

An opened sysfs file won't stop the unload. Only if we still have
a scsi_device still referencing the host.

> > I'll see whether I can come up with a fix.
>
> Unless I missing something I do not see any interlock / wait in free_netdev
> (in looking at test11).

Sorry, it's actually unregister_nedevice (throuch netdev_run_todo and
netdev_wait_allrefs).