From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J. R. Okajima" Subject: Re: Q: spin_unlock(dentry) after lock_parent(dentry) Date: Thu, 05 Jun 2014 02:03:08 +0900 Message-ID: <8257.1401901388@jrobl> References: <23341.1401806215@jrobl> <20140603231712.GU18016@ZenIV.linux.org.uk> Cc: linux-fsdevel@vger.kernel.org To: Al Viro Return-path: Received: from mail01-md.ns.itscom.net ([175.177.155.111]:47226 "EHLO mail01-md.ns.itscom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752457AbaFDRDM (ORCPT ); Wed, 4 Jun 2014 13:03:12 -0400 In-Reply-To: <20140603231712.GU18016@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Al Viro: > Nope. You are misreading it. Note that in *all* cases the parent is > locked. And NULL is returned exactly in the case when that parent is ::: Thanks. Please allow me another question. In the case of concurrent dentry_kill() and shrink_dentry_list(), dentry_kill() kills the dentry and calls list_del(&dentry->d_u.d_child). lock_parent() (called by shrink_dentry_list()) doesn't check d_child nor DCACHE_DENTRY_KILLED. So shrink_dentry_list() may get a parent of a dead dentry and tries traversing via d_parent. Is it correct to track d_parent after list_del(&dentry->d_u.d_child)? Should lock_parent() consider DCACHE_DENTRY_KILLED too? --- a/fs/dcache.c +++ b/fs/dcache.c @@ -533,7 +533,8 @@ failed: static inline struct dentry *lock_parent(struct dentry *dentry) { struct dentry *parent = dentry->d_parent; - if (IS_ROOT(dentry)) + if (IS_ROOT(dentry) + || (dentry->d_flags & DCACHE_DENTRY_KILLED)) return NULL; if (likely(spin_trylock(&parent->d_lock))) return parent; J. R. Okajima