Re: BUG: CD driver sends command during host removal

Luben Tuikov
2004-09-29T19:33:21Z

Alan Stern wrote:
> On Wed, 29 Sep 2004, Luben Tuikov wrote:
>
> > Hmm, once queuecommand() has been called, SCSI Core *should NOT* touch
> > the struct command until the LLDD calls scsi_done() or it times
> > out and ownership is given back indirectly via the appropriate
> > return result of the times_out() function.
>
> On 29 Sep 2004, James Bottomley wrote:
>
> > Right. scsi_remove_host tells the mid-layer that it's OK to trash all
> > inflight commands because you removed all their users before calling
> > it. It also tells us that you won't accept any future commands for this
> > host (because you'll error any attempt in queuecommand).
>
> It sounds like the two of you are in contradiction. Should the SCSI core
> deallocate in-flight commands without consulting the LLDD or shouldn't it?

If the host is really gone, then no pending commands would
ever "return".

This means that the LLDD can call scsi_done() immediately, without
any waiting or delay of any sort.

Basically, when your host is gone, plug queuecommand(), call
scsi_done() on all your pending commands, and call scsi_remove_host().
The only problem would be if you have to sleep while "recovering"
the pending commands, but I cannot imagine why you'd do that
as your host is gone.

Now since LLDD shouldn't keep internal queues of pending commands,
ideally, this function is left to SCSI Core.

Luben