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

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