summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2014-05-29 11:59:30 +0000
committerKrishnan Parthasarathi <kparthas@redhat.com>2014-06-02 04:42:39 -0700
commite8c13fa9bd2a838335e923ec48bcb66e2cb5861d (patch)
tree8c220e6ae06b790f0092ae0e9a06ccc560b477a8 /xlators/mgmt/glusterd
parent4f9314a5eda016d5a03ad637f2c6171794cc9291 (diff)
glusterd: Fetching the txn_id before performing glusterd_op_bricks_select in glusterd_brick_op()
In glusterd_brick_op(), the txn_id mut be fetched before failing the transaction for any other reason. Moving the fetching of txn_id to the beginning of the function. Also initializing txn_id to priv->global_txn_id where it wasn't initialized. Change-Id: I44d7daa444f00a626f24670c92324725f6c5fb35 BUG: 1102656 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/7926 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c26
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c17
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rpc-ops.c48
4 files changed, 51 insertions, 42 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 7303622aed7..e203e5af01f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -905,23 +905,25 @@ __glusterd_handle_stage_op (rpcsvc_request_t *req)
goto out;
}
- if (glusterd_friend_find_by_uuid (op_req.uuid, &peerinfo)) {
- gf_log (this->name, GF_LOG_WARNING, "%s doesn't "
- "belong to the cluster. Ignoring request.",
- uuid_utoa (op_req.uuid));
- ret = -1;
- goto out;
- }
-
ret = glusterd_req_ctx_create (req, op_req.op, op_req.uuid,
op_req.buf.buf_val, op_req.buf.buf_len,
gf_gld_mt_op_stage_ctx_t, &req_ctx);
- if (ret)
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to create req_ctx");
goto out;
+ }
ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id);
+ gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
+ uuid_utoa (*txn_id));
- gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
+ if (glusterd_friend_find_by_uuid (op_req.uuid, &peerinfo)) {
+ gf_log (this->name, GF_LOG_WARNING, "%s doesn't "
+ "belong to the cluster. Ignoring request.",
+ uuid_utoa (op_req.uuid));
+ ret = -1;
+ goto out;
+ }
/* In cases where there is no volname, the receivers won't have a
* transaction opinfo created, as for those operations, the locking
@@ -1009,8 +1011,8 @@ __glusterd_handle_commit_op (rpcsvc_request_t *req)
goto out;
ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id);
-
- gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
+ gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
+ uuid_utoa (*txn_id));
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_COMMIT_OP,
txn_id, req_ctx);
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 8b9ddf32259..4ad53c126e6 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -6488,7 +6488,7 @@ glusterd_op_sm ()
"type: '%s'",
glusterd_op_sm_event_name_get(event_type));
- gf_log ("", GF_LOG_DEBUG, "transaction ID = %s",
+ gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
uuid_utoa (event->txn_id));
ret = glusterd_get_txn_opinfo (&event->txn_id,
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index 929c86b718c..151d41f4e49 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -1929,6 +1929,7 @@ glusterd_do_replace_brick (void *data)
int32_t op = 0;
int32_t src_port = 0;
int32_t dst_port = 0;
+ int32_t ret = 0;
dict_t *dict = NULL;
char *src_brick = NULL;
char *dst_brick = NULL;
@@ -1937,16 +1938,16 @@ glusterd_do_replace_brick (void *data)
glusterd_brickinfo_t *dst_brickinfo = NULL;
glusterd_conf_t *priv = NULL;
uuid_t *txn_id = NULL;
+ xlator_t *this = NULL;
- int ret = 0;
-
- dict = data;
-
- GF_ASSERT (THIS);
- priv = THIS->private;
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
GF_ASSERT (priv);
+ GF_ASSERT (data);
txn_id = &priv->global_txn_id;
+ dict = data;
if (priv->timer) {
gf_timer_call_cancel (THIS->ctx, priv->timer);
@@ -1959,8 +1960,8 @@ glusterd_do_replace_brick (void *data)
"Replace brick operation detected");
ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id);
-
- gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
+ gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
+ uuid_utoa (*txn_id));
ret = dict_get_int32 (dict, "operation", &op);
if (ret) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
index 216806f4457..7025e9844db 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
@@ -897,11 +897,16 @@ __glusterd_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
char err_str[2048] = {0};
char *peer_str = NULL;
xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
uuid_t *txn_id = NULL;
this = THIS;
GF_ASSERT (this);
GF_ASSERT (req);
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ txn_id = &priv->global_txn_id;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
@@ -951,17 +956,14 @@ out:
(op_ret) ? "RJT" : "ACC", uuid_utoa (rsp.uuid));
ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id);
-
- gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
+ gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
+ uuid_utoa (*txn_id));
ret = glusterd_friend_find (rsp.uuid, NULL, &peerinfo);
-
- if (ret) {
+ if (ret)
gf_log (this->name, GF_LOG_CRITICAL, "Stage response received "
"from unknown peer: %s. Ignoring response.",
uuid_utoa (rsp.uuid));
- goto out;
- }
if (op_ret) {
event_type = GD_OP_EVENT_RCVD_RJT;
@@ -977,10 +979,8 @@ out:
OPERRSTR_STAGE_FAIL, peer_str);
opinfo.op_errstr = gf_strdup (err_str);
}
- if (!opinfo.op_errstr) {
+ if (!opinfo.op_errstr)
ret = -1;
- goto out;
- }
} else {
event_type = GD_OP_EVENT_RCVD_ACC;
}
@@ -1031,12 +1031,16 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
char err_str[2048] = {0};
char *peer_str = NULL;
xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
uuid_t *txn_id = NULL;
-
this = THIS;
GF_ASSERT (this);
GF_ASSERT (req);
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ txn_id = &priv->global_txn_id;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
@@ -1087,11 +1091,10 @@ __glusterd_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
(op_ret)?"RJT":"ACC", uuid_utoa (rsp.uuid));
ret = dict_get_bin (dict, "transaction_id", (void **)&txn_id);
-
- gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
+ gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
+ uuid_utoa (*txn_id));
ret = glusterd_friend_find (rsp.uuid, NULL, &peerinfo);
-
if (ret) {
gf_log (this->name, GF_LOG_CRITICAL, "Commit response for "
"'Volume %s' received from unknown peer: %s",
@@ -1791,9 +1794,12 @@ __glusterd_brick_op_cbk (struct rpc_req *req, struct iovec *iov,
}
out:
- ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id);
-
- gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
+ if (req_ctx && req_ctx->dict) {
+ ret = dict_get_bin (req_ctx->dict, "transaction_id",
+ (void **)&txn_id);
+ gf_log (this->name, GF_LOG_DEBUG,
+ "transaction ID = %s", uuid_utoa (*txn_id));
+ }
ev_ctx = GF_CALLOC (1, sizeof (*ev_ctx), gf_gld_mt_brick_rsp_ctx_t);
GF_ASSERT (ev_ctx);
@@ -1857,6 +1863,11 @@ glusterd_brick_op (call_frame_t *frame, xlator_t *this,
req_ctx = data;
GF_ASSERT (req_ctx);
INIT_LIST_HEAD (&opinfo.pending_bricks);
+
+ ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id);
+ gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
+ uuid_utoa (*txn_id));
+
ret = glusterd_op_bricks_select (req_ctx->op, req_ctx->dict, &op_errstr,
&opinfo.pending_bricks, NULL);
@@ -1868,11 +1879,6 @@ glusterd_brick_op (call_frame_t *frame, xlator_t *this,
goto out;
}
-
- ret = dict_get_bin (req_ctx->dict, "transaction_id", (void **)&txn_id);
-
- gf_log ("", GF_LOG_DEBUG, "transaction ID = %s", uuid_utoa (*txn_id));
-
list_for_each_entry (pending_node, &opinfo.pending_bricks, list) {
dummy_frame = create_frame (this, this->ctx->pool);
if (!dummy_frame)