Blame SOURCES/autofs-5.1.7-set-offset-parent-in-update_offset_entry.patch

beb904
autofs-5.1.7 - set offset parent in update_offset_entry()
beb904
beb904
From: Ian Kent <raven@themaw.net>
beb904
beb904
Avoid the list traversal in cache_set_parents() by setting the
beb904
offset parent when updating the offset.
beb904
beb904
Signed-off-by: Ian Kent <raven@themaw.net>
beb904
---
beb904
 CHANGELOG           |    1 +
beb904
 include/automount.h |    2 +-
beb904
 lib/cache.c         |   26 +++++++++++---------------
beb904
 modules/parse_sun.c |    5 ++++-
beb904
 4 files changed, 17 insertions(+), 17 deletions(-)
beb904
beb904
--- autofs-5.1.4.orig/CHANGELOG
beb904
+++ autofs-5.1.4/CHANGELOG
beb904
@@ -7,6 +7,7 @@
beb904
 - eliminate cache_lookup_offset() usage.
beb904
 - fix is mounted check on non existent path.
beb904
 - simplify cache_get_parent().
beb904
+- set offset parent in update_offset_entry().
beb904
 
beb904
 xx/xx/2018 autofs-5.1.5
beb904
 - fix flag file permission.
beb904
--- autofs-5.1.4.orig/include/automount.h
beb904
+++ autofs-5.1.4/include/automount.h
beb904
@@ -207,7 +207,7 @@ struct mapent *cache_partial_match_wild(
beb904
 int cache_add(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
beb904
 int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age);
beb904
 void cache_update_negative(struct mapent_cache *mc, struct map_source *ms, const char *key, time_t timeout);
beb904
-int cache_set_parents(struct mapent *mm);
beb904
+int cache_set_offset_parent(struct mapent_cache *mc, const char *offset);
beb904
 int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
beb904
 int cache_delete(struct mapent_cache *mc, const char *key);
beb904
 int cache_delete_offset(struct mapent_cache *mc, const char *key);
beb904
--- autofs-5.1.4.orig/lib/cache.c
beb904
+++ autofs-5.1.4/lib/cache.c
beb904
@@ -834,25 +834,21 @@ static struct mapent *get_offset_parent(
beb904
 	return NULL;
beb904
 }
beb904
 
beb904
-int cache_set_parents(struct mapent *mm)
beb904
+int cache_set_offset_parent(struct mapent_cache *mc, const char *offset)
beb904
 {
beb904
-	struct list_head *multi_head, *p;
beb904
-	struct mapent *this;
beb904
+	struct mapent *this, *parent;
beb904
 
beb904
-	if (!mm->multi)
beb904
+	this = cache_lookup_distinct(mc, offset);
beb904
+	if (!this)
beb904
+		return 0;
beb904
+	if (!this->multi)
beb904
 		return 0;
beb904
 
beb904
-	multi_head = &mm->multi->multi_list;
beb904
-
beb904
-	list_for_each(p, multi_head) {
beb904
-		struct mapent *parent;
beb904
-		this = list_entry(p, struct mapent, multi_list);
beb904
-		parent = get_offset_parent(mm->mc, this->key);
beb904
-		if (parent)
beb904
-			this->parent = parent;
beb904
-		else
beb904
-			this->parent = mm->multi;
beb904
-	}
beb904
+	parent = get_offset_parent(mc, offset);
beb904
+	if (parent)
beb904
+		this->parent = parent;
beb904
+	else
beb904
+		this->parent = this->multi;
beb904
 
beb904
 	return 1;
beb904
 }
beb904
--- autofs-5.1.4.orig/modules/parse_sun.c
beb904
+++ autofs-5.1.4/modules/parse_sun.c
beb904
@@ -861,6 +861,10 @@ update_offset_entry(struct autofs_point
beb904
 	}
beb904
 
beb904
 	ret = cache_update_offset(mc, name, m_key, m_mapent, age);
beb904
+
beb904
+	if (!cache_set_offset_parent(mc, m_key))
beb904
+		error(ap->logopt, "failed to set offset parent");
beb904
+
beb904
 	if (ret == CHE_DUPLICATE) {
beb904
 		warn(ap->logopt, MODPREFIX
beb904
 		     "syntax error or duplicate offset %s -> %s", path, loc);
beb904
@@ -1615,7 +1619,6 @@ dont_expand:
beb904
 		 */
beb904
 		if (me == me->multi)
beb904
 			clean_stale_multi_triggers(ap, me, NULL, NULL);
beb904
-		cache_set_parents(me);
beb904
 
beb904
 		rv = mount_subtree(ap, me, name, NULL, options, ctxt);
beb904