summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawa@redhat.com>2017-12-07 10:32:05 +0530
committerAmar Tumballi <amarts@redhat.com>2017-12-12 12:08:30 +0000
commite016bcaf8171373cbc327faf42a6b2f2c5449b0e (patch)
treeed46867202d804c00a2506a951ee2d81a3fdaf11 /xlators
parentd95db5505a9cb923e61ccd23d28b45ceb07b716f (diff)
glusterd : Fix glusterd mem leaks
Problem: glusterd eats a huge amount of meory during volume set/stop/start. Solution: At the time of compare graph topology create a graph and populate key values in the dictionary, after finished graph comparison we do destroy the new graph.At the time of construct graph we don't take any reference and for server xlators we do take reference in server_setvolume so in glusterd we do take reference after prepare a new graph while we do create a graph to compare graph topology. BUG: 1520245 Change-Id: I573133d57771b7dc431a04422c5001a06b7dda9a Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c34
2 files changed, 37 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index 56ddce88d5e..d0756fded40 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -1293,6 +1293,9 @@ out:
if (rsp.hndsk.hndsk_val)
GF_FREE (rsp.hndsk.hndsk_val);
+ if (args_dict)
+ dict_unref (args_dict);
+
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index aa8b4e4ede8..24d276b7cb0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -8992,6 +8992,36 @@ glusterd_defrag_volume_status_update (glusterd_volinfo_t *volinfo,
return ret;
}
+/*
+ The function is required to take dict ref for every xlator at graph.
+ At the time of compare graph topology create a graph and populate
+ key values in the dictionary, after finished graph comparison we do destroy
+ the new graph.At the time of construct graph we don't take any reference
+ so to avoid leak due to ref counter underflow we need to call dict_ref here.
+
+*/
+
+void
+glusterd_graph_take_reference (xlator_t *tree)
+{ xlator_t *trav = tree;
+ xlator_t *prev = tree;
+
+ if (!tree) {
+ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_TREE_NOT_FOUND,
+ "Translator tree not found");
+ return;
+ }
+
+ while (prev) {
+ trav = prev->next;
+ if (prev->options)
+ dict_ref (prev->options);
+ prev = trav;
+ }
+ return;
+}
+
+
int
glusterd_check_topology_identical (const char *filename1,
@@ -9039,11 +9069,15 @@ glusterd_check_topology_identical (const char *filename1,
if (grph1 == NULL)
goto out;
+ glusterd_graph_take_reference (grph1->first);
+
/* create the graph for filename2 */
grph2 = glusterfs_graph_construct(fp2);
if (grph2 == NULL)
goto out;
+ glusterd_graph_take_reference (grph2->first);
+
/* compare the graph topology */
*identical = is_graph_topology_equal(grph1, grph2);
ret = 0; /* SUCCESS */