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

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