Blame SOURCES/autofs-5.1.4-mark-removed-cache-entry-negative.patch

d5dcad
autofs-5.1.4 - mark removed cache entry negative
d5dcad
d5dcad
From: Ian Kent <raven@themaw.net>
d5dcad
d5dcad
When re-reading a map entries that have been removed are detected
d5dcad
and deleted from the map entry cache by lookup_prune_cache().
d5dcad
d5dcad
If a removed map entry is mounted at the time lookup_prune_cache()
d5dcad
is called the map entry is skippedi. This is done becuase the next
d5dcad
lookup (following the mount expire, which needs the cache entry to
d5dcad
remain) will detect the stale cache entry and a map update done
d5dcad
resulting in the istale entry being removed.
d5dcad
d5dcad
But if a map re-read is performed while the cache entry is mounted
d5dcad
the cache will appear to up to date so the removed entry will remain
d5dcad
valid even after it has expired.
d5dcad
d5dcad
To cover this case it's sufficient to mark the mounted cache entry
d5dcad
negative during the cache prune which prevent further lookups from
d5dcad
using the stale entry.
d5dcad
d5dcad
Signed-off-by: Ian Kent <raven@themaw.net>
d5dcad
---
d5dcad
 CHANGELOG       |    1 +
d5dcad
 daemon/lookup.c |   12 +++++++++---
d5dcad
 2 files changed, 10 insertions(+), 3 deletions(-)
d5dcad
d5dcad
--- autofs-5.1.4.orig/CHANGELOG
d5dcad
+++ autofs-5.1.4/CHANGELOG
d5dcad
@@ -29,6 +29,7 @@ xx/xx/2018 autofs-5.1.5
d5dcad
 - covarity fixes.
d5dcad
 - fix program usage message.
d5dcad
 - fix update_negative_cache() map source usage.
d5dcad
+- mark removed cache entry negative.
d5dcad
 
d5dcad
 19/12/2017 autofs-5.1.4
d5dcad
 - fix spec file url.
d5dcad
--- autofs-5.1.4.orig/daemon/lookup.c
d5dcad
+++ autofs-5.1.4/daemon/lookup.c
d5dcad
@@ -1417,15 +1417,21 @@ void lookup_prune_one_cache(struct autof
d5dcad
 		if (valid && valid->mc == mc) {
d5dcad
 			 /*
d5dcad
 			  * We've found a map entry that has been removed from
d5dcad
-			  * the current cache so it isn't really valid.
d5dcad
+			  * the current cache so it isn't really valid. Set the
d5dcad
+			  * mapent negative to prevent further mount requests
d5dcad
+			  * using the cache entry.
d5dcad
 			  */
d5dcad
+			debug(ap->logopt, "removed map entry detected, mark negative");
d5dcad
+			if (valid->mapent) {
d5dcad
+				free(valid->mapent);
d5dcad
+				valid->mapent = NULL;
d5dcad
+			}
d5dcad
 			cache_unlock(valid->mc);
d5dcad
 			valid = NULL;
d5dcad
 		}
d5dcad
 		if (!valid &&
d5dcad
 		    is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) {
d5dcad
-			debug(ap->logopt,
d5dcad
-			      "prune check posponed, %s mounted", path);
d5dcad
+			debug(ap->logopt, "prune posponed, %s mounted", path);
d5dcad
 			free(key);
d5dcad
 			free(path);
d5dcad
 			continue;