Sophie

Sophie

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

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

autofs-5.0.1 - fix cache_init() on source re-read

From: Ian Kent <raven@themaw.net>

The master map entry cache is released and re-allocated for each
map source upon master map re-read. This is done without holding
the master map entry write lock and, when there are many master
map entries, could lead to a race because other activities can be
underway concurrently. In this case then we must either use
additional expensive exclusive locking or not do the cache
re-recreate.

So the question really becomes what do we have to gain by releasing
and re-creating the cache since we spend a fairly significant amount
of effort on pruning stale entries during ongoing operation already.

This patch moves the allocation of the map entry cache (belonging to
the map source) into the function used to add the map source to the
master map entry and does not release and re-create the cache if the
source already exists for the given master map entry.

Note: this patch looks incomplete because part of the change has
already been applied due to a mistake and I decided, since it would
need to be applied at some point, to leave it applied. See patch226
for the hunks that are missing for this patch.
---

 lib/master_parse.y     |   10 ----------
 modules/mount_autofs.c |    8 --------
 2 files changed, 18 deletions(-)


--- autofs-5.0.1.orig/lib/master_parse.y
+++ autofs-5.0.1/lib/master_parse.y
@@ -832,16 +832,6 @@ int master_parse_entry(const char *buffe
 		return 0;
 	}
 
-	if (!source->mc) {
-		source->mc = cache_init(entry->ap, source);
-		if (!source->mc) {
-			error(m_logopt, "failed to init source cache");
-			if (new)
-				master_free_mapent(new);
-			local_free_vars();
-			return 0;
-		}
-	}
 	source->master_line = lineno;
 
 	entry->age = age;
--- autofs-5.0.1.orig/modules/mount_autofs.c
+++ autofs-5.0.1/modules/mount_autofs.c
@@ -213,14 +213,6 @@ int mount_mount(struct autofs_point *ap,
 		return 1;
 	}
 
-	source->mc = cache_init(entry->ap, source);
-	if (!source->mc) {
-		error(ap->logopt, MODPREFIX "failed to init source cache");
-		master_free_map_source(source, 0);
-		master_free_mapent(entry);
-		return 1;
-	}
-
 	mounts_mutex_lock(ap);
 
 	if (handle_mounts_startup_cond_init(&suc)) {