Re: BUG: CD driver sends command during host removal

Alan Stern
2004-10-11T20:03:37Z

On 11 Oct 2004, James Bottomley wrote:

> > But scsi_remove_host isn't synchronized at all with queuecommand, so what
> > about commands that arrive at just about _the same time_ as when
> > scsi_remove_host is called? The LLD has no way to tell which class such a
> > command belongs to. What then?
>
> The host's job is simply to send commands to the device ... if the
> device (or host) still exists in the system, you send them; if it
> doesn't, you error them.
>
> Even in the notified ejection case, there's no upper bound on the time
> it will take hotplug to clean up ... this can be particularly long if
> the user has things mounted and doesn't let us simply kill everything on
> the filesystem.
>
> So the only difference as far as the HBA sees it is that for notified
> ejection, when it calls scsi_remove_host() it can still send commands.
> For surprise ejection, the device is gone and it must error.

The problem arises when a command completes. In the notified ejection
case, if the LLD tries to call the scsi_done routine for a completed
command which was submitted before scsi_remove_host and which the SCSI
core has already cleaned up, it will cause an oops. Since the LLD has no
way to tell whether the core has cleaned up a command or not, its only
choice is to fail _every_ command starting shortly before it calls
scsi_remove_host.

Alan Stern