|
|
4d476f |
autofs-5.0.8 - add negative cache lookup to hesiod lookup
|
|
|
4d476f |
|
|
|
4d476f |
From: Ian Kent <raven@themaw.net>
|
|
|
4d476f |
|
|
|
4d476f |
Warning, this is completely untested.
|
|
|
4d476f |
|
|
|
4d476f |
I don't have a hesiod test environment so I can't test this at all.
|
|
|
4d476f |
If we do in fact have hesiod users then I'll need to work with them
|
|
|
4d476f |
to fix any reported problems.
|
|
|
4d476f |
---
|
|
|
4d476f |
CHANGELOG | 1 +
|
|
|
4d476f |
modules/lookup_hesiod.c | 39 ++++++++++++++++++++++++++++++++++++++-
|
|
|
4d476f |
2 files changed, 39 insertions(+), 1 deletion(-)
|
|
|
4d476f |
|
|
|
4d476f |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
4d476f |
+++ autofs-5.0.7/CHANGELOG
|
|
|
4d476f |
@@ -91,6 +91,7 @@
|
|
|
4d476f |
- fix bad mkdir permission on create.
|
|
|
4d476f |
- fix macro_addvar() and move init to main thread.
|
|
|
4d476f |
- change walk_tree() to take ap.
|
|
|
4d476f |
+- add negative cache lookup to hesiod lookup.
|
|
|
4d476f |
|
|
|
4d476f |
25/07/2012 autofs-5.0.7
|
|
|
4d476f |
=======================
|
|
|
4d476f |
--- autofs-5.0.7.orig/modules/lookup_hesiod.c
|
|
|
4d476f |
+++ autofs-5.0.7/modules/lookup_hesiod.c
|
|
|
4d476f |
@@ -99,10 +99,11 @@ int lookup_read_map(struct autofs_point
|
|
|
4d476f |
*/
|
|
|
4d476f |
int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *context)
|
|
|
4d476f |
{
|
|
|
4d476f |
+ struct lookup_context *ctxt = (struct lookup_context *) context;
|
|
|
4d476f |
struct map_source *source;
|
|
|
4d476f |
struct mapent_cache *mc;
|
|
|
4d476f |
+ struct mapent *me;
|
|
|
4d476f |
char **hes_result;
|
|
|
4d476f |
- struct lookup_context *ctxt = (struct lookup_context *) context;
|
|
|
4d476f |
int status, rv;
|
|
|
4d476f |
char **record, *best_record = NULL, *p;
|
|
|
4d476f |
int priority, lowest_priority = INT_MAX;
|
|
|
4d476f |
@@ -117,6 +118,32 @@ int lookup_mount(struct autofs_point *ap
|
|
|
4d476f |
MODPREFIX "looking up root=\"%s\", name=\"%s\"",
|
|
|
4d476f |
ap->path, name);
|
|
|
4d476f |
|
|
|
4d476f |
+ /* Check if we recorded a mount fail for this key anywhere */
|
|
|
4d476f |
+ me = lookup_source_mapent(ap, name, LKP_DISTINCT);
|
|
|
4d476f |
+ if (me) {
|
|
|
4d476f |
+ if (me->status >= time(NULL)) {
|
|
|
4d476f |
+ cache_unlock(me->mc);
|
|
|
4d476f |
+ return NSS_STATUS_NOTFOUND;
|
|
|
4d476f |
+ } else {
|
|
|
4d476f |
+ struct mapent_cache *smc = me->mc;
|
|
|
4d476f |
+ struct mapent *sme;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ if (me->mapent)
|
|
|
4d476f |
+ cache_unlock(smc);
|
|
|
4d476f |
+ else {
|
|
|
4d476f |
+ cache_unlock(smc);
|
|
|
4d476f |
+ cache_writelock(smc);
|
|
|
4d476f |
+ sme = cache_lookup_distinct(smc, name);
|
|
|
4d476f |
+ /* Negative timeout expired for non-existent entry. */
|
|
|
4d476f |
+ if (sme && !sme->mapent) {
|
|
|
4d476f |
+ if (cache_pop_mapent(sme) == CHE_FAIL)
|
|
|
4d476f |
+ cache_delete(smc, name);
|
|
|
4d476f |
+ }
|
|
|
4d476f |
+ cache_unlock(smc);
|
|
|
4d476f |
+ }
|
|
|
4d476f |
+ }
|
|
|
4d476f |
+ }
|
|
|
4d476f |
+
|
|
|
4d476f |
chdir("/"); /* If this is not here the filesystem stays
|
|
|
4d476f |
busy, for some reason... */
|
|
|
4d476f |
|
|
|
4d476f |
@@ -171,6 +198,16 @@ int lookup_mount(struct autofs_point *ap
|
|
|
4d476f |
if (status)
|
|
|
4d476f |
fatal(status);
|
|
|
4d476f |
|
|
|
4d476f |
+ if (rv) {
|
|
|
4d476f |
+ /* Don't update negative cache when re-connecting */
|
|
|
4d476f |
+ if (ap->flags & MOUNT_FLAG_REMOUNT)
|
|
|
4d476f |
+ return NSS_STATUS_TRYAGAIN;
|
|
|
4d476f |
+ cache_writelock(mc);
|
|
|
4d476f |
+ cache_update_negative(mc, source, name, ap->negative_timeout);
|
|
|
4d476f |
+ cache_unlock(mc);
|
|
|
4d476f |
+ return NSS_STATUS_TRYAGAIN;
|
|
|
4d476f |
+ }
|
|
|
4d476f |
+
|
|
|
4d476f |
/*
|
|
|
4d476f |
* Unavailable due to error such as module load fail
|
|
|
4d476f |
* or out of memory, etc.
|