From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J. Bruce Fields" Subject: Re: [git pull] vfs and fs fixes Date: Tue, 17 Apr 2012 20:47:06 -0400 Message-ID: <20120418004706.GA1924@fieldses.org> References: <20120417052511.GU6589@ZenIV.linux.org.uk> <20120417180129.GW6589@ZenIV.linux.org.uk> <20120417182825.GX6589@ZenIV.linux.org.uk> <20120417211419.GC27426@fieldses.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Al Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Linus Torvalds Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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 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: > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!mutex_trylock(inode->i_mutex)) > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -EAGA= IN; > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (atomic_read(inode->i_renames_in_prog= ress)) > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -EAGA= IN; > > > > and add an > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0atomic_inc(inode->i_renames_in_progress)= ; > > =C2=A0 =C2=A0 =C2=A0 =C2=A0atomic_dec(inode->i_renames_in_progress)= ; > > > > pair around rename. >=20 > 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 operation= s and > > rely on it instead of the i_mutex. =C2=A0I was trying to avoid addi= ng > > something like that (an inc, a dec, another error path) to every > > operation. =C2=A0And hoping to avoid adding another field to struct= inode. > > Oh well. >=20 > 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. >=20 > With a standard order, I don't think it would be at all wrong to just > take the inode lock on rename. >=20 > Linus