|
|
e7a346 |
From eadd7e7168349705b29bc6ae9f99ba3e6ae58060 Mon Sep 17 00:00:00 2001
|
|
|
e7a346 |
From: Sanju Rakonde <srakonde@redhat.com>
|
|
|
e7a346 |
Date: Mon, 16 Jul 2018 15:59:36 +0530
|
|
|
e7a346 |
Subject: [PATCH 326/333] glusterd: memory leak in get-state
|
|
|
e7a346 |
|
|
|
e7a346 |
Problem: gluster get-state command is leaking the memory when
|
|
|
e7a346 |
geo-replication session is configured.
|
|
|
e7a346 |
|
|
|
e7a346 |
Cause: In glusterd_print_gsync_status(), we are trying to get
|
|
|
e7a346 |
reference to the keys of gsync_dict. The references to keys of
|
|
|
e7a346 |
gsync_dict are stored status_vols[i]. status_vols[i] are
|
|
|
e7a346 |
allocated with a memory of size of gf_gsync_status_t.
|
|
|
e7a346 |
|
|
|
e7a346 |
Solution: Need not to use a array of pointers(status_vals), using
|
|
|
e7a346 |
a pointer to hold the reference to a key of gsync_dict is sufficient.
|
|
|
e7a346 |
|
|
|
e7a346 |
Followed the below steps for testing:
|
|
|
e7a346 |
1. Configured geo-rep session
|
|
|
e7a346 |
2. Ran gluster get-state command for 1000 times.
|
|
|
e7a346 |
|
|
|
e7a346 |
Without this patch, glusterd's memory was increasing significantly
|
|
|
e7a346 |
(around 22000KB per 1000 times), with this patch it reduced (1500KB
|
|
|
e7a346 |
per 1000 times)
|
|
|
e7a346 |
|
|
|
e7a346 |
>fixes: bz#1601423
|
|
|
e7a346 |
>Change-Id: I361f5525d71f821bb345419ccfdc20ca288ca292
|
|
|
e7a346 |
>Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
|
|
|
e7a346 |
|
|
|
e7a346 |
upstream patch: https://review.gluster.org/#/c/20521/
|
|
|
e7a346 |
|
|
|
e7a346 |
Change-Id: I361f5525d71f821bb345419ccfdc20ca288ca292
|
|
|
e7a346 |
BUG: 1599362
|
|
|
e7a346 |
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
|
|
|
e7a346 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/144325
|
|
|
e7a346 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
e7a346 |
Reviewed-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
e7a346 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
e7a346 |
---
|
|
|
e7a346 |
xlators/mgmt/glusterd/src/glusterd-handler.c | 53 ++++++++++------------------
|
|
|
e7a346 |
1 file changed, 19 insertions(+), 34 deletions(-)
|
|
|
e7a346 |
|
|
|
e7a346 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
e7a346 |
index 395b342..861ff17 100644
|
|
|
e7a346 |
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
e7a346 |
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
e7a346 |
@@ -5082,7 +5082,7 @@ glusterd_print_gsync_status (FILE *fp, dict_t *gsync_dict)
|
|
|
e7a346 |
int ret = -1;
|
|
|
e7a346 |
int gsync_count = 0;
|
|
|
e7a346 |
int i = 0;
|
|
|
e7a346 |
- gf_gsync_status_t **status_vals = NULL;
|
|
|
e7a346 |
+ gf_gsync_status_t *status_vals = NULL;
|
|
|
e7a346 |
char status_val_name[PATH_MAX] = {0,};
|
|
|
e7a346 |
|
|
|
e7a346 |
GF_VALIDATE_OR_GOTO (THIS->name, fp, out);
|
|
|
e7a346 |
@@ -5097,62 +5097,47 @@ glusterd_print_gsync_status (FILE *fp, dict_t *gsync_dict)
|
|
|
e7a346 |
goto out;
|
|
|
e7a346 |
}
|
|
|
e7a346 |
|
|
|
e7a346 |
- status_vals = GF_CALLOC (gsync_count, sizeof (gf_gsync_status_t *),
|
|
|
e7a346 |
- gf_common_mt_char);
|
|
|
e7a346 |
- if (!status_vals) {
|
|
|
e7a346 |
- ret = -1;
|
|
|
e7a346 |
- goto out;
|
|
|
e7a346 |
- }
|
|
|
e7a346 |
- for (i = 0; i < gsync_count; i++) {
|
|
|
e7a346 |
- status_vals[i] = GF_CALLOC (1, sizeof (gf_gsync_status_t),
|
|
|
e7a346 |
- gf_common_mt_char);
|
|
|
e7a346 |
- if (!status_vals[i]) {
|
|
|
e7a346 |
- ret = -1;
|
|
|
e7a346 |
- goto out;
|
|
|
e7a346 |
- }
|
|
|
e7a346 |
- }
|
|
|
e7a346 |
-
|
|
|
e7a346 |
for (i = 0; i < gsync_count; i++) {
|
|
|
e7a346 |
snprintf (status_val_name, sizeof(status_val_name), "status_value%d", i);
|
|
|
e7a346 |
|
|
|
e7a346 |
- ret = dict_get_bin (gsync_dict, status_val_name, (void **)&(status_vals[i]));
|
|
|
e7a346 |
+ ret = dict_get_bin (gsync_dict, status_val_name, (void **)&(status_vals));
|
|
|
e7a346 |
if (ret)
|
|
|
e7a346 |
goto out;
|
|
|
e7a346 |
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.session_slave: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(21, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(21, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.master_node: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(0, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(0, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.master_volume: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(1, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(1, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.master_brick: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(2, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(2, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.slave_user: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(3, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(3, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.slave: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(4, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(4, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.slave_node: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(5, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(5, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.status: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(6, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(6, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.crawl_status: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(7, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(7, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.last_synced: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(8, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(8, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.entry: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(9, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(9, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.data: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(10, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(10, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.meta: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(11, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(11, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.failures: %s\n", volcount, i+1,
|
|
|
e7a346 |
- get_struct_variable(12, status_vals[i]));
|
|
|
e7a346 |
+ get_struct_variable(12, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.checkpoint_time: %s\n", volcount,
|
|
|
e7a346 |
- i+1, get_struct_variable(13, status_vals[i]));
|
|
|
e7a346 |
+ i+1, get_struct_variable(13, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.checkpoint_completed: %s\n",
|
|
|
e7a346 |
- volcount, i+1, get_struct_variable(14, status_vals[i]));
|
|
|
e7a346 |
+ volcount, i+1, get_struct_variable(14, status_vals));
|
|
|
e7a346 |
fprintf (fp, "Volume%d.pair%d.checkpoint_completion_time: %s\n",
|
|
|
e7a346 |
- volcount, i+1, get_struct_variable(15, status_vals[i]));
|
|
|
e7a346 |
+ volcount, i+1, get_struct_variable(15, status_vals));
|
|
|
e7a346 |
}
|
|
|
e7a346 |
out:
|
|
|
e7a346 |
return ret;
|
|
|
e7a346 |
--
|
|
|
e7a346 |
1.8.3.1
|
|
|
e7a346 |
|