lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 9 Mar 2010 14:22:38 -0500
From:	Valerie Aurora <vaurora@...hat.com>
To:	Miklos Szeredi <miklos@...redi.hu>
Cc:	jblunck@...e.de, viro@...iv.linux.org.uk, hch@...radead.org,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/6] union-mount: Drive the union cache via dcache

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists