gfs2-utils: RHEL7 - libgfs2: Use the correct parent for rgrp tree insertion

Andrew Price andyp at fedoraproject.org
Tue Apr 7 21:24:07 UTC 2015


Gitweb:        http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=156b36b3637abfbc03f46b9fc7da5d5c23d031ec
Commit:        156b36b3637abfbc03f46b9fc7da5d5c23d031ec
Parent:        03a7bea1ace2ab3b8bd753662b6b848027a6e9b8
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Thu Feb 19 23:55:53 2015 +0000
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Wed Apr 1 16:51:35 2015 +0100

libgfs2: Use the correct parent for rgrp tree insertion

lgfs2_rgrps_append() was using the parent of the last rgrp instead of
the last rgrp itself as the intended parent when inserting new rgrps
into the tree. This left the tree unbalanced in such a way as to make
lookups of the last node in the tree effectively a linear list search.
This was done for each rgrp insertion so, although it didn't cause a
noticeable slow-down for smaller file sytems, tests on 250TB volumes
requiring over a million resource groups would become CPU bound and
could take hours to complete.

This patch fixes lgfs2_rgrps_append() to use the correct parent node for
rgrp tree insertions, giving a significant performance improvement when
creating file systems on large volumes.

Resolves: rhbz#1194446

Signed-off-by: Andrew Price <anprice at redhat.com>
---
 gfs2/libgfs2/rgrp.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index ed8e01d..cf4385a 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -539,9 +539,9 @@ struct osi_node *lgfs2_rgrps_root(lgfs2_rgrps_t rgs)
 lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry)
 {
 	lgfs2_rgrp_t rg;
-	lgfs2_rgrp_t lastrg = (lgfs2_rgrp_t)osi_last(&rgs->root);
 	struct osi_node **link = &rgs->root.osi_node;
-	struct osi_node *parent = NULL;
+	struct osi_node *parent = osi_last(&rgs->root);
+	lgfs2_rgrp_t lastrg = (lgfs2_rgrp_t)parent;
 
 	errno = EINVAL;
 	if (entry == NULL)
@@ -550,7 +550,6 @@ lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry)
 	if (lastrg != NULL) { /* Tree is not empty */
 		if (entry->ri_addr <= lastrg->ri.ri_addr)
 			return NULL; /* Appending with a lower address doesn't make sense */
-		parent = osi_parent(&lastrg->node);
 		link = &lastrg->node.osi_right;
 	}
 


More information about the cluster-commits mailing list