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

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