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