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

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