a3470f
From 47678bde5c2f8e674289d2b0893865ab3fa43940 Mon Sep 17 00:00:00 2001
a3470f
From: Atin Mukherjee <amukherj@redhat.com>
a3470f
Date: Sun, 1 Apr 2018 10:10:41 +0530
a3470f
Subject: [PATCH 207/212] glusterd: fix txn_opinfo memory leak
a3470f
a3470f
For transactions where there's no volname involved (eg : gluster v
a3470f
status), the originator node initiates with staging phase and what that
a3470f
means in op-sm there's no unlock event triggered which resulted into a
a3470f
txn_opinfo dictionary leak.
a3470f
a3470f
Credits : cynthia.zhou@nokia-sbell.com
a3470f
a3470f
> upstream patch : https://review.gluster.org/#/c/19801/
a3470f
a3470f
>Change-Id: I92fffbc2e8e1b010f489060f461be78aa2b86615
a3470f
>Fixes: bz#1550339
a3470f
>Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
a3470f
Change-Id: I92fffbc2e8e1b010f489060f461be78aa2b86615
a3470f
BUG: 1529451
a3470f
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/134448
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
---
a3470f
 xlators/mgmt/glusterd/src/glusterd-handler.c |  1 +
a3470f
 xlators/mgmt/glusterd/src/glusterd-op-sm.c   | 32 ++++++++++++++++++++--------
a3470f
 xlators/mgmt/glusterd/src/glusterd-op-sm.h   |  1 +
a3470f
 3 files changed, 25 insertions(+), 9 deletions(-)
a3470f
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
a3470f
index ddab159..dbf80a1 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
a3470f
@@ -1073,6 +1073,7 @@ __glusterd_handle_stage_op (rpcsvc_request_t *req)
a3470f
                 glusterd_txn_opinfo_init (&txn_op_info, &state, &op_req.op,
a3470f
                                           req_ctx->dict, req);
a3470f
 
a3470f
+                txn_op_info.skip_locking = _gf_true;
a3470f
                 ret = glusterd_set_txn_opinfo (txn_id, &txn_op_info);
a3470f
                 if (ret) {
a3470f
                         gf_msg (this->name, GF_LOG_ERROR, 0,
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
a3470f
index a02a0b3..72d349b 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
a3470f
@@ -5919,14 +5919,15 @@ glusterd_op_init_commit_rsp_dict (glusterd_op_t op)
a3470f
 static int
a3470f
 glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx)
a3470f
 {
a3470f
-        int                       ret        = 0;
a3470f
-        glusterd_req_ctx_t       *req_ctx    = NULL;
a3470f
-        int32_t                   status     = 0;
a3470f
-        char                     *op_errstr  = NULL;
a3470f
-        dict_t                   *dict       = NULL;
a3470f
-        dict_t                   *rsp_dict   = NULL;
a3470f
-        xlator_t                 *this       = NULL;
a3470f
-        uuid_t                   *txn_id     = NULL;
a3470f
+        int                       ret         = 0;
a3470f
+        glusterd_req_ctx_t       *req_ctx     = NULL;
a3470f
+        int32_t                   status      = 0;
a3470f
+        char                     *op_errstr   = NULL;
a3470f
+        dict_t                   *dict        = NULL;
a3470f
+        dict_t                   *rsp_dict    = NULL;
a3470f
+        xlator_t                 *this        = NULL;
a3470f
+        uuid_t                   *txn_id      = NULL;
a3470f
+        glusterd_op_info_t        txn_op_info = {{0},};
a3470f
 
a3470f
         this = THIS;
a3470f
         GF_ASSERT (this);
a3470f
@@ -5965,6 +5966,15 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx)
a3470f
                 ret = -1;
a3470f
                 goto out;
a3470f
         }
a3470f
+        ret = glusterd_get_txn_opinfo (&event->txn_id, &txn_op_info);
a3470f
+        if (ret) {
a3470f
+                gf_msg_callingfn (this->name, GF_LOG_ERROR, 0,
a3470f
+                        GD_MSG_TRANS_OPINFO_GET_FAIL,
a3470f
+                        "Unable to get transaction opinfo "
a3470f
+                        "for transaction ID : %s",
a3470f
+                        uuid_utoa (event->txn_id));
a3470f
+                goto out;
a3470f
+        }
a3470f
 
a3470f
         ret = dict_set_bin (rsp_dict, "transaction_id",
a3470f
                             txn_id, sizeof(*txn_id));
a3470f
@@ -5985,7 +5995,11 @@ out:
a3470f
 
a3470f
         if (rsp_dict)
a3470f
                 dict_unref (rsp_dict);
a3470f
-
a3470f
+        /* for no volname transactions, the txn_opinfo needs to be cleaned up
a3470f
+         * as there's no unlock event triggered
a3470f
+         */
a3470f
+        if (txn_op_info.skip_locking)
a3470f
+                ret = glusterd_clear_txn_opinfo (txn_id);
a3470f
         gf_msg_debug (this->name, 0, "Returning with %d", ret);
a3470f
 
a3470f
         return ret;
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
a3470f
index 24b1944..f2aee9c 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
a3470f
@@ -101,6 +101,7 @@ struct glusterd_op_info_ {
a3470f
         char                            *op_errstr;
a3470f
         struct  cds_list_head           pending_bricks;
a3470f
         uint32_t                        txn_generation;
a3470f
+        gf_boolean_t                    skip_locking;
a3470f
 };
a3470f
 
a3470f
 typedef struct glusterd_op_info_ glusterd_op_info_t;
a3470f
-- 
a3470f
1.8.3.1
a3470f