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

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