cb8e9e
From 048c377cc54ba7a034e8f9eac4394857858ca1b7 Mon Sep 17 00:00:00 2001
cb8e9e
From: Venky Shankar <vshankar@redhat.com>
cb8e9e
Date: Thu, 25 Jun 2015 12:07:24 +0530
cb8e9e
Subject: [PATCH 162/190] features/bitrot: convert pending gf_log() to gf_msg()
cb8e9e
cb8e9e
    Backport of http://review.gluster.org/11396
cb8e9e
cb8e9e
Change-Id: Idfd245327b485459ccbda503510b8ca0127bb66c
cb8e9e
BUG: 1232309
cb8e9e
Signed-off-by: Venky Shankar <vshankar@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/51746
cb8e9e
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
cb8e9e
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
cb8e9e
---
cb8e9e
 .../bit-rot/src/bitd/bit-rot-bitd-messages.h       |   27 ++++++++++++++++
cb8e9e
 xlators/features/bit-rot/src/bitd/bit-rot-scrub.c  |   32 ++++++++++++--------
cb8e9e
 xlators/features/bit-rot/src/bitd/bit-rot-ssm.c    |   12 ++++---
cb8e9e
 xlators/features/bit-rot/src/bitd/bit-rot.c        |   32 ++++++++++++-------
cb8e9e
 4 files changed, 73 insertions(+), 30 deletions(-)
cb8e9e
cb8e9e
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h
cb8e9e
index af3a74f..b4746bb 100644
cb8e9e
--- a/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h
cb8e9e
+++ b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h
cb8e9e
@@ -387,5 +387,32 @@
cb8e9e
  *
cb8e9e
  */
cb8e9e
 /*------------*/
cb8e9e
+#define BRB_MSG_SCRUB_THREAD_CLEANUP       (GLFS_BITROT_BITD_BASE + 49)
cb8e9e
+/*!
cb8e9e
+ * @messageid
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ *
cb8e9e
+ */
cb8e9e
+/*------------*/
cb8e9e
+#define BRB_MSG_SCRUBBER_CLEANED           (GLFS_BITROT_BITD_BASE + 50)
cb8e9e
+/*!
cb8e9e
+ * @messageid
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ *
cb8e9e
+ */
cb8e9e
+/*------------*/
cb8e9e
+#define BRB_MSG_GENERIC_SSM_INFO           (GLFS_BITROT_BITD_BASE + 51)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ *
cb8e9e
+ */
cb8e9e
+/*------------*/
cb8e9e
+#define BRB_MSG_ZERO_TIMEOUT_BUG           (GLFS_BITROT_BITD_BASE + 52)
cb8e9e
+
cb8e9e
 #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
cb8e9e
 #endif /* !_BITROT_BITD_MESSAGES_H_ */
cb8e9e
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
cb8e9e
index af31a3c..3a038ce 100644
cb8e9e
--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
cb8e9e
+++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
cb8e9e
@@ -542,11 +542,12 @@ br_fsscan_deactivate (xlator_t *this, br_child_t *child)
cb8e9e
         ret = gf_tw_del_timer (priv->timer_wheel, fsscan->timer);
cb8e9e
         if (ret == 0) {
cb8e9e
                 nstate = BR_SCRUB_STATE_STALLED;
cb8e9e
-                gf_log (this->name, GF_LOG_INFO, "Brick [%s] is under active "
cb8e9e
-                        "scrubbing. Pausing scrub..", child->brick_path);
cb8e9e
+                gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO,
cb8e9e
+                        "Brick [%s] is under active scrubbing. Pausing scrub..",
cb8e9e
+                        child->brick_path);
cb8e9e
         } else {
cb8e9e
                 nstate = BR_SCRUB_STATE_PAUSED;
cb8e9e
-                gf_log (this->name, GF_LOG_INFO,
cb8e9e
+                gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO,
cb8e9e
                         "Scrubber paused [Brick: %s]", child->brick_path);
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -617,8 +618,9 @@ br_fsscanner_exit_control (xlator_t *this, br_child_t *child)
cb8e9e
                 if (fsscan->state == BR_SCRUB_STATE_ACTIVE) {
cb8e9e
                         (void) br_fsscan_activate (this, child);
cb8e9e
                 } else {
cb8e9e
-                        gf_log (this->name, GF_LOG_INFO, "Brick [%s] waiting "
cb8e9e
-                                "to get rescheduled..", child->brick_path);
cb8e9e
+                        gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO,
cb8e9e
+                                "Brick [%s] waiting to get rescheduled..",
cb8e9e
+                                child->brick_path);
cb8e9e
                 }
cb8e9e
         }
cb8e9e
         UNLOCK (&child->lock);
cb8e9e
@@ -757,7 +759,8 @@ br_fsscan_schedule (xlator_t *this, br_child_t *child)
cb8e9e
         timo = br_fsscan_calculate_timeout (fsscan->boot,
cb8e9e
                                             fsscan->boot, fsscrub->frequency);
cb8e9e
         if (timo == 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR, "BUG: Zero schedule timeout");
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_ZERO_TIMEOUT_BUG,
cb8e9e
+                        "BUG: Zero schedule timeout");
cb8e9e
                 goto error_return;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -805,7 +808,8 @@ br_fsscan_activate (xlator_t *this, br_child_t *child)
cb8e9e
         timo = br_fsscan_calculate_timeout (fsscan->boot,
cb8e9e
                                             now.tv_sec, fsscrub->frequency);
cb8e9e
         if (timo == 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR, "BUG: Zero schedule timeout");
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_ZERO_TIMEOUT_BUG,
cb8e9e
+                        "BUG: Zero schedule timeout");
cb8e9e
                 return -1;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -815,8 +819,8 @@ br_fsscan_activate (xlator_t *this, br_child_t *child)
cb8e9e
         (void) gf_tw_mod_timer (priv->timer_wheel, fsscan->timer, timo);
cb8e9e
 
cb8e9e
         _br_child_set_scrub_state (child, BR_SCRUB_STATE_PENDING);
cb8e9e
-        gf_log (this->name, GF_LOG_INFO, "Scrubbing for %s rescheduled to run "
cb8e9e
-                "at %s", child->brick_path, timestr);
cb8e9e
+        gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO, "Scrubbing for "
cb8e9e
+                "%s rescheduled to run at %s", child->brick_path, timestr);
cb8e9e
 
cb8e9e
         return 0;
cb8e9e
 }
cb8e9e
@@ -840,7 +844,8 @@ br_fsscan_reschedule (xlator_t *this, br_child_t *child)
cb8e9e
         timo = br_fsscan_calculate_timeout (fsscan->boot,
cb8e9e
                                             now.tv_sec, fsscrub->frequency);
cb8e9e
         if (timo == 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR, "BUG: Zero schedule timeout");
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_ZERO_TIMEOUT_BUG,
cb8e9e
+                        "BUG: Zero schedule timeout");
cb8e9e
                 return -1;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -850,13 +855,14 @@ br_fsscan_reschedule (xlator_t *this, br_child_t *child)
cb8e9e
         fsscan->over = _gf_false;
cb8e9e
         ret = gf_tw_mod_timer_pending (priv->timer_wheel, fsscan->timer, timo);
cb8e9e
         if (ret == 0)
cb8e9e
-                gf_log (this->name, GF_LOG_INFO,
cb8e9e
+                gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO,
cb8e9e
                         "Scrubber for %s is currently running and would be "
cb8e9e
                         "rescheduled after completion", child->brick_path);
cb8e9e
         else {
cb8e9e
                 _br_child_set_scrub_state (child, BR_SCRUB_STATE_PENDING);
cb8e9e
-                gf_log (this->name, GF_LOG_INFO, "Scrubbing for %s rescheduled "
cb8e9e
-                        "to run at %s", child->brick_path, timestr);
cb8e9e
+                gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO,
cb8e9e
+                        "Scrubbing for %s rescheduled to run at %s",
cb8e9e
+                        child->brick_path, timestr);
cb8e9e
         }
cb8e9e
 
cb8e9e
         return 0;
cb8e9e
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c
cb8e9e
index c95e555..fcffc04 100644
cb8e9e
--- a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c
cb8e9e
+++ b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c
cb8e9e
@@ -10,6 +10,7 @@
cb8e9e
 
cb8e9e
 #include "bit-rot-ssm.h"
cb8e9e
 #include "bit-rot-scrub.h"
cb8e9e
+#include "bit-rot-bitd-messages.h"
cb8e9e
 
cb8e9e
 int br_scrub_ssm_noop (xlator_t *this, br_child_t *child)
cb8e9e
 {
cb8e9e
@@ -19,7 +20,7 @@ int br_scrub_ssm_noop (xlator_t *this, br_child_t *child)
cb8e9e
 int
cb8e9e
 br_scrub_ssm_state_pause (xlator_t *this, br_child_t *child)
cb8e9e
 {
cb8e9e
-        gf_log (this->name, GF_LOG_INFO,
cb8e9e
+        gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO,
cb8e9e
                 "Scrubber paused [Brick: %s]", child->brick_path);
cb8e9e
         _br_child_set_scrub_state (child, BR_SCRUB_STATE_PAUSED);
cb8e9e
         return 0;
cb8e9e
@@ -28,7 +29,7 @@ br_scrub_ssm_state_pause (xlator_t *this, br_child_t *child)
cb8e9e
 int
cb8e9e
 br_scrub_ssm_state_ipause (xlator_t *this, br_child_t *child)
cb8e9e
 {
cb8e9e
-        gf_log (this->name, GF_LOG_INFO,
cb8e9e
+        gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO,
cb8e9e
                 "Scrubber paused [Brick: %s]", child->brick_path);
cb8e9e
         _br_child_set_scrub_state (child, BR_SCRUB_STATE_IPAUSED);
cb8e9e
         return 0;
cb8e9e
@@ -42,7 +43,7 @@ br_scrub_ssm_state_active (xlator_t *this, br_child_t *child)
cb8e9e
         if (fsscan->over) {
cb8e9e
                 (void) br_fsscan_activate (this, child);
cb8e9e
         } else {
cb8e9e
-                gf_log (this->name, GF_LOG_INFO,
cb8e9e
+                gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO,
cb8e9e
                         "Scrubbing resumed [Brick %s]", child->brick_path);
cb8e9e
                 _br_child_set_scrub_state (child, BR_SCRUB_STATE_ACTIVE);
cb8e9e
         }
cb8e9e
@@ -53,8 +54,9 @@ br_scrub_ssm_state_active (xlator_t *this, br_child_t *child)
cb8e9e
 int
cb8e9e
 br_scrub_ssm_state_stall (xlator_t *this, br_child_t *child)
cb8e9e
 {
cb8e9e
-        gf_log (this->name, GF_LOG_INFO, "Brick [%s] is under active "
cb8e9e
-                "scrubbing. Pausing scrub..", child->brick_path);
cb8e9e
+        gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO,
cb8e9e
+                "Brick [%s] is under active scrubbing. Pausing scrub..",
cb8e9e
+                child->brick_path);
cb8e9e
         _br_child_set_scrub_state (child, BR_SCRUB_STATE_STALLED);
cb8e9e
         return 0;
cb8e9e
 }
cb8e9e
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c
cb8e9e
index 3952f41..cf9e8e2 100644
cb8e9e
--- a/xlators/features/bit-rot/src/bitd/bit-rot.c
cb8e9e
+++ b/xlators/features/bit-rot/src/bitd/bit-rot.c
cb8e9e
@@ -1264,7 +1264,8 @@ br_child_enaction (xlator_t *this, br_child_t *child, br_stub_init_t *stub)
cb8e9e
                 if (!ret) {
cb8e9e
                         child->witnessed = 1;
cb8e9e
                         _br_set_child_state (child, BR_CHILD_STATE_CONNECTED);
cb8e9e
-                        gf_log (this->name, GF_LOG_INFO,
cb8e9e
+                        gf_msg (this->name, GF_LOG_INFO,
cb8e9e
+                                0, BRB_MSG_CONNECTED_TO_BRICK,
cb8e9e
                                 "Connected to brick %s..", child->brick_path);
cb8e9e
                 }
cb8e9e
         }
cb8e9e
@@ -1389,7 +1390,8 @@ br_cleanup_scrubber (xlator_t *this, br_child_t *child)
cb8e9e
          */
cb8e9e
         ret = gf_thread_cleanup_xint (child->thread);
cb8e9e
         if (ret)
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR,
cb8e9e
+                gf_msg (this->name, GF_LOG_INFO,
cb8e9e
+                        0, BRB_MSG_SCRUB_THREAD_CLEANUP,
cb8e9e
                         "Error cleaning up scanner thread");
cb8e9e
 
cb8e9e
         /**
cb8e9e
@@ -1407,7 +1409,8 @@ br_cleanup_scrubber (xlator_t *this, br_child_t *child)
cb8e9e
          */
cb8e9e
         _br_child_set_scrub_state (child, BR_SCRUB_STATE_INACTIVE);
cb8e9e
 
cb8e9e
-        gf_log (this->name, GF_LOG_INFO,
cb8e9e
+        gf_msg (this->name, GF_LOG_INFO,
cb8e9e
+                0, BRB_MSG_SCRUBBER_CLEANED,
cb8e9e
                 "Cleaned up scrubber for brick [%s]", child->brick_path);
cb8e9e
 
cb8e9e
         return 0;
cb8e9e
@@ -1522,8 +1525,9 @@ _br_qchild_event (xlator_t *this, br_child_t *child, br_child_handler *call)
cb8e9e
 
cb8e9e
         childev = GF_CALLOC (1, sizeof (*childev), gf_br_mt_br_child_event_t);
cb8e9e
         if (!childev) {
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR, "Event unhandled for "
cb8e9e
-                        "child.. [Brick: %s]", child->xl->name);
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY,
cb8e9e
+                        "Event unhandled for child.. [Brick: %s]",
cb8e9e
+                        child->xl->name);
cb8e9e
                 return;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -1805,7 +1809,8 @@ br_init_children (xlator_t *this, br_private_t *priv)
cb8e9e
                 child->timer_pool = mem_pool_new
cb8e9e
                                     (struct gf_tw_timer_list,  4096);
cb8e9e
                 if (!child->timer_pool) {
cb8e9e
-                        gf_log (this->name, GF_LOG_ERROR,
cb8e9e
+                        gf_msg (this->name, GF_LOG_ERROR,
cb8e9e
+                                ENOMEM, BRB_MSG_NO_MEMORY,
cb8e9e
                                 "failed to allocate mem-pool for timer");
cb8e9e
                         errno = ENOMEM;
cb8e9e
                         goto freechild;
cb8e9e
@@ -1832,13 +1837,14 @@ init (xlator_t *this)
cb8e9e
 	br_private_t *priv = NULL;
cb8e9e
 
cb8e9e
 	if (!this->children) {
cb8e9e
-		gf_log (this->name, GF_LOG_ERROR, "FATAL: no children");
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_NO_CHILD,
cb8e9e
+                        "FATAL: no children");
cb8e9e
 		goto out;
cb8e9e
 	}
cb8e9e
 
cb8e9e
         priv = GF_CALLOC (1, sizeof (*priv), gf_br_mt_br_private_t);
cb8e9e
         if (!priv) {
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR,
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY,
cb8e9e
                         "failed to allocate memory (->priv)");
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
@@ -1930,9 +1936,10 @@ br_reconfigure_child (xlator_t *this, br_child_t *child)
cb8e9e
 
cb8e9e
         ret = br_scrub_state_machine (this, child);
cb8e9e
         if (ret) {
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR,
cb8e9e
-                        "Could not reschedule scrubber for brick: %s. "
cb8e9e
-                        "Scubbing will continue according to old frequency.",
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
+                        BRB_MSG_RESCHEDULE_SCRUBBER_FAILED,
cb8e9e
+                        "Could not reschedule scrubber for brick: %s. Scubbing "
cb8e9e
+                        "will continue according to old frequency.",
cb8e9e
                         child->brick_path);
cb8e9e
         }
cb8e9e
 }
cb8e9e
@@ -1963,7 +1970,8 @@ br_reconfigure_scrubber (xlator_t *this, dict_t *options)
cb8e9e
                 LOCK (&child->lock);
cb8e9e
                 {
cb8e9e
                         if (_br_child_failed_conn (child)) {
cb8e9e
-                                gf_log (this->name, GF_LOG_INFO,
cb8e9e
+                                gf_msg (this->name, GF_LOG_INFO,
cb8e9e
+                                        0, BRB_MSG_BRICK_INFO,
cb8e9e
                                         "Scrubber for brick [%s] failed "
cb8e9e
                                         "initialization, rescheduling is "
cb8e9e
                                         "skipped", child->brick_path);
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e