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

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