Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 53

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

autofs-5.0.1 - fix dont umount existing direct mount on reread

From: Ian Kent <raven@themaw.net>

A recent problem where we incorrectly umounted direct mounts on map
re-read, when the map name in the master map has changed, checks for
the stale entry in an old map source and updates the new entry from
information in the the stale entry. But this check can also match
an entry that has been removed from a direct map whose name hasn't
changed which leads to a deadlock when we try and take the cache
write lock on the (alleged) stale cache to update the new entry.
This is because, in this case, the cache we want to lock is in
fact the one we are reading and we already hold a read lock on it.
---

 daemon/state.c |   10 ++++++++++
 1 file changed, 10 insertions(+)


--- autofs-5.0.1.orig/daemon/state.c
+++ autofs-5.0.1/daemon/state.c
@@ -389,6 +389,16 @@ static void do_readmap_mount(struct auto
 		 * an empty cache awaiting a map re-load.
 		 */
 		valid = lookup_source_valid_mapent(ap, me->key, LKP_DISTINCT);
+		if (valid && valid->mc == me->mc) {
+			/*
+			 * We've found a map entry that has been removed from
+			 * the current cache so there is no need to update it.
+			 * The stale entry will be dealt with when we prune the
+			 * cache later.
+			 */
+			cache_unlock(valid->mc);
+			valid = NULL;
+		}
 		if (valid) {
 			struct mapent_cache *vmc = valid->mc;
 			cache_unlock(vmc);