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