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

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