cb8e9e
From 9d29714514da25b3c94fd7c0acb804920500680c Mon Sep 17 00:00:00 2001
cb8e9e
From: anand <anekkunt@redhat.com>
cb8e9e
Date: Mon, 8 Jun 2015 00:19:00 +0530
cb8e9e
Subject: [PATCH 214/234] glusterd: Get the local txn_info based on trans_id in op_sm call backs.
cb8e9e
cb8e9e
Issue: when two or more transactions are running concurrently in op_sm,
cb8e9e
global op_info might get corrupted.
cb8e9e
cb8e9e
Fix: Get local txn_info based on trans_id instead of using global txn_info for
cb8e9e
commands (replace_brick, re-balance, profile ) which are using op_sm in originator.
cb8e9e
cb8e9e
TODO: Handle errors properly in call backs and completely remove the global op_info from
cb8e9e
op_sm.
cb8e9e
cb8e9e
Backportof:
cb8e9e
>Change-Id: I9d61388acc125841ddc77e2bd560cb7f17ae0a5a
cb8e9e
>BUG: 1229139
cb8e9e
>Signed-off-by: anand <anekkunt@redhat.com>
cb8e9e
cb8e9e
Change-Id: I34dd174b5c71779664d71a0f15995a205271c42f
cb8e9e
BUG: 1230525
cb8e9e
Signed-off-by: anand <anekkunt@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/52564
cb8e9e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
cb8e9e
Tested-by: Atin Mukherjee <amukherj@redhat.com>
cb8e9e
---
cb8e9e
 xlators/mgmt/glusterd/src/glusterd-op-sm.c   |   15 ++++++-
cb8e9e
 xlators/mgmt/glusterd/src/glusterd-rpc-ops.c |   55 ++++++++++++--------------
cb8e9e
 xlators/mgmt/glusterd/src/glusterd-syncop.c  |   17 --------
cb8e9e
 xlators/mgmt/glusterd/src/glusterd-utils.c   |   32 +++++++--------
cb8e9e
 xlators/mgmt/glusterd/src/glusterd-utils.h   |    4 --
cb8e9e
 5 files changed, 53 insertions(+), 70 deletions(-)
cb8e9e
cb8e9e
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
cb8e9e
index 4619f57..b1ee5e3 100644
cb8e9e
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
cb8e9e
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
cb8e9e
@@ -3996,6 +3996,7 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx)
cb8e9e
         char                    *op_errstr  = NULL;
cb8e9e
         glusterd_op_t           op = GD_OP_NONE;
cb8e9e
         uint32_t                pending_count = 0;
cb8e9e
+        glusterd_op_info_t      txn_op_info = {{0},};
cb8e9e
 
cb8e9e
         this = THIS;
cb8e9e
         GF_ASSERT (this);
cb8e9e
@@ -4047,8 +4048,18 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx)
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
-        if (op == GD_OP_REPLACE_BRICK)
cb8e9e
-                glusterd_rb_use_rsp_dict (NULL, rsp_dict);
cb8e9e
+        if (op == GD_OP_REPLACE_BRICK) {
cb8e9e
+                ret = glusterd_get_txn_opinfo (&event->txn_id, &txn_op_info);
cb8e9e
+                if (ret) {
cb8e9e
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
+                                GD_MSG_TRANS_OPINFO_GET_FAIL,
cb8e9e
+                                "Failed to get txn_op_info "
cb8e9e
+                                "for txn_id = %s", uuid_utoa (event->txn_id));
cb8e9e
+                        goto out;
cb8e9e
+                }
cb8e9e
+
cb8e9e
+                glusterd_rb_use_rsp_dict (txn_op_info.op_ctx, rsp_dict);
cb8e9e
+        }
cb8e9e
 
cb8e9e
         rcu_read_lock ();
cb8e9e
         cds_list_for_each_entry_rcu (peerinfo, &priv->peers, uuid_list) {
cb8e9e
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
cb8e9e
index 0a144b9..50820d7 100644
cb8e9e
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
cb8e9e
+++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
cb8e9e
@@ -1131,6 +1131,7 @@ __glusterd_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
cb8e9e
         xlator_t                      *this = NULL;
cb8e9e
         glusterd_conf_t               *priv = NULL;
cb8e9e
         uuid_t                        *txn_id = NULL;
cb8e9e
+        glusterd_op_info_t            txn_op_info = {{0},};
cb8e9e
 
cb8e9e
         this = THIS;
cb8e9e
         GF_ASSERT (this);
cb8e9e
@@ -1200,6 +1201,14 @@ out:
cb8e9e
         gf_msg_debug (this->name, 0, "transaction ID = %s",
cb8e9e
                 uuid_utoa (*txn_id));
cb8e9e
 
cb8e9e
+        ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info);
cb8e9e
+        if (ret) {
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
+                        GD_MSG_TRANS_OPINFO_GET_FAIL,
cb8e9e
+                        "Failed to get txn_op_info "
cb8e9e
+                        "for txn_id = %s", uuid_utoa (*txn_id));
cb8e9e
+        }
cb8e9e
+
cb8e9e
         rcu_read_lock ();
cb8e9e
         peerinfo = glusterd_peerinfo_find (rsp.uuid, NULL);
cb8e9e
         if (peerinfo == NULL) {
cb8e9e
@@ -1233,7 +1242,7 @@ out:
cb8e9e
 
cb8e9e
         switch (rsp.op) {
cb8e9e
         case GD_OP_REPLACE_BRICK:
cb8e9e
-                glusterd_rb_use_rsp_dict (NULL, dict);
cb8e9e
+                glusterd_rb_use_rsp_dict (txn_op_info.op_ctx, dict);
cb8e9e
                 break;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -1268,7 +1277,7 @@ int32_t
cb8e9e
 __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
cb8e9e
                           int count, void *myframe)
cb8e9e
 {
cb8e9e
-        gd1_mgmt_commit_op_rsp         rsp   = {{0},};
cb8e9e
+        gd1_mgmt_commit_op_rsp        rsp   = {{0},};
cb8e9e
         int                           ret   = -1;
cb8e9e
         int32_t                       op_ret = -1;
cb8e9e
         glusterd_op_sm_event_type_t   event_type = GD_OP_EVENT_NONE;
cb8e9e
@@ -1279,6 +1288,7 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
cb8e9e
         xlator_t                      *this = NULL;
cb8e9e
         glusterd_conf_t               *priv = NULL;
cb8e9e
         uuid_t                        *txn_id = NULL;
cb8e9e
+        glusterd_op_info_t            txn_op_info = {{0},};
cb8e9e
 
cb8e9e
         this = THIS;
cb8e9e
         GF_ASSERT (this);
cb8e9e
@@ -1348,6 +1358,14 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
cb8e9e
         gf_msg_debug (this->name, 0, "transaction ID = %s",
cb8e9e
                 uuid_utoa (*txn_id));
cb8e9e
 
cb8e9e
+        ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info);
cb8e9e
+        if (ret) {
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
+                        GD_MSG_TRANS_OPINFO_GET_FAIL,
cb8e9e
+                        "Failed to get txn_op_info "
cb8e9e
+                        "for txn_id = %s", uuid_utoa (*txn_id));
cb8e9e
+        }
cb8e9e
+
cb8e9e
         rcu_read_lock ();
cb8e9e
         peerinfo = glusterd_peerinfo_find (rsp.uuid, NULL);
cb8e9e
         if (peerinfo == NULL) {
cb8e9e
@@ -1377,49 +1395,26 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
cb8e9e
                 }
cb8e9e
         } else {
cb8e9e
                 event_type = GD_OP_EVENT_RCVD_ACC;
cb8e9e
+                GF_ASSERT (rsp.op == txn_op_info.op);
cb8e9e
+
cb8e9e
                 switch (rsp.op) {
cb8e9e
                 case GD_OP_REPLACE_BRICK:
cb8e9e
-                        ret = glusterd_rb_use_rsp_dict (NULL, dict);
cb8e9e
-                        if (ret)
cb8e9e
-                                goto unlock;
cb8e9e
-                break;
cb8e9e
-
cb8e9e
-                case GD_OP_SYNC_VOLUME:
cb8e9e
-                        ret = glusterd_sync_use_rsp_dict (NULL, dict);
cb8e9e
+                        ret = glusterd_rb_use_rsp_dict (txn_op_info.op_ctx, dict);
cb8e9e
                         if (ret)
cb8e9e
                                 goto unlock;
cb8e9e
                 break;
cb8e9e
 
cb8e9e
                 case GD_OP_PROFILE_VOLUME:
cb8e9e
-                        ret = glusterd_profile_volume_use_rsp_dict (NULL, dict);
cb8e9e
-                        if (ret)
cb8e9e
-                                goto unlock;
cb8e9e
-                break;
cb8e9e
-
cb8e9e
-                case GD_OP_GSYNC_SET:
cb8e9e
-                        ret = glusterd_gsync_use_rsp_dict (NULL, dict, rsp.op_errstr);
cb8e9e
-                        if (ret)
cb8e9e
-                                goto unlock;
cb8e9e
-                break;
cb8e9e
-
cb8e9e
-                case GD_OP_STATUS_VOLUME:
cb8e9e
-                        ret = glusterd_volume_status_copy_to_op_ctx_dict (NULL, dict);
cb8e9e
+                        ret = glusterd_profile_volume_use_rsp_dict (txn_op_info.op_ctx, dict);
cb8e9e
                         if (ret)
cb8e9e
                                 goto unlock;
cb8e9e
                 break;
cb8e9e
 
cb8e9e
                 case GD_OP_REBALANCE:
cb8e9e
                 case GD_OP_DEFRAG_BRICK_VOLUME:
cb8e9e
-                        ret = glusterd_volume_rebalance_use_rsp_dict (NULL, dict);
cb8e9e
-                        if (ret)
cb8e9e
-                                goto unlock;
cb8e9e
-                break;
cb8e9e
-
cb8e9e
-                case GD_OP_HEAL_VOLUME:
cb8e9e
-                        ret = glusterd_volume_heal_use_rsp_dict (NULL, dict);
cb8e9e
+                        ret = glusterd_volume_rebalance_use_rsp_dict (txn_op_info.op_ctx, dict);
cb8e9e
                         if (ret)
cb8e9e
                                 goto unlock;
cb8e9e
-
cb8e9e
                 break;
cb8e9e
 
cb8e9e
                 default:
cb8e9e
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
cb8e9e
index a54073e..1d5deb8 100644
cb8e9e
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
cb8e9e
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
cb8e9e
@@ -245,11 +245,6 @@ glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp)
cb8e9e
                 }
cb8e9e
         break;
cb8e9e
 
cb8e9e
-        case GD_OP_REPLACE_BRICK:
cb8e9e
-                ret = glusterd_rb_use_rsp_dict (aggr, rsp);
cb8e9e
-                if (ret)
cb8e9e
-                        goto out;
cb8e9e
-        break;
cb8e9e
 
cb8e9e
         case GD_OP_SYNC_VOLUME:
cb8e9e
                 ret = glusterd_sync_use_rsp_dict (aggr, rsp);
cb8e9e
@@ -257,12 +252,6 @@ glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp)
cb8e9e
                         goto out;
cb8e9e
         break;
cb8e9e
 
cb8e9e
-        case GD_OP_PROFILE_VOLUME:
cb8e9e
-                ret = glusterd_profile_volume_use_rsp_dict (aggr, rsp);
cb8e9e
-                if (ret)
cb8e9e
-                        goto out;
cb8e9e
-        break;
cb8e9e
-
cb8e9e
         case GD_OP_GSYNC_CREATE:
cb8e9e
         break;
cb8e9e
 
cb8e9e
@@ -278,12 +267,6 @@ glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp)
cb8e9e
                         goto out;
cb8e9e
         break;
cb8e9e
 
cb8e9e
-        case GD_OP_REBALANCE:
cb8e9e
-        case GD_OP_DEFRAG_BRICK_VOLUME:
cb8e9e
-                ret = glusterd_volume_rebalance_use_rsp_dict (aggr, rsp);
cb8e9e
-                if (ret)
cb8e9e
-                        goto out;
cb8e9e
-        break;
cb8e9e
 
cb8e9e
         case GD_OP_HEAL_VOLUME:
cb8e9e
                 ret = glusterd_volume_heal_use_rsp_dict (aggr, rsp);
cb8e9e
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
cb8e9e
index 7347fb2..770cbf7 100644
cb8e9e
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
cb8e9e
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
cb8e9e
@@ -7404,13 +7404,11 @@ glusterd_rb_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
cb8e9e
                 ctx = aggr;
cb8e9e
 
cb8e9e
         } else {
cb8e9e
-                ctx = glusterd_op_get_ctx ();
cb8e9e
-                if (!ctx) {
cb8e9e
-                        gf_msg ("glusterd", GF_LOG_ERROR, 0,
cb8e9e
-                                GD_MSG_OPCTX_GET_FAIL,
cb8e9e
-                                "Operation Context is not present");
cb8e9e
-                        GF_ASSERT (0);
cb8e9e
-                }
cb8e9e
+              gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
+                      GD_MSG_OPCTX_GET_FAIL,
cb8e9e
+                      "Operation Context is not present");
cb8e9e
+                ret = -1;
cb8e9e
+                goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
         if (rsp_dict) {
cb8e9e
@@ -7518,14 +7516,15 @@ glusterd_profile_volume_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
cb8e9e
                 ret = 0; //no bricks in the rsp
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
-
cb8e9e
-        op = glusterd_op_get_op ();
cb8e9e
-        GF_ASSERT (GD_OP_PROFILE_VOLUME == op);
cb8e9e
         if (aggr) {
cb8e9e
                 ctx_dict = aggr;
cb8e9e
 
cb8e9e
         } else {
cb8e9e
-                ctx_dict = glusterd_op_get_ctx ();
cb8e9e
+              gf_msg ("glusterd", GF_LOG_ERROR, 0,
cb8e9e
+                       GD_MSG_OPCTX_GET_FAIL,
cb8e9e
+                       "Operation Context is not present");
cb8e9e
+                ret = -1;
cb8e9e
+                goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
         ret = dict_get_int32 (ctx_dict, "count", &count);
cb8e9e
@@ -7962,16 +7961,15 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
cb8e9e
         GF_ASSERT (rsp_dict);
cb8e9e
         conf = THIS->private;
cb8e9e
 
cb8e9e
-        op = glusterd_op_get_op ();
cb8e9e
-        GF_ASSERT ((GD_OP_REBALANCE == op) ||
cb8e9e
-                   (GD_OP_DEFRAG_BRICK_VOLUME == op));
cb8e9e
-
cb8e9e
         if (aggr) {
cb8e9e
                 ctx_dict = aggr;
cb8e9e
 
cb8e9e
         } else {
cb8e9e
-                ctx_dict = glusterd_op_get_ctx (op);
cb8e9e
-
cb8e9e
+              gf_msg ("glusterd", GF_LOG_ERROR, 0,
cb8e9e
+                      GD_MSG_OPCTX_GET_FAIL,
cb8e9e
+                      "Operation Context is not present");
cb8e9e
+                ret = -1;
cb8e9e
+                goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
         if (!ctx_dict)
cb8e9e
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
cb8e9e
index 27c51fa..44fcdd3 100644
cb8e9e
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
cb8e9e
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
cb8e9e
@@ -425,10 +425,6 @@ int32_t
cb8e9e
 glusterd_handle_node_rsp (dict_t *req_ctx, void *pending_entry,
cb8e9e
                           glusterd_op_t op, dict_t *rsp_dict, dict_t *op_ctx,
cb8e9e
                           char **op_errstr, gd_node_type type);
cb8e9e
-int
cb8e9e
-glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict);
cb8e9e
-int
cb8e9e
-glusterd_volume_heal_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict);
cb8e9e
 
cb8e9e
 int32_t
cb8e9e
 glusterd_check_if_quota_trans_enabled (glusterd_volinfo_t *volinfo);
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e