diff options
author | Joseph Fernandes <josferna@redhat.com> | 2014-05-28 13:56:04 +0530 |
---|---|---|
committer | Kaushal M <kaushal@redhat.com> | 2014-07-02 02:19:37 -0700 |
commit | 831efecf927788f26b630cb82d5d6ff4af411a3d (patch) | |
tree | cee0cd0b3925185f72b5b6e7996717df9fb69e0e /xlators/mgmt | |
parent | 858b570a0c62d31416f0aee8c385b3118a1fad43 (diff) |
glusterd/snapshot : Fix for snap create preval for remote peer err msg
Fix for the snap create prevalidation error collation when remote peer failed.
Change-Id: If9563580eae4d9bc4d4d795f0b434f2c85b94007
BUG: 1101993
Signed-off-by: Joseph Fernandes <josferna@redhat.com>
Reviewed-on: http://review.gluster.org/7899
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijaikumar Mallikarjuna <vmallika@redhat.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-mgmt.c | 71 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-mgmt.h | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-syncop.c | 57 |
3 files changed, 46 insertions, 86 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c index e93afb27dab..52b4184ee7a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c @@ -25,7 +25,7 @@ extern struct rpc_clnt_program gd_mgmt_v3_prog; -static void +void gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno, char *op_errstr, int op_code, glusterd_peerinfo_t *peerinfo, u_char *uuid) @@ -35,6 +35,9 @@ gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno, char op_err[PATH_MAX] = ""; int32_t len = -1; xlator_t *this = NULL; + int is_operrstr_blk = 0; + char *err_string = NULL; + char *cli_err_str = NULL; this = THIS; GF_ASSERT (this); @@ -50,68 +53,76 @@ gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno, else peer_str = uuid_utoa (uuid); - if (op_errstr && strcmp (op_errstr, "")) { - len = snprintf (err_str, sizeof(err_str) - 1, - "Error: %s", op_errstr); - err_str[len] = '\0'; - } + is_operrstr_blk = (op_errstr && strcmp (op_errstr, "")); + err_string = (is_operrstr_blk) ? op_errstr : err_str; switch (op_code) { case GLUSTERD_MGMT_V3_LOCK: { - len = snprintf (op_err, sizeof(op_err) - 1, + len = snprintf (op_err, sizeof(op_err), "Locking failed " - "on %s. %s", peer_str, err_str); + "on %s. %s", peer_str, + err_string); break; } case GLUSTERD_MGMT_V3_PRE_VALIDATE: { - len = snprintf (op_err, sizeof(op_err) - 1, + len = snprintf (op_err, sizeof(op_err), "Pre Validation failed " - "on %s. %s", peer_str, err_str); + "on %s. %s", peer_str, + err_string); break; } case GLUSTERD_MGMT_V3_BRICK_OP: { - len = snprintf (op_err, sizeof(op_err) - 1, + len = snprintf (op_err, sizeof(op_err), "Brick ops failed " - "on %s. %s", peer_str, err_str); + "on %s. %s", peer_str, + err_string); break; } case GLUSTERD_MGMT_V3_COMMIT: { - len = snprintf (op_err, sizeof(op_err) - 1, - "Commit failed on %s. %s", - peer_str, err_str); + len = snprintf (op_err, sizeof(op_err), + "Commit failed" + " on %s. %s", peer_str, + err_string); break; } case GLUSTERD_MGMT_V3_POST_VALIDATE: { - len = snprintf (op_err, sizeof(op_err) - 1, + len = snprintf (op_err, sizeof(op_err), "Post Validation failed " - "on %s. %s", peer_str, err_str); + "on %s. %s", peer_str, + err_string); break; } case GLUSTERD_MGMT_V3_UNLOCK: { - len = snprintf (op_err, sizeof(op_err) - 1, + len = snprintf (op_err, sizeof(op_err), "Unlocking failed " - "on %s. %s", peer_str, err_str); + "on %s. %s", peer_str, + err_string); break; } + default : + len = snprintf (op_err, sizeof(op_err), + "Unknown error! " + "on %s. %s", peer_str, + err_string); } - op_err[len] = '\0'; + + cli_err_str = ((is_operrstr_blk) ? op_errstr : op_err); if (args->errstr) { - len = snprintf (err_str, sizeof(err_str) - 1, - "%s\n%s", args->errstr, - op_err); + len = snprintf (err_str, sizeof(err_str), + "%s\n%s", args->errstr, + cli_err_str); GF_FREE (args->errstr); args->errstr = NULL; } else - len = snprintf (err_str, sizeof(err_str) - 1, - "%s", op_err); - err_str[len] = '\0'; + len = snprintf (err_str, sizeof(err_str), + "%s", cli_err_str); gf_log (this->name, GF_LOG_ERROR, "%s", op_err); args->errstr = gf_strdup (err_str); @@ -567,7 +578,7 @@ out: if (rsp_dict) dict_unref (rsp_dict); - gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL, + gd_mgmt_v3_collate_errors (args, op_ret, op_errno, rsp.op_errstr, GLUSTERD_MGMT_V3_PRE_VALIDATE, peerinfo, rsp.uuid); @@ -802,7 +813,7 @@ gd_mgmt_v3_brick_op_cbk_fn (struct rpc_req *req, struct iovec *iov, op_errno = rsp.op_errno; out: - gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL, + gd_mgmt_v3_collate_errors (args, op_ret, op_errno, rsp.op_errstr, GLUSTERD_MGMT_V3_BRICK_OP, peerinfo, rsp.uuid); @@ -1032,7 +1043,7 @@ out: if (rsp_dict) dict_unref (rsp_dict); - gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL, + gd_mgmt_v3_collate_errors (args, op_ret, op_errno, rsp.op_errstr, GLUSTERD_MGMT_V3_COMMIT, peerinfo, rsp.uuid); @@ -1230,7 +1241,7 @@ gd_mgmt_v3_post_validate_cbk_fn (struct rpc_req *req, struct iovec *iov, op_errno = rsp.op_errno; out: - gd_mgmt_v3_collate_errors (args, op_ret, op_errno, NULL, + gd_mgmt_v3_collate_errors (args, op_ret, op_errno, rsp.op_errstr, GLUSTERD_MGMT_V3_POST_VALIDATE, peerinfo, rsp.uuid); if (rsp.op_errstr) diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.h b/xlators/mgmt/glusterd/src/glusterd-mgmt.h index c8b0f066639..ab9265c75c4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt.h +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.h @@ -15,6 +15,10 @@ #include "config.h" #endif +void gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno, + char *op_errstr, int op_code, + glusterd_peerinfo_t *peerinfo, u_char *uuid); + int32_t gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict, char **op_errstr, dict_t *rsp_dict); diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c index 1381edbab9d..6e7a9b6c8be 100644 --- a/xlators/mgmt/glusterd/src/glusterd-syncop.c +++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c @@ -13,6 +13,7 @@ #include "xdr-generic.h" #include "glusterd1-xdr.h" #include "glusterd-syncop.h" +#include "glusterd-mgmt.h" #include "glusterd.h" #include "glusterd-op-sm.h" @@ -34,62 +35,6 @@ gd_synctask_barrier_wait (struct syncargs *args, int count) } static void -gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno, - char *op_errstr, int op_code, - glusterd_peerinfo_t *peerinfo, u_char *uuid) -{ - char err_str[PATH_MAX] = "Please check log file for details."; - char op_err[PATH_MAX] = ""; - char *peer_str = NULL; - - if (op_ret) { - args->op_ret = op_ret; - args->op_errno = op_errno; - - if (peerinfo) - peer_str = peerinfo->hostname; - else - peer_str = uuid_utoa (uuid); - - if (op_errstr && strcmp (op_errstr, "")) - snprintf (err_str, sizeof(err_str) - 1, - "Error: %s", op_errstr); - - switch (op_code) { - case GLUSTERD_MGMT_V3_LOCK: - { - snprintf (op_err, sizeof(op_err) - 1, - "Locking failed " - "on %s. %s", peer_str, err_str); - break; - } - case GLUSTERD_MGMT_V3_UNLOCK: - { - snprintf (op_err, sizeof(op_err) - 1, - "Unlocking failed " - "on %s. %s", peer_str, err_str); - break; - } - } - - if (args->errstr) { - snprintf (err_str, sizeof(err_str) - 1, - "%s\n%s", args->errstr, - op_err); - GF_FREE (args->errstr); - args->errstr = NULL; - } else - snprintf (err_str, sizeof(err_str) - 1, - "%s", op_err); - - gf_log ("", GF_LOG_ERROR, "%s", op_err); - args->errstr = gf_strdup (err_str); - } - - return; -} - -static void gd_collate_errors (struct syncargs *args, int op_ret, int op_errno, char *op_errstr, int op_code, glusterd_peerinfo_t *peerinfo, u_char *uuid) |