linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Valerie Aurora <vaurora@redhat.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: jblunck@suse.de, viro@zeniv.linux.org.uk, hch@infradead.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/6] union-mount: Drive the union cache via dcache
Date: Tue, 9 Mar 2010 14:22:38 -0500	[thread overview]
Message-ID: <20100309192237.GA10605@shell> (raw)
In-Reply-To: <E1NnE05-00069x-VI@pomaz-ex.szeredi.hu>

On Thu, Mar 04, 2010 at 05:34:13PM +0100, Miklos Szeredi wrote:
> On Wed, 3 Mar 2010, Valerie Aurora wrote:
> > On Wed, Mar 03, 2010 at 06:35:55PM +0100, Miklos Szeredi wrote:
> > > On Tue,  2 Mar 2010, Valerie Aurora wrote:
> > > > +/*
> > > > + * This must be called after __d_drop_unions() without holding any locks.
> > > > + * Note: The dentry might still be reachable via a lookup but at that time it
> > > > + * already a negative dentry. Otherwise it would be unhashed. The union_mount
> > > > + * structure itself is still reachable through mnt->mnt_unions (which we
> > > > + * protect against with union_lock).
> > > > + *
> > > > + * We were worried about a recursive dput() call through:
> > > > + *
> > > > + * dput()->d_kill()->shrink_d_unions()->union_put()->dput()
> > > > + *
> > > > + * But this path can only be reached if the dentry is unhashed when we
> > > > + * enter the first dput(), and it can only be unhashed if it was
> > > > + * rmdir()'d, and d_delete() calls shrink_d_unions() for us.
> > > > + */
> > > > +void shrink_d_unions(struct dentry *dentry)
> > > > +{
> > > > +	struct union_mount *this, *next;
> > > > +
> > > > +repeat:
> > > > +	spin_lock(&union_lock);
> > > > +	list_for_each_entry_safe(this, next, &dentry->d_unions, u_unions) {
> > > > +		BUG_ON(!hlist_unhashed(&this->u_hash));
> > > > +		BUG_ON(!hlist_unhashed(&this->u_rhash));
> > > > +		list_del(&this->u_unions);
> > > > +		this->u_next.dentry->d_unionized--;
> > > > +		spin_unlock(&union_lock);
> > > > +		union_put(this);
> > > > +		goto repeat;
> > > 
> > > This loop is weird.  That list_for_each_entry_safe is just used to
> > > initialize "this", since it unconditionally restarts from the
> > > beginning.
> > 
> > This loop is definitely weird, but the alternative is so simple
> > (replace the goto with a spin_lock()) that I suspect Jan had a reason
> > to write it this way.  Jan, do you recall?
> 
> Something like the following is equivalent but more readable:
> 
> 	struct list_head *head = &dentry->d_unions;
> 
> 	spin_lock(&union_lock);
> 	while (!list_empty(head) {
> 		this = list_entry(head->next, struct union_mount, u_unions);
> 		...
> 		spin_unlock(&union_lock);
> 		union_put(this);
> 		spin_lock(&union_lock);
> 	}
> 	spin_unlock(&union_lock);

Okay, I will rewrite it along those lines.  Thanks,

-VAL

  reply	other threads:[~2010-03-09 19:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-02 22:11 [RFC PATCH 0/6] Union mount core rewrite v1 Valerie Aurora
2010-03-02 22:11 ` [PATCH 1/6] union-mount: Introduce union_mount structure and basic operations Valerie Aurora
2010-03-02 22:11   ` [PATCH 2/6] union-mount: Drive the union cache via dcache Valerie Aurora
2010-03-02 22:11     ` [PATCH 3/6] union-mount: Implement union lookup Valerie Aurora
2010-03-02 22:11       ` [PATCH 4/6] union-mount: Support for mounting union mount file systems Valerie Aurora
2010-03-02 22:11         ` [PATCH 5/6] union-mount: Call do_whiteout() on unlink and rmdir in unions Valerie Aurora
2010-03-02 22:11           ` [PATCH 6/6] union-mount: Copy up directory entries on first readdir() Valerie Aurora
2010-03-03 21:53             ` Multiple read-only layers in union mounts (was Re: [PATCH 6/6] union-mount: Copy up directory entries on first readdir()) Valerie Aurora
2010-03-03 17:35     ` [PATCH 2/6] union-mount: Drive the union cache via dcache Miklos Szeredi
2010-03-03 21:49       ` Valerie Aurora
2010-03-04 16:34         ` Miklos Szeredi
2010-03-09 19:22           ` Valerie Aurora [this message]
2010-03-03 17:33   ` [PATCH 1/6] union-mount: Introduce union_mount structure and basic operations Miklos Szeredi
2010-03-03 20:45     ` Valerie Aurora
2010-03-04 16:24       ` Miklos Szeredi
2010-03-09 19:49         ` Valerie Aurora
2010-03-03 17:28 ` [RFC PATCH 0/6] Union mount core rewrite v1 Miklos Szeredi
2010-03-03 20:31   ` Valerie Aurora

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=20100309192237.GA10605@shell \
    --to=vaurora@redhat.com \
    --cc=hch@infradead.org \
    --cc=jblunck@suse.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).