From 058ccf9520794280f3fc254de00e3f604e3cfbb7 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 5 Jul 2016 14:33:15 +0530 Subject: glusterd: Fix memory leak in glusterd (un)lock RPCs Problem: At the time of execute "gluster volume profile info" command It does have memory leak in glusterd. Solution: Modify the code to prevent memory leak in glusterd. Fix : 1) Unref dict and free dict_val buffer in glusterd_mgmt_v3_lock_peer and glusterd_mgmt_v3_unlock_peers. Test : To verify the patch run below loop to generate io traffic for (( i=0 ; i<=1000000 ; i++ )); do echo "hi Start Line " > file$i; cat file$i >> /dev/null; done To verify the improvement in memory leak specific to glusterd run below command cnt=0;while [ $cnt -le 1000 ]; do pmap -x | grep total; gluster volume profile distributed info > /dev/null; cnt=`expr $cnt + 1`; done After apply this patch it will reduce leak significantly. > Reviewed-on: http://review.gluster.org/14862 > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: Atin Mukherjee > Reviewed-by: Prashanth Pai BUG: 1363747 Change-Id: I52a0ca47adb20bfe4b1848a11df23e5e37c5cea9 Signed-off-by: Mohit Agrawal Signed-off-by: Oleksandr Natalenko Reviewed-on: http://review.gluster.org/15081 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c index ffe678b0ff2..73f70476310 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c @@ -1789,6 +1789,10 @@ glusterd_mgmt_v3_lock_peers (call_frame_t *frame, xlator_t *this, (xdrproc_t)xdr_gd1_mgmt_v3_lock_req); out: gf_msg_debug (this->name, 0, "Returning %d", ret); + if (dict) + dict_unref (dict); + if (req.dict.dict_val) + GF_FREE (req.dict.dict_val); return ret; } @@ -1866,6 +1870,11 @@ glusterd_mgmt_v3_unlock_peers (call_frame_t *frame, xlator_t *this, xdr_gd1_mgmt_v3_unlock_req); out: gf_msg_debug (this->name, 0, "Returning %d", ret); + if (dict) + dict_unref(dict); + + if (req.dict.dict_val) + GF_FREE (req.dict.dict_val); return ret; } -- cgit