Blame SOURCES/autofs-5.1.5-dont-use-tree_is_mounted-for-mounted-checks.patch

8fa62f
autofs-5.1.5 - don't use tree_is_mounted() for mounted checks
8fa62f
8fa62f
From: Ian Kent <raven@themaw.net>
8fa62f
8fa62f
Always use is_mounted() for mounted checks.
8fa62f
8fa62f
If the proc mount table actually needs to be used this could be
8fa62f
very inefficient but the miscelaneous device ioctl interface
8fa62f
has been available to quite a few years now so it really needs
8fa62f
to be used to avoid the scanning of mount tables.
8fa62f
8fa62f
Signed-off-by: Ian Kent <raven@themaw.net>
8fa62f
---
8fa62f
 CHANGELOG           |    1 +
8fa62f
 daemon/direct.c     |   12 ++++--------
8fa62f
 daemon/state.c      |    4 ++--
8fa62f
 include/automount.h |    2 +-
8fa62f
 include/mounts.h    |    1 -
8fa62f
 lib/mounts.c        |   40 ----------------------------------------
8fa62f
 6 files changed, 8 insertions(+), 52 deletions(-)
8fa62f
8fa62f
--- autofs-5.1.4.orig/CHANGELOG
8fa62f
+++ autofs-5.1.4/CHANGELOG
8fa62f
@@ -69,6 +69,7 @@ xx/xx/2018 autofs-5.1.5
8fa62f
 - add glibc getmntent_r().
8fa62f
 - use local getmntent_r in table_is_mounted().
8fa62f
 - refactor unlink_active_mounts() in direct.c.
8fa62f
+- don't use tree_is_mounted() for mounted checks.
8fa62f
 
8fa62f
 19/12/2017 autofs-5.1.4
8fa62f
 - fix spec file url.
8fa62f
--- autofs-5.1.4.orig/daemon/direct.c
8fa62f
+++ autofs-5.1.4/daemon/direct.c
8fa62f
@@ -82,7 +82,7 @@ static void mnts_cleanup(void *arg)
8fa62f
 	return;
8fa62f
 }
8fa62f
 
8fa62f
-int do_umount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me)
8fa62f
+int do_umount_autofs_direct(struct autofs_point *ap, struct mapent *me)
8fa62f
 {
8fa62f
 	struct ioctl_ops *ops = get_ioctl_ops();
8fa62f
 	char buf[MAX_ERR_BUF];
8fa62f
@@ -98,7 +98,7 @@ int do_umount_autofs_direct(struct autof
8fa62f
 
8fa62f
 	if (me->ioctlfd != -1) {
8fa62f
 		if (ap->state == ST_READMAP &&
8fa62f
-		    tree_is_mounted(mnts, me->key, MNTS_REAL)) {
8fa62f
+		    is_mounted(me->key, MNTS_REAL)) {
8fa62f
 			error(ap->logopt,
8fa62f
 			      "attempt to umount busy direct mount %s",
8fa62f
 			      me->key);
8fa62f
@@ -204,11 +204,8 @@ int umount_autofs_direct(struct autofs_p
8fa62f
 {
8fa62f
 	struct map_source *map;
8fa62f
 	struct mapent_cache *nc, *mc;
8fa62f
-	struct mnt_list *mnts;
8fa62f
 	struct mapent *me, *ne;
8fa62f
 
8fa62f
-	mnts = tree_make_mnt_tree("/");
8fa62f
-	pthread_cleanup_push(mnts_cleanup, mnts);
8fa62f
 	nc = ap->entry->master->nc;
8fa62f
 	cache_readlock(nc);
8fa62f
 	pthread_cleanup_push(cache_lock_cleanup, nc);
8fa62f
@@ -233,7 +230,7 @@ int umount_autofs_direct(struct autofs_p
8fa62f
 			 * catatonic regardless of the reason for the
8fa62f
 			 * failed umount.
8fa62f
 			 */
8fa62f
-			error = do_umount_autofs_direct(ap, mnts, me);
8fa62f
+			error = do_umount_autofs_direct(ap, me);
8fa62f
 			if (!error)
8fa62f
 				goto done;
8fa62f
 
8fa62f
@@ -246,7 +243,6 @@ done:
8fa62f
 		map = map->next;
8fa62f
 	}
8fa62f
 	pthread_cleanup_pop(1);
8fa62f
-	pthread_cleanup_pop(1);
8fa62f
 
8fa62f
 	close(ap->state_pipe[0]);
8fa62f
 	close(ap->state_pipe[1]);
8fa62f
@@ -947,7 +943,7 @@ void *expire_proc_direct(void *arg)
8fa62f
 			}
8fa62f
 
8fa62f
 			/* It's got a mount, deal with in the outer loop */
8fa62f
-			if (tree_is_mounted(mnts, me->key, MNTS_REAL)) {
8fa62f
+			if (is_mounted(me->key, MNTS_REAL)) {
8fa62f
 				pthread_setcancelstate(cur_state, NULL);
8fa62f
 				continue;
8fa62f
 			}
8fa62f
--- autofs-5.1.4.orig/daemon/state.c
8fa62f
+++ autofs-5.1.4/daemon/state.c
8fa62f
@@ -438,8 +438,8 @@ static void do_readmap_mount(struct auto
8fa62f
 				else
8fa62f
 					ap->exp_runfreq = runfreq;
8fa62f
 			}
8fa62f
-		} else if (!tree_is_mounted(mnts, me->key, MNTS_REAL))
8fa62f
-			do_umount_autofs_direct(ap, mnts, me);
8fa62f
+		} else if (!is_mounted(me->key, MNTS_REAL))
8fa62f
+			do_umount_autofs_direct(ap, me);
8fa62f
 		else
8fa62f
 			debug(ap->logopt,
8fa62f
 			      "%s is mounted", me->key);
8fa62f
--- autofs-5.1.4.orig/include/automount.h
8fa62f
+++ autofs-5.1.4/include/automount.h
8fa62f
@@ -613,7 +613,7 @@ void submount_signal_parent(struct autof
8fa62f
 void close_mount_fds(struct autofs_point *ap);
8fa62f
 int umount_autofs(struct autofs_point *ap, const char *root, int force);
8fa62f
 int umount_autofs_indirect(struct autofs_point *ap, const char *root);
8fa62f
-int do_umount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me);
8fa62f
+int do_umount_autofs_direct(struct autofs_point *ap, struct mapent *me);
8fa62f
 int umount_autofs_direct(struct autofs_point *ap);
8fa62f
 int umount_autofs_offset(struct autofs_point *ap, struct mapent *me);
8fa62f
 int handle_packet_expire_indirect(struct autofs_point *ap, autofs_packet_expire_indirect_t *pkt);
8fa62f
--- autofs-5.1.4.orig/include/mounts.h
8fa62f
+++ autofs-5.1.4/include/mounts.h
8fa62f
@@ -107,7 +107,6 @@ struct mnt_list *tree_make_mnt_tree(cons
8fa62f
 int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include);
8fa62f
 int tree_get_mnt_sublist(struct mnt_list *mnts, struct list_head *list, const char *path, int include);
8fa62f
 int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char *path);
8fa62f
-int tree_is_mounted(struct mnt_list *mnts, const char *path, unsigned int type);
8fa62f
 void set_tsd_user_vars(unsigned int, uid_t, gid_t);
8fa62f
 const char *mount_type_str(unsigned int);
8fa62f
 void set_exp_timeout(struct autofs_point *ap, struct map_source *source, time_t timeout);
8fa62f
--- autofs-5.1.4.orig/lib/mounts.c
8fa62f
+++ autofs-5.1.4/lib/mounts.c
8fa62f
@@ -1368,46 +1368,6 @@ int tree_find_mnt_ents(struct mnt_list *
8fa62f
 	return 0;
8fa62f
 }
8fa62f
 
8fa62f
-int tree_is_mounted(struct mnt_list *mnts, const char *path, unsigned int type)
8fa62f
-{
8fa62f
-	struct ioctl_ops *ops = get_ioctl_ops();
8fa62f
-	struct list_head *p;
8fa62f
-	struct list_head list;
8fa62f
-	int mounted = 0;
8fa62f
-
8fa62f
-	if (ops->ismountpoint)
8fa62f
-		return ioctl_is_mounted(path, type);
8fa62f
-
8fa62f
-	INIT_LIST_HEAD(&list);
8fa62f
-
8fa62f
-	if (!tree_find_mnt_ents(mnts, &list, path))
8fa62f
-		return 0;
8fa62f
-
8fa62f
-	list_for_each(p, &list) {
8fa62f
-		struct mnt_list *mptr;
8fa62f
-
8fa62f
-		mptr = list_entry(p, struct mnt_list, entries);
8fa62f
-
8fa62f
-		if (type) {
8fa62f
-			if (type & MNTS_REAL) {
8fa62f
-				if (mptr->flags & MNTS_AUTOFS) {
8fa62f
-					mounted = 1;
8fa62f
-					break;
8fa62f
-				}
8fa62f
-			} else if (type & MNTS_AUTOFS) {
8fa62f
-				if (mptr->flags & MNTS_AUTOFS) {
8fa62f
-					mounted = 1;
8fa62f
-					break;
8fa62f
-				}
8fa62f
-			} else {
8fa62f
-				mounted = 1;
8fa62f
-				break;
8fa62f
-			}
8fa62f
-		}
8fa62f
-	}
8fa62f
-	return mounted;
8fa62f
-}
8fa62f
-
8fa62f
 void set_tsd_user_vars(unsigned int logopt, uid_t uid, gid_t gid)
8fa62f
 {
8fa62f
 	struct thread_stdenv_vars *tsv;