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

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