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

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