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

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