Re: [git pull] vfs and fs fixes

From: J. Bruce Fields
Date: Tue Apr 17 2012 - 20:47:07 EST


On Tue, Apr 17, 2012 at 03:08:26PM -0700, Linus Torvalds wrote:
> On Tue, Apr 17, 2012 at 2:14 PM, J. Bruce Fields <bfields@xxxxxxxxxxxx> wrote:
> > On Tue, Apr 17, 2012 at 07:28:26PM +0100, Al Viro wrote:>
> > Maybe instead I could continue using the i_mutex but handle rename some
> > other way; e.g. in delegation code:
> >
> > Â Â Â Âif (!mutex_trylock(inode->i_mutex))
> > Â Â Â Â Â Â Â Âreturn -EAGAIN;
> > Â Â Â Âif (atomic_read(inode->i_renames_in_progress))
> > Â Â Â Â Â Â Â Âreturn -EAGAIN;
> >
> > and add an
> >
> > Â Â Â Âatomic_inc(inode->i_renames_in_progress);
> > Â Â Â Âatomic_dec(inode->i_renames_in_progress);
> >
> > pair around rename.
>
> Please don't make up your own locking. Plus it's broken anyway, since
> a rename could come in directly after your atomic_read (and this is
> *why* people shouldn't make up their own locks - they are invariably
> broken).

Doh, yes, sounds like a good rule. (I was misremembering some previous
attempt at this--which admittedly may just have failed in some more
complicated way.)

--b.

> > Or I could increment that counter for all the conflicting operations and
> > rely on it instead of the i_mutex. ÂI was trying to avoid adding
> > something like that (an inc, a dec, another error path) to every
> > operation. ÂAnd hoping to avoid adding another field to struct inode.
> > Oh well.
>
> We could just say that we can do a double inode lock, but then
> standardize on the order. And the only sane order is comparing inode
> pointers, not inode numbers like ext4 apparently does.
>
> With a standard order, I don't think it would be at all wrong to just
> take the inode lock on rename.
>
> Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/