rpms/autofs/F-11 autofs-5.0.4-always-read-file-maps-key-lookup-fixes.patch, NONE, 1.1 autofs-5.0.4-always-read-file-maps-multi-map-fix.patch, NONE, 1.1 autofs-5.0.4-dont-umount-existing-direct-mount-on-reread.patch, NONE, 1.1 autofs-5.0.4-fix-kernel-includes.patch, NONE, 1.1 autofs-5.0.4-improve-manual-umount-recovery.patch, NONE, 1.1 autofs-5.0.4-library-reload-fix-update-fix.patch, NONE, 1.1 autofs-5.0.4-use-intr-as-hosts-mount-default.patch, NONE, 1.1 autofs-5.0.4-dont-fail-on-ipv6-address-adding-host.patch, 1.1, 1.2 autofs.spec, 1.282, 1.283

Ian Kent iankent at fedoraproject.org
Mon May 18 02:59:16 UTC 2009


Author: iankent

Update of /cvs/pkgs/rpms/autofs/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26420

Modified Files:
	autofs-5.0.4-dont-fail-on-ipv6-address-adding-host.patch 
	autofs.spec 
Added Files:
	autofs-5.0.4-always-read-file-maps-key-lookup-fixes.patch 
	autofs-5.0.4-always-read-file-maps-multi-map-fix.patch 
	autofs-5.0.4-dont-umount-existing-direct-mount-on-reread.patch 
	autofs-5.0.4-fix-kernel-includes.patch 
	autofs-5.0.4-improve-manual-umount-recovery.patch 
	autofs-5.0.4-library-reload-fix-update-fix.patch 
	autofs-5.0.4-use-intr-as-hosts-mount-default.patch 
Log Message:
* Mon May 18 2009 Ian Kent <ikent at redhat.com> - 1:5.0.4-29
- use intr option as hosts mount default.
- sync kernel includes with upstream kernel.
- dont umount existing direct mount on master re-read.
- fix incorrect shutdown introduced by library relaod fixes.
- improve manual umount recovery.
- always read file maps multi map fix.
- always read file maps key lookup fixes.


autofs-5.0.4-always-read-file-maps-key-lookup-fixes.patch:

--- NEW FILE autofs-5.0.4-always-read-file-maps-key-lookup-fixes.patch ---
autofs-5.0.4 - always read file maps key lookup fixes

From: Ian Kent <raven at themaw.net>

Since we always read file maps at start we need to ensure that
we return a not found if the key isn't found in the cache. Also,
if we're looking through a "multi" map we can't use the cache
lookup optimisation because, in this case, there is a single map
source shared by the "multi" maps so we may not get correct results
from the lookup if a map later in the search has been modified.
---

 CHANGELOG             |    1 +
 modules/lookup_file.c |   17 +++++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index 972ef63..5000f0c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -48,6 +48,7 @@
 - improve manual umount recovery.
 - dont fail on ipv6 address when adding host.
 - always read file maps multi map fix.
+- always read file maps key lookup fixes.
 
 4/11/2008 autofs-5.0.4
 -----------------------
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
index bd30bc5..a4ca39d 100644
--- a/modules/lookup_file.c
+++ b/modules/lookup_file.c
@@ -1003,13 +1003,15 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
 			 * If any map instances are present for this source
 			 * then either we have plus included entries or we
 			 * are looking through the list of nsswitch sources.
-			 * In either case we cannot avoid reading through the
-			 * map because we must preserve the key order over
-			 * multiple sources. But also, we can't know, at this
-			 * point, if a source instance has been changed since
-			 * the last time we checked it.
+			 * In either case, or if it's a "multi" source, we
+			 * cannot avoid reading through the map because we
+			 * must preserve the key order over multiple sources
+			 * or maps. But also, we can't know, at this point,
+			 * if a source instance has been changed since the
+			 * last time we checked it.
 			 */
-			if (!source->instance)
+			if (!source->instance &&
+			    source->type && strcmp(source->type, "multi"))
 				goto do_cache_lookup;
 		} else
 			source->stale = 1;
@@ -1055,6 +1057,9 @@ do_cache_lookup:
 	}
 	cache_unlock(mc);
 
+	if (!me)
+		return NSS_STATUS_NOTFOUND;
+
 	if (!mapent)
 		return NSS_STATUS_TRYAGAIN;
 

autofs-5.0.4-always-read-file-maps-multi-map-fix.patch:

--- NEW FILE autofs-5.0.4-always-read-file-maps-multi-map-fix.patch ---
autofs-5.0.4 - always read file maps multi map fix

From: Ian Kent <raven at themaw.net>

Since "multi" map entries may contain file maps themselves and we
always want to read file maps we need to move the chack of whether
to read the map from lookup_nss_read_map() into the individual
map type lookup modules.
---

 CHANGELOG                |    1 +
 daemon/lookup.c          |   14 --------------
 modules/lookup_hosts.c   |    8 ++++++++
 modules/lookup_ldap.c    |    8 ++++++++
 modules/lookup_nisplus.c |    8 ++++++++
 modules/lookup_yp.c      |    8 ++++++++
 6 files changed, 33 insertions(+), 14 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index 7e1012f..972ef63 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -47,6 +47,7 @@
 - fix incorrect shutdown introduced by library relaod fixes.
 - improve manual umount recovery.
 - dont fail on ipv6 address when adding host.
+- always read file maps multi map fix.
 
 4/11/2008 autofs-5.0.4
 -----------------------
diff --git a/daemon/lookup.c b/daemon/lookup.c
index bc94655..9d5a5c8 100644
--- a/daemon/lookup.c
+++ b/daemon/lookup.c
@@ -278,20 +278,6 @@ static int do_read_map(struct autofs_point *ap, struct map_source *map, time_t a
 	map->lookup = lookup;
 	master_source_unlock(ap->entry);
 
-	/* If we don't need to create directories then there's no use
-	 * reading the map. We just need to test that the map is valid
-	 * for the fail cases to function correctly and to cache the
-	 * lookup handle.
-	 *
-	 * We always need to read the whole map for direct mounts in
-	 * order to mount the triggers. We also want to read the whole
-	 * map if it's a file map to avoid potentially lengthy linear
-	 * file scanning.
-	 */
-	if (strcmp(map->type, "file") &&
-	    !(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT)
-		return NSS_STATUS_SUCCESS;
-
 	if (!map->stale)
 		return NSS_STATUS_SUCCESS;
 
diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c
index d3ae0e2..a213780 100644
--- a/modules/lookup_hosts.c
+++ b/modules/lookup_hosts.c
@@ -89,6 +89,14 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
 	ap->entry->current = NULL;
 	master_source_current_signal(ap->entry);
 
+	/*
+	 * If we don't need to create directories then there's no use
+	 * reading the map. We always need to read the whole map for
+	 * direct mounts in order to mount the triggers.
+	 */
+	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT)
+		return NSS_STATUS_SUCCESS;
+
 	mc = source->mc;
 
 	status = pthread_mutex_lock(&hostent_mutex);
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 8c6a8f2..a847622 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -2236,6 +2236,14 @@ static int read_one_map(struct autofs_point *ap,
 	ap->entry->current = NULL;
 	master_source_current_signal(ap->entry);
 
+	/*
+	 * If we don't need to create directories then there's no use
+	 * reading the map. We always need to read the whole map for
+	 * direct mounts in order to mount the triggers.
+	 */
+	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT)
+		return NSS_STATUS_SUCCESS;
+
 	sp.ap = ap;
 	sp.age = age;
 
diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
index 0c75905..ae53481 100644
--- a/modules/lookup_nisplus.c
+++ b/modules/lookup_nisplus.c
@@ -180,6 +180,14 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
 	ap->entry->current = NULL;
 	master_source_current_signal(ap->entry);
 
+	/*
+	 * If we don't need to create directories then there's no use
+	 * reading the map. We always need to read the whole map for
+	 * direct mounts in order to mount the triggers.
+	 */
+	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT)
+		return NSS_STATUS_SUCCESS;
+
 	mc = source->mc;
 
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
index ce438e8..208f95e 100644
--- a/modules/lookup_yp.c
+++ b/modules/lookup_yp.c
@@ -322,6 +322,14 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
 	ap->entry->current = NULL;
 	master_source_current_signal(ap->entry);
 
+	/*
+	 * If we don't need to create directories then there's no use
+	 * reading the map. We always need to read the whole map for
+	 * direct mounts in order to mount the triggers.
+	 */
+	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT)
+		return NSS_STATUS_SUCCESS;
+
 	ypcb_data.ap = ap;
 	ypcb_data.source = source;
 	ypcb_data.logopt = logopt;

autofs-5.0.4-dont-umount-existing-direct-mount-on-reread.patch:

--- NEW FILE autofs-5.0.4-dont-umount-existing-direct-mount-on-reread.patch ---
autofs-5.0.4 - dont umount existing direct mount on master re-read

From: Ian Kent <raven at themaw.net>

Since direct mounts can have multiple entries in the master map they each
have an instance associated with them. If one entry changes, such as the
mount options, the instance comparison test fails and a new instance is
added. This causes autofs to get confused because there are now two
entries that contain the same mount information in different internal
caches. There are several consequences of this, most of which are just
noise in the log, but it also causes confuion for the expiration of mounts
since, for an active mount, the old cache entry can't be pruned until it's
umounted. Also, the map caches were not being properly pruned.
---

 CHANGELOG           |    1 
 daemon/lookup.c     |  160 ++++++++++++++++++++++++++++-----------------------
 daemon/state.c      |   90 +++++++++++++++++++++--------
 include/automount.h |    1 
 4 files changed, 156 insertions(+), 96 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index 387af5e..7ca45fd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -43,6 +43,7 @@
 - use percent hack for master map keys.
 - use intr option as hosts mount default.
 - fix kernel includes.
+- dont umount existing direct mount on master re-read.
 
 4/11/2008 autofs-5.0.4
 -----------------------
diff --git a/daemon/lookup.c b/daemon/lookup.c
index fd2ce55..bc94655 100644
--- a/daemon/lookup.c
+++ b/daemon/lookup.c
@@ -1016,96 +1016,114 @@ static char *make_fullpath(const char *root, const char *key)
 	return path;
 }
 
-int lookup_prune_cache(struct autofs_point *ap, time_t age)
+void lookup_prune_one_cache(struct autofs_point *ap, struct mapent_cache *mc, time_t age)
 {
-	struct master_mapent *entry = ap->entry;
-	struct map_source *map;
-	struct mapent_cache *mc;
 	struct mapent *me, *this;
 	char *path;
 	int status = CHE_FAIL;
 
-	pthread_cleanup_push(master_source_lock_cleanup, entry);
-	master_source_readlock(entry);
+	me = cache_enumerate(mc, NULL);
+	while (me) {
+		struct mapent *valid;
+		char *key = NULL, *next_key = NULL;
 
-	map = entry->maps;
-	while (map) {
-		/* Is the map stale */
-		if (!map->stale) {
-			map = map->next;
+		if (me->age >= age) {
+			me = cache_enumerate(mc, me);
 			continue;
 		}
-		mc = map->mc;
-		pthread_cleanup_push(cache_lock_cleanup, mc);
-		cache_readlock(mc);
-		me = cache_enumerate(mc, NULL);
-		while (me) {
-			char *key = NULL, *next_key = NULL;
 
-			if (me->age >= age) {
-				me = cache_enumerate(mc, me);
-				continue;
-			}
+		key = strdup(me->key);
+		me = cache_enumerate(mc, me);
+		if (!key || *key == '*') {
+			if (key)
+				free(key);
+			continue;
+		}
 
-			key = strdup(me->key);
-			me = cache_enumerate(mc, me);
-			if (!key || *key == '*') {
-				if (key)
-					free(key);
-				continue;
-			}
+		path = make_fullpath(ap->path, key);
+		if (!path) {
+			warn(ap->logopt, "can't malloc storage for path");
+			free(key);
+			continue;
+		}
 
-			path = make_fullpath(ap->path, key);
-			if (!path) {
-				warn(ap->logopt,
-				     "can't malloc storage for path");
-				free(key);
-				continue;
-			}
+		/*
+		 * If this key has another valid entry we want to prune it,
+		 * even if it's a mount, as the valid entry will take the
+		 * mount if it is a direct mount or it's just a stale indirect
+		 * cache entry.
+		 */
+		valid = lookup_source_valid_mapent(ap, key, LKP_DISTINCT);
+		if (!valid &&
+		    is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) {
+			debug(ap->logopt,
+			      "prune check posponed, %s mounted", path);
+			free(key);
+			free(path);
+			continue;
+		}
+		if (valid)
+			cache_unlock(valid->mc);
 
-			if (is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) {
-				debug(ap->logopt,
-				      "prune check posponed, %s mounted", path);
-				free(key);
-				free(path);
-				continue;
-			}
+		if (me)
+			next_key = strdup(me->key);
 
-			if (me)
-				next_key = strdup(me->key);
+		cache_unlock(mc);
 
+		cache_writelock(mc);
+		this = cache_lookup_distinct(mc, key);
+		if (!this) {
 			cache_unlock(mc);
+			goto next;
+		}
 
-			cache_writelock(mc);
-			this = cache_lookup_distinct(mc, key);
-			if (!this) {
-				cache_unlock(mc);
-				goto next;
-			}
-
-			if (!is_mounted(_PROC_MOUNTS, path, MNTS_AUTOFS)) {
-				status = CHE_FAIL;
-				if (this->ioctlfd == -1)
-					status = cache_delete(mc, key);
-				if (status != CHE_FAIL) {
-					if (ap->type == LKP_INDIRECT) {
-						if (ap->flags & MOUNT_FLAG_GHOST)
-							rmdir_path(ap, path, ap->dev);
-					} else
-						rmdir_path(ap, path, this->dev);
-				}
+		if (valid)
+			cache_delete(mc, key);
+		else if (!is_mounted(_PROC_MOUNTS, path, MNTS_AUTOFS)) {
+			status = CHE_FAIL;
+			if (this->ioctlfd == -1)
+				status = cache_delete(mc, key);
+			if (status != CHE_FAIL) {
+				if (ap->type == LKP_INDIRECT) {
+					if (ap->flags & MOUNT_FLAG_GHOST)
+						rmdir_path(ap, path, ap->dev);
+				} else
+					rmdir_path(ap, path, this->dev);
 			}
-			cache_unlock(mc);
+		}
+		cache_unlock(mc);
 
 next:
-			cache_readlock(mc);
-			if (next_key) {
-				me = cache_lookup_distinct(mc, next_key);
-				free(next_key);
-			}
-			free(key);
-			free(path);
+		cache_readlock(mc);
+		if (next_key) {
+			me = cache_lookup_distinct(mc, next_key);
+			free(next_key);
 		}
+		free(key);
+		free(path);
+	}
+
+	return;
+}
+
+int lookup_prune_cache(struct autofs_point *ap, time_t age)
+{
+	struct master_mapent *entry = ap->entry;
+	struct map_source *map;
+
+	pthread_cleanup_push(master_source_lock_cleanup, entry);
+	master_source_readlock(entry);
+
+	map = entry->maps;
+	while (map) {
+		/* Is the map stale */
+		if (!map->stale) {
+			map = map->next;
+			continue;
+		}
+		pthread_cleanup_push(cache_lock_cleanup, map->mc);
+		cache_readlock(map->mc);
+		lookup_prune_one_cache(ap, map->mc, age);
 		pthread_cleanup_pop(1);
 		map->stale = 0;
 		map = map->next;
@@ -1124,7 +1142,6 @@ struct mapent *lookup_source_valid_mapent(struct autofs_point *ap, const char *k
 	struct mapent_cache *mc;
 	struct mapent *me = NULL;
 
-	master_source_readlock(entry);
 	map = entry->maps;
 	while (map) {
 		/*
@@ -1147,7 +1164,6 @@ struct mapent *lookup_source_valid_mapent(struct autofs_point *ap, const char *k
 		cache_unlock(mc);
 		map = map->next;
 	}
-	master_source_unlock(entry);
 
 	return me;
 }
diff --git a/daemon/state.c b/daemon/state.c
index 533e241..84ccba3 100644
--- a/daemon/state.c
+++ b/daemon/state.c
@@ -352,6 +352,68 @@ static void tree_mnts_cleanup(void *arg)
 	return;
 }
 
+static void do_readmap_mount(struct autofs_point *ap, struct mnt_list *mnts,
+			     struct map_source *map, struct mapent *me, time_t now)
+{
+	struct mapent_cache *nc;
+	struct mapent *ne, *nested, *valid;
+
+	nc = ap->entry->master->nc;
+
+	ne = cache_lookup_distinct(nc, me->key);
+	if (!ne) {
+		nested = cache_partial_match(nc, me->key);
+		if (nested) {
+			error(ap->logopt,
+			      "removing invalid nested null entry %s",
+			      nested->key);
+			nested = cache_partial_match(nc, me->key);
+			if (nested)
+				cache_delete(nc, nested->key);
+		}
+	}
+
+	if (me->age < now || (ne && map->master_line > ne->age)) {
+		/*
+		 * The map instance may have changed, such as the map name or
+		 * the mount options, but the direct map entry may still exist
+		 * in one of the other maps. If so then update the new cache
+		 * entry device and inode so we can find it at lookup. Later,
+		 * the mount for the new cache entry will just update the
+		 * timeout.
+		 *
+		 * TODO: how do we recognise these orphaned map instances. We
+		 * can't just delete these instances when the cache becomes
+		 * empty because that is a valid state for a master map entry.
+		 * This is becuase of the requirement to continue running with
+		 * an empty cache awaiting a map re-load.
+		 */
+		valid = lookup_source_valid_mapent(ap, me->key, LKP_DISTINCT);
+		if (valid) {
+			struct mapent_cache *vmc = valid->mc;
+			cache_unlock(vmc);
+			debug(ap->logopt,
+			     "updating cache entry for valid direct trigger %s",
+			     me->key);
+			cache_writelock(vmc);
+			valid = cache_lookup_distinct(vmc, me->key);
+			/* Take over the mount if there is one */
+			valid->ioctlfd = me->ioctlfd;
+			me->ioctlfd = -1;
+			/* Set device and inode number of the new mapent */
+			cache_set_ino_index(vmc, me->key, me->dev, me->ino);
+			cache_unlock(vmc);
+		} else if (!tree_is_mounted(mnts, me->key, MNTS_REAL))
+			do_umount_autofs_direct(ap, mnts, me);
+		else
+			debug(ap->logopt,
+			      "%s is mounted", me->key);
+	} else
+		do_mount_autofs_direct(ap, mnts, me);
+
+	return;
+}
+
 static void *do_readmap(void *arg)
 {
 	struct autofs_point *ap;
@@ -398,7 +460,8 @@ static void *do_readmap(void *arg)
 		lookup_prune_cache(ap, now);
 		status = lookup_ghost(ap, ap->path);
 	} else {
-		struct mapent *me, *ne, *nested;
+		struct mapent *me;
+
 		mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/");
 		pthread_cleanup_push(tree_mnts_cleanup, mnts);
 		pthread_cleanup_push(master_source_lock_cleanup, ap->entry);
@@ -418,31 +481,10 @@ static void *do_readmap(void *arg)
 			cache_readlock(mc);
 			me = cache_enumerate(mc, NULL);
 			while (me) {
-				ne = cache_lookup_distinct(nc, me->key);
-				if (!ne) {
-					nested = cache_partial_match(nc, me->key);
-					if (nested) {
-						error(ap->logopt,
-						"removing invalid nested null entry %s",
-						nested->key);
-						nested = cache_partial_match(nc, me->key);
-						if (nested)
-							cache_delete(nc, nested->key);
-					}
-				}
-
-				/* TODO: check return of do_... */
-				if (me->age < now || (ne && map->master_line > ne->age)) {
-					if (!tree_is_mounted(mnts, me->key, MNTS_REAL))
-						do_umount_autofs_direct(ap, mnts, me);
-					else
-                                		debug(ap->logopt,
-						      "%s is mounted", me->key);
-				} else
-					do_mount_autofs_direct(ap, mnts, me);
-
+				do_readmap_mount(ap, mnts, map, me, now);
 				me = cache_enumerate(mc, me);
 			}
+			lookup_prune_one_cache(ap, map->mc, now);
 			pthread_cleanup_pop(1);
 			map->stale = 0;
 			map = map->next;
diff --git a/include/automount.h b/include/automount.h
index d4675bd..ae517a7 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -238,6 +238,7 @@ int lookup_enumerate(struct autofs_point *ap,
 int lookup_ghost(struct autofs_point *ap, const char *root);
 int lookup_nss_mount(struct autofs_point *ap, struct map_source *source, const char *name, int name_len);
 void lookup_close_lookup(struct autofs_point *ap);
+void lookup_prune_one_cache(struct autofs_point *ap, struct mapent_cache *mc, time_t age);
 int lookup_prune_cache(struct autofs_point *ap, time_t age);
 struct mapent *lookup_source_valid_mapent(struct autofs_point *ap, const char *key, unsigned int type);
 struct mapent *lookup_source_mapent(struct autofs_point *ap, const char *key, unsigned int type);

autofs-5.0.4-fix-kernel-includes.patch:

--- NEW FILE autofs-5.0.4-fix-kernel-includes.patch ---
autofs-5.0.4 - fix kernel includes

From: Valerie Aurora Henson <vaurora at redhat.com>

autofs_dev-ioctl.h is included by both the kernel module and autofs,
and it includes two kernel header files. The compile worked if the
kernel headers were installed but failed otherwise.

imk: there are a couple of other instances were we include kernel
headers. I've tried to fix that up too.
---

 CHANGELOG                      |    1 +
 include/automount.h            |    3 +--
 include/dev-ioctl-lib.h        |    3 +--
 include/linux/auto_dev-ioctl.h |    7 ++++++-
 include/linux/auto_fs.h        |    6 ++++--
 5 files changed, 13 insertions(+), 7 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index a42dd14..387af5e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -42,6 +42,7 @@
 - zero s_magic is valid.
 - use percent hack for master map keys.
 - use intr option as hosts mount default.
+- fix kernel includes.
 
 4/11/2008 autofs-5.0.4
 -----------------------
diff --git a/include/automount.h b/include/automount.h
index 615e07d..d4675bd 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -8,12 +8,11 @@
 #ifndef AUTOMOUNT_H
 #define AUTOMOUNT_H
 
-#include <sys/types.h>
 #include <paths.h>
 #include <limits.h>
 #include <time.h>
 #include <syslog.h>
-#include <linux/types.h>
+#include <sys/types.h>
 #include <pthread.h>
 #include <sched.h>
 #include <errno.h>
diff --git a/include/dev-ioctl-lib.h b/include/dev-ioctl-lib.h
index b7b8211..6d35da2 100644
--- a/include/dev-ioctl-lib.h
+++ b/include/dev-ioctl-lib.h
@@ -21,8 +21,7 @@
 #ifndef AUTOFS_DEV_IOCTL_LIB_H
 #define AUTOFS_DEV_IOCTL_LIB_H
 
-#include <sys/types.h>
-#include "linux/auto_dev-ioctl.h"
+#include <linux/auto_dev-ioctl.h>
 
 #define CONTROL_DEVICE  "/dev/autofs"
 
diff --git a/include/linux/auto_dev-ioctl.h b/include/linux/auto_dev-ioctl.h
index 91a7739..850f39b 100644
--- a/include/linux/auto_dev-ioctl.h
+++ b/include/linux/auto_dev-ioctl.h
@@ -10,8 +10,13 @@
 #ifndef _LINUX_AUTO_DEV_IOCTL_H
 #define _LINUX_AUTO_DEV_IOCTL_H
 
+#include <linux/auto_fs.h>
+
+#ifdef __KERNEL__
 #include <linux/string.h>
-#include <linux/types.h>
+#else
+#include <string.h>
+#endif /* __KERNEL__ */
 
 #define AUTOFS_DEVICE_NAME		"autofs"
 
diff --git a/include/linux/auto_fs.h b/include/linux/auto_fs.h
index bd39f09..91d414f 100644
--- a/include/linux/auto_fs.h
+++ b/include/linux/auto_fs.h
@@ -17,11 +17,13 @@
 #ifdef __KERNEL__
 #include <linux/fs.h>
 #include <linux/limits.h>
+#include <linux/types.h>
+#include <linux/ioctl.h>
+#else
 #include <asm/types.h>
+#include <sys/ioctl.h>
 #endif /* __KERNEL__ */
 
-#include <linux/ioctl.h>
-
 /* This file describes autofs v3 */
 #define AUTOFS_PROTO_VERSION	3
 

autofs-5.0.4-improve-manual-umount-recovery.patch:

--- NEW FILE autofs-5.0.4-improve-manual-umount-recovery.patch ---
autofs-5.0.4 - improve manual umount recovery

From: Ian Kent <raven at themaw.net>

The check for manually umounted mounts in the expire of direct mounts is
racy and the check itself is inadequate in that it can incorrectly clear
the descriptor of an active mount. Also, we do a similar test following
the expire which is a waste since we can catch this on the next expire.
So these two tests have been combined and the check done only prior to
the expire. In the indirect expire we don't have a check at all so we
add one.
---

 CHANGELOG         |    1 +
 daemon/direct.c   |   28 ++++++++++------------------
 daemon/indirect.c |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 57 insertions(+), 19 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index 5e01812..89aaa99 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -45,6 +45,7 @@
 - fix kernel includes.
 - dont umount existing direct mount on master re-read.
 - fix incorrect shutdown introduced by library relaod fixes.
+- improve manual umount recovery.
 
 4/11/2008 autofs-5.0.4
 -----------------------
diff --git a/daemon/direct.c b/daemon/direct.c
index 4f4ff20..1ed2b15 100644
--- a/daemon/direct.c
+++ b/daemon/direct.c
@@ -881,13 +881,14 @@ void *expire_proc_direct(void *arg)
 			 * avoid maintaining a file handle for control
 			 * functions as once it's mounted all opens are
 			 * directed to the mount not the trigger.
-			 * But first expire possible rootless offsets first.
 			 */
 
-			/* Offsets always have a real mount at their base */
+			/* Check for manual umount */
 			cache_writelock(me->mc);
-			if (strstr(next->opts, "offset")) {
-				ops->close(ap->logopt, me->ioctlfd);
+			if (me->ioctlfd != -1 && 
+			    fstat(ioctlfd, &st) != -1 &&
+			    !count_mounts(ap->logopt, next->path, st.st_dev)) {
+				ops->close(ap->logopt, ioctlfd);
 				me->ioctlfd = -1;
 				cache_unlock(me->mc);
 				pthread_setcancelstate(cur_state, NULL);
@@ -904,15 +905,6 @@ void *expire_proc_direct(void *arg)
 				continue;
 			}
 
-			cache_writelock(me->mc);
-			if (me->ioctlfd != -1 && 
-			    fstat(ioctlfd, &st) != -1 &&
-			    !count_mounts(ap->logopt, next->path, st.st_dev)) {
-				ops->close(ap->logopt, ioctlfd);
-				me->ioctlfd = -1;
-			}
-			cache_unlock(me->mc);
-
 			pthread_setcancelstate(cur_state, NULL);
 			continue;
 		}
@@ -1068,7 +1060,7 @@ int handle_packet_expire_direct(struct autofs_point *ap, autofs_packet_expire_di
 	map = ap->entry->maps;
 	while (map) {
 		mc = map->mc;
-		cache_readlock(mc);
+		cache_writelock(mc);
 		me = cache_lookup_ino(mc, pkt->dev, pkt->ino);
 		if (me)
 			break;
@@ -1345,7 +1337,7 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_
 		}
 
 		mc = map->mc;
-		cache_readlock(mc);
+		cache_writelock(mc);
 		me = cache_lookup_ino(mc, pkt->dev, pkt->ino);
 		if (me)
 			break;
@@ -1367,10 +1359,10 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_
 
 	if (me->ioctlfd != -1) {
 		/* Maybe someone did a manual umount, clean up ! */
-		ioctlfd = me->ioctlfd;
+		close(me->ioctlfd);
 		me->ioctlfd = -1;
-	} else
-		ops->open(ap->logopt, &ioctlfd, me->dev, me->key);
+	}
+	ops->open(ap->logopt, &ioctlfd, me->dev, me->key);
 
 	if (ioctlfd == -1) {
 		cache_unlock(mc);
diff --git a/daemon/indirect.c b/daemon/indirect.c
index 2539282..bc39e63 100644
--- a/daemon/indirect.c
+++ b/daemon/indirect.c
@@ -428,8 +428,53 @@ void *expire_proc_indirect(void *arg)
 			pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
 			if (strstr(next->opts, "indirect"))
 				master_notify_submount(ap, next->path, ap->state);
-			pthread_setcancelstate(cur_state, NULL);
+			else if (strstr(next->opts, "offset")) {
+				struct map_source *map;
+				struct mapent_cache *mc = NULL;
+				struct mapent *me = NULL;
+				struct stat st;
+
+				master_source_readlock(ap->entry);
+
+				map = ap->entry->maps;
+				while (map) {
+					mc = map->mc;
+					cache_writelock(mc);
+					me = cache_lookup_distinct(mc, next->path);
+					if (me)
+						break;
+					cache_unlock(mc);
+					map = map->next;
+				}
 
+				if (!mc || !me) {
+					master_source_unlock(ap->entry);
+					pthread_setcancelstate(cur_state, NULL);
+					continue;
+				}
+
+				/* Check for manual umount */
+				if (me->ioctlfd != -1 &&
+				    (fstat(me->ioctlfd, &st) == -1 ||
+				     !count_mounts(ap->logopt, me->key, st.st_dev))) {
+					if (is_mounted(_PROC_MOUNTS, me->key, MNTS_REAL)) {
+						error(ap->logopt,
+						      "error: possible mtab mismatch %s",
+						      me->key);
+						cache_unlock(mc);
+						master_source_unlock(ap->entry);
+						pthread_setcancelstate(cur_state, NULL);
+						continue;
+					}
+					close(me->ioctlfd);
+					me->ioctlfd = -1;
+				}
+
+				cache_unlock(mc);
+				master_source_unlock(ap->entry);
+			}
+
+			pthread_setcancelstate(cur_state, NULL);
 			continue;
 		}
 

autofs-5.0.4-library-reload-fix-update-fix.patch:

--- NEW FILE autofs-5.0.4-library-reload-fix-update-fix.patch ---
autofs-5.0.4 - library reload fix update fix

From: Ian Kent <raven at themaw.net>

The library reload fixes introduced a bug which causes autofs to
incorrectly shutdown. Previously the signal handling thread only
recieved signals either when they were explicity sent or it was
time to shutdown so continuing on to call the signal handling
routine was the correct thing to do. Now we need to join with
the mount handling thread at exit but, in this case, we don't
want to continue on to the signal handling routine as that will
incorrectly cause the signal to be passed on to other mount
handling threads.
---

 CHANGELOG          |    1 +
 daemon/automount.c |   18 ++++++++++++++++--
 lib/master.c       |    2 --
 3 files changed, 17 insertions(+), 4 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index 7ca45fd..5e01812 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -44,6 +44,7 @@
 - use intr option as hosts mount default.
 - fix kernel includes.
 - dont umount existing direct mount on master re-read.
+- fix incorrect shutdown introduced by library relaod fixes.
 
 4/11/2008 autofs-5.0.4
 -----------------------
diff --git a/daemon/automount.c b/daemon/automount.c
index 80691fa..3a0fe0b 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -1332,8 +1332,22 @@ static void *statemachine(void *arg)
 		case SIGTERM:
 		case SIGINT:
 		case SIGUSR2:
-			if (master_done(master_list))
-				return NULL;
+			master_mutex_lock();
+			if (list_empty(&master_list->completed)) {
+				if (list_empty(&master_list->mounts)) {
+					master_mutex_unlock();
+					return NULL;
+				}
+			} else {
+				if (master_done(master_list)) {
+					master_mutex_unlock();
+					return NULL;
+				}
+				master_mutex_unlock();
+				break;
+			}
+			master_mutex_unlock();
+
 		case SIGUSR1:
 			do_signals(master_list, sig);
 			break;
diff --git a/lib/master.c b/lib/master.c
index 762094f..e43f835 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -1182,7 +1182,6 @@ int master_done(struct master *master)
 	struct master_mapent *entry;
 	int res = 0;
 
-	master_mutex_lock();
 	head = &master->completed;
 	p = head->next;
 	while (p != head) {
@@ -1195,7 +1194,6 @@ int master_done(struct master *master)
 	}
 	if (list_empty(&master->mounts))
 		res = 1;
-	master_mutex_unlock();
 
 	return res;
 }

autofs-5.0.4-use-intr-as-hosts-mount-default.patch:

--- NEW FILE autofs-5.0.4-use-intr-as-hosts-mount-default.patch ---
autofs-5.0.4 - use intr option as hosts mount default

From: Ian Kent <raven at themaw.net>

Use the "intr" option as default mount option for the hosts map
unless explicily overridden.
---

 CHANGELOG            |    1 +
 man/auto.master.5.in |    5 +++--
 modules/parse_sun.c  |   11 +++++++----
 3 files changed, 11 insertions(+), 6 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index 8258e00..a42dd14 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -41,6 +41,7 @@
 - reset flex scanner when setting buffer.
 - zero s_magic is valid.
 - use percent hack for master map keys.
+- use intr option as hosts mount default.
 
 4/11/2008 autofs-5.0.4
 -----------------------
diff --git a/man/auto.master.5.in b/man/auto.master.5.in
index aaa6324..7b7004f 100644
--- a/man/auto.master.5.in
+++ b/man/auto.master.5.in
@@ -208,8 +208,9 @@ For example, with an entry in the master map of
 accessing /net/myserver will mount exports from myserver on directories below
 /net/myserver.
 .P
-NOTE: mounts done from a hosts map will be mounted with the "nosuid" and "nodev" options
-unless the options "suid" and "dev" are explicitly given in the master map entry.
+NOTE: mounts done from a hosts map will be mounted with the "nosuid,nodev,intr" options
+unless overridden by explicily specifying the "suid", "dev" or "nointr" options in the
+master map entry.
 .SH LDAP MAPS
 If the map type \fBldap\fP is specified the mapname is of the form
 \fB[//servername/]dn\fP, where the optional \fBservername\fP is
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
index 65417e1..db36ae2 100644
--- a/modules/parse_sun.c
+++ b/modules/parse_sun.c
@@ -607,9 +607,10 @@ static int sun_mount(struct autofs_point *ap, const char *root,
 			int len = strlen(options);
 			int suid = strstr(options, "suid") ? 0 : 7;
 			int dev = strstr(options, "dev") ? 0 : 6;
+			int nointr = strstr(options, "nointr") ? 0 : 5;
 
-			if (suid || dev) {
-				char *tmp = alloca(len + suid + dev + 1);
+			if (suid || dev || nointr) {
+				char *tmp = alloca(len + suid + dev + nointr + 1);
 				if (!tmp) {
 					error(ap->logopt, MODPREFIX
 					      "alloca failed for options");
@@ -623,10 +624,12 @@ static int sun_mount(struct autofs_point *ap, const char *root,
 					strcat(tmp, ",nosuid");
 				if (dev)
 					strcat(tmp, ",nodev");
+				if (nointr)
+					strcat(tmp, ",intr");
 				options = tmp;
 			}
 		} else {
-			char *tmp = alloca(13);
+			char *tmp = alloca(18);
 			if (!tmp) {
 				error(ap->logopt,
 				      MODPREFIX "alloca failed for options");
@@ -634,7 +637,7 @@ static int sun_mount(struct autofs_point *ap, const char *root,
 					return -1;
 				return 1;
 			}
-			strcpy(tmp, "nosuid,nodev");
+			strcpy(tmp, "nosuid,nodev,intr");
 			options = tmp;
 		}
 	}

autofs-5.0.4-dont-fail-on-ipv6-address-adding-host.patch:

Index: autofs-5.0.4-dont-fail-on-ipv6-address-adding-host.patch
===================================================================
RCS file: /cvs/pkgs/rpms/autofs/F-11/autofs-5.0.4-dont-fail-on-ipv6-address-adding-host.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- autofs-5.0.4-dont-fail-on-ipv6-address-adding-host.patch	6 May 2009 16:27:05 -0000	1.1
+++ autofs-5.0.4-dont-fail-on-ipv6-address-adding-host.patch	18 May 2009 02:59:14 -0000	1.2
@@ -9,15 +9,14 @@ parse_location() function to fail to add
 in fact it should.
 ---
 
+ CHANGELOG            |    1 +
  include/replicated.h |    1 +
  modules/replicated.c |    9 ++++++++-
- 2 files changed, 9 insertions(+), 1 deletions(-)
+ 3 files changed, 10 insertions(+), 1 deletion(-)
 
 
-diff --git a/include/replicated.h b/include/replicated.h
-index e0133ff..fd87c08 100644
---- a/include/replicated.h
-+++ b/include/replicated.h
+--- autofs-5.0.4.orig/include/replicated.h
++++ autofs-5.0.4/include/replicated.h
 @@ -21,6 +21,7 @@
  #define PROXIMITY_SUBNET        0x0002
  #define PROXIMITY_NET           0x0004
@@ -26,11 +25,9 @@ index e0133ff..fd87c08 100644
  
  #define NFS2_SUPPORTED		0x0010
  #define NFS3_SUPPORTED		0x0020
-diff --git a/modules/replicated.c b/modules/replicated.c
-index 79845d0..a66de9f 100644
---- a/modules/replicated.c
-+++ b/modules/replicated.c
-@@ -181,7 +181,7 @@ static unsigned int get_proximity(struct sockaddr *host_addr)
+--- autofs-5.0.4.orig/modules/replicated.c
++++ autofs-5.0.4/modules/replicated.c
+@@ -181,7 +181,7 @@ static unsigned int get_proximity(struct
  
  	case AF_INET6:
  #ifndef INET6
@@ -39,7 +36,7 @@ index 79845d0..a66de9f 100644
  #else
  		addr6 = (struct sockaddr_in6 *) host_addr;
  		hst6_addr = (struct in6_addr *) &addr6->sin6_addr;
-@@ -1048,6 +1048,13 @@ static int add_new_host(struct host **list,
+@@ -1048,6 +1048,13 @@ static int add_new_host(struct host **li
  	int addr_len;
  
  	prx = get_proximity(host_addr->ai_addr);
@@ -53,3 +50,13 @@ index 79845d0..a66de9f 100644
  	if (prx == PROXIMITY_ERROR)
  		return 0;
  
+--- autofs-5.0.4.orig/CHANGELOG
++++ autofs-5.0.4/CHANGELOG
+@@ -46,6 +46,7 @@
+ - dont umount existing direct mount on master re-read.
+ - fix incorrect shutdown introduced by library relaod fixes.
+ - improve manual umount recovery.
++- dont fail on ipv6 address when adding host.
+ 
+ 4/11/2008 autofs-5.0.4
+ -----------------------


Index: autofs.spec
===================================================================
RCS file: /cvs/pkgs/rpms/autofs/F-11/autofs.spec,v
retrieving revision 1.282
retrieving revision 1.283
diff -u -p -r1.282 -r1.283
--- autofs.spec	6 May 2009 16:32:50 -0000	1.282
+++ autofs.spec	18 May 2009 02:59:14 -0000	1.283
@@ -4,7 +4,7 @@
 Summary: A tool for automatically mounting and unmounting filesystems
 Name: autofs
 Version: 5.0.4
-Release: 27
+Release: 29
 Epoch: 1
 License: GPLv2+
 Group: System Environment/Daemons
@@ -51,7 +51,14 @@ Patch38: autofs-5.0.4-fix-st_remove_task
 Patch39: autofs-5.0.4-reset-flex-scanner-when-setting-buffer.patch
 Patch40: autofs-5.0.4-zero-s_magic-is-valid.patch
 Patch41: autofs-5.0.4-use-percent-hack-for-master.patch
-Patch42: autofs-5.0.4-dont-fail-on-ipv6-address-adding-host.patch
+Patch42: autofs-5.0.4-use-intr-as-hosts-mount-default.patch
+Patch43: autofs-5.0.4-fix-kernel-includes.patch
+Patch44: autofs-5.0.4-dont-umount-existing-direct-mount-on-reread.patch
+Patch45: autofs-5.0.4-library-reload-fix-update-fix.patch
+Patch46: autofs-5.0.4-improve-manual-umount-recovery.patch
+Patch47: autofs-5.0.4-dont-fail-on-ipv6-address-adding-host.patch
+Patch48: autofs-5.0.4-always-read-file-maps-multi-map-fix.patch
+Patch49: autofs-5.0.4-always-read-file-maps-key-lookup-fixes.patch
 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel module-init-tools util-linux nfs-utils e2fsprogs libtirpc-devel
 Requires: kernel >= 2.6.17
@@ -135,6 +142,13 @@ echo %{version}-%{release} > .version
 %patch40 -p1
 %patch41 -p1
 %patch42 -p1
+%patch43 -p1
+%patch44 -p1
+%patch45 -p1
+%patch46 -p1
+%patch47 -p1
+%patch48 -p1
+%patch49 -p1
 
 %build
 #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir}
@@ -187,6 +201,15 @@ fi
 %{_libdir}/autofs/
 
 %changelog
+* Mon May 18 2009 Ian Kent <ikent at redhat.com> - 1:5.0.4-29
+- use intr option as hosts mount default.
+- sync kernel includes with upstream kernel.
+- dont umount existing direct mount on master re-read.
+- fix incorrect shutdown introduced by library relaod fixes.
+- improve manual umount recovery.
+- always read file maps multi map fix.
+- always read file maps key lookup fixes.
+
 * Wed May 6 2009 Ian Kent <ikent at redhat.com> - 1:5.0.4-27
 - dont fail on ipv6 address adding host.
 




More information about the scm-commits mailing list