On Wed, May 28, 2014 at 11:39 AM, Al Viro wrote: > > OK, the warnings about averting your eyes very much apply; the thing below > definitely needs more massage before it becomes acceptable I've been looking at the this too, and I have to say, I absolutely hate your DCACHE_MAY_FREE logic. It makes it really hard to follow what the heck is happening across threads. So just to understand the code, how about this (UNTESTED!) patch? It gets rid of the DCACHE_MAY_FREE logic entirely, and makes the rules imho much more straightforward: - whoever calls "dentry_kill()" first is the one that frees things. - dentry_kill() does *not* touch the shrink list at all. In fact, *nothing* touches the shrink list, except for the shrinker. - the shrinkers remove entries from their own lists - the shrinker list logic depends on the actual freeing of the dentry to be delayed until the RCU grace period (already true for RCU-lookup dentries) In other words, that whole "may-free" thing goes away, the whole shrink-list locking issues go away, there are no subtle rules. Nobody else ever touches the shrink-list entries than the entity walking the shrink-lists. Once DCACHE_SHRINK_LIST is set, nobody else is It does require that the dentry shrinking code always hold the RCU lock for reading, because others may actually be doing the final dput() while the thing is on the shrinking list (and holding the RCU lock is what protects the entry from actually being free'd). NOTE! I don't claim that this fixes anything, but I do think that it makes that whole cross-thread complexity of that DCACHE_MAY_FREE go away. I think it's easier to understand, and it removes code in the process. Comments? Linus