aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorIan Kent <raven@themaw.net>2017-11-23 16:10:22 +0800
committerIan Kent <raven@themaw.net>2018-10-15 11:37:35 +0800
commit8ad2589aa6eb3f1054ad8064387b06cdb5b7b322 (patch)
treeb39a22f38c4f109d0eddd4438f9285aa80595cb1 /modules
parent35562fb354521c38cc24b413b3fc50b52278996c (diff)
downloadautofs-8ad2589aa6eb3f1054ad8064387b06cdb5b7b322.tar.gz
autofs-5.1.4 - refactor negative map entry check
Create a function to check for a negative map entry on lookup and use it in each of the relevant modules. Signed-off-by: Ian Kent <raven@themaw.net>
Diffstat (limited to 'modules')
-rw-r--r--modules/lookup_file.c22
-rw-r--r--modules/lookup_hesiod.c22
-rw-r--r--modules/lookup_hosts.c22
-rw-r--r--modules/lookup_ldap.c22
-rw-r--r--modules/lookup_nisplus.c22
-rw-r--r--modules/lookup_program.c22
-rw-r--r--modules/lookup_sss.c22
-rw-r--r--modules/lookup_yp.c22
8 files changed, 16 insertions, 160 deletions
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
index ed5caa47..6986830b 100644
--- a/modules/lookup_file.c
+++ b/modules/lookup_file.c
@@ -1177,27 +1177,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, key, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, key) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, key);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, key);
- }
- cache_unlock(smc);
- }
- }
}
/*
diff --git a/modules/lookup_hesiod.c b/modules/lookup_hesiod.c
index b3278d20..54cf278c 100644
--- a/modules/lookup_hesiod.c
+++ b/modules/lookup_hesiod.c
@@ -397,27 +397,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, name, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, name) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, name);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, name);
- }
- cache_unlock(smc);
- }
- }
}
/* If this is not here the filesystem stays busy, for some reason... */
diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c
index 163b02d5..744062e2 100644
--- a/modules/lookup_hosts.c
+++ b/modules/lookup_hosts.c
@@ -314,27 +314,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, name, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, name) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, name);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, name);
- }
- cache_unlock(smc);
- }
- }
}
cache_readlock(mc);
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 911a34a5..f7432a2a 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -3687,27 +3687,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, key, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, key) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, key);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, key);
- }
- cache_unlock(smc);
- }
- }
}
/*
diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
index 8dee4630..cbd03cdb 100644
--- a/modules/lookup_nisplus.c
+++ b/modules/lookup_nisplus.c
@@ -709,27 +709,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, key, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, key) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, key);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, key);
- }
- cache_unlock(smc);
- }
- }
}
/*
diff --git a/modules/lookup_program.c b/modules/lookup_program.c
index 56e19394..fcb1af74 100644
--- a/modules/lookup_program.c
+++ b/modules/lookup_program.c
@@ -601,27 +601,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, name, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, name) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, name);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, name);
- }
- cache_unlock(smc);
- }
- }
}
/* Catch installed direct offset triggers */
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
index 78598300..ce60acd3 100644
--- a/modules/lookup_sss.c
+++ b/modules/lookup_sss.c
@@ -726,27 +726,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, key, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, key) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, key);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, key);
- }
- cache_unlock(smc);
- }
- }
}
/*
diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
index d1ffcae4..38f75497 100644
--- a/modules/lookup_yp.c
+++ b/modules/lookup_yp.c
@@ -813,27 +813,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
/* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, key, LKP_DISTINCT);
if (me) {
- if (me->status >= monotonic_time(NULL)) {
- cache_unlock(me->mc);
+ /* negative timeout has not passed, return fail */
+ if (cache_lookup_negative(me, key) == CHE_UNAVAIL)
return NSS_STATUS_NOTFOUND;
- } else {
- struct mapent_cache *smc = me->mc;
- struct mapent *sme;
-
- if (me->mapent)
- cache_unlock(smc);
- else {
- cache_unlock(smc);
- cache_writelock(smc);
- sme = cache_lookup_distinct(smc, key);
- /* Negative timeout expired for non-existent entry. */
- if (sme && !sme->mapent) {
- if (cache_pop_mapent(sme) == CHE_FAIL)
- cache_delete(smc, key);
- }
- cache_unlock(smc);
- }
- }
}
/*