From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 In-Reply-To: <20180223201317.GG30522@ZenIV.linux.org.uk> References: <20180222235025.28662-1-john.ogness@linutronix.de> <20180222235025.28662-7-john.ogness@linutronix.de> <20180223035814.GZ30522@ZenIV.linux.org.uk> <20180223040814.GA30522@ZenIV.linux.org.uk> <87h8q7erlo.fsf@linutronix.de> <20180223150928.GC30522@ZenIV.linux.org.uk> <20180223174216.GD30522@ZenIV.linux.org.uk> <20180223201317.GG30522@ZenIV.linux.org.uk> From: Linus Torvalds Date: Fri, 23 Feb 2018 13:35:52 -0800 Message-ID: Subject: Re: [BUG] lock_parent() breakage when used from shrink_dentry_list() (was Re: [PATCH v2 6/6] fs/dcache: Avoid remaining try_lock loop in shrink_dentry_list()) To: Al Viro Cc: linux-fsdevel , Christoph Hellwig , Thomas Gleixner , Peter Zijlstra , Sebastian Andrzej Siewior , Linux Kernel Mailing List , John Ogness Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: On Fri, Feb 23, 2018 at 12:13 PM, Al Viro wrote: > Look: > dentry placed on a shrink list > we pick the fucker from the list and lock it. > we call lock_parent() on it. > dentry is not a root and it's not deleted, so we proceed. > trylock fails. > we grab rcu_read_lock() > we drop dentry->d_lock [ deleted the bad things ] Should we just instead get the ref to the dentry before dropping the lock, so that nobody else can get to dentry_kill? This is too subtle, and your fix to check d_lockref.count < 0 sounds wrong to me. If it's really gone, maybe it has been reused and the refcount is positive again, but it's something else than a dentry entirely? Hmm. No, you extended the rcu read section, so I guess your patch is fine. And lock_parent already has that pattern, soiit's not new. Ok, I agree, looks like lock_parent should just re-check that thing that it already checked earler, but that now might be true again because of we dropped d_lock. Linus