summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rpc/xdr/src/glusterd1-xdr.c9
-rw-r--r--rpc/xdr/src/glusterd1-xdr.h2
-rw-r--r--rpc/xdr/src/glusterd1.x2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c13
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c38
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.h7
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd3_1-mops.c19
8 files changed, 76 insertions, 18 deletions
diff --git a/rpc/xdr/src/glusterd1-xdr.c b/rpc/xdr/src/glusterd1-xdr.c
index 3ddd55688..7c9038dcf 100644
--- a/rpc/xdr/src/glusterd1-xdr.c
+++ b/rpc/xdr/src/glusterd1-xdr.c
@@ -201,6 +201,8 @@ xdr_gd1_mgmt_stage_op_rsp (XDR *xdrs, gd1_mgmt_stage_op_rsp *objp)
return FALSE;
if (!xdr_int (xdrs, &objp->op_errno))
return FALSE;
+ if (!xdr_string (xdrs, &objp->op_errstr, ~0))
+ return FALSE;
return TRUE;
}
@@ -235,6 +237,8 @@ xdr_gd1_mgmt_commit_op_rsp (XDR *xdrs, gd1_mgmt_commit_op_rsp *objp)
return FALSE;
if (!xdr_int (xdrs, &objp->op_errno))
return FALSE;
+ if (!xdr_string (xdrs, &objp->op_errstr, ~0))
+ return FALSE;
} else {
IXDR_PUT_LONG(buf, objp->op);
@@ -256,6 +260,8 @@ xdr_gd1_mgmt_commit_op_rsp (XDR *xdrs, gd1_mgmt_commit_op_rsp *objp)
return FALSE;
if (!xdr_int (xdrs, &objp->op_errno))
return FALSE;
+ if (!xdr_string (xdrs, &objp->op_errstr, ~0))
+ return FALSE;
} else {
objp->op = IXDR_GET_LONG(buf);
@@ -278,6 +284,9 @@ xdr_gd1_mgmt_commit_op_rsp (XDR *xdrs, gd1_mgmt_commit_op_rsp *objp)
return FALSE;
if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
return FALSE;
+ if (!xdr_string (xdrs, &objp->op_errstr, ~0))
+ return FALSE;
+
return TRUE;
}
diff --git a/rpc/xdr/src/glusterd1-xdr.h b/rpc/xdr/src/glusterd1-xdr.h
index 0c738d00c..fe7c44eb2 100644
--- a/rpc/xdr/src/glusterd1-xdr.h
+++ b/rpc/xdr/src/glusterd1-xdr.h
@@ -130,6 +130,7 @@ struct gd1_mgmt_stage_op_rsp {
int op;
int op_ret;
int op_errno;
+ char *op_errstr;
};
typedef struct gd1_mgmt_stage_op_rsp gd1_mgmt_stage_op_rsp;
@@ -152,6 +153,7 @@ struct gd1_mgmt_commit_op_rsp {
u_int dict_len;
char *dict_val;
} dict;
+ char *op_errstr;
};
typedef struct gd1_mgmt_commit_op_rsp gd1_mgmt_commit_op_rsp;
diff --git a/rpc/xdr/src/glusterd1.x b/rpc/xdr/src/glusterd1.x
index 19fa7af68..a4f7b8558 100644
--- a/rpc/xdr/src/glusterd1.x
+++ b/rpc/xdr/src/glusterd1.x
@@ -77,6 +77,7 @@ struct gd1_mgmt_stage_op_rsp {
int op;
int op_ret;
int op_errno;
+ string op_errstr<>;
} ;
struct gd1_mgmt_commit_op_req {
@@ -91,6 +92,7 @@ struct gd1_mgmt_commit_op_rsp {
int op;
int op_ret;
int op_errno;
+ string op_errstr<>;
} ;
struct gd1_mgmt_friend_update {
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index c3834cd71..f1a9ef5ef 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -1988,7 +1988,7 @@ out:
int
glusterd_op_stage_send_resp (rpcsvc_request_t *req,
- int32_t op, int32_t status)
+ int32_t op, int32_t status, char *op_errstr)
{
gd1_mgmt_stage_op_rsp rsp = {{0},};
@@ -1998,6 +1998,10 @@ glusterd_op_stage_send_resp (rpcsvc_request_t *req,
rsp.op_ret = status;
glusterd_get_uuid (&rsp.uuid);
rsp.op = op;
+ if (op_errstr)
+ rsp.op_errstr = op_errstr;
+ else
+ rsp.op_errstr = "";
ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
gd_xdr_serialize_mgmt_stage_op_rsp);
@@ -2048,7 +2052,7 @@ out:
int
glusterd_op_commit_send_resp (rpcsvc_request_t *req,
- int32_t op, int32_t status)
+ int32_t op, int32_t status, char *op_errstr)
{
dict_t *rsp_dict = NULL;
gd1_mgmt_commit_op_rsp rsp = {{0}, };
@@ -2059,6 +2063,11 @@ glusterd_op_commit_send_resp (rpcsvc_request_t *req,
glusterd_get_uuid (&rsp.uuid);
rsp.op = op;
+ if (op_errstr)
+ rsp.op_errstr = op_errstr;
+ else
+ rsp.op_errstr = "";
+
rsp_dict = dict_new ();
if (!rsp_dict) {
gf_log ("", GF_LOG_DEBUG,
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index cdec2e098..c84d86800 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -3059,7 +3059,7 @@ out:
int32_t
glusterd_op_send_cli_response (int32_t op, int32_t op_ret,
int32_t op_errno, rpcsvc_request_t *req,
- void *op_ctx)
+ void *op_ctx, char *op_errstr)
{
int32_t ret = -1;
gd_serialize_t sfunc = NULL;
@@ -3199,6 +3199,11 @@ out:
return ret;
}
+int32_t
+glusterd_op_clear_errstr() {
+ opinfo.op_errstr = NULL;
+ return 0;
+}
int32_t
glusterd_op_txn_complete ()
@@ -3212,6 +3217,8 @@ glusterd_op_txn_complete ()
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);
@@ -3230,6 +3237,8 @@ glusterd_op_txn_complete ()
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;
@@ -3245,14 +3254,18 @@ glusterd_op_txn_complete ()
ctx_free = glusterd_op_get_ctx_free (op);
glusterd_op_set_ctx (op, NULL);
glusterd_op_clear_ctx_free (op);
+ glusterd_op_clear_errstr ();
}
out:
pthread_mutex_unlock (&opinfo.lock);
ret = glusterd_op_send_cli_response (cli_op, op_ret,
- op_errno, req, ctx);
+ op_errno, req, ctx, op_errstr);
if (ctx_free && ctx && (op != -1))
glusterd_op_free_ctx (op, ctx, ctx_free);
+ if (op_errstr)
+ GF_FREE (op_errstr);
+
gf_log ("glusterd", GF_LOG_NORMAL, "Returning %d", ret);
return ret;
}
@@ -3292,6 +3305,7 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx)
gd1_mgmt_stage_op_req *req = NULL;
glusterd_op_stage_ctx_t *stage_ctx = NULL;
int32_t status = 0;
+ char *op_errstr = NULL;
GF_ASSERT (ctx);
@@ -3299,13 +3313,16 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx)
req = &stage_ctx->stage_req;
- status = glusterd_op_stage_validate (req);
+ status = glusterd_op_stage_validate (req, &op_errstr);
if (status) {
gf_log ("", GF_LOG_ERROR, "Validate failed: %d", status);
}
- ret = glusterd_op_stage_send_resp (stage_ctx->req, req->op, status);
+ ret = glusterd_op_stage_send_resp (stage_ctx->req, req->op, status, op_errstr);
+
+ if (op_errstr)
+ GF_FREE (op_errstr);
gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
@@ -3319,6 +3336,7 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx)
gd1_mgmt_stage_op_req *req = NULL;
glusterd_op_commit_ctx_t *commit_ctx = NULL;
int32_t status = 0;
+ char *op_errstr = NULL;
GF_ASSERT (ctx);
@@ -3326,13 +3344,16 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx)
req = &commit_ctx->stage_req;
- status = glusterd_op_commit_perform (req);
+ status = glusterd_op_commit_perform (req, &op_errstr);
if (status) {
gf_log ("", GF_LOG_ERROR, "Commit failed: %d", status);
}
- ret = glusterd_op_commit_send_resp (commit_ctx->req, req->op, status);
+ ret = glusterd_op_commit_send_resp (commit_ctx->req, req->op, status, op_errstr);
+
+ if (op_errstr)
+ GF_FREE (op_errstr);
gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
@@ -3357,7 +3378,7 @@ glusterd_op_sm_transition_state (glusterd_op_info_t *opinfo,
}
int32_t
-glusterd_op_stage_validate (gd1_mgmt_stage_op_req *req)
+glusterd_op_stage_validate (gd1_mgmt_stage_op_req *req, char **op_errstr)
{
int ret = -1;
@@ -3412,7 +3433,7 @@ glusterd_op_stage_validate (gd1_mgmt_stage_op_req *req)
int32_t
-glusterd_op_commit_perform (gd1_mgmt_stage_op_req *req)
+glusterd_op_commit_perform (gd1_mgmt_stage_op_req *req, char **op_errstr)
{
int ret = -1;
@@ -3935,3 +3956,4 @@ int32_t
glusterd_opinfo_unlock(){
return (pthread_mutex_unlock(&opinfo.lock));
}
+
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index 930224a92..66435c8d2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -123,6 +123,7 @@ struct glusterd_op_info_ {
pthread_mutex_t lock;
int32_t cli_op;
gf_boolean_t ctx_free[GD_OP_MAX];
+ char *op_errstr;
};
typedef struct glusterd_op_info_ glusterd_op_info_t;
@@ -191,10 +192,10 @@ int
glusterd_op_build_payload (glusterd_op_t op, gd1_mgmt_stage_op_req **req);
int32_t
-glusterd_op_stage_validate (gd1_mgmt_stage_op_req *req);
+glusterd_op_stage_validate (gd1_mgmt_stage_op_req *req, char **op_errstr);
int32_t
-glusterd_op_commit_perform (gd1_mgmt_stage_op_req *req);
+glusterd_op_commit_perform (gd1_mgmt_stage_op_req *req, char **op_errstr);
void *
glusterd_op_get_ctx (glusterd_op_t op);
@@ -208,7 +209,7 @@ glusterd_op_set_cli_op (gf_mgmt_procnum op);
int32_t
glusterd_op_send_cli_response (int32_t op, int32_t op_ret,
int32_t op_errno, rpcsvc_request_t *req,
- void *ctx);
+ void *ctx, char *op_errstr);
int32_t
glusterd_op_get_op ();
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index d733a84f4..708080a13 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -247,7 +247,7 @@ glusterd_op_unlock_send_resp (rpcsvc_request_t *req, int32_t status);
int
glusterd_op_stage_send_resp (rpcsvc_request_t *req,
- int32_t op, int32_t status);
+ int32_t op, int32_t status, char *op_errstr);
int
glusterd_op_commmit_send_resp (rpcsvc_request_t *req,
@@ -293,7 +293,7 @@ glusterd_xfer_cli_probe_resp (rpcsvc_request_t *req, int32_t op_ret,
int
glusterd_op_commit_send_resp (rpcsvc_request_t *req,
- int32_t op, int32_t status);
+ int32_t op, int32_t status, char *op_errstr);
int
glusterd_xfer_friend_remove_resp (rpcsvc_request_t *req, char *hostname, int port);
diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
index c9c1493ff..eb752a665 100644
--- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
+++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
@@ -479,6 +479,7 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
+ rsp.op_errstr = "";
goto out;
}
@@ -487,6 +488,7 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("", GF_LOG_ERROR, "error");
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
+ rsp.op_errstr = "";
goto out;
}
uuid_unparse (rsp.uuid, str);
@@ -506,6 +508,7 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov,
if (op_ret) {
event_type = GD_OP_EVENT_RCVD_RJT;
opinfo.op_ret = op_ret;
+ opinfo.op_errstr = rsp.op_errstr;
} else {
event_type = GD_OP_EVENT_RCVD_ACC;
}
@@ -581,6 +584,7 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
+ rsp.op_errstr = "";
goto out;
}
@@ -589,6 +593,7 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("", GF_LOG_ERROR, "error");
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
+ rsp.op_errstr = "";
goto out;
}
uuid_unparse (rsp.uuid, str);
@@ -623,6 +628,7 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov,
if (op_ret) {
event_type = GD_OP_EVENT_RCVD_RJT;
opinfo.op_ret = op_ret;
+ opinfo.op_errstr = rsp.op_errstr;
} else {
if (rsp.op == GD_OP_REPLACE_BRICK) {
ret = glusterd_rb_use_rsp_dict (dict);
@@ -1003,6 +1009,7 @@ glusterd3_1_stage_op (call_frame_t *frame, xlator_t *this,
int32_t pending_peer = 0;
int i = 0;
call_frame_t *dummy_frame = NULL;
+ char *op_errstr = NULL;
if (!this) {
ret = -1;
@@ -1036,10 +1043,11 @@ glusterd3_1_stage_op (call_frame_t *frame, xlator_t *this,
if (ret)
goto out;
- ret = glusterd_op_stage_validate (req);
+ ret = glusterd_op_stage_validate (req, &op_errstr);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Staging failed");
+ opinfo.op_errstr = op_errstr;
goto out;
}
@@ -1093,6 +1101,7 @@ glusterd3_1_commit_op (call_frame_t *frame, xlator_t *this,
int32_t pending_peer = 0;
int i = 0;
call_frame_t *dummy_frame = NULL;
+ char *op_errstr = NULL;
if (!this) {
ret = -1;
@@ -1125,10 +1134,11 @@ glusterd3_1_commit_op (call_frame_t *frame, xlator_t *this,
if (ret)
goto out;
- ret = glusterd_op_commit_perform ((gd1_mgmt_stage_op_req *)req);
+ ret = glusterd_op_commit_perform ((gd1_mgmt_stage_op_req *)req, &op_errstr);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Commit failed");
+ opinfo.op_errstr = op_errstr;
goto out;
}
@@ -1177,6 +1187,7 @@ glusterd_handle_rpc_msg (rpcsvc_request_t *req)
{
int ret = -1;
gf_boolean_t is_cli_req = _gf_false;
+ char *op_errstr = NULL;
GF_ASSERT (req);
@@ -1300,10 +1311,12 @@ out:
be 0, and we should not point to any RPC errors, because
otherwise rpcsvc.c will send an error reply for the same
request, which causes double replies */
- ret = glusterd_op_send_cli_response (req->procnum, ret, 0, req, NULL);
+ ret = glusterd_op_send_cli_response (req->procnum, ret, 0, req, NULL, op_errstr);
if (!ret)
req->rpc_err = SUCCESS;
}
+ if (op_errstr)
+ GF_FREE (op_errstr);
if (!ret)
gf_log ("", GF_LOG_WARNING, "Returning %d", ret);