Skip to contentSkip to conversation

Map update problem patches

PATCH In review Ian Kent 2 participants 4 messages Aug 21, 2017

Subsystems (2)
lore
Share & tools
lore

Ian Kent

author maintainer
#0 lore raw

cover Map update problem patches

Here is what I believe to be a better solution to the recent direct map update problem that was reported.

Unfortunately, the NSS map instance handling is overly complicated and I don't see a way to improve it. Becuase of this resolving problems in this area often introduces side effects.

So please look at these patches carefully.

---

Ian Kent (2):
autofs-5.1.3 - fix possible map instance memory leak autofs-5.1.3 - check map instances for staleness on map update

 daemon/lookup.c  |   11 +++++++----
 daemon/state.c   |    2 +-
 include/master.h |    1 +
 lib/master.c     |    2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)

--
Ian
--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#1 lore raw

PATCH 1/2 autofs-5.1.3 - fix possible map instance memory leak

When using a temporary map unconditionally updating the original map instance pointer will lead to a memory leak when the instance pointer is already set (among other problems).

---
 daemon/lookup.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
daemon/lookup.c +4 -2
index 583d3d37..569fffaf 100644
@@ -536,7 +536,8 @@ static enum nsswitch_status read_map_source(struct nss_source *this,
 	result = read_file_source_instance(ap, &tmap, age);
 	pthread_cleanup_pop(1);
 
-	map->instance = tmap.instance;
+	if (!map->instance)
+		map->instance = tmap.instance;
 
 	return result;
 }
@@ -1089,7 +1090,8 @@ static enum nsswitch_status lookup_map_name(struct nss_source *this,
 
 	result = lookup_name_file_source_instance(ap, &tmap, name, name_len);
 
-	map->instance = tmap.instance;
+	if (!map->instance)
+		map->instance = tmap.instance;
 
 	/* path is freed in free_argv */
 	free_argv(tmap.argc, tmap.argv);

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#2 lore raw

PATCH 2/2 autofs-5.1.3 - check map instances for staleness on map update

In reply to Ian Kent

When there are multiple map source instances bypassing the cache update when any one of the map sources returns NSS_STATUS_UNAVAIL is too strong.

When the map is marked not stale also check the instances before skipping the cache update.

---
 daemon/lookup.c  |    5 +++--
 daemon/state.c   |    2 +-
 include/master.h |    1 +
 lib/master.c     |    2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)
daemon/lookup.c +3 -2
index 569fffaf..cb67e7d9 100644
@@ -633,7 +633,8 @@ int lookup_nss_read_map(struct autofs_point *ap, struct map_source *source, time
 			if (result == NSS_STATUS_UNKNOWN)
 				continue;
 
-			/* Don't try to update the map cache if it's unavailable */
+			/* Try to avoid updating the map cache if an instance
+			 * is unavailable */
 			if (result == NSS_STATUS_UNAVAIL)
 				map->stale = 0;
 
@@ -1453,7 +1454,7 @@ int lookup_prune_cache(struct autofs_point *ap, time_t age)
 	map = entry->maps;
 	while (map) {
 		/* Is the map stale */
-		if (!map->stale) {
+		if (!map->stale && !check_stale_instances(map)) {
 			map = map->next;
 			continue;
 		}
daemon/state.c +1 -1
index cd0dd939..72bba6af 100644
@@ -512,7 +512,7 @@ static void *do_readmap(void *arg)
 		map = ap->entry->maps;
 		while (map) {
 			/* Is map source up to date or no longer valid */
-			if (!map->stale) {
+			if (!map->stale && !check_stale_instances(map)) {
 				map = map->next;
 				continue;
 			}
include/master.h +1 -0
index 087ddbe6..e1d272fb 100644
@@ -97,6 +97,7 @@ struct map_source *
 master_find_source_instance(struct map_source *, const char *, const char *, int, const char **);
 struct map_source *
 master_add_source_instance(struct map_source *, const char *, const char *, time_t, int, const char **);
+int check_stale_instances(struct map_source *);
 void clear_stale_instances(struct map_source *);
 void send_map_update_request(struct autofs_point *);
 void master_source_writelock(struct master_mapent *);
lib/master.c +1 -1
index 142f97ed..22b1522a 100644
@@ -521,7 +521,7 @@ master_add_source_instance(struct map_source *source, const char *type, const ch
 	return new;
 }
 
-static int check_stale_instances(struct map_source *source)
+int check_stale_instances(struct map_source *source)
 {
 	struct map_source *map;
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

#3 lore raw
In reply to Ian Kent
Quoted 9 lines · Ian Kent

Here is what I believe to be a better solution to the recent direct map update problem that was reported.

Unfortunately, the NSS map instance handling is overly complicated and I don't see a way to improve it. Becuase of this resolving problems in this area often introduces side effects.

So please look at these patches carefully.

I tested the patches and they seem to fix the issue I reported.

Thanks for the effort ;)

Oscar Salvador
--
To unsubscribe from this list: send the line "unsubscribe autofs" in