autofs misuses checks for ->d_subdirs emptiness; the cursors are in the same lists, resulting in false negatives. It's not needed anyway, since autofs maintains counter in struct autofs_info, containing 0 for removed ones, 1 for live symlinks and 1 + number of children for live directories, which is precisely what we need for those checks. This series switches to use of that counter and untangles the crap around its uses (it needs not be atomic and there's a bunch of completely pointless "defensive" checks). This fell out of dcache_readdir work; the main point is to get rid of ->d_subdirs abuses in there. I've more followup cleanups, but I hadn't run those by Ian yet, so they can go next cycle. The following changes since commit 5f68056ca50fdd3954a93ae66fea7452abddb66f: autofs_lookup(): hold ->d_lock over playing with ->d_flags (2019-07-27 10:03:14 -0400) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git next.autofs for you to fetch changes up to 850d71acd52cd331474116fbd60cf8b3f3ded93e: autofs: don't bother with atomics for ino->count (2019-09-17 23:31:27 -0400) ---------------------------------------------------------------- Al Viro (4): autofs_clear_leaf_automount_flags(): use ino->count instead of ->d_subdirs autofs: get rid of pointless checks around ->count handling autofs_dir_rmdir(): check ino->count for deciding whether it's empty... autofs: don't bother with atomics for ino->count fs/autofs/autofs_i.h | 2 +- fs/autofs/expire.c | 6 +++--- fs/autofs/root.c | 39 ++++++++++++++------------------------- 3 files changed, 18 insertions(+), 29 deletions(-)