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

29d2b9
autofs-5.1.7 - set offset parent in update_offset_entry()
29d2b9
29d2b9
From: Ian Kent <raven@themaw.net>
29d2b9
29d2b9
Avoid the list traversal in cache_set_parents() by setting the
29d2b9
offset parent when updating the offset.
29d2b9
29d2b9
Signed-off-by: Ian Kent <raven@themaw.net>
29d2b9
---
29d2b9
 CHANGELOG           |    1 +
29d2b9
 include/automount.h |    2 +-
29d2b9
 lib/cache.c         |   26 +++++++++++---------------
29d2b9
 modules/parse_sun.c |    5 ++++-
29d2b9
 4 files changed, 17 insertions(+), 17 deletions(-)
29d2b9
29d2b9
diff --git a/CHANGELOG b/CHANGELOG
29d2b9
index ee746277..c4ebb52f 100644
29d2b9
--- a/CHANGELOG
29d2b9
+++ b/CHANGELOG
29d2b9
@@ -8,6 +8,7 @@
29d2b9
 - eliminate cache_lookup_offset() usage.
29d2b9
 - fix is mounted check on non existent path.
29d2b9
 - simplify cache_get_parent().
29d2b9
+- set offset parent in update_offset_entry().
29d2b9
 
29d2b9
 25/01/2021 autofs-5.1.7
29d2b9
 - make bind mounts propagation slave by default.
29d2b9
diff --git a/include/automount.h b/include/automount.h
29d2b9
index 2f09e8e7..730be19a 100644
29d2b9
--- a/include/automount.h
29d2b9
+++ b/include/automount.h
29d2b9
@@ -208,7 +208,7 @@ int cache_add(struct mapent_cache *mc, struct map_source *ms, const char *key, c
29d2b9
 int cache_update_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age);
29d2b9
 int cache_lookup_negative(struct mapent *me, const char *key);
29d2b9
 void cache_update_negative(struct mapent_cache *mc, struct map_source *ms, const char *key, time_t timeout);
29d2b9
-int cache_set_parents(struct mapent *mm);
29d2b9
+int cache_set_offset_parent(struct mapent_cache *mc, const char *offset);
29d2b9
 int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age);
29d2b9
 int cache_delete(struct mapent_cache *mc, const char *key);
29d2b9
 int cache_delete_offset(struct mapent_cache *mc, const char *key);
29d2b9
diff --git a/lib/cache.c b/lib/cache.c
29d2b9
index 53f290cd..ce9e9bd2 100644
29d2b9
--- a/lib/cache.c
29d2b9
+++ b/lib/cache.c
29d2b9
@@ -864,25 +864,21 @@ static struct mapent *get_offset_parent(struct mapent_cache *mc,
29d2b9
 	return NULL;
29d2b9
 }
29d2b9
 
29d2b9
-int cache_set_parents(struct mapent *mm)
29d2b9
+int cache_set_offset_parent(struct mapent_cache *mc, const char *offset)
29d2b9
 {
29d2b9
-	struct list_head *multi_head, *p;
29d2b9
-	struct mapent *this;
29d2b9
+	struct mapent *this, *parent;
29d2b9
 
29d2b9
-	if (!mm->multi)
29d2b9
+	this = cache_lookup_distinct(mc, offset);
29d2b9
+	if (!this)
29d2b9
+		return 0;
29d2b9
+	if (!this->multi)
29d2b9
 		return 0;
29d2b9
 
29d2b9
-	multi_head = &mm->multi->multi_list;
29d2b9
-
29d2b9
-	list_for_each(p, multi_head) {
29d2b9
-		struct mapent *parent;
29d2b9
-		this = list_entry(p, struct mapent, multi_list);
29d2b9
-		parent = get_offset_parent(mm->mc, this->key);
29d2b9
-		if (parent)
29d2b9
-			this->parent = parent;
29d2b9
-		else
29d2b9
-			this->parent = mm->multi;
29d2b9
-	}
29d2b9
+	parent = get_offset_parent(mc, offset);
29d2b9
+	if (parent)
29d2b9
+		this->parent = parent;
29d2b9
+	else
29d2b9
+		this->parent = this->multi;
29d2b9
 
29d2b9
 	return 1;
29d2b9
 }
29d2b9
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
29d2b9
index 819d6adc..f42af7b7 100644
29d2b9
--- a/modules/parse_sun.c
29d2b9
+++ b/modules/parse_sun.c
29d2b9
@@ -859,6 +859,10 @@ update_offset_entry(struct autofs_point *ap, const char *name,
29d2b9
 	}
29d2b9
 
29d2b9
 	ret = cache_update_offset(mc, name, m_key, m_mapent, age);
29d2b9
+
29d2b9
+	if (!cache_set_offset_parent(mc, m_key))
29d2b9
+		error(ap->logopt, "failed to set offset parent");
29d2b9
+
29d2b9
 	if (ret == CHE_DUPLICATE) {
29d2b9
 		warn(ap->logopt, MODPREFIX
29d2b9
 		     "syntax error or duplicate offset %s -> %s", path, loc);
29d2b9
@@ -1613,7 +1617,6 @@ dont_expand:
29d2b9
 		 */
29d2b9
 		if (me == me->multi)
29d2b9
 			clean_stale_multi_triggers(ap, me, NULL, NULL);
29d2b9
-		cache_set_parents(me);
29d2b9
 
29d2b9
 		rv = mount_subtree(ap, me, name, NULL, options, ctxt);
29d2b9