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