On Sun, May 27, 2018 at 08:14:30PM -0600, Andreas Dilger wrote: > > if (!(flags & RENAME_EXCHANGE) && target) { > > - if (is_dir) > > + if (is_dir) { > > + shrink_dcache_parent(new_dentry); > > target->i_flags |= S_DEAD; > > Would it be better to set S_DEAD on the removed directory before > shrink_dcache_parent() is called (here and in vfs_rmdir()), or is > there no way for a new dentry to be added to the parent after the > shrink is done? It's locked (exclusive). Lookups (as well as readdir preseeding of dcache in case of filesystems that do it) are under the same lock held at least shared. The same goes for all IS_DEADDIR callers - exact same locking is used for S_DEAD handling as well. So the order really doesn't matter here.