public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Luben Tuikov <luben_tuikov@adaptec.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Christoph Hellwig <hch@infradead.org>,
	Mike Anderson <andmike@us.ibm.com>,
	James Bottomley <James.Bottomley@SteelEye.com>,
	SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: Questions about scsi_target_reap and starget/sdev lifecyle
Date: Wed, 22 Jun 2005 11:46:33 -0400	[thread overview]
Message-ID: <42B987D9.3060201@adaptec.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0506221052170.6128-100000@iolanthe.rowland.org>

On 06/22/05 11:12, Alan Stern wrote:
> 
> For the unplug case you are right.  For the notify case it's a little 
> tricky because of the interaction with command cancellation (if commands 
> need to be cancelled) and the need to allow the cache flush without 
> allowing other commands.

The notify event can "travel" right behind flush-cache and "close doors"
behind.  (since it travels from the application client to the device)

> Yes.  But in fact usb-storage has a small loophole.  Before calling
> scsi_remove_host, we set a flag that causes the queuecommand routine to
> reject all new commands and any currently-executing command to fail-fast.  
> However there is a small window between the time a command is accepted and
> the time it starts to execute (because execution takes place in a
> separate kernel thread).  If a command has been accepted and has not
> started to execute, then usb-storage doesn't cancel it.  We've been
> relying on the midlayer to cancel it for us.

Sounds like a race to me.  You should always be able to
identify/find a command at any point after it has been submitted
by queuecommand().

> There's no reason usb-storage can't cancel the command before calling
> scsi_remove_host.  I tried out a patch to do just that, and it worked
> fine.  (Waiting until after scsi_remove_host to cancel the command doesn't
> work, for the obvious reason that the midlayer may have already cancelled
> it.)  I'll submit the patch; it should solve this particular problem for

Yes indeed: the proper order is:
	* lock the front door,
	* empty all rooms,
	* call scsi_remove_host().

This is on _hot-unplug_ since the event came from the SDS.
In the event of a notified unplug, the event would be known to
SCSI Core _before_ it is known to the LLDD, so SCSI Core would
lock the "fence gate", send flush-cache (which would seem as any
other command to you), then wait for that to return (which would
mean no other commands are pending, since this was the last command
to be sent after locking the "fence gate") and then it would
call scsi_remove_host() or whatever appropriate.

> usb-storage.  I don't know how any other hot-unpluggable LLDDs will handle
> cancellation during unplug.

In case the LLDD is implemented properly, just doing nothing should suffice. ;-)

	Luben



  reply	other threads:[~2005-06-22 15:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-14 21:27 Questions about scsi_target_reap and starget/sdev lifecyle Alan Stern
2005-06-15  3:28 ` James Bottomley
2005-06-15 20:07   ` Alan Stern
2005-06-15 21:11   ` Alan Stern
2005-06-15 23:03     ` James Bottomley
2005-06-16  2:22       ` Alan Stern
2005-06-16  7:31         ` Mike Anderson
2005-06-16 13:57           ` James Bottomley
2005-06-17  2:01             ` Alan Stern
2005-06-18 20:14             ` Alan Stern
2005-06-20 15:52               ` Brian King
2005-06-20 16:35                 ` Alan Stern
2005-06-20 17:31                   ` Patrick Mansfield
2005-06-20 19:24                     ` Alan Stern
2005-06-21 17:12               ` Mike Anderson
2005-06-21 17:43                 ` Patrick Mansfield
2005-06-21 19:24                   ` Mike Anderson
2005-06-21 20:04                 ` Alan Stern
2005-06-21 20:10                   ` Christoph Hellwig
2005-06-21 20:33                     ` Alan Stern
2005-06-21 20:58                       ` Mike Anderson
2005-06-21 21:22                         ` Alan Stern
2005-06-22 13:44                         ` Luben Tuikov
2005-06-22 13:36                       ` Luben Tuikov
2005-06-22 15:12                         ` Alan Stern
2005-06-22 15:46                           ` Luben Tuikov [this message]
2005-06-22 16:16                             ` Alan Stern
2005-06-22 16:53                               ` Luben Tuikov
2005-06-21 21:08                   ` Mike Anderson
2005-06-21 21:37                     ` Alan Stern

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=42B987D9.3060201@adaptec.com \
    --to=luben_tuikov@adaptec.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=andmike@us.ibm.com \
    --cc=hch@infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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