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

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