summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-op-sm.c
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2014-01-17 05:51:17 +0000
committerAvra Sengupta <asengupt@redhat.com>2014-01-21 02:09:28 +0000
commit56b8ed7592e53226e356bced53147d365c5024e6 (patch)
treed66b54d2fe8fa8008716c08656f57559a82130ba /xlators/mgmt/glusterd/src/glusterd-op-sm.c
parent44be8c36ac764a652b8575b0e3115c0b88c1c50f (diff)
glusterd/vol-locks: Dict_ref while adding req_ctx->dict to txn_opinfos
Introducing a wrapper function glusterd_txn_opinfo_init(), to initialize the opinfo to be set in the txn_id engine. Removed glusterd_op_fini_ctx() as the txn opinfo should only be cleared by glusterd_clear_txn_opinfo(). Change-Id: I17e85a162d6a3bca79941f8603d0c2b579f0d194 Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c85
1 files changed, 35 insertions, 50 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 28c58f036..88c8858de 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -81,7 +81,7 @@ struct txn_opinfo_object_ {
typedef struct txn_opinfo_object_ txn_opinfo_obj;
int32_t
-glusterd_txn_opinfo_init ()
+glusterd_txn_opinfo_dict_init ()
{
int32_t ret = -1;
@@ -97,12 +97,35 @@ out:
}
void
-glusterd_txn_opinfo_fini ()
+glusterd_txn_opinfo_dict_fini ()
{
if (txn_opinfo)
dict_destroy (txn_opinfo);
}
+void
+glusterd_txn_opinfo_init (glusterd_op_info_t *opinfo,
+ glusterd_op_sm_state_info_t *state,
+ glusterd_op_t *op,
+ dict_t *op_ctx,
+ rpcsvc_request_t *req)
+{
+ GF_ASSERT (opinfo);
+
+ if (state)
+ opinfo->state = *state;
+
+ if (op)
+ opinfo->op = *op;
+
+ opinfo->op_ctx = dict_ref(op_ctx);
+
+ if (req)
+ opinfo->req = req;
+
+ return;
+}
+
int32_t
glusterd_get_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo)
{
@@ -179,7 +202,8 @@ out:
int32_t
glusterd_clear_txn_opinfo (uuid_t *txn_id)
{
- int32_t ret = -1;
+ int32_t ret = -1;
+ glusterd_op_info_t txn_op_info = {{0},};
if (!txn_id) {
gf_log ("", GF_LOG_ERROR, "Empty transaction id received.");
@@ -187,6 +211,14 @@ glusterd_clear_txn_opinfo (uuid_t *txn_id)
goto out;
}
+ ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Transaction opinfo not found");
+ goto out;
+ }
+
+ dict_unref (txn_op_info.op_ctx);
+
dict_del(txn_opinfo, uuid_utoa (*txn_id));
ret = 0;
@@ -4277,7 +4309,6 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_op_commit_send_resp (req_ctx->req, req_ctx->op,
status, op_errstr, rsp_dict);
- glusterd_op_fini_ctx ();
if (op_errstr && (strcmp (op_errstr, "")))
GF_FREE (op_errstr);
@@ -4306,7 +4337,6 @@ glusterd_op_ac_send_commit_failed (glusterd_op_sm_event_t *event, void *ctx)
opinfo.op_ret, opinfo.op_errstr,
op_ctx);
- glusterd_op_fini_ctx ();
if (opinfo.op_errstr && (strcmp (opinfo.op_errstr, ""))) {
GF_FREE (opinfo.op_errstr);
opinfo.op_errstr = NULL;
@@ -6174,51 +6204,6 @@ glusterd_op_clear_op (glusterd_op_t op)
}
int32_t
-glusterd_op_init_ctx (glusterd_op_t op, glusterd_op_info_t *op_info)
-{
- int ret = 0;
- dict_t *dict = NULL;
- xlator_t *this = NULL;
-
- this = THIS;
- GF_ASSERT (this);
- GF_ASSERT (GD_OP_NONE < op && op < GD_OP_MAX);
-
- if (_gf_false == glusterd_need_brick_op (op)) {
- gf_log (this->name, GF_LOG_DEBUG, "Received op: %s, returning",
- gd_op_list[op]);
- goto out;
- }
- dict = dict_new ();
- if (dict == NULL) {
- ret = -1;
- goto out;
- }
-
- op_info->op_ctx = dict;
-out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
- return ret;
-}
-
-
-
-int32_t
-glusterd_op_fini_ctx ()
-{
- dict_t *dict = NULL;
-
- dict = glusterd_op_get_ctx ();
- if (dict)
- dict_unref (dict);
-
- glusterd_op_reset_ctx ();
- return 0;
-}
-
-
-
-int32_t
glusterd_op_free_ctx (glusterd_op_t op, void *ctx)
{