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