From 129728f257bead0ce0c28b98d3989fabaebe21cd Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Thu, 6 Dec 2012 13:08:11 +0530 Subject: glusterd: log enhancements for volume start * changed some of the log messages to give as much information as available in case of failure * added logs to identify on which machine lock/stage/commit failed * added macros to represent error strings to maintain uniformity among error messages for a given kind of error * moved error logs wherever possible, from caller to callee to avoid code duplication Change-Id: I0e98d5d3ba086c99240f2fbd642451f175f51942 BUG: 812356 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/4353 Reviewed-by: Pranith Kumar Karampuri Reviewed-by: Vijay Bellur Tested-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index e0683d5ba6a..6ef0b21c5ae 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -2328,16 +2328,17 @@ glusterd_dict_set_volid (dict_t *dict, char *volname, char **op_errstr) glusterd_volinfo_t *volinfo = NULL; char *volid = NULL; char msg[1024] = {0,}; + xlator_t *this = NULL; + + this = THIS; + GF_ASSERT (this); if (!dict || !volname) goto out; ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - snprintf (msg, sizeof (msg), "Volume %s does not exist", - volname); - gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); - *op_errstr = gf_strdup (msg); + snprintf (msg, sizeof (msg), FMTSTR_CHECK_VOL_EXISTS, volname); goto out; } volid = gf_strdup (uuid_utoa (volinfo->volume_id)); @@ -2347,11 +2348,15 @@ glusterd_dict_set_volid (dict_t *dict, char *volname, char **op_errstr) } ret = dict_set_dynstr (dict, "vol-id", volid); if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, - "Failed to set volume id in dictionary"); + snprintf (msg, sizeof (msg), "Failed to set volume id of volume" + " %s", volname); goto out; } out: + if (msg[0] != '\0') { + gf_log (this->name, GF_LOG_ERROR, "%s", msg); + *op_errstr = strdup (msg); + } return ret; } @@ -2366,7 +2371,7 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) char *volname = NULL; uint32_t status_cmd = GF_CLI_STATUS_NONE; char *errstr = NULL; - xlator_t *this = THIS; + xlator_t *this = NULL; GF_ASSERT (req); @@ -2390,8 +2395,11 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) } else { #define GD_SYNC_OPCODE_KEY "sync-mgmt-operation" ret = dict_get_int32 (op_ctx, GD_SYNC_OPCODE_KEY, (int32_t*)&op); - if (ret) + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to get volume" + " operation"); goto out; + } ctx = op_ctx; #undef GD_SYNC_OPCODE_KEY } @@ -2403,8 +2411,12 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) ++glusterfs_port; ret = dict_set_int32 (dict, "port", glusterfs_port); - if (ret) + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to set port in " + "dictionary"); goto out; + } dict_copy (dict, req_dict); } break; -- cgit