public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Hannes Reinecke <hare@suse.de>,
	Kay Sievers <kay.sievers@vrfy.org>,
	SCSI development list <linux-scsi@vger.kernel.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Kernel development list <linux-kernel@vger.kernel.org>,
	Tejun Heo <tj@kernel.org>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	linux-fsdevel@vger.kernel.org,
	"Eric W. Biederman" <ebiederm@aristanetworks.com>
Subject: Re: [PATCH 25/20] sysfs: Only support removing emtpy sysfs directories.
Date: Thu, 28 May 2009 18:21:44 +0000	[thread overview]
Message-ID: <1243534904.2830.13.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0905281105310.3037-100000@iolanthe.rowland.org>

On Thu, 2009-05-28 at 11:24 -0400, Alan Stern wrote:
> On Wed, 27 May 2009, James Bottomley wrote:
> 
> > Right, and I think reap_ref can be seconded to count underlying device
> > visibility.
> 
> Exactly.  It should count the number of underlying devices that have 
> not yet been removed from visibility (this may include some which still 
> have to become visible), plus one if we want to keep the target hanging 
> around for a while with no visible children (while scanning it, for 
> example).
> 
> >  However, the piece that's missing, is the fact that all of
> > this has to be tied into the host state.  If the host is running, you
> > can't remove the target from visibility even if all its children are
> > invisible because it might get another visible child added.
> 
> Are you sure about that?  It's not obvious at all to me.

Yes ... otherwise you have to elongate the DEL interval from a few ms to
potentially anything.  That would allow locking a target in a dying
state and prevent any new LUNs being added.

> For example, suppose during scanning it turns out there are no LUNs at
> a particular target address.  Why should the empty target be retained?  
> You'd end up with unusable targets at all possible bus addresses.
> 
> Besides, if a target is removed from visibility and then another child
> is added, the answer is simply to create a new target structure.  
> There's already code in scsi_alloc_target() to do this.

As I've said several times, this could be done, but we'd have to audit
the code paths to make sure we allow for multiple same targets in the
list.

> >  once it goes
> > into the cancel or del states, it can't acquire new children, so then
> > it's safe to make a target with no visible children invisible.
> 
> If you grant my point above, targets don't need to be tied into the
> host state.  They can be removed from visibility whenever the reap_ref
> counter goes to 0.  This will happen naturally while the host is in 
> the CANCEL state, thanks to scsi_forget_host().
> 
> There's another point to consider.  If you do accept my argument that 
> empty targets can be removed from visibility regardless of the host's 
> state, then this removal races with addition of a new child.  Since 
> removal involves calling device_del(), it can't be protected by the 
> host lock.  Instead we'd have to use a mutex to protect both target 
> addition and target removal.

No, this is state model 101 ... you alter the state inside the lock and
call del outside of it.  Technically you're lying about the state for
the few us it takes to run out of the lock and del the target, but
there's a papal indulgence for that.

> Since the host's scan_mutex already protects target addition, extending 
> its scope to encompass target removal (and perhaps sdev removal too) 
> seems natural.  Do you agree?

James



  parent reply	other threads:[~2009-05-28 18:21 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ac3eb2510905260927we3c748akbbcaf3f3ac1da096@mail.gmail.com>
2009-05-26 19:29 ` [PATCH 25/20] sysfs: Only support removing emtpy sysfs directories Alan Stern
2009-05-26 21:09   ` James Bottomley
2009-05-26 21:13     ` Kay Sievers
2009-05-26 21:56       ` Alan Stern
2009-05-26 22:03         ` Kay Sievers
2009-05-26 23:49           ` James Bottomley
2009-05-27  0:02             ` Kay Sievers
2009-05-27  2:17               ` Alan Stern
2009-05-27 11:35                 ` Hannes Reinecke
2009-05-27 16:01                   ` James Bottomley
2009-05-27 16:16                     ` Alan Stern
2009-05-27 16:24                       ` James Bottomley
2009-05-27 17:01                         ` Alan Stern
2009-05-27 17:08                           ` James Bottomley
2009-05-27 18:07                             ` Alan Stern
2009-05-27 19:44                               ` James Bottomley
2009-05-27 20:40                                 ` Alan Stern
2009-05-27 20:49                                   ` James Bottomley
2009-05-27 21:31                                     ` Alan Stern
2009-05-27 21:42                                       ` James Bottomley
2009-05-27 22:15                                         ` Alan Stern
2009-05-27 22:22                                           ` James Bottomley
2009-05-28 15:24                                             ` Alan Stern
2009-05-28 15:45                                               ` Eric W. Biederman
2009-05-28 17:51                                                 ` Alan Stern
2009-05-28 18:21                                               ` James Bottomley [this message]
2009-05-28 20:02                                                 ` Alan Stern
2009-05-28 20:10                                                   ` James Bottomley
2009-05-28 21:04                                                     ` Alan Stern
2009-05-29 12:32                                                       ` Hannes Reinecke
2009-05-29 20:08                                                     ` Alan Stern
2009-05-27 18:00                 ` Eric W. Biederman
2009-05-27 18:15                   ` Alan Stern
2009-05-27 18:24                     ` Eric W. Biederman
2009-05-27 21:38                       ` Alan Stern
2009-05-27 22:06                         ` Eric W. Biederman
2009-05-27 22:18                           ` Alan Stern
2009-05-26 21:39     ` Alan Stern
     [not found] <1243252896.4853.9.camel@poy>
2009-05-25 15:49 ` Alan Stern
2009-05-25 18:19   ` Kay Sievers
2009-05-25 20:14     ` 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=1243534904.2830.13.camel@localhost.localdomain \
    --to=james.bottomley@hansenpartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=cornelia.huck@de.ibm.com \
    --cc=ebiederm@aristanetworks.com \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@suse.de \
    --cc=hare@suse.de \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tj@kernel.org \
    /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