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

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