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

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