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