From 2ed703a6f9b28e02bbdccd72cea578074d575596 Mon Sep 17 00:00:00 2001 From: Nandaja Varma Date: Thu, 9 Jul 2015 11:37:16 +0530 Subject: [PATCH 246/279] glusterd: Porting the left out gf_log_callingfns to new framework. Back port of patch http://review.gluster.org/11719 cherry-picked from commit 68059dbe0116150cac06958f95832fd1bda54cfb: > Change-Id: I1b0ad54238895475ddbacc4fffacac8dc6e887fe > BUG: 1244721 > Signed-off-by: Nandaja Varma > Reviewed-on: http://review.gluster.org/11719 > Tested-by: NetBSD Build System > Tested-by: Gluster Build System > Reviewed-by: Atin Mukherjee Change-Id: I1b0ad54238895475ddbacc4fffacac8dc6e887fe BUG: 1241649 Signed-off-by: Nandaja Varma Reviewed-on: https://code.engineering.redhat.com/gerrit/54934 Reviewed-by: Atin Mukherjee Tested-by: Atin Mukherjee --- xlators/mgmt/glusterd/src/glusterd-locks.c | 15 +++++-- xlators/mgmt/glusterd/src/glusterd-messages.h | 42 +++++++++++++++++++- xlators/mgmt/glusterd/src/glusterd-mgmt.c | 6 ++- xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 11 +++-- xlators/mgmt/glusterd/src/glusterd-statedump.c | 5 ++- 5 files changed, 66 insertions(+), 13 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c index a16e499..272dd07 100644 --- a/xlators/mgmt/glusterd/src/glusterd-locks.c +++ b/xlators/mgmt/glusterd/src/glusterd-locks.c @@ -541,7 +541,8 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno, is_valid = glusterd_mgmt_v3_is_type_valid (type); if (is_valid != _gf_true) { - gf_log_callingfn (this->name, GF_LOG_ERROR, + gf_msg_callingfn (this->name, GF_LOG_ERROR, + EINVAL, GD_MSG_INVALID_ENTRY, "Invalid entity. Cannot perform locking " "operation on %s types", type); ret = -1; @@ -570,7 +571,8 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno, /* If the lock has already been held for the given volume * we fail */ if (!gf_uuid_is_null (owner)) { - gf_log_callingfn (this->name, GF_LOG_WARNING, + gf_msg_callingfn (this->name, GF_LOG_WARNING, + 0, GD_MSG_LOCK_ALREADY_HELD, "Lock for %s held by %s", name, uuid_utoa (owner)); ret = -1; @@ -645,7 +647,8 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type) is_valid = glusterd_mgmt_v3_is_type_valid (type); if (is_valid != _gf_true) { - gf_log_callingfn (this->name, GF_LOG_ERROR, + gf_msg_callingfn (this->name, GF_LOG_ERROR, EINVAL, + GD_MSG_INVALID_ENTRY, "Invalid entity. Cannot perform unlocking " "operation on %s types", type); ret = -1; @@ -673,7 +676,8 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type) } if (gf_uuid_is_null (owner)) { - gf_log_callingfn (this->name, GF_LOG_WARNING, + gf_msg_callingfn (this->name, GF_LOG_WARNING, + 0, GD_MSG_LOCK_NOT_HELD, "Lock for %s %s not held", type, name); ret = -1; goto out; @@ -681,7 +685,8 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type) ret = gf_uuid_compare (uuid, owner); if (ret) { - gf_log_callingfn (this->name, GF_LOG_WARNING, + gf_msg_callingfn (this->name, GF_LOG_WARNING, + 0, GD_MSG_LOCK_OWNER_MISMATCH, "Lock owner mismatch. " "Lock for %s %s held by %s", type, name, uuid_utoa (owner)); diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h index ea44e18..8f80e99 100644 --- a/xlators/mgmt/glusterd/src/glusterd-messages.h +++ b/xlators/mgmt/glusterd/src/glusterd-messages.h @@ -45,7 +45,7 @@ */ #define GLUSTERD_COMP_BASE GLFS_MSGID_GLUSTERD -#define GLFS_NUM_MESSAGES 563 +#define GLFS_NUM_MESSAGES 568 #define GLFS_MSGID_END (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1) /* Messaged with message IDs */ #define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages" @@ -4554,6 +4554,46 @@ */ #define GD_MSG_ROOT_SQUASH_FAILED (GLUSTERD_COMP_BASE + 563) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define GD_MSG_LOCK_OWNER_MISMATCH (GLUSTERD_COMP_BASE + 564) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define GD_MSG_LOCK_NOT_HELD (GLUSTERD_COMP_BASE + 565) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define GD_MSG_LOCK_ALREADY_HELD (GLUSTERD_COMP_BASE + 566) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define GD_MSG_SVC_START_SUCCESS (GLUSTERD_COMP_BASE + 567) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define GD_MSG_SVC_STOP_SUCCESS (GLUSTERD_COMP_BASE + 568) + /*------------*/ #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" #endif /* !_GLUSTERD_MESSAGES_H_ */ diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c index 607d2c5..326d868 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c @@ -173,7 +173,8 @@ gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict, ret = glusterd_op_stage_replace_brick (dict, op_errstr, rsp_dict); if (ret) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_PRE_VALIDATION_FAIL, "Replace-brick prevalidation failed."); goto out; } @@ -860,7 +861,8 @@ glusterd_mgmt_v3_build_payload (dict_t **req, char **op_errstr, dict_t *dict, { ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_DICT_GET_FAILED, "volname is not present in " "operation ctx"); goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c index 8325508..fa86ca0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c @@ -62,13 +62,15 @@ glusterd_handle_replicate_replace_brick (glusterd_volinfo_t *volinfo, ret = sys_lsetxattr (brickinfo->path, GF_AFR_DIRTY, dirty, sizeof (dirty), 0); if (ret == -1) { - gf_log (THIS->name, GF_LOG_ERROR, "Failed to set extended" + gf_msg (THIS->name, GF_LOG_ERROR, errno, + GD_MSG_SETXATTR_FAIL, "Failed to set extended" " attribute %s : %s.", GF_AFR_DIRTY, strerror (errno)); goto out; } if (mkdtemp (tmpmount) == NULL) { - gf_log (THIS->name, GF_LOG_ERROR, + gf_msg (THIS->name, GF_LOG_ERROR, errno, + GD_MSG_DIR_OP_FAILED, "failed to create a temporary mount directory."); ret = -1; goto out; @@ -99,7 +101,8 @@ glusterd_handle_replicate_replace_brick (glusterd_volinfo_t *volinfo, brickinfo->brick_id, sizeof (brickinfo->brick_id), 0); if (ret == -1) - gf_log (THIS->name, GF_LOG_ERROR, "Failed to set extended" + gf_msg (THIS->name, GF_LOG_ERROR, errno, + GD_MSG_SETXATTR_FAIL, "Failed to set extended" " attribute %s : %s", GF_AFR_REPLACE_BRICK, strerror (errno)); gf_umount_lazy (THIS->name, tmpmount, 1); @@ -108,7 +111,7 @@ lock: out: if (pid) GF_FREE (pid); - gf_log ("", GF_LOG_DEBUG, "Returning with ret"); + gf_msg_debug ("glusterd", 0, "Returning with ret"); return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-statedump.c b/xlators/mgmt/glusterd/src/glusterd-statedump.c index 24a479e..83207dc 100644 --- a/xlators/mgmt/glusterd/src/glusterd-statedump.c +++ b/xlators/mgmt/glusterd/src/glusterd-statedump.c @@ -19,6 +19,7 @@ #include "glusterd-quotad-svc.h" #include "glusterd-nfs-svc.h" #include "glusterd-locks.h" +#include "glusterd-messages.h" static void glusterd_dump_peer (glusterd_peerinfo_t *peerinfo, char *input_key, int index, @@ -155,7 +156,9 @@ glusterd_dict_mgmt_v3_lock_statedump (dict_t *dict) char dump[64*1024] = {0,}; if (!dict) { - gf_log_callingfn ("glusterd", GF_LOG_WARNING, "dict NULL"); + gf_msg_callingfn ("glusterd", GF_LOG_WARNING, EINVAL, + GD_MSG_DICT_EMPTY, + "dict NULL"); goto out; } for (trav = dict->members_list; trav; trav = trav->next) { -- 1.7.1