|
Ian Kent |
cc4062 |
autofs-5.0.5 - fix cache_init() on source re-read
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
From: Ian Kent <raven@themaw.net>
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
The master map entry cache is released and re-allocated for each
|
|
Ian Kent |
cc4062 |
map source upon master map re-read. This is done without holding
|
|
Ian Kent |
cc4062 |
the master map entry write lock and, when there are many master
|
|
Ian Kent |
cc4062 |
map entries, could lead to a race because other activities can be
|
|
Ian Kent |
cc4062 |
underway concurrently. In this case then we must either use
|
|
Ian Kent |
cc4062 |
additional expensive exclusive locking or not do the cache
|
|
Ian Kent |
cc4062 |
re-recreate.
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
So the question really becomes what do we have to gain by releasing
|
|
Ian Kent |
cc4062 |
and re-creating the cache since we spend a fairly significant amount
|
|
Ian Kent |
cc4062 |
of effort on pruning stale entries during ongoing operation already.
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
This patch moves the allocation of the map entry cache (belonging to
|
|
Ian Kent |
cc4062 |
the map source) into the function used to add the map source to the
|
|
Ian Kent |
cc4062 |
master map entry and does not release and re-create the cache if the
|
|
Ian Kent |
cc4062 |
source already exists for the given master map entry.
|
|
Ian Kent |
cc4062 |
---
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
CHANGELOG | 1 +
|
|
Ian Kent |
cc4062 |
lib/master.c | 6 ++++++
|
|
Ian Kent |
cc4062 |
lib/master_parse.y | 10 ----------
|
|
Ian Kent |
cc4062 |
modules/mount_autofs.c | 8 --------
|
|
Ian Kent |
cc4062 |
4 files changed, 7 insertions(+), 18 deletions(-)
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
--- autofs-5.0.5.orig/CHANGELOG
|
|
Ian Kent |
cc4062 |
+++ autofs-5.0.5/CHANGELOG
|
|
Ian Kent |
cc4062 |
@@ -38,6 +38,7 @@
|
|
Ian Kent |
cc4062 |
- fix parse_sun() module init.
|
|
Ian Kent |
cc4062 |
- dont check null cache on expire.
|
|
Ian Kent |
cc4062 |
- fix null cache race.
|
|
Ian Kent |
cc4062 |
+- fix cache_init() on source re-read.
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
03/09/2009 autofs-5.0.5
|
|
Ian Kent |
cc4062 |
-----------------------
|
|
Ian Kent |
cc4062 |
--- autofs-5.0.5.orig/lib/master.c
|
|
Ian Kent |
cc4062 |
+++ autofs-5.0.5/lib/master.c
|
|
Ian Kent |
cc4062 |
@@ -188,6 +188,12 @@ master_add_map_source(struct master_mape
|
|
Ian Kent |
cc4062 |
source->argc = argc;
|
|
Ian Kent |
cc4062 |
source->argv = tmpargv;
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
+ source->mc = cache_init(entry->ap, source);
|
|
Ian Kent |
cc4062 |
+ if (!source->mc) {
|
|
Ian Kent |
cc4062 |
+ master_free_map_source(source, 0);
|
|
Ian Kent |
cc4062 |
+ return NULL;
|
|
Ian Kent |
cc4062 |
+ }
|
|
Ian Kent |
cc4062 |
+
|
|
Ian Kent |
cc4062 |
master_source_writelock(entry);
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
if (!entry->maps) {
|
|
Ian Kent |
cc4062 |
--- autofs-5.0.5.orig/lib/master_parse.y
|
|
Ian Kent |
cc4062 |
+++ autofs-5.0.5/lib/master_parse.y
|
|
Ian Kent |
cc4062 |
@@ -830,16 +830,6 @@ int master_parse_entry(const char *buffe
|
|
Ian Kent |
cc4062 |
return 0;
|
|
Ian Kent |
cc4062 |
}
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
- if (!source->mc) {
|
|
Ian Kent |
cc4062 |
- source->mc = cache_init(entry->ap, source);
|
|
Ian Kent |
cc4062 |
- if (!source->mc) {
|
|
Ian Kent |
cc4062 |
- error(m_logopt, "failed to init source cache");
|
|
Ian Kent |
cc4062 |
- if (new)
|
|
Ian Kent |
cc4062 |
- master_free_mapent(new);
|
|
Ian Kent |
cc4062 |
- local_free_vars();
|
|
Ian Kent |
cc4062 |
- return 0;
|
|
Ian Kent |
cc4062 |
- }
|
|
Ian Kent |
cc4062 |
- }
|
|
Ian Kent |
cc4062 |
source->master_line = lineno;
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
entry->age = age;
|
|
Ian Kent |
cc4062 |
--- autofs-5.0.5.orig/modules/mount_autofs.c
|
|
Ian Kent |
cc4062 |
+++ autofs-5.0.5/modules/mount_autofs.c
|
|
Ian Kent |
cc4062 |
@@ -200,14 +200,6 @@ int mount_mount(struct autofs_point *ap,
|
|
Ian Kent |
cc4062 |
}
|
|
Ian Kent |
cc4062 |
free_map_type_info(info);
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
- source->mc = cache_init(entry->ap, source);
|
|
Ian Kent |
cc4062 |
- if (!source->mc) {
|
|
Ian Kent |
cc4062 |
- error(ap->logopt, MODPREFIX "failed to init source cache");
|
|
Ian Kent |
cc4062 |
- master_free_map_source(source, 0);
|
|
Ian Kent |
cc4062 |
- master_free_mapent(entry);
|
|
Ian Kent |
cc4062 |
- return 1;
|
|
Ian Kent |
cc4062 |
- }
|
|
Ian Kent |
cc4062 |
-
|
|
Ian Kent |
cc4062 |
mounts_mutex_lock(ap);
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
if (handle_mounts_startup_cond_init(&suc)) {
|