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

65 lines
2.2 KiB
Diff
Raw Normal View History

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