summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c43
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.h9
3 files changed, 59 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 65791d413..6c99ae70b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -2097,6 +2097,8 @@ glusterd_create_volume (rpcsvc_request_t *req, dict_t *dict)
glusterd_op_set_ctx (GD_OP_CREATE_VOLUME, dict);
+ glusterd_op_set_ctx_free (GD_OP_CREATE_VOLUME, _gf_true);
+
glusterd_op_set_req (req);
data = dict_get (dict, "volname");
@@ -2140,6 +2142,7 @@ glusterd_start_volume (rpcsvc_request_t *req, char *volname, int flags)
glusterd_op_set_op (GD_OP_START_VOLUME);
glusterd_op_set_ctx (GD_OP_START_VOLUME, ctx);
+ glusterd_op_set_ctx_free (GD_OP_START_VOLUME, _gf_true);
glusterd_op_set_req (req);
ret = glusterd_op_txn_begin ();
@@ -2167,6 +2170,7 @@ glusterd_stop_volume (rpcsvc_request_t *req, char *volname, int flags)
glusterd_op_set_op (GD_OP_STOP_VOLUME);
glusterd_op_set_ctx (GD_OP_STOP_VOLUME, ctx);
+ glusterd_op_set_ctx_free (GD_OP_STOP_VOLUME, _gf_true);
glusterd_op_set_req (req);
ret = glusterd_op_txn_begin ();
@@ -2194,6 +2198,7 @@ glusterd_delete_volume (rpcsvc_request_t *req, char *volname, int flags)
glusterd_op_set_op (GD_OP_DELETE_VOLUME);
glusterd_op_set_ctx (GD_OP_DELETE_VOLUME, ctx);
+ glusterd_op_set_ctx_free (GD_OP_DELETE_VOLUME, _gf_true);
glusterd_op_set_req (req);
ret = glusterd_op_txn_begin ();
@@ -2213,6 +2218,7 @@ glusterd_add_brick (rpcsvc_request_t *req, dict_t *dict)
glusterd_op_set_op (GD_OP_ADD_BRICK);
glusterd_op_set_ctx (GD_OP_ADD_BRICK, dict);
+ glusterd_op_set_ctx_free (GD_OP_ADD_BRICK, _gf_true);
glusterd_op_set_req (req);
ret = glusterd_op_txn_begin ();
@@ -2232,6 +2238,8 @@ glusterd_replace_brick (rpcsvc_request_t *req, dict_t *dict)
glusterd_op_set_ctx (GD_OP_REPLACE_BRICK, dict);
+ glusterd_op_set_ctx_free (GD_OP_REPLACE_BRICK, _gf_true);
+
ret = glusterd_op_txn_begin ();
return ret;
@@ -2248,6 +2256,7 @@ glusterd_remove_brick (rpcsvc_request_t *req, dict_t *dict)
glusterd_op_set_op (GD_OP_REMOVE_BRICK);
glusterd_op_set_ctx (GD_OP_REMOVE_BRICK, dict);
+ glusterd_op_set_ctx_free (GD_OP_REMOVE_BRICK, _gf_true);
glusterd_op_set_req (req);
ret = glusterd_op_txn_begin ();
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 64b4a18c0..ecbe7b150 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -51,7 +51,7 @@
#include <signal.h>
static struct list_head gd_op_sm_queue;
-glusterd_op_info_t opinfo;
+glusterd_op_info_t opinfo = {{0},};
static int glusterfs_port = GLUSTERD_DEFAULT_PORT;
static void
@@ -2470,6 +2470,7 @@ glusterd_op_txn_complete ()
glusterd_op_clear_commit_op (op);
glusterd_op_clear_op (op);
glusterd_op_clear_ctx (op);
+ glusterd_op_clear_ctx_free (op);
}
out:
@@ -3033,7 +3034,9 @@ glusterd_op_clear_ctx (glusterd_op_t op)
opinfo.op_ctx[op] = NULL;
- //Cleanup to be done here
+ if (ctx && glusterd_op_get_ctx_free(op)) {
+ GF_FREE(ctx);
+ }
return 0;
}
@@ -3048,6 +3051,42 @@ glusterd_op_get_ctx (glusterd_op_t op)
}
+int32_t
+glusterd_op_set_ctx_free (glusterd_op_t op, gf_boolean_t ctx_free)
+{
+
+ GF_ASSERT (op < GD_OP_MAX);
+ GF_ASSERT (op > GD_OP_NONE);
+
+ opinfo.ctx_free[op] = ctx_free;
+
+ return 0;
+
+}
+
+int32_t
+glusterd_op_clear_ctx_free (glusterd_op_t op)
+{
+
+ GF_ASSERT (op < GD_OP_MAX);
+ GF_ASSERT (op > GD_OP_NONE);
+
+ opinfo.ctx_free[op] = _gf_false;
+
+ return 0;
+
+}
+
+gf_boolean_t
+glusterd_op_get_ctx_free (glusterd_op_t op)
+{
+ GF_ASSERT (op < GD_OP_MAX);
+ GF_ASSERT (op > GD_OP_NONE);
+
+ return opinfo.ctx_free[op];
+
+}
+
int
glusterd_op_sm_init ()
{
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index afb134637..d72ecadd2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -118,6 +118,7 @@ struct glusterd_op_info_ {
int32_t op_errno;
pthread_mutex_t lock;
int32_t cli_op;
+ gf_boolean_t ctx_free[GD_OP_MAX];
};
typedef struct glusterd_op_info_ glusterd_op_info_t;
@@ -216,4 +217,12 @@ glusterd_op_clear_ctx (glusterd_op_t op);
int32_t
glusterd_opinfo_unlock();
+int32_t
+glusterd_op_set_ctx_free (glusterd_op_t op, gf_boolean_t ctx_free);
+
+int32_t
+glusterd_op_clear_ctx_free (glusterd_op_t op);
+
+gf_boolean_t
+glusterd_op_get_ctx_free (glusterd_op_t op);
#endif