autofs-5.1.9 - remove directory cleanup umount_multi()

From: Ian Kent <raven@themaw.net>

Mount point directories are removed at umount if needed and the map
entry cache is cleaned on map re-read so remove this from the
umount_multi() function.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG          |    1 +
 daemon/automount.c |   70 +---------------------------------------------------
 2 files changed, 2 insertions(+), 69 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 50aa7d480..b18d360dd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -97,6 +97,7 @@
 - improve local mount localion path resolution.
 - make open_mutex usage more consistent at process spawn.
 - remove mount point directory at umount if we created it.
+- remove directory cleanup umount_multi().
 
 02/11/2023 autofs-5.1.9
 - fix kernel mount status notification.
diff --git a/daemon/automount.c b/daemon/automount.c
index 05fe8ac33..83c348be4 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -490,59 +490,6 @@ int count_mounts(struct autofs_point *ap, const char *path, dev_t dev)
 	return counter.count;
 }
 
-static void check_rm_dirs(struct autofs_point *ap, const char *path, int incl)
-{
-	/*
-	 * If we're a submount the kernel can't know we're trying to
-	 * shutdown and so cannot block processes walking into the
-	 * mount point directory. If this is the call to umount_multi()
-	 * made during shutdown (incl == 0) we have to leave any mount
-	 * point directories in place so we can recover if needed. The
-	 * umount itself will clean these directories up for us
-	 * automagically.
-	 */
-	if (!incl && ap->submount)
-		return;
-
-	if ((!(ap->flags & MOUNT_FLAG_GHOST)) ||
-	    (ap->state == ST_SHUTDOWN_PENDING ||
-	     ap->state == ST_SHUTDOWN_FORCE ||
-	     ap->state == ST_SHUTDOWN))
-		rm_unwanted(ap, path, incl);
-	else if ((ap->flags & MOUNT_FLAG_GHOST) && (ap->type == LKP_INDIRECT))
-		rm_unwanted(ap, path, 0);
-}
-
-/* Try to purge cache entries kept around due to existing mounts */
-static void update_map_cache(struct autofs_point *ap, const char *path)
-{
-	struct map_source *map;
-	struct mapent_cache *mc;
-	const char *key;
-
-	if (ap->type == LKP_INDIRECT)
-		key = strrchr(path, '/') + 1;
-	else
-		key = path;
-
-	map = ap->entry->maps;
-	while (map) {
-		struct mapent *me = NULL;
-
-		mc = map->mc;
-		cache_writelock(mc);
-		me = cache_lookup_distinct(mc, key);
-		/* Only for invalid map entries */
-		if (me && map->age > me->age)
-			cache_delete(mc, key);
-		cache_unlock(mc);
-
-		map = map->next;
-	}
-
-	return;
-}
-
 static int umount_subtree_mounts(struct autofs_point *ap, const char *path, unsigned int is_autofs_fs)
 {
 	struct mapent_cache *mc;
@@ -651,7 +598,6 @@ int umount_multi(struct autofs_point *ap, const char *path, int incl)
 	struct mnt_list *sbmnt;
 	int is_autofs_fs;
 	struct stat st;
-	int left;
 
 	debug(ap->logopt, "path %s incl %d", path, incl);
 
@@ -719,21 +665,7 @@ int umount_multi(struct autofs_point *ap, const char *path, int incl)
 		mnts_put_mount(sbmnt);
 	}
 
-	left = umount_subtree_mounts(ap, path, is_autofs_fs);
-
-	/* Delete detritus like unwanted mountpoints and symlinks
-	 * for indirect mounts. This can't be done for direct mounts
-	 * here because there's an ioctl file handle open on the
-	 * autofs trigger mount for them so it must be done after
-	 * the expire.
-	 */
-	if (ap->type == LKP_INDIRECT &&
-	    ap->state != ST_READMAP && left == 0) {
-		update_map_cache(ap, path);
-		check_rm_dirs(ap, path, incl);
-	}
-
-	return left;
+	return umount_subtree_mounts(ap, path, is_autofs_fs);
 }
 
 static void umount_all(struct autofs_point *ap)
