|
|
887953 |
From 63aa90525f8f408526ee5e16c42dcc976245eca7 Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
887953 |
Date: Thu, 22 Nov 2018 18:28:35 +0530
|
|
|
887953 |
Subject: [PATCH 451/451] core: Resolve memory leak at the time of graph init
|
|
|
887953 |
|
|
|
887953 |
Problem: In the commit 751b14f2bfd40e08ad395ccd98c6eb0a41ac4e91
|
|
|
887953 |
one code path is missed to avoid leak at the time
|
|
|
887953 |
of calling graph init
|
|
|
887953 |
|
|
|
887953 |
Solution: Before destroying graph call xlator fini to avoid leak for
|
|
|
887953 |
server-side xlators those call init during graph init
|
|
|
887953 |
|
|
|
887953 |
> Credit: Pranith Kumar Karampuri
|
|
|
887953 |
> fixes: bz#1651431
|
|
|
887953 |
|
|
|
887953 |
> Change-Id: I6e7cff0d792ab9d954524b28667e94f2d9ec19a2
|
|
|
887953 |
> Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
|
|
|
887953 |
> (Cherry pick from commit 12285e76e8f93ef6f6aa2611869bd1f40955dc9e)
|
|
|
887953 |
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/21695/)
|
|
|
887953 |
|
|
|
887953 |
Change-Id: Ie81635622552d43f41bbbaf810c5009a2c772a31
|
|
|
887953 |
BUG: 1650138
|
|
|
887953 |
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/156609
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
glusterfsd/src/glusterfsd.c | 36 +++++++++++++++++++++++++++++++++---
|
|
|
887953 |
1 file changed, 33 insertions(+), 3 deletions(-)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
|
|
|
887953 |
index 262a0c1..2e43cdb 100644
|
|
|
887953 |
--- a/glusterfsd/src/glusterfsd.c
|
|
|
887953 |
+++ b/glusterfsd/src/glusterfsd.c
|
|
|
887953 |
@@ -2338,6 +2338,23 @@ out:
|
|
|
887953 |
}
|
|
|
887953 |
#endif
|
|
|
887953 |
|
|
|
887953 |
+int
|
|
|
887953 |
+glusterfs_graph_fini(glusterfs_graph_t *graph)
|
|
|
887953 |
+{
|
|
|
887953 |
+ xlator_t *trav = NULL;
|
|
|
887953 |
+
|
|
|
887953 |
+ trav = graph->first;
|
|
|
887953 |
+
|
|
|
887953 |
+ while (trav) {
|
|
|
887953 |
+ if (trav->init_succeeded) {
|
|
|
887953 |
+ trav->fini(trav);
|
|
|
887953 |
+ trav->init_succeeded = 0;
|
|
|
887953 |
+ }
|
|
|
887953 |
+ trav = trav->next;
|
|
|
887953 |
+ }
|
|
|
887953 |
+
|
|
|
887953 |
+ return 0;
|
|
|
887953 |
+}
|
|
|
887953 |
|
|
|
887953 |
int
|
|
|
887953 |
glusterfs_process_volfp (glusterfs_ctx_t *ctx, FILE *fp)
|
|
|
887953 |
@@ -2384,10 +2401,23 @@ out:
|
|
|
887953 |
fclose (fp);
|
|
|
887953 |
|
|
|
887953 |
if (ret) {
|
|
|
887953 |
- if (graph && (ctx && (ctx->active != graph)))
|
|
|
887953 |
- glusterfs_graph_destroy (graph);
|
|
|
887953 |
+ /* TODO This code makes to generic for all graphs
|
|
|
887953 |
+ client as well as servers.For now it destroys
|
|
|
887953 |
+ graph only for server-side xlators not for client-side
|
|
|
887953 |
+ xlators, before destroying a graph call xlator fini for
|
|
|
887953 |
+ xlators those call xlator_init to avoid leak
|
|
|
887953 |
+ */
|
|
|
887953 |
+ if (graph) {
|
|
|
887953 |
+ xl = graph->first;
|
|
|
887953 |
+ if ((ctx && (ctx->active != graph)) &&
|
|
|
887953 |
+ (xl && !strcmp(xl->type, "protocol/server"))) {
|
|
|
887953 |
+ glusterfs_graph_fini(graph);
|
|
|
887953 |
+ glusterfs_graph_destroy(graph);
|
|
|
887953 |
+ }
|
|
|
887953 |
+ }
|
|
|
887953 |
+
|
|
|
887953 |
/* there is some error in setting up the first graph itself */
|
|
|
887953 |
- if (!ctx->active) {
|
|
|
887953 |
+ if (!ctx || !ctx->active) {
|
|
|
887953 |
emancipate (ctx, ret);
|
|
|
887953 |
cleanup_and_exit (ret);
|
|
|
887953 |
}
|
|
|
887953 |
--
|
|
|
887953 |
1.8.3.1
|
|
|
887953 |
|