Blame SOURCES/autofs-5.1.7-eliminate-redundant-cache-lookup-in-tree_mapent_add_node.patch

29d2b9
autofs-5.1.7 - eliminate redundant cache lookup in tree_mapent_add_node()
29d2b9
29d2b9
From: Ian Kent <raven@themaw.net>
29d2b9
29d2b9
Since we need to create the offset tree after adding the offset entries
29d2b9
to the mapent cache (from a list.h list) there's no need to lookup the
29d2b9
mapent in tree_mapent_add_node() and validate it. Just use it directly
29d2b9
when calling tree_mapent_add_node() and avoid a cache lookup on every
29d2b9
node addition.
29d2b9
29d2b9
Signed-off-by: Ian Kent <raven@themaw.net>
29d2b9
---
29d2b9
 CHANGELOG           |    1 +
29d2b9
 include/mounts.h    |    2 +-
29d2b9
 lib/mounts.c        |   13 ++-----------
29d2b9
 modules/parse_sun.c |    2 +-
29d2b9
 4 files changed, 5 insertions(+), 13 deletions(-)
29d2b9
29d2b9
--- autofs-5.1.7.orig/CHANGELOG
29d2b9
+++ autofs-5.1.7/CHANGELOG
29d2b9
@@ -71,6 +71,7 @@
29d2b9
 - fix amd hosts mount expire.
29d2b9
 - fix offset entries order.
29d2b9
 - use mapent tree root for tree_mapent_add_node().
29d2b9
+- eliminate redundant cache lookup in tree_mapent_add_node().
29d2b9
 
29d2b9
 25/01/2021 autofs-5.1.7
29d2b9
 - make bind mounts propagation slave by default.
29d2b9
--- autofs-5.1.7.orig/include/mounts.h
29d2b9
+++ autofs-5.1.7/include/mounts.h
29d2b9
@@ -170,7 +170,7 @@ void mnts_get_expire_list(struct list_he
29d2b9
 void mnts_put_expire_list(struct list_head *mnts);
29d2b9
 void mnts_set_mounted_mount(struct autofs_point *ap, const char *name, unsigned int flags);
29d2b9
 struct tree_node *tree_mapent_root(struct mapent *me);
29d2b9
-int tree_mapent_add_node(struct mapent_cache *mc, struct tree_node *root, const char *key);
29d2b9
+int tree_mapent_add_node(struct mapent_cache *mc, struct tree_node *root, struct mapent *me);
29d2b9
 int tree_mapent_delete_offsets(struct mapent_cache *mc, const char *key);
29d2b9
 void tree_mapent_cleanup_offsets(struct mapent *oe);
29d2b9
 int tree_mapent_mount_offsets(struct mapent *oe, int nonstrict);
29d2b9
--- autofs-5.1.7.orig/lib/mounts.c
29d2b9
+++ autofs-5.1.7/lib/mounts.c
29d2b9
@@ -1519,19 +1519,10 @@ static void tree_mapent_free(struct tree
29d2b9
 }
29d2b9
 
29d2b9
 int tree_mapent_add_node(struct mapent_cache *mc,
29d2b9
-			 struct tree_node *root, const char *key)
29d2b9
+			 struct tree_node *root, struct mapent *me)
29d2b9
 {
29d2b9
-	unsigned int logopt = mc->ap->logopt;
29d2b9
 	struct tree_node *n;
29d2b9
 	struct mapent *parent;
29d2b9
-	struct mapent *me;
29d2b9
-
29d2b9
-	me = cache_lookup_distinct(mc, key);
29d2b9
-	if (!me) {
29d2b9
-		error(logopt,
29d2b9
-		     "failed to find key %s of multi-mount", key);
29d2b9
-		return 0;
29d2b9
-	}
29d2b9
 
29d2b9
 	n = tree_add_node(root, me);
29d2b9
 	if (!n)
29d2b9
@@ -1540,7 +1531,7 @@ int tree_mapent_add_node(struct mapent_c
29d2b9
 	MAPENT_SET_ROOT(me, root)
29d2b9
 
29d2b9
 	/* Set the subtree parent */
29d2b9
-	parent = cache_get_offset_parent(mc, key);
29d2b9
+	parent = cache_get_offset_parent(mc, me->key);
29d2b9
 	if (!parent)
29d2b9
 		MAPENT_SET_PARENT(me, root)
29d2b9
 	else
29d2b9
--- autofs-5.1.7.orig/modules/parse_sun.c
29d2b9
+++ autofs-5.1.7/modules/parse_sun.c
29d2b9
@@ -1546,7 +1546,7 @@ dont_expand:
29d2b9
 			return 1;
29d2b9
 		}
29d2b9
 		list_for_each_entry_safe(oe, tmp, &offsets, work) {
29d2b9
-			if (!tree_mapent_add_node(mc, MAPENT_ROOT(me), oe->key))
29d2b9
+			if (!tree_mapent_add_node(mc, MAPENT_ROOT(me), oe))
29d2b9
 				error(ap->logopt, "failed to add offset %s to tree", oe->key);
29d2b9
 			list_del_init(&oe->work);
29d2b9
 		}