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

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