Blame SOURCES/autofs-5.1.6-use-a-valid-timeout-in-lookup_prune_one_cache.patch

1b50e3
autofs-5.1.6 - use a valid timeout in lookup_prune_one_cache()
1b50e3
1b50e3
From: Ian Kent <raven@themaw.net>
1b50e3
1b50e3
For a very long time the map entry cache has been allowed to grow
1b50e3
without pruning old entries until a map read is needed and there's
1b50e3
been a constant struggle to set the map stale only when really needed
1b50e3
so that in use entries aren't pruned.
1b50e3
1b50e3
But somewhere along the line that's become broken and the sss error
1b50e3
handling updates don't work properly because of this (or rather don't
1b50e3
work well).
1b50e3
1b50e3
Add a positive map entry cache timeout so that recently seen map
1b50e3
entries don't get removed in the map read following the lookup that
1b50e3
added them when the map isn't actually read such as with nobrowse
1b50e3
indirect mounts.
1b50e3
1b50e3
The valid timeout probably should become configurable at some point
1b50e3
too.
1b50e3
1b50e3
Signed-off-by: Ian Kent <raven@themaw.net>
1b50e3
---
1b50e3
 CHANGELOG           |    1 +
1b50e3
 daemon/lookup.c     |   15 +++++++++++++++
1b50e3
 include/automount.h |    1 +
1b50e3
 3 files changed, 17 insertions(+)
1b50e3
1b50e3
diff --git a/CHANGELOG b/CHANGELOG
1b50e3
index 309def2..3608345 100644
1b50e3
--- a/CHANGELOG
1b50e3
+++ b/CHANGELOG
1b50e3
@@ -108,6 +108,7 @@ xx/xx/2018 autofs-5.1.5
1b50e3
 - update sss timeout documentation.
1b50e3
 - refactor sss getautomntbyname().
1b50e3
 - improve sss getautomntbyname() error handling.
1b50e3
+- use a valid timeout in lookup_prune_one_cache().
1b50e3
 
1b50e3
 19/12/2017 autofs-5.1.4
1b50e3
 - fix spec file url.
1b50e3
diff --git a/daemon/lookup.c b/daemon/lookup.c
1b50e3
index 2b9c7e8..8bf1335 100644
1b50e3
--- a/daemon/lookup.c
1b50e3
+++ b/daemon/lookup.c
1b50e3
@@ -1354,6 +1354,21 @@ void lookup_prune_one_cache(struct autofs_point *ap, struct mapent_cache *mc, ti
1b50e3
 			continue;
1b50e3
 		}
1b50e3
 
1b50e3
+		if (ap->type == LKP_INDIRECT) {
1b50e3
+			/* If the map hasn't been read (nobrowse
1b50e3
+			 * indirect mounts) then keep cached entries
1b50e3
+			 * for POSITIVE_TIMEOUT.
1b50e3
+			 */
1b50e3
+			if (!(ap->flags & (MOUNT_FLAG_GHOST |
1b50e3
+					   MOUNT_FLAG_AMD_CACHE_ALL))) {
1b50e3
+				time_t until = me->age + POSITIVE_TIMEOUT;
1b50e3
+				if ((long) age - (long) until < 0) {
1b50e3
+					me = cache_enumerate(mc, me);
1b50e3
+					continue;
1b50e3
+				}
1b50e3
+			}
1b50e3
+		}
1b50e3
+
1b50e3
 		key = strdup(me->key);
1b50e3
 		me = cache_enumerate(mc, me);
1b50e3
 		/* Don't consider any entries with a wildcard */
1b50e3
diff --git a/include/automount.h b/include/automount.h
1b50e3
index 49c9ff9..bb264a1 100644
1b50e3
--- a/include/automount.h
1b50e3
+++ b/include/automount.h
1b50e3
@@ -139,6 +139,7 @@ struct autofs_point;
1b50e3
 
1b50e3
 #define NULL_MAP_HASHSIZE	64
1b50e3
 #define NEGATIVE_TIMEOUT	10
1b50e3
+#define POSITIVE_TIMEOUT	120
1b50e3
 #define UMOUNT_RETRIES		8
1b50e3
 #define EXPIRE_RETRIES		3
1b50e3