256ebe
From 6c004c6c8b8f98f56e186740881520b8364e6f85 Mon Sep 17 00:00:00 2001
256ebe
From: Atin Mukherjee <amukherj@redhat.com>
256ebe
Date: Mon, 18 Mar 2019 16:08:04 +0530
256ebe
Subject: [PATCH 45/52] glusterd: fix txn-id mem leak
256ebe
256ebe
This commit ensures the following:
256ebe
1. Don't send commit op request to the remote nodes when gluster v
256ebe
status all is executed as for the status all transaction the local
256ebe
commit gets the name of the volumes and remote commit ops are
256ebe
technically a no-op. So no need for additional rpc requests.
256ebe
2. In op state machine flow, if the transaction is in staged state and
256ebe
op_info.skip_locking is true, then no need to set the txn id in the
256ebe
priv->glusterd_txn_opinfo dictionary which never gets freed.
256ebe
256ebe
> Fixes: bz#1691164
256ebe
> Change-Id: Ib6a9300ea29633f501abac2ba53fb72ff648c822
256ebe
> Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
256ebe
256ebe
upstream patch: https://review.gluster.org/#/c/glusterfs/+/22388/
256ebe
256ebe
BUG: 1670415
256ebe
Change-Id: Ib6a9300ea29633f501abac2ba53fb72ff648c822
256ebe
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
256ebe
Reviewed-on: https://code.engineering.redhat.com/gerrit/166449
256ebe
Tested-by: RHGS Build Bot <nigelb@redhat.com>
256ebe
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
256ebe
---
256ebe
 xlators/mgmt/glusterd/src/glusterd-op-sm.c  | 26 ++++++++++++++++++++------
256ebe
 xlators/mgmt/glusterd/src/glusterd-syncop.c | 16 ++++++++++++++++
256ebe
 2 files changed, 36 insertions(+), 6 deletions(-)
256ebe
256ebe
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
256ebe
index cbbb5d9..12d857a 100644
256ebe
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
256ebe
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
256ebe
@@ -5652,6 +5652,9 @@ glusterd_op_ac_stage_op(glusterd_op_sm_event_t *event, void *ctx)
256ebe
     dict_t *dict = NULL;
256ebe
     xlator_t *this = NULL;
256ebe
     uuid_t *txn_id = NULL;
256ebe
+    glusterd_op_info_t txn_op_info = {
256ebe
+        {0},
256ebe
+    };
256ebe
 
256ebe
     this = THIS;
256ebe
     GF_ASSERT(this);
256ebe
@@ -5686,6 +5689,7 @@ glusterd_op_ac_stage_op(glusterd_op_sm_event_t *event, void *ctx)
256ebe
         ret = -1;
256ebe
         goto out;
256ebe
     }
256ebe
+    ret = glusterd_get_txn_opinfo(&event->txn_id, &txn_op_info);
256ebe
 
256ebe
     ret = dict_set_bin(rsp_dict, "transaction_id", txn_id, sizeof(*txn_id));
256ebe
     if (ret) {
256ebe
@@ -5704,6 +5708,12 @@ out:
256ebe
 
256ebe
     gf_msg_debug(this->name, 0, "Returning with %d", ret);
256ebe
 
256ebe
+    /* for no volname transactions, the txn_opinfo needs to be cleaned up
256ebe
+     * as there's no unlock event triggered
256ebe
+     */
256ebe
+    if (txn_op_info.skip_locking)
256ebe
+        ret = glusterd_clear_txn_opinfo(txn_id);
256ebe
+
256ebe
     if (rsp_dict)
256ebe
         dict_unref(rsp_dict);
256ebe
 
256ebe
@@ -8159,12 +8169,16 @@ glusterd_op_sm()
256ebe
                            "Unable to clear "
256ebe
                            "transaction's opinfo");
256ebe
             } else {
256ebe
-                ret = glusterd_set_txn_opinfo(&event->txn_id, &opinfo);
256ebe
-                if (ret)
256ebe
-                    gf_msg(this->name, GF_LOG_ERROR, 0,
256ebe
-                           GD_MSG_TRANS_OPINFO_SET_FAIL,
256ebe
-                           "Unable to set "
256ebe
-                           "transaction's opinfo");
256ebe
+                if (!(event_type == GD_OP_EVENT_STAGE_OP &&
256ebe
+                      opinfo.state.state == GD_OP_STATE_STAGED &&
256ebe
+                      opinfo.skip_locking)) {
256ebe
+                    ret = glusterd_set_txn_opinfo(&event->txn_id, &opinfo);
256ebe
+                    if (ret)
256ebe
+                        gf_msg(this->name, GF_LOG_ERROR, 0,
256ebe
+                               GD_MSG_TRANS_OPINFO_SET_FAIL,
256ebe
+                               "Unable to set "
256ebe
+                               "transaction's opinfo");
256ebe
+                }
256ebe
             }
256ebe
 
256ebe
             glusterd_destroy_op_event_ctx(event);
256ebe
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
256ebe
index 1741cf8..618d8bc 100644
256ebe
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
256ebe
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
256ebe
@@ -1392,6 +1392,8 @@ gd_commit_op_phase(glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
256ebe
     char *errstr = NULL;
256ebe
     struct syncargs args = {0};
256ebe
     int type = GF_QUOTA_OPTION_TYPE_NONE;
256ebe
+    uint32_t cmd = 0;
256ebe
+    gf_boolean_t origin_glusterd = _gf_false;
256ebe
 
256ebe
     this = THIS;
256ebe
     GF_ASSERT(this);
256ebe
@@ -1449,6 +1451,20 @@ commit_done:
256ebe
     gd_syncargs_init(&args, op_ctx);
256ebe
     synctask_barrier_init((&args));
256ebe
     peer_cnt = 0;
256ebe
+    origin_glusterd = is_origin_glusterd(req_dict);
256ebe
+
256ebe
+    if (op == GD_OP_STATUS_VOLUME) {
256ebe
+        ret = dict_get_uint32(req_dict, "cmd", &cmd);
256ebe
+        if (ret)
256ebe
+            goto out;
256ebe
+
256ebe
+        if (origin_glusterd) {
256ebe
+            if ((cmd & GF_CLI_STATUS_ALL)) {
256ebe
+                ret = 0;
256ebe
+                goto out;
256ebe
+            }
256ebe
+        }
256ebe
+    }
256ebe
 
256ebe
     RCU_READ_LOCK;
256ebe
     cds_list_for_each_entry_rcu(peerinfo, &conf->peers, uuid_list)
256ebe
-- 
256ebe
1.8.3.1
256ebe