summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2011-04-08 02:50:03 +0000
committerVijay Bellur <vijay@gluster.com>2011-04-08 03:26:58 -0700
commit6db2b422f05d0553d0a83af603ae4d176b41cbdf (patch)
tree2e6bb3e744fe28af84f253d611de3e71bfebb230
parent64cefcee88c6164f20668187929c76ec54a72d23 (diff)
mgmt/glusterd: Fix op_ctx issue with replace brickv3.2.0qa10
Replace brick recognizes command originator by the presence of op_ctx. Brick op uses the op_ctx to collect the brick response on all the machines in cluster. This patch satisfies both these assumptions to make glusterd functional in replace-brick. This is a hack for 3.2.0. Need to Fix the assumptions in later release. Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Vijay Bellur <vijay@gluster.com> BUG: 2691 ([glusterfs-3.2.0qa9]: glusterd error) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2691
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c54
1 files changed, 46 insertions, 8 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 3206b35..f86de92 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -6470,15 +6470,50 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx)
return ret;
}
+static gf_boolean_t
+glusterd_need_brick_op (glusterd_op_t op)
+{
+ GF_ASSERT (op < GD_OP_MAX);
+ GF_ASSERT (op > GD_OP_NONE);
+
+ switch (op) {
+ case GD_OP_PROFILE_VOLUME:
+ return _gf_true;
+ default:
+ return _gf_false;
+ }
+ return _gf_false;
+}
+
+static dict_t*
+glusterd_op_init_commit_rsp_dict (glusterd_op_t op)
+{
+ dict_t *rsp_dict = NULL;
+ dict_t *op_ctx = NULL;
+
+ GF_ASSERT (op < GD_OP_MAX);
+ GF_ASSERT (op > GD_OP_NONE);
+
+ if (glusterd_need_brick_op (op)) {
+ op_ctx = glusterd_op_get_ctx (op);
+ GF_ASSERT (op_ctx);
+ rsp_dict = dict_ref (op_ctx);
+ } else {
+ rsp_dict = dict_new ();
+ }
+
+ return rsp_dict;
+}
+
static int
glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx)
{
int ret = 0;
- glusterd_req_ctx_t *req_ctx = NULL;
+ glusterd_req_ctx_t *req_ctx = NULL;
int32_t status = 0;
char *op_errstr = NULL;
- dict_t *op_ctx = NULL;
dict_t *dict = NULL;
+ dict_t *rsp_dict = NULL;
GF_ASSERT (ctx);
@@ -6486,21 +6521,25 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx)
dict = req_ctx->dict;
- op_ctx = glusterd_op_get_ctx (req_ctx->op);
+ rsp_dict = glusterd_op_init_commit_rsp_dict (req_ctx->op);
+ if (NULL == rsp_dict)
+ return -1;
status = glusterd_op_commit_perform (req_ctx->op, dict, &op_errstr,
- op_ctx);
+ rsp_dict);
if (status) {
gf_log ("", GF_LOG_ERROR, "Commit failed: %d", status);
}
ret = glusterd_op_commit_send_resp (req_ctx->req, req_ctx->op,
- status, op_errstr, op_ctx);
+ status, op_errstr, rsp_dict);
glusterd_op_fini_ctx (req_ctx->op);
if (op_errstr && (strcmp (op_errstr, "")))
GF_FREE (op_errstr);
+ if (rsp_dict)
+ dict_unref (rsp_dict);
gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
return ret;
@@ -7646,7 +7685,7 @@ glusterd_op_init_ctx (glusterd_op_t op)
int ret = 0;
dict_t *dict = NULL;
- if (GD_OP_PROFILE_VOLUME != op) {
+ if (_gf_false == glusterd_need_brick_op (op)) {
gf_log ("", GF_LOG_DEBUG, "Received op: %d, returning", op);
goto out;
}
@@ -7927,7 +7966,7 @@ out:
if (fd >= 0)
close (fd);
if (input_fd >= 0)
- close (input_fd);
+ close (input_fd);
if (output_fd >= 0)
close (output_fd);
if (buf)
@@ -7935,4 +7974,3 @@ out:
unlink (export_path);
return ret;
}
-