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

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