summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2012-09-12 17:16:22 +0530
committerAnand Avati <avati@redhat.com>2012-09-20 08:26:22 -0700
commite09245b8d152fdae8152f8e29d2be1827e6090e1 (patch)
treec930304e13da4d4f56b60ef692653d445ba10f30 /xlators
parentf9652adfd1315c0a817917eb35f61f43f58e673b (diff)
glusterd: Fix to log command status at the appropriate time
PROBLEM: In the existing implementation, the success/failure of execution of a command is decided (and logged) in glusterd handler functions. Strictly speaking, the logging mechanism must take into account what course the command takes within the state machine before concluding whether it succeeded or failed. FIX: This patch attempts to fix the above issue for vol commands. The format of the log message is as follows: for failure: <command string> : FAILED : <cause of failure> for success: <command string> : SUCCESS APPROACH (in a nutshell): * The command string is packed into dict at cli and sent to glusterd. * glusterd logs the command status just before doing a "submit_reply", which is called (either directly or indirectly via a call to glusterd_op_cli_send_response) at 2 places for every vol command: i. in handler functions, and ii. in glusterd_op_txn_complete In short, the failure of a command in the handler implies the command has indeed failed. However, its success in the handler does NOT necessarily mean the command succeeded/will succeed. Change-Id: I5a8a2ddc318ef2dc2a9699f704a6bcd2f0ab0277 BUG: 823081 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/3948 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c29
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c54
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-log-ops.c10
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c7
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c53
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c14
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rpc-ops.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c35
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h5
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c63
11 files changed, 107 insertions, 175 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index 9efccd9a49a..b32c9872ac3 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -343,7 +343,6 @@ glusterd_handle_add_brick (rpcsvc_request_t *req)
char *bricks = NULL;
char *volname = NULL;
int brick_count = 0;
- char *brick_list = NULL;
void *cli_rsp = NULL;
char err_str[2048] = {0,};
gf_cli_rsp rsp = {0,};
@@ -388,8 +387,6 @@ glusterd_handle_add_brick (rpcsvc_request_t *req)
ret = dict_get_str (dict, "volname", &volname);
- gf_cmd_log ("Volume add-brick", "on volname: %s attempted",
- volname);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
snprintf (err_str, sizeof (err_str), "Unable to get volume "
@@ -510,9 +507,6 @@ brick_val:
goto out;
}
- gf_cmd_log ("Volume add-brick", "volname: %s type %d count:%d bricks:%s"
- ,volname, volinfo->type, brick_count, brick_list);
-
if (type != volinfo->type) {
ret = dict_set_int32 (dict, "type", type);
if (ret)
@@ -523,19 +517,17 @@ brick_val:
ret = glusterd_op_begin (req, GD_OP_ADD_BRICK, dict);
out:
- gf_cmd_log ("Volume add-brick","on volname: %s %s", volname,
- (ret != 0)? "FAILED" : "SUCCESS");
if (ret) {
- if (dict)
- dict_unref (dict);
rsp.op_ret = -1;
rsp.op_errno = 0;
if (err_str[0] == '\0')
snprintf (err_str, sizeof (err_str), "Operation failed");
rsp.op_errstr = err_str;
cli_rsp = &rsp;
- glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL,
- (xdrproc_t)xdr_gf_cli_rsp);
+ glusterd_to_cli (req, cli_rsp, NULL, 0, NULL,
+ (xdrproc_t)xdr_gf_cli_rsp, dict);
+ if (dict)
+ dict_unref (dict);
ret = 0; //sent error to cli, prevent second reply
}
@@ -610,7 +602,6 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
goto out;
}
- gf_cmd_log ("Volume remove-brick","on volname: %s attempted", volname);
ret = dict_get_int32 (dict, "count", &count);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to get count");
@@ -814,17 +805,11 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
break;
}
}
- gf_cmd_log ("Volume remove-brick","volname: %s count:%d bricks:%s",
- volname, count, brick_list);
ret = glusterd_op_begin (req, GD_OP_REMOVE_BRICK, dict);
- gf_cmd_log ("Volume remove-brick","on volname: %s %s", volname,
- (ret) ? "FAILED" : "SUCCESS");
out:
if (ret) {
- if (dict)
- dict_unref (dict);
rsp.op_ret = -1;
rsp.op_errno = 0;
if (err_str[0] == '\0')
@@ -832,8 +817,10 @@ out:
gf_log ("", GF_LOG_ERROR, "%s", err_str);
rsp.op_errstr = err_str;
cli_rsp = &rsp;
- glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL,
- (xdrproc_t)xdr_gf_cli_rsp);
+ glusterd_to_cli (req, cli_rsp, NULL, 0, NULL,
+ (xdrproc_t)xdr_gf_cli_rsp, dict);
+ if (dict)
+ dict_unref (dict);
ret = 0; //sent error to cli, prevent second reply
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index 29e3bdd7690..3dcb12f39ef 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -131,21 +131,17 @@ glusterd_handle_gsync_set (rpcsvc_request_t *req)
break;
}
- gf_cmd_log ("volume "GEOREP, " %s command on %s,%s", operation, master,
- slave);
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");
out:
glusterd_friend_sm ();
glusterd_op_sm ();
if (ret) {
+ ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
+ dict, "operation failed");
if (dict)
dict_unref (dict);
- ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
}
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 01f2adb3858..13e53c17f6c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -982,19 +982,16 @@ glusterd_handle_reset_volume (rpcsvc_request_t *req)
goto out;
}
- gf_cmd_log ("Volume reset", "volume : %s", volname);
ret = glusterd_op_begin (req, GD_OP_RESET_VOLUME, dict);
- gf_cmd_log ("Volume reset", " on volume %s %s ", volname,
- ((ret == 0)? " SUCCEDED":" FAILED"));
out:
glusterd_friend_sm ();
glusterd_op_sm ();
if (ret) {
+ ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
+ dict, "operation failed");
if (dict)
dict_unref (dict);
- ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
}
return ret;
@@ -1067,12 +1064,7 @@ glusterd_handle_set_volume (rpcsvc_request_t *req)
goto out;
}
-
- 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_cmd_log ("volume set", "volume-name:%s: key:%s, value:%s %s",
- volname, key, value, (ret == 0)? "SUCCEDED" : "FAILED" );
out:
glusterd_friend_sm ();
@@ -1083,7 +1075,7 @@ out:
(op_errstr)? op_errstr:"");
else if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
+ dict, "operation failed");
if (op_errstr)
GF_FREE (op_errstr);
@@ -1187,8 +1179,8 @@ out:
cli_rsp.op_errstr = msg;
if (msg[0] == '\0')
snprintf (msg, sizeof (msg), "Operation failed");
- glusterd_submit_reply(req, &cli_rsp, NULL, 0, NULL,
- (xdrproc_t)xdr_gf_cli_rsp);
+ glusterd_to_cli (req, &cli_rsp, NULL, 0, NULL,
+ (xdrproc_t)xdr_gf_cli_rsp, dict);
if (dict)
dict_unref (dict);
@@ -1830,22 +1822,19 @@ glusterd_handle_cli_profile_volume (rpcsvc_request_t *req)
goto out;
}
- gf_cmd_log ("Volume stats", "volume : %s, op: %d", volname, op);
ret = glusterd_op_begin (req, cli_op, dict);
- gf_cmd_log ("Volume stats", " on volume %s, op: %d %s ",
- volname, op,
- ((ret == 0)? " SUCCEDED":" FAILED"));
out:
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret && dict)
- dict_unref (dict);
free (cli_req.dict.dict_val);
- if (ret)
+ if (ret) {
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
+ dict, "operation failed");
+ if (dict)
+ dict_unref (dict);
+ }
gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -2648,15 +2637,15 @@ glusterd_handle_status_volume (rpcsvc_request_t *req)
ret = glusterd_op_begin (req, GD_OP_STATUS_VOLUME, dict);
out:
- if (ret && dict)
- dict_unref (dict);
-
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret)
+ if (ret) {
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
+ dict, "operation failed");
+ if (dict)
+ dict_unref (dict);
+ }
free (cli_req.dict.dict_val);
return ret;
@@ -2710,19 +2699,16 @@ glusterd_handle_cli_clearlocks_volume (rpcsvc_request_t *req)
ret = glusterd_op_begin (req, cli_op, dict);
- gf_cmd_log ("clear-locks", "on volume %s %s", volname,
- ((0 == ret) ? "SUCCEEDED" : "FAILED"));
-
out:
- if (ret && dict)
- dict_unref (dict);
-
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret)
+ if (ret) {
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
+ dict, "operation failed");
+ if (dict)
+ dict_unref (dict);
+ }
free (cli_req.dict.dict_val);
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
index 4b35afde776..9ab52a349b8 100644
--- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
@@ -72,15 +72,15 @@ glusterd_handle_log_rotate (rpcsvc_request_t *req)
ret = glusterd_op_begin (req, GD_OP_LOG_ROTATE, dict);
out:
- if (ret && dict)
- dict_unref (dict);
-
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret)
+ if (ret) {
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
+ dict, "operation failed");
+ if (dict)
+ dict_unref (dict);
+ }
free (cli_req.dict.dict_val);
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 1f97fe119d9..103f88e7ac5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -91,20 +91,17 @@ glusterd_handle_quota (rpcsvc_request_t *req)
strncpy (operation, "remove", sizeof (operation));
break;
}
- gf_cmd_log ("volume quota", " %s command on %s", operation, volname);
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");
out:
glusterd_friend_sm ();
glusterd_op_sm ();
if (ret) {
+ ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
+ dict, "operation failed");
if (dict)
dict_unref (dict);
- ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
}
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index 2de20fdcf6e..dab8f68f0b1 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -40,51 +40,6 @@
int32_t
glusterd_brick_op_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe);
-
-void
-glusterd_rebalance_cmd_attempted_log (int cmd, char *volname)
-{
- switch (cmd) {
- case GF_DEFRAG_CMD_START_LAYOUT_FIX:
- gf_cmd_log ("Volume rebalance"," on volname: %s "
- "cmd: start fix layout , attempted",
- volname);
- gf_log ("glusterd", GF_LOG_INFO, "Received rebalance "
- "volume start layout fix on %s", volname);
- break;
- case GF_DEFRAG_CMD_START_FORCE:
- gf_cmd_log ("Volume rebalance"," on volname: %s "
- "cmd: start data force attempted",
- volname);
- gf_log ("glusterd", GF_LOG_INFO, "Received rebalance "
- "volume start migrate data on %s", volname);
- break;
- case GF_DEFRAG_CMD_START:
- gf_cmd_log ("Volume rebalance"," on volname: %s "
- "cmd: start, attempted", volname);
- gf_log ("glusterd", GF_LOG_INFO, "Received rebalance "
- "volume start on %s", volname);
- break;
- case GF_DEFRAG_CMD_STOP:
- gf_cmd_log ("Volume rebalance"," on volname: %s "
- "cmd: stop, attempted", volname);
- gf_log ("glusterd", GF_LOG_INFO, "Received rebalance "
- "volume stop on %s", volname);
- break;
- default:
- break;
- }
-}
-
-void
-glusterd_rebalance_cmd_log (int cmd, char *volname, int status)
-{
- if (cmd != GF_DEFRAG_CMD_STATUS) {
- gf_cmd_log ("volume rebalance"," on volname: %s %d %s",
- volname, cmd, ((status)?"FAILED":"SUCCESS"));
- }
-}
-
int
glusterd_defrag_start_validate (glusterd_volinfo_t *volinfo, char *op_errstr,
size_t len)
@@ -463,8 +418,6 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req)
goto out;
}
- glusterd_rebalance_cmd_attempted_log (cmd, volname);
-
ret = dict_set_static_bin (dict, "node-uuid", MY_UUID, 16);
if (ret)
goto out;
@@ -482,10 +435,10 @@ out:
glusterd_op_sm ();
if (ret) {
+ ret = glusterd_op_send_cli_response (GD_OP_REBALANCE, ret, 0, req,
+ dict, "operation failed");
if (dict)
dict_unref (dict);
- ret = glusterd_op_send_cli_response (GD_OP_REBALANCE, ret, 0, req,
- NULL, "operation failed");
}
free (cli_req.dict.dict_val);//malloced by xdr
@@ -628,8 +581,6 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
break;
}
- glusterd_rebalance_cmd_log (cmd, volname, ret);
-
out:
if (ret && op_errstr && msg[0])
*op_errstr = gf_strdup (msg);
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index f921279923c..5fcbb84e5d3 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -140,25 +140,21 @@ glusterd_handle_replace_brick (rpcsvc_request_t *req)
gf_log ("", GF_LOG_DEBUG, "dst brick=%s", dst_brick);
gf_log ("glusterd", GF_LOG_INFO, "Received replace brick %s request",
operation);
- gf_cmd_log ("Volume replace-brick","volname: %s src_brick:%s"
- " dst_brick:%s op:%s", volname, src_brick, dst_brick,
- operation);
ret = glusterd_op_begin (req, GD_OP_REPLACE_BRICK, dict);
- gf_cmd_log ("Volume replace-brick","on volname: %s %s", volname,
- (ret) ? "FAILED" : "SUCCESS");
out:
- if (ret && dict)
- dict_unref (dict);
free (cli_req.dict.dict_val);//malloced by xdr
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret)
+ if (ret) {
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
+ dict, "operation failed");
+ if (dict)
+ dict_unref (dict);
+ }
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
index 0a31868c8b5..89d2dd1e6b9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
@@ -172,8 +172,8 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
cli_rsp = &rsp;
xdrproc = (xdrproc_t) xdr_gf_cli_rsp;
- glusterd_submit_reply (req, cli_rsp, NULL, 0, NULL,
- xdrproc);
+ glusterd_to_cli (req, cli_rsp, NULL, 0, NULL,
+ xdrproc, ctx);
ret = 0;
GF_FREE (free_ptr);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index efae2b51846..821ea2cc450 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -37,7 +37,6 @@
#include "glusterd-pmap.h"
#include "xdr-generic.h"
-
#include <sys/resource.h>
#include <inttypes.h>
#include <signal.h>
@@ -5712,3 +5711,37 @@ glusterd_volset_help (dict_t *dict, char **op_errstr)
gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
+
+int
+glusterd_to_cli (rpcsvc_request_t *req, gf_cli_rsp *arg, struct iovec *payload,
+ int payloadcount, struct iobref *iobref, xdrproc_t xdrproc,
+ dict_t *dict)
+{
+ int ret = -1;
+ char *cmd = NULL;
+ int op_ret = 0;
+ char *op_errstr = NULL;
+ int op_errno = 0;
+
+ op_ret = arg->op_ret;
+ op_errstr = arg->op_errstr;
+ op_errno = arg->op_errno;
+
+ ret = dict_get_str (dict, "cmd-str", &cmd);
+ if (ret)
+ gf_log ("glusterd", GF_LOG_ERROR, "Failed to get command string");
+
+ if (cmd) {
+ if (op_ret)
+ gf_cmd_log ("", "%s : FAILED %s %s", cmd,
+ (op_errstr)? ":":" ",
+ (op_errstr)? op_errstr: " ");
+ else
+ gf_cmd_log ("", "%s : SUCCESS", cmd);
+ }
+
+ glusterd_submit_reply (req, arg, payload, payloadcount, iobref,
+ (xdrproc_t) xdrproc);
+
+ return ret;
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 3084af9be7d..167bffaac71 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -67,6 +67,11 @@ glusterd_submit_reply (rpcsvc_request_t *req, void *arg,
struct iobref *iobref, xdrproc_t xdrproc);
int
+glusterd_to_cli (rpcsvc_request_t *req, gf_cli_rsp *arg, struct iovec *payload,
+ int payloadcount, struct iobref *iobref, xdrproc_t xdrproc,
+ dict_t *dict);
+
+int
glusterd_submit_request (struct rpc_clnt *rpc, void *req,
call_frame_t *frame, rpc_clnt_prog_t *prog,
int procnum, struct iobref *iobref,
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 8d7c8475f5a..c6bde925de2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -98,7 +98,6 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
"name");
goto out;
}
- gf_cmd_log ("Volume create", "on volname: %s attempted", volname);
if ((ret = glusterd_check_volume_exists (volname))) {
snprintf(err_str, 2048, "Volume %s already exists", volname);
@@ -153,11 +152,6 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
free_ptr = brick_list;
}
- gf_cmd_log ("Volume create", "on volname: %s type:%s count:%d bricks:%s",
- volname, ((type == 0)? "DEFAULT":
- ((type == 1)? "STRIPE":"REPLICATE")), brick_count, bricks);
-
-
while ( i < brick_count) {
i++;
brick= strtok_r (brick_list, " \n", &tmpptr);
@@ -193,21 +187,19 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
goto out;
ret = glusterd_op_begin (req, GD_OP_CREATE_VOLUME, dict);
- gf_cmd_log ("Volume create", "on volname: %s %s", volname,
- (ret != 0) ? "FAILED": "SUCCESS");
out:
if (ret) {
- if (dict)
- dict_unref (dict);
rsp.op_ret = -1;
rsp.op_errno = 0;
if (err_str[0] == '\0')
snprintf (err_str, sizeof (err_str), "Operation failed");
rsp.op_errstr = err_str;
cli_rsp = &rsp;
- glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL,
- (xdrproc_t)xdr_gf_cli_rsp);
+ glusterd_to_cli (req, cli_rsp, NULL, 0, NULL,
+ (xdrproc_t)xdr_gf_cli_rsp, dict);
+ if (dict)
+ dict_unref (dict);
ret = 0; //Client response sent, prevent second response
}
@@ -270,12 +262,7 @@ glusterd_handle_cli_start_volume (rpcsvc_request_t *req)
ret = glusterd_op_begin (req, GD_OP_START_VOLUME, dict);
- gf_cmd_log ("volume start","on volname: %s %s", volname,
- ((ret == 0) ? "SUCCESS": "FAILED"));
-
out:
- if (ret && dict)
- dict_unref (dict);
free (cli_req.dict.dict_val); //its malloced by xdr
glusterd_friend_sm ();
@@ -283,7 +270,9 @@ out:
if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
+ dict, "operation failed");
+ if (dict)
+ dict_unref (dict);
return ret;
}
@@ -334,8 +323,6 @@ glusterd_handle_cli_stop_volume (rpcsvc_request_t *req)
"for volume %s", dup_volname);
ret = glusterd_op_begin (req, GD_OP_STOP_VOLUME, dict);
- gf_cmd_log ("Volume stop","on volname: %s %s", dup_volname,
- ((ret)?"FAILED":"SUCCESS"));
out:
free (cli_req.dict.dict_val); //its malloced by xdr
@@ -344,10 +331,10 @@ out:
glusterd_op_sm ();
if (ret) {
+ ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
+ dict, "operation failed");
if (dict)
dict_unref (dict);
- ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
}
return ret;
@@ -394,26 +381,22 @@ glusterd_handle_cli_delete_volume (rpcsvc_request_t *req)
goto out;
}
- gf_cmd_log ("Volume delete","on volname: %s attempted", volname);
-
gf_log ("glusterd", GF_LOG_INFO, "Received delete vol req"
"for volume %s", volname);
ret = glusterd_op_begin (req, GD_OP_DELETE_VOLUME, dict);
- gf_cmd_log ("Volume delete", "on volname: %s %s", volname,
- ((ret) ? "FAILED" : "SUCCESS"));
out:
free (cli_req.dict.dict_val); //its malloced by xdr
- if (ret && dict)
- dict_unref (dict);
glusterd_friend_sm ();
glusterd_op_sm ();
if (ret) {
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
+ dict, "operation failed");
+ if (dict)
+ dict_unref (dict);
}
return ret;
@@ -485,13 +468,7 @@ glusterd_handle_cli_heal_volume (rpcsvc_request_t *req)
ret = glusterd_op_begin (req, GD_OP_HEAL_VOLUME, dict);
- gf_cmd_log ("volume heal","on volname: %s %s", volname,
- ((ret == 0) ? "SUCCESS": "FAILED"));
-
out:
- if (ret && dict)
- dict_unref (dict);
-
glusterd_friend_sm ();
glusterd_op_sm ();
@@ -499,7 +476,9 @@ out:
if (!op_errstr)
op_errstr = gf_strdup ("operation failed");
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, op_errstr);
+ dict, op_errstr);
+ if (dict)
+ dict_unref (dict);
GF_FREE (op_errstr);
}
@@ -515,6 +494,7 @@ glusterd_handle_cli_statedump_volume (rpcsvc_request_t *req)
char *options = NULL;
dict_t *dict = NULL;
int32_t option_cnt = 0;
+ glusterd_op_t cli_op = GD_OP_STATEDUMP_VOLUME;
GF_ASSERT (req);
@@ -562,12 +542,13 @@ glusterd_handle_cli_statedump_volume (rpcsvc_request_t *req)
ret = glusterd_op_begin (req, GD_OP_STATEDUMP_VOLUME, dict);
- gf_cmd_log ("statedump", "on volume %s %s", volname,
- ((0 == ret) ? "SUCCEEDED" : "FAILED"));
-
out:
- if (ret && dict)
- dict_unref (dict);
+ if (ret) {
+ ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
+ dict, "Operation failed");
+ if (dict)
+ dict_unref (dict);
+ }
free (cli_req.dict.dict_val);
glusterd_friend_sm ();
glusterd_op_sm();