summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c372
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c521
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.h52
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rpc-ops.c12
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c2
8 files changed, 348 insertions, 619 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 09ed6ae2c..d13f32500 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -404,33 +404,49 @@ out:
}
int32_t
-glusterd_op_txn_begin ()
+glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx)
{
- int32_t ret = -1;
- glusterd_conf_t *priv = NULL;
- int32_t locked = 0;
+ int32_t ret = -1;
+ xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
+ int32_t locked = 0;
- priv = THIS->private;
+ GF_ASSERT (req);
+ GF_ASSERT ((op > GD_OP_NONE) && (op < GD_OP_MAX));
+ GF_ASSERT (NULL != ctx);
+
+ this = THIS;
+ priv = this->private;
GF_ASSERT (priv);
ret = glusterd_lock (priv->uuid);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_log (this->name, GF_LOG_ERROR,
"Unable to acquire local lock, ret: %d", ret);
goto out;
}
locked = 1;
- gf_log ("glusterd", GF_LOG_INFO, "Acquired local lock");
+ gf_log (this->name, GF_LOG_INFO, "Acquired local lock");
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_START_LOCK, NULL);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to acquire cluster"
+ " lock.");
+ goto out;
+ }
+
+ glusterd_op_set_op (op);
+ glusterd_op_set_ctx (ctx);
+ glusterd_op_set_req (req);
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
out:
if (locked && ret)
glusterd_unlock (priv->uuid);
+
+ gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
@@ -597,7 +613,7 @@ glusterd_handle_commit_op (rpcsvc_request_t *req)
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_COMMIT_OP, req_ctx);
if (ret)
goto out;
- ret = glusterd_op_init_ctx (op_req.op);
+ ret = glusterd_op_init_ctx ();
out:
if (op_req.buf.buf_val)
@@ -830,20 +846,11 @@ out:
}
int32_t
-glusterd_op_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx,
- gf_boolean_t is_ctx_free)
+glusterd_op_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx)
{
int ret = -1;
- GF_ASSERT (req);
- GF_ASSERT ((op > GD_OP_NONE) && (op < GD_OP_MAX));
- GF_ASSERT ((NULL != ctx) || (_gf_false == is_ctx_free));
- glusterd_op_set_op (op);
- glusterd_op_set_ctx (op, ctx);
- glusterd_op_set_ctx_free (op, is_ctx_free);
- glusterd_op_set_req (req);
-
- ret = glusterd_op_txn_begin ();
+ ret = glusterd_op_txn_begin (req, op, ctx);
return ret;
}
@@ -872,23 +879,11 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
uuid_t volume_id = {0,};
glusterd_brickinfo_t *tmpbrkinfo = NULL;
glusterd_volinfo_t tmpvolinfo = {{0},};
- int lock_fail = 0;
- glusterd_op_t cli_op = GD_OP_CREATE_VOLUME;
GF_ASSERT (req);
INIT_LIST_HEAD (&tmpvolinfo.bricks);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- snprintf (err_str, sizeof (err_str), "Another operation is in "
- "progress, please retry after some time");
- goto out;
- }
-
this = THIS;
GF_ASSERT(this);
@@ -1014,7 +1009,7 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
brickinfo = NULL;
}
- ret = glusterd_op_begin (req, GD_OP_CREATE_VOLUME, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_CREATE_VOLUME, dict);
gf_cmd_log ("Volume create", "on volname: %s %s", volname,
(ret != 0) ? "FAILED": "SUCCESS");
@@ -1032,8 +1027,6 @@ out:
glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL,
gf_xdr_serialize_cli_create_vol_rsp,
(xdrproc_t)xdr_gf1_cli_create_vol_rsp);
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
ret = 0; //Client response sent, prevent second response
}
@@ -1058,21 +1051,12 @@ glusterd_handle_cli_start_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
gf1_cli_start_vol_req cli_req = {0,};
- int lock_fail = 0;
char *dup_volname = NULL;
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_START_VOLUME;
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d", ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_start_vol_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -1098,7 +1082,7 @@ glusterd_handle_cli_start_volume (rpcsvc_request_t *req)
ret = dict_set_int32 (dict, "flags", cli_req.flags);
if (ret)
goto out;
- ret = glusterd_op_begin (req, GD_OP_START_VOLUME, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_START_VOLUME, dict);
gf_cmd_log ("volume start","on volname: %s %s", cli_req.volname,
((ret == 0) ? "SUCCESS": "FAILED"));
@@ -1112,13 +1096,9 @@ out:
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret) {
+ if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
-
- }
return ret;
}
@@ -1129,22 +1109,12 @@ glusterd_handle_cli_stop_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
gf1_cli_stop_vol_req cli_req = {0,};
- int lock_fail = 0;
char *dup_volname = NULL;
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_STOP_VOLUME;
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_stop_vol_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -1171,7 +1141,7 @@ glusterd_handle_cli_stop_volume (rpcsvc_request_t *req)
if (ret)
goto out;
- ret = glusterd_op_begin (req, GD_OP_STOP_VOLUME, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_STOP_VOLUME, dict);
gf_cmd_log ("Volume stop","on volname: %s %s", cli_req.volname,
((ret)?"FAILED":"SUCCESS"));
@@ -1187,8 +1157,6 @@ out:
dict_unref (dict);
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
}
return ret;
@@ -1197,7 +1165,6 @@ out:
int
glusterd_handle_cli_delete_volume (rpcsvc_request_t *req)
{
- int lock_fail = 0;
int32_t ret = -1;
gf1_cli_delete_vol_req cli_req = {0,};
glusterd_op_delete_volume_ctx_t *ctx = NULL;
@@ -1205,15 +1172,6 @@ glusterd_handle_cli_delete_volume (rpcsvc_request_t *req)
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_delete_vol_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -1231,7 +1189,7 @@ glusterd_handle_cli_delete_volume (rpcsvc_request_t *req)
strncpy (ctx->volume_name, cli_req.volname, GD_VOLUME_NAME_MAX);
- ret = glusterd_op_begin (req, GD_OP_DELETE_VOLUME, ctx, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_DELETE_VOLUME, ctx);
gf_cmd_log ("Volume delete", "on volname: %s %s", cli_req.volname,
((ret) ? "FAILED" : "SUCCESS"));
@@ -1243,10 +1201,11 @@ out:
glusterd_op_sm ();
if (ret) {
+ if (ctx)
+ GF_FREE (ctx);
+
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
}
return ret;
@@ -1275,8 +1234,6 @@ glusterd_handle_add_brick (rpcsvc_request_t *req)
char *free_ptr = NULL;
glusterd_brickinfo_t *tmpbrkinfo = NULL;
glusterd_volinfo_t tmpvolinfo = {{0},};
- int lock_fail = 0;
- glusterd_op_t cli_op = GD_OP_ADD_BRICK;
int total_bricks = 0;
this = THIS;
@@ -1288,17 +1245,6 @@ glusterd_handle_add_brick (rpcsvc_request_t *req)
INIT_LIST_HEAD (&tmpvolinfo.bricks);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- snprintf (err_str, sizeof (err_str), "Another operation is in "
- "progress, please retry after some time");
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_add_brick_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -1439,7 +1385,7 @@ brick_val:
brickinfo = NULL;
}
- ret = glusterd_op_begin (req, GD_OP_ADD_BRICK, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_ADD_BRICK, dict);
gf_cmd_log ("Volume add-brick","on volname: %s %s", volname,
(ret != 0)? "FAILED" : "SUCCESS");
@@ -1457,8 +1403,6 @@ out:
glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL,
gf_xdr_serialize_cli_add_brick_rsp,
(xdrproc_t)xdr_gf1_cli_add_brick_rsp);
- if (!lock_fail)
- glusterd_opinfo_unlock();
ret = 0; //sent error to cli, prevent second reply
}
@@ -1486,20 +1430,10 @@ glusterd_handle_replace_brick (rpcsvc_request_t *req)
char *dst_brick = NULL;
int32_t op = 0;
char operation[256];
- int lock_fail = 0;
glusterd_op_t cli_op = GD_OP_REPLACE_BRICK;
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_replace_brick_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -1573,7 +1507,7 @@ glusterd_handle_replace_brick (rpcsvc_request_t *req)
" dst_brick:%s op:%s",cli_req.volname, src_brick, dst_brick
,operation);
- ret = glusterd_op_begin (req, GD_OP_REPLACE_BRICK, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_REPLACE_BRICK, dict);
gf_cmd_log ("Volume replace-brick","on volname: %s %s", cli_req.volname,
(ret) ? "FAILED" : "SUCCESS");
@@ -1586,13 +1520,9 @@ out:
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret) {
+ if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
-
- }
return ret;
}
@@ -1606,20 +1536,10 @@ glusterd_handle_reset_volume (rpcsvc_request_t *req)
int32_t ret = -1;
gf1_cli_reset_vol_req cli_req = {0,};
dict_t *dict = NULL;
- int lock_fail = 0;
glusterd_op_t cli_op = GD_OP_RESET_VOLUME;
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_set_vol_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -1643,7 +1563,7 @@ glusterd_handle_reset_volume (rpcsvc_request_t *req)
}
gf_cmd_log ("Volume reset", "volume : %s", cli_req.volname);
- ret = glusterd_op_begin (req, GD_OP_RESET_VOLUME, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_RESET_VOLUME, dict);
gf_cmd_log ("Volume reset", " on volume %s %s ", cli_req.volname,
((ret == 0)? " SUCCEDED":" FAILED"));
@@ -1658,8 +1578,6 @@ out:
dict_unref (dict);
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
}
return ret;
@@ -1671,7 +1589,6 @@ glusterd_handle_gsync_set (rpcsvc_request_t *req)
int32_t ret = 0;
dict_t *dict = NULL;
gf1_cli_gsync_set_req cli_req = {{0},};
- int lock_fail = 0;
glusterd_op_t cli_op = GD_OP_GSYNC_SET;
char *master = NULL;
char *slave = NULL;
@@ -1686,15 +1603,6 @@ glusterd_handle_gsync_set (rpcsvc_request_t *req)
priv = THIS->private;
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_gsync_set_req (req->msg[0], &cli_req)) {
req->rpc_err = GARBAGE_ARGS;
goto out;
@@ -1771,7 +1679,7 @@ glusterd_handle_gsync_set (rpcsvc_request_t *req)
gf_cmd_log ("volume "GEOREP, " %s command on %s,%s", operation, master,
slave);
- ret = glusterd_op_begin (req, GD_OP_GSYNC_SET, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_GSYNC_SET, dict);
gf_cmd_log ("volume "GEOREP, " %s command on %s,%s %s ", operation,
master, slave, (ret != 0)? "FAILED" : "SUCCEEDED");
@@ -1784,8 +1692,6 @@ out:
dict_unref (dict);
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
}
return ret;
}
@@ -1796,7 +1702,6 @@ glusterd_handle_quota (rpcsvc_request_t *req)
int32_t ret = -1;
gf1_cli_quota_req cli_req = {0,};
dict_t *dict = NULL;
- int lock_fail = 0;
glusterd_op_t cli_op = GD_OP_QUOTA;
char operation[256] = {0, };
char *volname = NULL;
@@ -1804,14 +1709,6 @@ glusterd_handle_quota (rpcsvc_request_t *req)
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
if (!gf_xdr_to_cli_quota_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -1866,7 +1763,7 @@ glusterd_handle_quota (rpcsvc_request_t *req)
break;
}
gf_cmd_log ("volume quota", " %s command on %s", operation, volname);
- ret = glusterd_op_begin (req, GD_OP_QUOTA, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_QUOTA, dict);
gf_cmd_log ("volume quota", " %s command on %s %s", operation,volname,
(ret != 0)? "FAILED" : "SUCCEEDED");
@@ -1879,8 +1776,6 @@ out:
dict_unref (dict);
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
}
if (cli_req.volname)
free (cli_req.volname); //malloced by xdr
@@ -1894,7 +1789,6 @@ glusterd_handle_set_volume (rpcsvc_request_t *req)
int32_t ret = -1;
gf1_cli_set_vol_req cli_req = {0,};
dict_t *dict = NULL;
- int lock_fail = 0;
glusterd_op_t cli_op = GD_OP_SET_VOLUME;
char *key = NULL;
char *value = NULL;
@@ -1902,15 +1796,6 @@ glusterd_handle_set_volume (rpcsvc_request_t *req)
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_set_vol_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -1962,7 +1847,7 @@ glusterd_handle_set_volume (rpcsvc_request_t *req)
gf_cmd_log ("volume set", "volume-name:%s: key:%s, value:%s",volname,
key, value);
- ret = glusterd_op_begin (req, GD_OP_SET_VOLUME, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_SET_VOLUME, dict);
gf_cmd_log ("volume set", "volume-name:%s: key:%s, value:%s %s",
volname, key, value, (ret == 0)? "SUCCEDED" : "FAILED" );
out:
@@ -1977,8 +1862,6 @@ out:
dict_unref (dict);
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
}
return ret;
}
@@ -2005,20 +1888,9 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
gf1_cli_remove_brick_rsp rsp = {0,};
void *cli_rsp = NULL;
char vol_type[256] = {0,};
- int lock_fail = 0;
- glusterd_op_t cli_op = GD_OP_REMOVE_BRICK;
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_remove_brick_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -2154,7 +2026,7 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
gf_cmd_log ("Volume remove-brick","volname: %s count:%d bricks:%s",
cli_req.volname, count, brick_list);
- ret = glusterd_op_begin (req, GD_OP_REMOVE_BRICK, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_REMOVE_BRICK, dict);
gf_cmd_log ("Volume remove-brick","on volname: %s %s",cli_req.volname,
(ret) ? "FAILED" : "SUCCESS");
@@ -2173,8 +2045,6 @@ out:
glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL,
gf_xdr_serialize_cli_remove_brick_rsp,
(xdrproc_t)xdr_gf1_cli_remove_brick_rsp);
- if (!lock_fail)
- glusterd_opinfo_unlock();
ret = 0; //sent error to cli, prevent second reply
@@ -2196,20 +2066,10 @@ glusterd_handle_log_filename (rpcsvc_request_t *req)
int32_t ret = -1;
gf1_cli_log_filename_req cli_req = {0,};
dict_t *dict = NULL;
- int lock_fail = 0;
glusterd_op_t cli_op = GD_OP_LOG_FILENAME;
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_log_filename_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -2233,7 +2093,7 @@ glusterd_handle_log_filename (rpcsvc_request_t *req)
if (ret)
goto out;
- ret = glusterd_op_begin (req, GD_OP_LOG_FILENAME, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_LOG_FILENAME, dict);
out:
if (ret && dict)
@@ -2242,13 +2102,9 @@ out:
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret) {
+ if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
-
- }
return ret;
}
@@ -2266,22 +2122,11 @@ glusterd_handle_log_locate (rpcsvc_request_t *req)
char *tmp_brick = NULL;
uint32_t found = 0;
glusterd_brickinfo_t *tmpbrkinfo = NULL;
- int lock_fail = 0;
- glusterd_op_t cli_op = GD_OP_LOG_LOCATE;
GF_ASSERT (req);
priv = THIS->private;
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_log_locate_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -2366,9 +2211,6 @@ out:
glusterd_friend_sm ();
glusterd_op_sm ();
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
-
return ret;
}
@@ -2376,20 +2218,12 @@ int
glusterd_handle_log_level (rpcsvc_request_t *req)
{
int32_t ret = -1;
- int lock_fail = 0;
dict_t *dict = NULL;
gf1_cli_log_level_req cli_req = {0,};
glusterd_op_t cli_op = GD_OP_LOG_LEVEL;
GF_ASSERT(req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
if (!gf_xdr_to_cli_log_level_req(req->msg[0], &cli_req)) {
gf_log ("glusterd", GF_LOG_ERROR, "Failed to decode rpc message");
@@ -2416,7 +2250,7 @@ glusterd_handle_log_level (rpcsvc_request_t *req)
if (ret)
goto out;
- ret = glusterd_op_begin (req, cli_op, dict, _gf_true);
+ ret = glusterd_op_begin (req, cli_op, dict);
out:
if (ret && dict)
@@ -2425,12 +2259,9 @@ glusterd_handle_log_level (rpcsvc_request_t *req)
glusterd_friend_sm();
glusterd_op_sm();
- if (ret) {
+ if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, NULL,
"Operation failed");
- if (!lock_fail)
- (void)glusterd_opinfo_unlock ();
- }
return ret;
}
@@ -2441,20 +2272,10 @@ glusterd_handle_log_rotate (rpcsvc_request_t *req)
int32_t ret = -1;
gf1_cli_log_rotate_req cli_req = {0,};
dict_t *dict = NULL;
- int lock_fail = 0;
glusterd_op_t cli_op = GD_OP_LOG_ROTATE;
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_log_rotate_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -2480,7 +2301,7 @@ glusterd_handle_log_rotate (rpcsvc_request_t *req)
if (ret)
goto out;
- ret = glusterd_op_begin (req, GD_OP_LOG_ROTATE, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_LOG_ROTATE, dict);
out:
if (ret && dict)
@@ -2489,12 +2310,9 @@ out:
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret) {
+ if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
- }
return ret;
}
@@ -2510,20 +2328,9 @@ glusterd_handle_sync_volume (rpcsvc_request_t *req)
gf_boolean_t free_hostname = _gf_true;
gf_boolean_t free_volname = _gf_true;
glusterd_volinfo_t *volinfo = NULL;
- int lock_fail = 0;
- glusterd_op_t cli_op = GD_OP_SYNC_VOLUME;
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_sync_volume_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -2589,7 +2396,7 @@ glusterd_handle_sync_volume (rpcsvc_request_t *req)
}
}
- ret = glusterd_op_begin (req, GD_OP_SYNC_VOLUME, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_SYNC_VOLUME, dict);
out:
if (ret) {
@@ -2607,8 +2414,6 @@ out:
if (dict)
dict_unref (dict);
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
ret = 0; //sent error to cli, prevent second reply
}
@@ -3203,21 +3008,11 @@ glusterd_handle_cli_profile_volume (rpcsvc_request_t *req)
dict_t *dict = NULL;
char msg[2048] = {0,};
gf_boolean_t free_volname = _gf_true;
- int lock_fail = 0;
glusterd_op_t cli_op = GD_OP_PROFILE_VOLUME;
dict_t *tmp_dict = NULL;
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_stats_volume_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -3257,7 +3052,7 @@ glusterd_handle_cli_profile_volume (rpcsvc_request_t *req)
gf_cmd_log ("Volume stats", "volume : %s, op: %d", cli_req.volname,
cli_req.op);
- ret = glusterd_op_begin (req, cli_op, dict, _gf_true);
+ ret = glusterd_op_begin (req, cli_op, dict);
gf_cmd_log ("Volume stats", " on volume %s, op: %d %s ",
cli_req.volname, cli_req.op,
((ret == 0)? " SUCCEDED":" FAILED"));
@@ -3275,13 +3070,9 @@ out:
free (cli_req.dict_req.dict_req_val);
if (free_volname)
free (cli_req.volname); // malloced by xdr
- if (ret) {
+ if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
-
- }
gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -3880,20 +3671,10 @@ glusterd_handle_status_volume (rpcsvc_request_t *req)
int32_t ret = -1;
gf1_cli_status_volume_req cli_req = {0,};
dict_t *dict = NULL;
- int lock_fail = 0;
glusterd_op_t cli_op = GD_OP_STATUS_VOLUME;
GF_ASSERT (req);
- ret = glusterd_op_set_cli_op (cli_op);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
- ret);
- lock_fail = 1;
- goto out;
- }
-
- ret = -1;
if (!gf_xdr_to_cli_status_volume_req (req->msg[0], &cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
@@ -3911,7 +3692,7 @@ glusterd_handle_status_volume (rpcsvc_request_t *req)
if (ret)
goto out;
- ret = glusterd_op_begin (req, GD_OP_STATUS_VOLUME, dict, _gf_true);
+ ret = glusterd_op_begin (req, GD_OP_STATUS_VOLUME, dict);
out:
if (ret && dict)
@@ -3920,13 +3701,9 @@ out:
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret) {
+ if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- if (!lock_fail)
- (void) glusterd_opinfo_unlock ();
-
- }
return ret;
}
@@ -3979,11 +3756,13 @@ glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata,
rpc_clnt_event_t event,
void *data)
{
- xlator_t *this = NULL;
- glusterd_conf_t *conf = NULL;
- int ret = 0;
- glusterd_peerinfo_t *peerinfo = NULL;
- glusterd_peerctx_t *peerctx = NULL;
+ xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
+ int ret = 0;
+ glusterd_peerinfo_t *peerinfo = NULL;
+ glusterd_peerctx_t *peerctx = NULL;
+ uuid_t owner = {0,};
+ uuid_t *peer_uuid = NULL;
peerctx = mydata;
if (!peerctx)
@@ -4012,6 +3791,34 @@ glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata,
gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_DISCONNECT");
peerinfo->connected = 0;
+ /*
+ local glusterd (thinks that it) is the owner of the cluster
+ lock and 'fails' the operation on the first disconnect from
+ a peer.
+ */
+ glusterd_get_lock_owner (&owner);
+ if (!uuid_compare (conf->uuid, owner)) {
+ ret = glusterd_op_sm_inject_event (GD_OP_EVENT_START_UNLOCK,
+ NULL);
+ if (ret)
+ gf_log (this->name, GF_LOG_ERROR, "Unable"
+ " to enqueue cluster unlock event");
+ break;
+ }
+
+ peer_uuid = GF_CALLOC (1, sizeof (*peer_uuid), gf_common_mt_char);
+ if (!peer_uuid) {
+ ret = -1;
+ break;
+ }
+
+ uuid_copy (*peer_uuid, peerinfo->uuid);
+ ret = glusterd_op_sm_inject_event (GD_OP_EVENT_LOCAL_UNLOCK_NO_RESP,
+ peer_uuid);
+ if (ret)
+ gf_log (this->name, GF_LOG_ERROR, "Unable"
+ " to enque local lock flush event.");
+
//default_notify (this, GF_EVENT_CHILD_DOWN, NULL);
break;
@@ -4022,6 +3829,7 @@ glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata,
break;
}
+ glusterd_op_sm ();
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index df78d33b6..a36d10b68 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -76,6 +76,7 @@ static char *glusterd_op_sm_state_names[] = {
"Brick op failed",
"Brick op Committed",
"Brick op Commit failed",
+ "Ack drain",
"Invalid",
};
@@ -93,6 +94,7 @@ static char *glusterd_op_sm_event_names[] = {
"GD_OP_EVENT_UNLOCK",
"GD_OP_EVENT_START_UNLOCK",
"GD_OP_EVENT_ALL_ACK",
+ "GD_OP_EVENT_LOCAL_UNLOCK_NO_RESP",
"GD_OP_EVENT_INVALID"
};
@@ -1737,7 +1739,7 @@ glusterd_op_stage_remove_brick (dict_t *dict)
}
if (glusterd_is_defrag_on(volinfo)) {
- ctx = glusterd_op_get_ctx (GD_OP_REMOVE_BRICK);
+ ctx = glusterd_op_get_ctx ();
errstr = gf_strdup("Rebalance is in progress. Please retry"
" after completion");
if (!errstr) {
@@ -1764,7 +1766,7 @@ glusterd_op_stage_remove_brick (dict_t *dict)
}
if (volinfo->brick_count == brick_count) {
- ctx = glusterd_op_get_ctx (GD_OP_REMOVE_BRICK);
+ ctx = glusterd_op_get_ctx ();
if (!ctx) {
gf_log ("", GF_LOG_ERROR,
"Operation Context is not present");
@@ -3854,7 +3856,7 @@ rb_do_operation_status (glusterd_volinfo_t *volinfo,
int ret = 0;
gf_boolean_t origin = _gf_false;
- ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ ctx = glusterd_op_get_ctx ();
if (!ctx) {
gf_log ("", GF_LOG_ERROR,
"Operation Context is not present");
@@ -3933,7 +3935,7 @@ rb_update_srcbrick_port (glusterd_brickinfo_t *src_brickinfo, dict_t *rsp_dict,
this = THIS;
- ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ ctx = glusterd_op_get_ctx ();
if (ctx) {
dict_ret = dict_get_int32 (req_dict, "src-brick-port", &src_port);
if (src_port)
@@ -3963,7 +3965,7 @@ rb_update_srcbrick_port (glusterd_brickinfo_t *src_brickinfo, dict_t *rsp_dict,
}
}
- ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ ctx = glusterd_op_get_ctx ();
if (ctx) {
ret = dict_set_int32 (ctx, "src-brick-port", src_brickinfo->port);
if (ret) {
@@ -3989,7 +3991,7 @@ rb_update_dstbrick_port (glusterd_brickinfo_t *dst_brickinfo, dict_t *rsp_dict,
int dict_ret = 0;
int dst_port = 0;
- ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ ctx = glusterd_op_get_ctx ();
if (ctx) {
dict_ret = dict_get_int32 (req_dict, "dst-brick-port", &dst_port);
if (dst_port)
@@ -4011,7 +4013,7 @@ rb_update_dstbrick_port (glusterd_brickinfo_t *dst_brickinfo, dict_t *rsp_dict,
}
}
- ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ ctx = glusterd_op_get_ctx ();
if (ctx) {
ret = dict_set_int32 (ctx, "dst-brick-port",
dst_brickinfo->port);
@@ -4166,7 +4168,7 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
case GF_REPLACE_OP_COMMIT:
case GF_REPLACE_OP_COMMIT_FORCE:
{
- ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ ctx = glusterd_op_get_ctx ();
if (ctx) {
ret = rb_do_operation_commit (volinfo, src_brickinfo, dst_brickinfo);
if (ret) {
@@ -4236,7 +4238,7 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
{
gf_log ("", GF_LOG_DEBUG,
"Received pause - doing nothing");
- ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ ctx = glusterd_op_get_ctx ();
if (ctx) {
ret = rb_do_operation_pause (volinfo, src_brickinfo,
dst_brickinfo);
@@ -4254,7 +4256,7 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
case GF_REPLACE_OP_ABORT:
{
- ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ ctx = glusterd_op_get_ctx ();
if (ctx) {
ret = rb_do_operation_abort (volinfo, src_brickinfo, dst_brickinfo);
if (ret) {
@@ -4290,7 +4292,7 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
{
gf_log ("", GF_LOG_DEBUG,
"received status - doing nothing");
- ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ ctx = glusterd_op_get_ctx ();
if (ctx) {
if (glusterd_is_rb_paused (volinfo)) {
ret = dict_set_str (ctx, "status-reply",
@@ -4923,7 +4925,7 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (ret < 0)
goto out;
- ctx = glusterd_op_get_ctx (GD_OP_GSYNC_SET);
+ ctx = glusterd_op_get_ctx ();
resp_dict = ctx ? ctx : rsp_dict;
GF_ASSERT (resp_dict);
@@ -5279,7 +5281,7 @@ glusterd_quota_get_limit_usages (glusterd_conf_t *priv,
char cmd_str [1024] = {0, };
char *ret_str = NULL;
- ctx = glusterd_op_get_ctx (GD_OP_QUOTA);
+ ctx = glusterd_op_get_ctx ();
if (ctx == NULL)
return 0;
@@ -5645,7 +5647,7 @@ create_vol:
ret = 0;
out:
- ctx = glusterd_op_get_ctx (GD_OP_QUOTA);
+ ctx = glusterd_op_get_ctx ();
if (ctx && start_crawl == _gf_true)
glusterd_quota_initiate_fs_crawl (priv, volname);
@@ -6642,7 +6644,7 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr,
if (!rsp_dict) {
//this should happen only on source
ret = 0;
- rsp_dict = glusterd_op_get_ctx (GD_OP_STATUS_VOLUME);
+ rsp_dict = glusterd_op_get_ctx ();
}
if (volname) {
@@ -6767,11 +6769,32 @@ glusterd_op_ac_send_unlock (glusterd_op_sm_event_t *event, void *ctx)
}
static int
+glusterd_op_ac_ack_drain (glusterd_op_sm_event_t *event, void *ctx)
+{
+ int ret = 0;
+
+ if (opinfo.pending_count > 0)
+ opinfo.pending_count--;
+
+ if (!opinfo.pending_count)
+ ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACK, NULL);
+
+ gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+
+ return ret;
+}
+
+static int
+glusterd_op_ac_send_unlock_drain (glusterd_op_sm_event_t *event, void *ctx)
+{
+ return glusterd_op_ac_ack_drain (event, ctx);
+}
+
+static int
glusterd_op_ac_lock (glusterd_op_sm_event_t *event, void *ctx)
{
- int ret = 0;
glusterd_op_lock_ctx_t *lock_ctx = NULL;
- int32_t status = 0;
+ int32_t ret = 0;
GF_ASSERT (event);
@@ -6779,13 +6802,11 @@ glusterd_op_ac_lock (glusterd_op_sm_event_t *event, void *ctx)
lock_ctx = (glusterd_op_lock_ctx_t *)ctx;
- status = glusterd_lock (lock_ctx->uuid);
-
- gf_log ("", GF_LOG_DEBUG, "Lock Returned %d", status);
+ ret = glusterd_lock (lock_ctx->uuid);
- ret = glusterd_op_lock_send_resp (lock_ctx->req, status);
+ gf_log ("", GF_LOG_DEBUG, "Lock Returned %d", ret);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ glusterd_op_lock_send_resp (lock_ctx->req, ret);
return ret;
}
@@ -6805,9 +6826,25 @@ glusterd_op_ac_unlock (glusterd_op_sm_event_t *event, void *ctx)
gf_log ("", GF_LOG_DEBUG, "Unlock Returned %d", ret);
- ret = glusterd_op_unlock_send_resp (lock_ctx->req, ret);
+ glusterd_op_unlock_send_resp (lock_ctx->req, ret);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ return ret;
+}
+
+static int
+glusterd_op_ac_local_unlock (glusterd_op_sm_event_t *event, void *ctx)
+{
+ int ret = 0;
+ uuid_t *originator = NULL;
+
+ GF_ASSERT (event);
+ GF_ASSERT (ctx);
+
+ originator = (uuid_t *) ctx;
+
+ ret = glusterd_unlock (*originator);
+
+ gf_log ("", GF_LOG_DEBUG, "Unlock Returned %d", ret);
return ret;
}
@@ -6834,21 +6871,21 @@ out:
}
int
-glusterd_op_build_payload (glusterd_op_t op, dict_t **req)
+glusterd_op_build_payload (dict_t **req)
{
int ret = -1;
void *ctx = NULL;
dict_t *req_dict = NULL;
+ glusterd_op_t op = GD_OP_NONE;
- GF_ASSERT (op < GD_OP_MAX);
- GF_ASSERT (op > GD_OP_NONE);
GF_ASSERT (req);
req_dict = dict_new ();
if (!req_dict)
goto out;
- ctx = (void*)glusterd_op_get_ctx (op);
+ op = glusterd_op_get_op ();
+ ctx = (void*)glusterd_op_get_ctx ();
if (!ctx) {
gf_log ("", GF_LOG_ERROR, "Null Context for "
"op %d", op);
@@ -6920,7 +6957,7 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx)
glusterd_peerinfo_t *peerinfo = NULL;
dict_t *dict = NULL;
char *op_errstr = NULL;
- int i = 0;
+ glusterd_op_t op = GD_OP_NONE;
uint32_t pending_count = 0;
this = THIS;
@@ -6928,27 +6965,14 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx)
priv = this->private;
GF_ASSERT (priv);
- for ( i = GD_OP_NONE; i < GD_OP_MAX; i++) {
- if (opinfo.pending_op[i])
- break;
- }
-
- if (GD_OP_MAX == i) {
- //No pending ops, inject stage_acc
- ret = glusterd_op_sm_inject_event
- (GD_OP_EVENT_STAGE_ACC, NULL);
-
- return ret;
- }
-
- glusterd_op_clear_pending_op (i);
+ op = glusterd_op_get_op ();
- ret = glusterd_op_build_payload (i, &dict);
+ ret = glusterd_op_build_payload (&dict);
if (ret)
goto out;
/* rsp_dict NULL from source */
- ret = glusterd_op_stage_validate (i, dict, &op_errstr, NULL);
+ ret = glusterd_op_stage_validate (op, dict, &op_errstr, NULL);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Staging failed");
opinfo.op_errstr = op_errstr;
@@ -7008,6 +7032,7 @@ glusterd_op_start_rb_timer (dict_t *dict)
struct timeval timeout = {0, };
glusterd_conf_t *priv = NULL;
int32_t ret = -1;
+ dict_t *rb_ctx = NULL;
GF_ASSERT (dict);
priv = THIS->private;
@@ -7028,9 +7053,16 @@ glusterd_op_start_rb_timer (dict_t *dict)
timeout.tv_usec = 0;
+ rb_ctx = dict_copy (dict, rb_ctx);
+ if (!rb_ctx) {
+ gf_log (THIS->name, GF_LOG_ERROR, "Couldn't copy "
+ "replace brick context. Can't start replace brick");
+ ret = -1;
+ goto out;
+ }
priv->timer = gf_timer_call_after (THIS->ctx, timeout,
glusterd_do_replace_brick,
- (void *) dict);
+ (void *) rb_ctx);
ret = 0;
@@ -7049,32 +7081,21 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx)
dict_t *op_dict = NULL;
glusterd_peerinfo_t *peerinfo = NULL;
char *op_errstr = NULL;
- int i = 0;
- uint32_t pending_count = 0;
+ glusterd_op_t op = GD_OP_NONE;
+ uint32_t pending_count = 0;
this = THIS;
GF_ASSERT (this);
priv = this->private;
GF_ASSERT (priv);
- for ( i = GD_OP_NONE; i < GD_OP_MAX; i++) {
- if (opinfo.commit_op[i])
- break;
- }
-
- if (GD_OP_MAX == i) {
- //No pending ops, return
- return 0;
- }
-
- glusterd_op_clear_commit_op (i);
-
- ret = glusterd_op_build_payload (i, &dict);
+ op = glusterd_op_get_op ();
+ ret = glusterd_op_build_payload (&dict);
if (ret)
goto out;
- ret = glusterd_op_commit_perform (i, dict, &op_errstr, NULL); //rsp_dict invalid for source
+ ret = glusterd_op_commit_perform (op, dict, &op_errstr, NULL); //rsp_dict invalid for source
if (ret) {
gf_log ("", GF_LOG_ERROR, "Commit failed");
opinfo.op_errstr = op_errstr;
@@ -7117,14 +7138,15 @@ out:
}
if (!opinfo.pending_count) {
- op_dict = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
- if (!op_dict) {
+ if (op == GD_OP_REPLACE_BRICK) {
+ op_dict = glusterd_op_get_ctx ();
+ ret = glusterd_op_start_rb_timer (op_dict);
+
+ } else {
+
ret = glusterd_op_sm_inject_all_acc ();
- goto err;
}
-
- op_dict = dict_ref (op_dict);
- ret = glusterd_op_start_rb_timer (op_dict);
+ goto err;
}
err:
@@ -7399,8 +7421,8 @@ out:
else
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_COMMIT_ACC, NULL);
-// if (dict)
-// dict_unref (dict);
+ if (dict)
+ dict_unref (dict);
glusterd_op_sm ();
}
@@ -7413,8 +7435,10 @@ glusterd_op_ac_rcvd_commit_op_acc (glusterd_op_sm_event_t *event, void *ctx)
glusterd_conf_t *priv = NULL;
dict_t *dict = NULL;
int ret = 0;
- gf_boolean_t commit_ack_inject = _gf_false;
+ gf_boolean_t commit_ack_inject = _gf_true;
+ glusterd_op_t op = GD_OP_NONE;
+ op = glusterd_op_get_op ();
priv = THIS->private;
GF_ASSERT (event);
@@ -7424,16 +7448,26 @@ glusterd_op_ac_rcvd_commit_op_acc (glusterd_op_sm_event_t *event, void *ctx)
if (opinfo.pending_count > 0)
goto out;
- dict = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
- if (dict) {
+ if (op == GD_OP_REPLACE_BRICK) {
+ dict = glusterd_op_get_ctx ();
+ if (!dict) {
+ gf_log (THIS->name, GF_LOG_CRITICAL, "Operation "
+ "context is not present.");
+ ret = -1;
+ goto out;
+ }
+
ret = glusterd_op_start_rb_timer (dict);
- if (ret)
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "Couldn't start "
+ "replace-brick operation.");
goto out;
+ }
+
commit_ack_inject = _gf_false;
- goto out;
+ goto out;
}
- commit_ack_inject = _gf_true;
out:
if (commit_ack_inject) {
if (ret)
@@ -7466,7 +7500,6 @@ out:
return ret;
}
-
int32_t
glusterd_op_clear_errstr() {
opinfo.op_errstr = NULL;
@@ -7474,26 +7507,20 @@ glusterd_op_clear_errstr() {
}
int32_t
-glusterd_op_set_ctx (glusterd_op_t op, void *ctx)
+glusterd_op_set_ctx (void *ctx)
{
- GF_ASSERT (op < GD_OP_MAX);
- GF_ASSERT (op > GD_OP_NONE);
-
- opinfo.op_ctx[op] = ctx;
+ opinfo.op_ctx = ctx;
return 0;
}
int32_t
-glusterd_op_reset_ctx (glusterd_op_t op)
+glusterd_op_reset_ctx ()
{
- GF_ASSERT (op < GD_OP_MAX);
- GF_ASSERT (op > GD_OP_NONE);
-
- glusterd_op_set_ctx (op, NULL);
+ glusterd_op_set_ctx (NULL);
return 0;
}
@@ -7506,53 +7533,39 @@ glusterd_op_txn_complete ()
int32_t op = -1;
int32_t op_ret = 0;
int32_t op_errno = 0;
- int32_t cli_op = 0;
rpcsvc_request_t *req = NULL;
void *ctx = NULL;
- gf_boolean_t ctx_free = _gf_false;
char *op_errstr = NULL;
priv = THIS->private;
GF_ASSERT (priv);
- ret = glusterd_unlock (priv->uuid);
-
- if (ret) {
- gf_log ("glusterd", GF_LOG_CRITICAL,
- "Unable to clear local lock, ret: %d", ret);
- goto out;
- }
-
- gf_log ("glusterd", GF_LOG_INFO, "Cleared local lock");
-
+ op = glusterd_op_get_op ();
+ ctx = glusterd_op_get_ctx ();
op_ret = opinfo.op_ret;
op_errno = opinfo.op_errno;
- cli_op = opinfo.cli_op;
req = opinfo.req;
if (opinfo.op_errstr)
op_errstr = opinfo.op_errstr;
-
opinfo.op_ret = 0;
opinfo.op_errno = 0;
+ glusterd_op_clear_op ();
+ glusterd_op_reset_ctx ();
+ glusterd_op_clear_errstr ();
- op = glusterd_op_get_op ();
+ ret = glusterd_unlock (priv->uuid);
- if (op != -1) {
- glusterd_op_clear_pending_op (op);
- glusterd_op_clear_commit_op (op);
- glusterd_op_clear_op (op);
- ctx = glusterd_op_get_ctx (op);
- ctx_free = glusterd_op_get_ctx_free (op);
- glusterd_op_reset_ctx (op);
- glusterd_op_clear_ctx_free (op);
- glusterd_op_clear_errstr ();
+ /* unlock cant/shouldnt fail here!! */
+ if (ret) {
+ gf_log ("glusterd", GF_LOG_CRITICAL,
+ "Unable to clear local lock, ret: %d", ret);
+ } else {
+ gf_log ("glusterd", GF_LOG_INFO, "Cleared local lock");
}
-out:
- pthread_mutex_unlock (&opinfo.lock);
- ret = glusterd_op_send_cli_response (cli_op, op_ret,
+ ret = glusterd_op_send_cli_response (op, op_ret,
op_errno, req, ctx, op_errstr);
if (ret) {
@@ -7562,11 +7575,11 @@ out:
ret = 0;
}
- if (ctx_free && ctx && (op != -1))
- glusterd_op_free_ctx (op, ctx, ctx_free);
+ glusterd_op_free_ctx (op, ctx);
if (op_errstr && (strcmp (op_errstr, "")))
GF_FREE (op_errstr);
+
gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
@@ -7662,31 +7675,32 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx)
}
static gf_boolean_t
-glusterd_need_brick_op (glusterd_op_t op)
+glusterd_need_brick_op ()
{
- GF_ASSERT (op < GD_OP_MAX);
- GF_ASSERT (op > GD_OP_NONE);
+ gf_boolean_t ret = _gf_false;
+ glusterd_op_t op = GD_OP_NONE;
+ op = glusterd_op_get_op ();
switch (op) {
case GD_OP_PROFILE_VOLUME:
- return _gf_true;
+ ret = _gf_true;
+ break;
default:
- return _gf_false;
+ ret = _gf_false;
}
- return _gf_false;
+
+ return ret;
}
static dict_t*
-glusterd_op_init_commit_rsp_dict (glusterd_op_t op)
+glusterd_op_init_commit_rsp_dict ()
{
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);
+ if (glusterd_need_brick_op ()) {
+ op_ctx = glusterd_op_get_ctx ();
GF_ASSERT (op_ctx);
rsp_dict = dict_ref (op_ctx);
} else {
@@ -7712,7 +7726,7 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx)
dict = req_ctx->dict;
- rsp_dict = glusterd_op_init_commit_rsp_dict (req_ctx->op);
+ rsp_dict = glusterd_op_init_commit_rsp_dict ();
if (NULL == rsp_dict)
return -1;
status = glusterd_op_commit_perform (req_ctx->op, dict, &op_errstr,
@@ -7725,7 +7739,7 @@ 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 (req_ctx->op);
+ glusterd_op_fini_ctx ();
if (op_errstr && (strcmp (op_errstr, "")))
GF_FREE (op_errstr);
@@ -7747,13 +7761,13 @@ glusterd_op_ac_send_commit_failed (glusterd_op_sm_event_t *event, void *ctx)
req_ctx = ctx;
- op_ctx = glusterd_op_get_ctx (req_ctx->op);
+ op_ctx = glusterd_op_get_ctx ();
ret = glusterd_op_commit_send_resp (req_ctx->req, req_ctx->op,
opinfo.op_ret, opinfo.op_errstr,
op_ctx);
- glusterd_op_fini_ctx (req_ctx->op);
+ glusterd_op_fini_ctx ();
if (opinfo.op_errstr && (strcmp (opinfo.op_errstr, ""))) {
GF_FREE (opinfo.op_errstr);
opinfo.op_errstr = NULL;
@@ -8295,7 +8309,7 @@ glusterd_op_ac_send_brick_op (glusterd_op_sm_event_t *event, void *ctx)
op = glusterd_op_get_op ();
req_ctx->op = op;
uuid_copy (req_ctx->uuid, priv->uuid);
- ret = glusterd_op_build_payload (op, &req_ctx->dict);
+ ret = glusterd_op_build_payload (&req_ctx->dict);
if (ret)//TODO:what to do??
goto out;
}
@@ -8353,7 +8367,7 @@ glusterd_op_ac_rcvd_brick_op_acc (glusterd_op_sm_event_t *event, void *ctx)
if (opinfo.brick_pending_count > 0)
opinfo.brick_pending_count--;
op = req_ctx->op;
- op_ctx = glusterd_op_get_ctx (op);
+ op_ctx = glusterd_op_get_ctx ();
glusterd_handle_brick_rsp (brickinfo, op, ev_ctx->rsp_dict,
op_ctx, &op_errstr);
@@ -8417,30 +8431,32 @@ glusterd_op_sm_t glusterd_op_state_default [] = {
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
{GD_OP_STATE_DEFAULT, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_DEFAULT, glusterd_op_ac_none}, //EVENT_ALL_ACK
+ {GD_OP_STATE_DEFAULT, glusterd_op_ac_none}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_DEFAULT, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_lock_sent [] = {
{GD_OP_STATE_LOCK_SENT, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_LOCK_SENT, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_LOCK_SENT, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_LOCK_SENT, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_LOCK_SENT, glusterd_op_ac_rcvd_lock_acc}, //EVENT_RCVD_ACC
{GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_send_stage_op}, //EVENT_ALL_ACC
{GD_OP_STATE_LOCK_SENT, glusterd_op_ac_none}, //EVENT_STAGE_ACC
{GD_OP_STATE_LOCK_SENT, glusterd_op_ac_none}, //EVENT_COMMIT_ACC
- {GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_send_unlock}, //EVENT_RCVD_RJT
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_send_unlock_drain}, //EVENT_RCVD_RJT
{GD_OP_STATE_LOCK_SENT, glusterd_op_ac_none}, //EVENT_STAGE_OP
{GD_OP_STATE_LOCK_SENT, glusterd_op_ac_none}, //EVENT_COMMIT_OP
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
- {GD_OP_STATE_LOCK_SENT, glusterd_op_ac_none}, //EVENT_START_UNLOCK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_LOCK_SENT, glusterd_op_ac_none}, //EVENT_ALL_ACK
+ {GD_OP_STATE_LOCK_SENT, glusterd_op_ac_none}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_LOCK_SENT, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_locked [] = {
{GD_OP_STATE_LOCKED, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_LOCKED, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_LOCKED, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_LOCKED, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_LOCKED, glusterd_op_ac_none}, //EVENT_RCVD_ACC
{GD_OP_STATE_LOCKED, glusterd_op_ac_none}, //EVENT_ALL_ACC
{GD_OP_STATE_LOCKED, glusterd_op_ac_none}, //EVENT_STAGE_ACC
@@ -8451,13 +8467,14 @@ glusterd_op_sm_t glusterd_op_state_locked [] = {
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
{GD_OP_STATE_LOCKED, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_LOCKED, glusterd_op_ac_none}, //EVENT_ALL_ACK
+ {GD_OP_STATE_DEFAULT, glusterd_op_ac_local_unlock}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_LOCKED, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_stage_op_sent [] = {
{GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_rcvd_stage_op_acc}, //EVENT_RCVD_ACC
{GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_send_brick_op}, //EVENT_ALL_ACC
{GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_send_brick_op}, //EVENT_STAGE_ACC
@@ -8466,15 +8483,16 @@ glusterd_op_sm_t glusterd_op_state_stage_op_sent [] = {
{GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_none}, //EVENT_STAGE_OP
{GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_none}, //EVENT_COMMIT_OP
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
- {GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_none}, //EVENT_START_UNLOCK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_none}, //EVENT_ALL_ACK
+ {GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_none}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_STAGE_OP_SENT, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_stage_op_failed [] = {
{GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_stage_op_failed}, //EVENT_RCVD_ACC
{GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_none}, //EVENT_ALL_ACC
{GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_none}, //EVENT_STAGE_ACC
@@ -8483,15 +8501,16 @@ glusterd_op_sm_t glusterd_op_state_stage_op_failed [] = {
{GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_none}, //EVENT_STAGE_OP
{GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_none}, //EVENT_COMMIT_OP
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
- {GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_none}, //EVENT_START_UNLOCK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_send_unlock}, //EVENT_ALL_ACK
+ {GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_none}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_STAGE_OP_FAILED, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_staged [] = {
{GD_OP_STATE_STAGED, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_STAGED, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_STAGED, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_STAGED, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_STAGED, glusterd_op_ac_none}, //EVENT_RCVD_ACC
{GD_OP_STATE_STAGED, glusterd_op_ac_none}, //EVENT_ALL_ACC
{GD_OP_STATE_STAGED, glusterd_op_ac_none}, //EVENT_STAGE_ACC
@@ -8502,13 +8521,14 @@ glusterd_op_sm_t glusterd_op_state_staged [] = {
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
{GD_OP_STATE_STAGED, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_STAGED, glusterd_op_ac_none}, //EVENT_ALL_ACK
+ {GD_OP_STATE_DEFAULT, glusterd_op_ac_local_unlock}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_STAGED, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_brick_op_sent [] = {
{GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_rcvd_brick_op_acc}, //EVENT_RCVD_ACC
{GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_none}, //EVENT_ALL_ACC
{GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_none}, //EVENT_STAGE_ACC
@@ -8517,15 +8537,16 @@ glusterd_op_sm_t glusterd_op_state_brick_op_sent [] = {
{GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_none}, //EVENT_BRICK_OP
{GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_none}, //EVENT_COMMIT_OP
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
- {GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_none}, //EVENT_START_UNLOCK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_send_commit_op}, //EVENT_ALL_ACK
+ {GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_none}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_BRICK_OP_SENT, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_brick_op_failed [] = {
{GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_brick_op_failed}, //EVENT_RCVD_ACC
{GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_none}, //EVENT_ALL_ACC
{GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_none}, //EVENT_STAGE_ACC
@@ -8534,15 +8555,16 @@ glusterd_op_sm_t glusterd_op_state_brick_op_failed [] = {
{GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_none}, //EVENT_BRICK_OP
{GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_none}, //EVENT_COMMIT_OP
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
- {GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_none}, //EVENT_START_UNLOCK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_send_unlock}, //EVENT_ALL_ACK
+ {GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_none}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_BRICK_OP_FAILED, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_brick_committed [] = {
{GD_OP_STATE_BRICK_COMMITTED, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_BRICK_COMMITTED, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_BRICK_COMMITTED, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_BRICK_COMMITTED, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_BRICK_COMMITTED, glusterd_op_ac_rcvd_brick_op_acc}, //EVENT_RCVD_ACC
{GD_OP_STATE_BRICK_COMMITTED, glusterd_op_ac_none}, //EVENT_ALL_ACC
{GD_OP_STATE_BRICK_COMMITTED, glusterd_op_ac_none}, //EVENT_STAGE_ACC
@@ -8553,13 +8575,14 @@ glusterd_op_sm_t glusterd_op_state_brick_committed [] = {
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
{GD_OP_STATE_BRICK_COMMITTED, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_COMMITED, glusterd_op_ac_commit_op}, //EVENT_ALL_ACK
+ {GD_OP_STATE_DEFAULT, glusterd_op_ac_local_unlock}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_BRICK_COMMITTED, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_brick_commit_failed [] = {
{GD_OP_STATE_BRICK_COMMIT_FAILED, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_BRICK_COMMIT_FAILED, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_BRICK_COMMIT_FAILED, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_BRICK_COMMIT_FAILED, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_BRICK_COMMIT_FAILED, glusterd_op_ac_brick_op_failed}, //EVENT_RCVD_ACC
{GD_OP_STATE_BRICK_COMMIT_FAILED, glusterd_op_ac_none}, //EVENT_ALL_ACC
{GD_OP_STATE_BRICK_COMMIT_FAILED, glusterd_op_ac_none}, //EVENT_STAGE_ACC
@@ -8570,13 +8593,14 @@ glusterd_op_sm_t glusterd_op_state_brick_commit_failed [] = {
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
{GD_OP_STATE_BRICK_COMMIT_FAILED, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_BRICK_COMMIT_FAILED, glusterd_op_ac_send_commit_failed}, //EVENT_ALL_ACK
+ {GD_OP_STATE_DEFAULT, glusterd_op_ac_local_unlock}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_BRICK_COMMIT_FAILED, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_commit_op_failed [] = {
{GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_commit_op_failed}, //EVENT_RCVD_ACC
{GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_none}, //EVENT_ALL_ACC
{GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_none}, //EVENT_STAGE_ACC
@@ -8585,15 +8609,16 @@ glusterd_op_sm_t glusterd_op_state_commit_op_failed [] = {
{GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_none}, //EVENT_STAGE_OP
{GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_none}, //EVENT_COMMIT_OP
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
- {GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_none}, //EVENT_START_UNLOCK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_send_unlock}, //EVENT_ALL_ACK
+ {GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_none}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_COMMIT_OP_FAILED, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_commit_op_sent [] = {
{GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_rcvd_commit_op_acc}, //EVENT_RCVD_ACC
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_send_unlock}, //EVENT_ALL_ACC
{GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_none}, //EVENT_STAGE_ACC
@@ -8602,15 +8627,16 @@ glusterd_op_sm_t glusterd_op_state_commit_op_sent [] = {
{GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_none}, //EVENT_STAGE_OP
{GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_none}, //EVENT_COMMIT_OP
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
- {GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_send_unlock}, //EVENT_START_UNLOCK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_none}, //EVENT_ALL_ACK
+ {GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_none}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_COMMIT_OP_SENT, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_committed [] = {
{GD_OP_STATE_COMMITED, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_COMMITED, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_COMMITED, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_COMMITED, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_COMMITED, glusterd_op_ac_none}, //EVENT_RCVD_ACC
{GD_OP_STATE_COMMITED, glusterd_op_ac_none}, //EVENT_ALL_ACC
{GD_OP_STATE_COMMITED, glusterd_op_ac_none}, //EVENT_STAGE_ACC
@@ -8621,26 +8647,45 @@ glusterd_op_sm_t glusterd_op_state_committed [] = {
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
{GD_OP_STATE_COMMITED, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_COMMITED, glusterd_op_ac_none}, //EVENT_ALL_ACK
+ {GD_OP_STATE_DEFAULT, glusterd_op_ac_local_unlock}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_COMMITED, glusterd_op_ac_none}, //EVENT_MAX
};
glusterd_op_sm_t glusterd_op_state_unlock_sent [] = {
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none}, //EVENT_NONE
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none},//EVENT_START_LOCK
- {GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none}, //EVENT_LOCK
+ {GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_lock}, //EVENT_LOCK
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_rcvd_unlock_acc}, //EVENT_RCVD_ACC
{GD_OP_STATE_DEFAULT, glusterd_op_ac_unlocked_all}, //EVENT_ALL_ACC
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none}, //EVENT_STAGE_ACC
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none}, //EVENT_COMMIT_ACC
- {GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none}, //EVENT_RCVD_RJT
+ {GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_rcvd_unlock_acc}, //EVENT_RCVD_RJT
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none}, //EVENT_STAGE_OP
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none}, //EVENT_COMMIT_OP
- {GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
- {GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none}, //EVENT_START_UNLOCK
+ {GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_START_UNLOCK
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none}, //EVENT_ALL_ACK
+ {GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none}, //EVENT_LOCAL_UNLOCK_NO_RESP
{GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_none}, //EVENT_MAX
};
+glusterd_op_sm_t glusterd_op_state_ack_drain [] = {
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_NONE
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none},//EVENT_START_LOCK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_lock}, //EVENT_LOCK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_send_unlock_drain}, //EVENT_RCVD_ACC
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_ALL_ACC
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_STAGE_ACC
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_COMMIT_ACC
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_send_unlock_drain}, //EVENT_RCVD_RJT
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_STAGE_OP
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_COMMIT_OP
+ {GD_OP_STATE_DEFAULT, glusterd_op_ac_unlock}, //EVENT_UNLOCK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_START_UNLOCK
+ {GD_OP_STATE_UNLOCK_SENT, glusterd_op_ac_send_unlock}, //EVENT_ALL_ACK
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_LOCAL_UNLOCK_NO_RESP
+ {GD_OP_STATE_ACK_DRAIN, glusterd_op_ac_none}, //EVENT_MAX
+};
glusterd_op_sm_t *glusterd_op_state_table [] = {
glusterd_op_state_default,
@@ -8656,7 +8701,8 @@ glusterd_op_sm_t *glusterd_op_state_table [] = {
glusterd_op_state_brick_op_sent,
glusterd_op_state_brick_op_failed,
glusterd_op_state_brick_committed,
- glusterd_op_state_brick_commit_failed
+ glusterd_op_state_brick_commit_failed,
+ glusterd_op_state_ack_drain
};
int
@@ -8717,6 +8763,14 @@ glusterd_destroy_req_ctx (glusterd_req_ctx_t *ctx)
}
void
+glusterd_destroy_local_unlock_ctx (uuid_t *ctx)
+{
+ if (!ctx)
+ return;
+ GF_FREE (ctx);
+}
+
+void
glusterd_destroy_op_event_ctx (glusterd_op_sm_event_t *event)
{
if (!event)
@@ -8731,6 +8785,9 @@ glusterd_destroy_op_event_ctx (glusterd_op_sm_event_t *event)
case GD_OP_EVENT_ALL_ACK:
glusterd_destroy_req_ctx (event->ctx);
break;
+ case GD_OP_EVENT_LOCAL_UNLOCK_NO_RESP:
+ glusterd_destroy_local_unlock_ctx (event->ctx);
+ break;
default:
break;
}
@@ -8806,9 +8863,7 @@ glusterd_op_set_op (glusterd_op_t op)
GF_ASSERT (op < GD_OP_MAX);
GF_ASSERT (op > GD_OP_NONE);
- opinfo.op[op] = 1;
- opinfo.pending_op[op] = 1;
- opinfo.commit_op[op] = 1;
+ opinfo.op = op;
return 0;
@@ -8818,40 +8873,8 @@ int32_t
glusterd_op_get_op ()
{
- int i = 0;
- int32_t ret = 0;
-
- for ( i = 0; i < GD_OP_MAX; i++) {
- if (opinfo.op[i])
- break;
- }
-
- if ( i == GD_OP_MAX)
- ret = -1;
- else
- ret = i;
-
- return ret;
-
-}
-
-
-int32_t
-glusterd_op_set_cli_op (glusterd_op_t op)
-{
-
- int32_t ret = 0;
-
- ret = pthread_mutex_trylock (&opinfo.lock);
+ return opinfo.op;
- if (ret)
- goto out;
-
- opinfo.cli_op = op;
-
-out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
- return ret;
}
int32_t
@@ -8864,51 +8887,24 @@ glusterd_op_set_req (rpcsvc_request_t *req)
}
int32_t
-glusterd_op_clear_pending_op (glusterd_op_t op)
-{
-
- GF_ASSERT (op < GD_OP_MAX);
- GF_ASSERT (op > GD_OP_NONE);
-
- opinfo.pending_op[op] = 0;
-
- return 0;
-
-}
-
-int32_t
-glusterd_op_clear_commit_op (glusterd_op_t op)
-{
-
- GF_ASSERT (op < GD_OP_MAX);
- GF_ASSERT (op > GD_OP_NONE);
-
- opinfo.commit_op[op] = 0;
-
- return 0;
-
-}
-
-int32_t
glusterd_op_clear_op (glusterd_op_t op)
{
- GF_ASSERT (op < GD_OP_MAX);
- GF_ASSERT (op > GD_OP_NONE);
-
- opinfo.op[op] = 0;
+ opinfo.op = GD_OP_NONE;
return 0;
}
int32_t
-glusterd_op_init_ctx (glusterd_op_t op)
+glusterd_op_init_ctx ()
{
int ret = 0;
dict_t *dict = NULL;
+ glusterd_op_t op = GD_OP_NONE;
- if (_gf_false == glusterd_need_brick_op (op)) {
+ op = glusterd_op_get_op ();
+ if (_gf_false == glusterd_need_brick_op ()) {
gf_log ("", GF_LOG_DEBUG, "Received op: %d, returning", op);
goto out;
}
@@ -8917,10 +8913,7 @@ glusterd_op_init_ctx (glusterd_op_t op)
ret = -1;
goto out;
}
- ret = glusterd_op_set_ctx (op, dict);
- if (ret)
- goto out;
- ret = glusterd_op_set_ctx_free (op, _gf_true);
+ ret = glusterd_op_set_ctx (dict);
if (ret)
goto out;
out:
@@ -8931,29 +8924,25 @@ out:
int32_t
-glusterd_op_fini_ctx (glusterd_op_t op)
+glusterd_op_fini_ctx ()
{
dict_t *dict = NULL;
- if (glusterd_op_get_ctx_free (op)) {
- dict = glusterd_op_get_ctx (op);
- if (dict)
- dict_unref (dict);
- }
- glusterd_op_reset_ctx (op);
+ 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, gf_boolean_t ctx_free)
+glusterd_op_free_ctx (glusterd_op_t op, void *ctx)
{
- GF_ASSERT (op < GD_OP_MAX);
- GF_ASSERT (op > GD_OP_NONE);
-
- if (ctx && ctx_free) {
+ if (ctx) {
switch (op) {
case GD_OP_CREATE_VOLUME:
case GD_OP_STOP_VOLUME:
@@ -8981,53 +8970,17 @@ glusterd_op_free_ctx (glusterd_op_t op, void *ctx, gf_boolean_t ctx_free)
break;
}
}
- return 0;
-
-}
-
-void *
-glusterd_op_get_ctx (glusterd_op_t op)
-{
- GF_ASSERT (op < GD_OP_MAX);
- GF_ASSERT (op > GD_OP_NONE);
-
- return opinfo.op_ctx[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;
+ glusterd_op_reset_ctx ();
return 0;
}
-gf_boolean_t
-glusterd_op_get_ctx_free (glusterd_op_t op)
+void *
+glusterd_op_get_ctx ()
{
- GF_ASSERT (op < GD_OP_MAX);
- GF_ASSERT (op > GD_OP_NONE);
- return opinfo.ctx_free[op];
+ return opinfo.op_ctx;
}
@@ -9040,10 +8993,6 @@ glusterd_op_sm_init ()
}
int32_t
-glusterd_opinfo_unlock(){
- return (pthread_mutex_unlock(&opinfo.lock));
-}
-int32_t
glusterd_volume_stats_write_perf (char *brick_path, int32_t blk_size,
int32_t blk_count, double *throughput, double *time)
{
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index 4f33898cd..c5ed99fb9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -58,6 +58,7 @@ typedef enum glusterd_op_sm_state_ {
GD_OP_STATE_BRICK_OP_FAILED,
GD_OP_STATE_BRICK_COMMITTED,
GD_OP_STATE_BRICK_COMMIT_FAILED,
+ GD_OP_STATE_ACK_DRAIN,
GD_OP_STATE_MAX,
} glusterd_op_sm_state_t;
@@ -75,6 +76,7 @@ typedef enum glusterd_op_sm_event_type_ {
GD_OP_EVENT_UNLOCK,
GD_OP_EVENT_START_UNLOCK,
GD_OP_EVENT_ALL_ACK,
+ GD_OP_EVENT_LOCAL_UNLOCK_NO_RESP,
GD_OP_EVENT_MAX
} glusterd_op_sm_event_type_t;
@@ -104,17 +106,12 @@ struct glusterd_op_info_ {
int32_t pending_count;
int32_t brick_pending_count;
int32_t op_count;
- glusterd_op_t op[GD_OP_MAX];
- glusterd_op_t pending_op[GD_OP_MAX];
- glusterd_op_t commit_op[GD_OP_MAX];
+ glusterd_op_t op;
struct list_head op_peers;
- void *op_ctx[GD_OP_MAX];
+ void *op_ctx;
rpcsvc_request_t *req;
int32_t op_ret;
int32_t op_errno;
- pthread_mutex_t lock;
- int32_t cli_op;
- gf_boolean_t ctx_free[GD_OP_MAX];
char *op_errstr;
struct list_head pending_bricks;
};
@@ -186,19 +183,13 @@ int
glusterd_op_sm ();
int32_t
-glusterd_op_set_ctx (glusterd_op_t op, void *ctx);
+glusterd_op_set_ctx (void *ctx);
int32_t
glusterd_op_set_op (glusterd_op_t op);
-int32_t
-glusterd_op_clear_pending_op (glusterd_op_t op);
-
-int32_t
-glusterd_op_clear_commit_op (glusterd_op_t op);
-
int
-glusterd_op_build_payload (glusterd_op_t op, dict_t **req);
+glusterd_op_build_payload (dict_t **req);
int32_t
glusterd_op_stage_validate (glusterd_op_t op, dict_t *req, char **op_errstr,
@@ -209,15 +200,12 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *req, char **op_errstr,
dict_t* dict);
void *
-glusterd_op_get_ctx (glusterd_op_t op);
+glusterd_op_get_ctx ();
int32_t
glusterd_op_set_req (rpcsvc_request_t *req);
int32_t
-glusterd_op_set_cli_op (glusterd_op_t op);
-
-int32_t
glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
int32_t op_errno, rpcsvc_request_t *req,
void *ctx, char *op_errstr);
@@ -225,28 +213,10 @@ int32_t
glusterd_op_get_op ();
int32_t
-glusterd_op_clear_pending_op (glusterd_op_t op);
-
-int32_t
-glusterd_op_clear_commit_op (glusterd_op_t op);
-
-int32_t
-glusterd_op_clear_op (glusterd_op_t op);
-
-int32_t
-glusterd_op_free_ctx (glusterd_op_t op, void *ctx, gf_boolean_t ctx_free);
-
-int32_t
-glusterd_opinfo_unlock();
+glusterd_op_clear_op ();
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);
+glusterd_op_free_ctx (glusterd_op_t op, void *ctx);
int
glusterd_check_option_exists(char *optstring, char **completion);
@@ -278,9 +248,9 @@ glusterd_handle_brick_rsp (glusterd_brickinfo_t *brickinfo,
char **op_errstr);
void glusterd_op_brick_disconnect (void *data);
int32_t
-glusterd_op_init_ctx (glusterd_op_t op);
+glusterd_op_init_ctx ();
int32_t
-glusterd_op_fini_ctx (glusterd_op_t op);
+glusterd_op_fini_ctx ();
int32_t
glusterd_volume_stats_read_perf (char *brick_path, int32_t blk_size,
int32_t blk_count, double *throughput, double *time);
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
index 36868d3ce..0ba0aad63 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
@@ -776,6 +776,7 @@ glusterd3_1_cluster_lock_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
+out:
op_ret = rsp.op_ret;
gf_log ("glusterd", GF_LOG_INFO,
@@ -803,7 +804,6 @@ glusterd3_1_cluster_lock_cbk (struct rpc_req *req, struct iovec *iov,
glusterd_op_sm ();
}
-out:
GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe));
return ret;
}
@@ -835,6 +835,7 @@ glusterd3_1_cluster_unlock_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
+out:
op_ret = rsp.op_ret;
gf_log ("glusterd", GF_LOG_INFO,
@@ -862,7 +863,6 @@ glusterd3_1_cluster_unlock_cbk (struct rpc_req *req, struct iovec *iov,
glusterd_op_sm ();
}
-out:
GLUSTERD_STACK_DESTROY (((call_frame_t *)myframe));
return ret;
}
@@ -972,7 +972,7 @@ glusterd_gsync_use_rsp_dict (dict_t *rsp_dict, char *op_errstr)
dict_t *ctx = NULL;
int ret = 0;
- ctx = glusterd_op_get_ctx (GD_OP_GSYNC_SET);
+ ctx = glusterd_op_get_ctx ();
if (!ctx) {
gf_log ("", GF_LOG_ERROR,
"Operation Context is not present");
@@ -1008,7 +1008,7 @@ glusterd_rb_use_rsp_dict (dict_t *rsp_dict)
dict_t *ctx = NULL;
- ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ ctx = glusterd_op_get_ctx ();
if (!ctx) {
gf_log ("", GF_LOG_ERROR,
"Operation Context is not present");
@@ -1105,6 +1105,7 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
}
}
+out:
op_ret = rsp.op_ret;
gf_log ("glusterd", GF_LOG_INFO,
@@ -1154,7 +1155,6 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
glusterd_op_sm ();
}
-out:
if (rsp.op_errstr && strcmp (rsp.op_errstr, "error"))
free (rsp.op_errstr); //malloced by xdr
if (dict) {
@@ -1227,7 +1227,7 @@ glusterd_profile_volume_use_rsp_dict (dict_t *rsp_dict)
op = glusterd_op_get_op ();
GF_ASSERT (GD_OP_PROFILE_VOLUME == op);
- ctx_dict = glusterd_op_get_ctx (op);
+ ctx_dict = glusterd_op_get_ctx ();
ret = dict_get_int32 (ctx_dict, "count", &count);
rsp_ctx.count = count;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index bb7d82ac6..589bbbe20 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -68,7 +68,7 @@
char *glusterd_sock_dir = "/tmp";
static glusterd_lock_t lock;
-static int32_t
+int32_t
glusterd_get_lock_owner (uuid_t *uuid)
{
uuid_copy (*uuid, lock.owner) ;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 93e2cb92d..1a4dadf1f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -54,10 +54,12 @@ typedef struct glusterd_voldict_ctx_ {
typedef int (*glusterd_condition_func) (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo,
void *ctx);
-
typedef struct glusterd_lock_ glusterd_lock_t;
int32_t
+glusterd_get_lock_owner (uuid_t *cur_owner);
+
+int32_t
glusterd_lock (uuid_t new_owner);
int32_t
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index d16289a21..050a02e4b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1769,7 +1769,7 @@ glusterd_get_volopt_content (gf_boolean_t xml_out)
}
#endif
- ctx = glusterd_op_get_ctx (GD_OP_SET_VOLUME);
+ ctx = glusterd_op_get_ctx ();
if (!ctx) {
/*extract the vol-set-help output only in host glusterd*/
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 7bd52b964..1fde10abc 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -68,7 +68,7 @@ glusterd_opinfo_init ()
{
int32_t ret = -1;
- ret = pthread_mutex_init (&opinfo.lock, NULL);
+ opinfo.op = GD_OP_NONE;
return ret;
}