7f4c2a
From 1814b75a778d8b2cfb51ac45215495c6b17a5720 Mon Sep 17 00:00:00 2001
7f4c2a
From: Mohamed Ashiq <ashiq333@gmail.com>
7f4c2a
Date: Tue, 19 May 2015 15:21:46 +0530
7f4c2a
Subject: [PATCH 168/190] event,parse-utils,quota-common-utils,rbthash/libglusterfs : Porting to new logging framework
7f4c2a
7f4c2a
Change-Id: I13ae9a97fe442c06cf50fe77c63718ea0858dc4d
7f4c2a
BUG: 1231792
7f4c2a
Signed-off-by: Mohamed Ashiq Liyazudeen <mliyazud@redhat.com>
7f4c2a
Reviewed-on: http://review.gluster.org/10823
7f4c2a
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
7f4c2a
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/51695
7f4c2a
Reviewed-by: Venky Shankar <vshankar@redhat.com>
7f4c2a
Tested-by: Venky Shankar <vshankar@redhat.com>
7f4c2a
---
7f4c2a
 libglusterfs/src/event-epoll.c        |   80 +++++++++++++++++----------------
7f4c2a
 libglusterfs/src/event-history.c      |    9 ++--
7f4c2a
 libglusterfs/src/event-poll.c         |   46 ++++++++++---------
7f4c2a
 libglusterfs/src/event.c              |    3 +-
7f4c2a
 libglusterfs/src/parse-utils.c        |    7 +--
7f4c2a
 libglusterfs/src/quota-common-utils.c |   29 +++++++-----
7f4c2a
 libglusterfs/src/rbthash.c            |   56 ++++++++++++++---------
7f4c2a
 7 files changed, 126 insertions(+), 104 deletions(-)
7f4c2a
7f4c2a
diff --git a/libglusterfs/src/event-epoll.c b/libglusterfs/src/event-epoll.c
7f4c2a
index 92420f3..9403217 100644
7f4c2a
--- a/libglusterfs/src/event-epoll.c
7f4c2a
+++ b/libglusterfs/src/event-epoll.c
7f4c2a
@@ -20,6 +20,7 @@
7f4c2a
 #include "event.h"
7f4c2a
 #include "mem-pool.h"
7f4c2a
 #include "common-utils.h"
7f4c2a
+#include "libglusterfs-messages.h"
7f4c2a
 
7f4c2a
 #ifndef _CONFIG_H
7f4c2a
 #define _CONFIG_H
7f4c2a
@@ -252,8 +253,9 @@ event_pool_new_epoll (int count, int eventthreadcount)
7f4c2a
         epfd = epoll_create (count);
7f4c2a
 
7f4c2a
         if (epfd == -1) {
7f4c2a
-                gf_log ("epoll", GF_LOG_ERROR, "epoll fd creation failed (%s)",
7f4c2a
-                        strerror (errno));
7f4c2a
+                gf_msg ("epoll", GF_LOG_ERROR, errno,
7f4c2a
+                        LG_MSG_EPOLL_FD_CREATE_FAILED, "epoll fd creation "
7f4c2a
+                        "failed");
7f4c2a
                 GF_FREE (event_pool->reg);
7f4c2a
                 GF_FREE (event_pool);
7f4c2a
                 event_pool = NULL;
7f4c2a
@@ -287,7 +289,7 @@ __slot_update_events (struct event_slot_epoll *slot, int poll_in, int poll_out)
7f4c2a
 		/* do nothing */
7f4c2a
 		break;
7f4c2a
 	default:
7f4c2a
-		gf_log ("epoll", GF_LOG_ERROR,
7f4c2a
+		gf_msg ("epoll", GF_LOG_ERROR, 0, LG_MSG_INVALID_POLL_IN,
7f4c2a
 			"invalid poll_in value %d", poll_in);
7f4c2a
 		break;
7f4c2a
 	}
7f4c2a
@@ -303,7 +305,7 @@ __slot_update_events (struct event_slot_epoll *slot, int poll_in, int poll_out)
7f4c2a
 		/* do nothing */
7f4c2a
 		break;
7f4c2a
 	default:
7f4c2a
-		gf_log ("epoll", GF_LOG_ERROR,
7f4c2a
+		gf_msg ("epoll", GF_LOG_ERROR, 0, LG_MSG_INVALID_POLL_OUT,
7f4c2a
 			"invalid poll_out value %d", poll_out);
7f4c2a
 		break;
7f4c2a
 	}
7f4c2a
@@ -345,7 +347,7 @@ event_register_epoll (struct event_pool *event_pool, int fd,
7f4c2a
 
7f4c2a
 	idx = event_slot_alloc (event_pool, fd);
7f4c2a
 	if (idx == -1) {
7f4c2a
-		gf_log ("epoll", GF_LOG_ERROR,
7f4c2a
+		gf_msg ("epoll", GF_LOG_ERROR, 0, LG_MSG_SLOT_NOT_FOUND,
7f4c2a
 			"could not find slot for fd=%d", fd);
7f4c2a
 		return -1;
7f4c2a
 	}
7f4c2a
@@ -384,10 +386,9 @@ event_register_epoll (struct event_pool *event_pool, int fd,
7f4c2a
 	UNLOCK (&slot->lock);
7f4c2a
 
7f4c2a
 	if (ret == -1) {
7f4c2a
-		gf_log ("epoll", GF_LOG_ERROR,
7f4c2a
-			"failed to add fd(=%d) to epoll fd(=%d) (%s)",
7f4c2a
-			fd, event_pool->fd, strerror (errno));
7f4c2a
-
7f4c2a
+		gf_msg ("epoll", GF_LOG_ERROR, errno,
7f4c2a
+                        LG_MSG_EPOLL_FD_ADD_FAILED, "failed to add fd(=%d) to "
7f4c2a
+                        "epoll fd(=%d)", fd, event_pool->fd);
7f4c2a
 		event_slot_unref (event_pool, slot, idx);
7f4c2a
 		idx = -1;
7f4c2a
 	}
7f4c2a
@@ -416,9 +417,10 @@ event_unregister_epoll_common (struct event_pool *event_pool, int fd,
7f4c2a
                 ret = epoll_ctl (event_pool->fd, EPOLL_CTL_DEL, fd, NULL);
7f4c2a
 
7f4c2a
                 if (ret == -1) {
7f4c2a
-                        gf_log ("epoll", GF_LOG_ERROR,
7f4c2a
-                                "fail to del fd(=%d) from epoll fd(=%d) (%s)",
7f4c2a
-                                fd, event_pool->fd, strerror (errno));
7f4c2a
+                        gf_msg ("epoll", GF_LOG_ERROR, errno,
7f4c2a
+                                LG_MSG_EPOLL_FD_DEL_FAILED, "fail to del "
7f4c2a
+                                "fd(=%d) from epoll fd(=%d)", fd,
7f4c2a
+                                event_pool->fd);
7f4c2a
                         goto unlock;
7f4c2a
                 }
7f4c2a
 
7f4c2a
@@ -500,9 +502,10 @@ event_select_on_epoll (struct event_pool *event_pool, int fd, int idx,
7f4c2a
 		ret = epoll_ctl (event_pool->fd, EPOLL_CTL_MOD, fd,
7f4c2a
 				 &epoll_event);
7f4c2a
 		if (ret == -1) {
7f4c2a
-			gf_log ("epoll", GF_LOG_ERROR,
7f4c2a
-				"failed to modify fd(=%d) events to %d",
7f4c2a
-				fd, epoll_event.events);
7f4c2a
+			gf_msg ("epoll", GF_LOG_ERROR, errno,
7f4c2a
+                                LG_MSG_EPOLL_FD_MODIFY_FAILED, "failed to "
7f4c2a
+                                "modify fd(=%d) events to %d", fd,
7f4c2a
+                                epoll_event.events);
7f4c2a
 		}
7f4c2a
 	}
7f4c2a
 unlock:
7f4c2a
@@ -541,19 +544,19 @@ event_dispatch_epoll_handler (struct event_pool *event_pool,
7f4c2a
 	{
7f4c2a
 		fd = slot->fd;
7f4c2a
 		if (fd == -1) {
7f4c2a
-			gf_log ("epoll", GF_LOG_ERROR,
7f4c2a
-				"stale fd found on idx=%d, gen=%d, events=%d, "
7f4c2a
-				"slot->gen=%d",
7f4c2a
+			gf_msg ("epoll", GF_LOG_ERROR, 0,
7f4c2a
+                                LG_MSG_STALE_FD_FOUND, "stale fd found on "
7f4c2a
+                                "idx=%d, gen=%d, events=%d, slot->gen=%d",
7f4c2a
 				idx, gen, event->events, slot->gen);
7f4c2a
 			/* fd got unregistered in another thread */
7f4c2a
 			goto pre_unlock;
7f4c2a
 		}
7f4c2a
 
7f4c2a
 		if (gen != slot->gen) {
7f4c2a
-			gf_log ("epoll", GF_LOG_ERROR,
7f4c2a
-				"generation mismatch on idx=%d, gen=%d, "
7f4c2a
-				"slot->gen=%d, slot->fd=%d",
7f4c2a
-				idx, gen, slot->gen, slot->fd);
7f4c2a
+			gf_msg ("epoll", GF_LOG_ERROR, 0,
7f4c2a
+                                LG_MSG_GENERATION_MISMATCH, "generation "
7f4c2a
+                                "mismatch on idx=%d, gen=%d, slot->gen=%d, "
7f4c2a
+                                "slot->fd=%d", idx, gen, slot->gen, slot->fd);
7f4c2a
 			/* slot was re-used and therefore is another fd! */
7f4c2a
 			goto pre_unlock;
7f4c2a
 		}
7f4c2a
@@ -582,11 +585,10 @@ pre_unlock:
7f4c2a
 			/* event_unregister() happened while we were
7f4c2a
 			   in handler()
7f4c2a
 			*/
7f4c2a
-			gf_log ("epoll", GF_LOG_DEBUG,
7f4c2a
-				"generation bumped on idx=%d from "
7f4c2a
-				"gen=%d to slot->gen=%d, fd=%d, "
7f4c2a
-				"slot->fd=%d",
7f4c2a
-				idx, gen, slot->gen, fd, slot->fd);
7f4c2a
+			gf_msg_debug ("epoll", 0, "generation bumped on idx=%d"
7f4c2a
+                                      " from gen=%d to slot->gen=%d, fd=%d, "
7f4c2a
+				      "slot->fd=%d", idx, gen, slot->gen, fd,
7f4c2a
+                                      slot->fd);
7f4c2a
 			goto post_unlock;
7f4c2a
 		}
7f4c2a
 
7f4c2a
@@ -626,7 +628,8 @@ event_dispatch_epoll_worker (void *data)
7f4c2a
 
7f4c2a
         GF_VALIDATE_OR_GOTO ("event", event_pool, out);
7f4c2a
 
7f4c2a
-        gf_log ("epoll", GF_LOG_INFO, "Started thread with index %d", myindex);
7f4c2a
+        gf_msg ("epoll", GF_LOG_INFO, 0, LG_MSG_STARTED_EPOLL_THREAD, "Started"
7f4c2a
+                " thread with index %d", myindex);
7f4c2a
 
7f4c2a
         pthread_mutex_lock (&event_pool->mutex);
7f4c2a
         {
7f4c2a
@@ -655,8 +658,9 @@ event_dispatch_epoll_worker (void *data)
7f4c2a
                         }
7f4c2a
                         pthread_mutex_unlock (&event_pool->mutex);
7f4c2a
                         if (timetodie) {
7f4c2a
-                                gf_log ("epoll", GF_LOG_INFO,
7f4c2a
-                                        "Exited thread with index %d", myindex);
7f4c2a
+                                gf_msg ("epoll", GF_LOG_INFO, 0,
7f4c2a
+                                        LG_MSG_EXITED_EPOLL_THREAD, "Exited "
7f4c2a
+                                        "thread with index %d", myindex);
7f4c2a
                                 goto out;
7f4c2a
                         }
7f4c2a
                 }
7f4c2a
@@ -709,8 +713,6 @@ event_dispatch_epoll (struct event_pool *event_pool)
7f4c2a
                         ev_data = GF_CALLOC (1, sizeof (*ev_data),
7f4c2a
                                      gf_common_mt_event_pool);
7f4c2a
                         if (!ev_data) {
7f4c2a
-                                gf_log ("epoll", GF_LOG_WARNING,
7f4c2a
-                                        "Allocation failure for index %d", i);
7f4c2a
                                 if (i == 0) {
7f4c2a
                                         /* Need to suceed creating 0'th
7f4c2a
                                          * thread, to joinable and wait */
7f4c2a
@@ -738,7 +740,8 @@ event_dispatch_epoll (struct event_pool *event_pool)
7f4c2a
                                 if (i != 0)
7f4c2a
                                         pthread_detach (event_pool->pollers[i]);
7f4c2a
                         } else {
7f4c2a
-                                gf_log ("epoll", GF_LOG_WARNING,
7f4c2a
+                                gf_msg ("epoll", GF_LOG_WARNING, 0,
7f4c2a
+                                        LG_MSG_START_EPOLL_THREAD_FAILED,
7f4c2a
                                         "Failed to start thread for index %d",
7f4c2a
                                         i);
7f4c2a
                                 if (i == 0) {
7f4c2a
@@ -804,9 +807,6 @@ event_reconfigure_threads_epoll (struct event_pool *event_pool, int value)
7f4c2a
                                                       sizeof (*ev_data),
7f4c2a
                                                       gf_common_mt_event_pool);
7f4c2a
                                         if (!ev_data) {
7f4c2a
-                                                gf_log ("epoll", GF_LOG_WARNING,
7f4c2a
-                                                  "Allocation failure for"
7f4c2a
-                                                  " index %d", i);
7f4c2a
                                                 continue;
7f4c2a
                                         }
7f4c2a
 
7f4c2a
@@ -817,9 +817,11 @@ event_reconfigure_threads_epoll (struct event_pool *event_pool, int value)
7f4c2a
                                                 event_dispatch_epoll_worker,
7f4c2a
                                                 ev_data);
7f4c2a
                                         if (ret) {
7f4c2a
-                                                gf_log ("epoll", GF_LOG_WARNING,
7f4c2a
-                                                  "Failed to start thread for"
7f4c2a
-                                                  " index %d", i);
7f4c2a
+                                                gf_msg ("epoll", GF_LOG_WARNING,
7f4c2a
+                                                        0,
7f4c2a
+                                                        LG_MSG_START_EPOLL_THREAD_FAILED,
7f4c2a
+                                                        "Failed to start thread"
7f4c2a
+                                                        " for index %d", i);
7f4c2a
                                                 GF_FREE (ev_data);
7f4c2a
                                         } else {
7f4c2a
                                                 pthread_detach (t_id);
7f4c2a
diff --git a/libglusterfs/src/event-history.c b/libglusterfs/src/event-history.c
7f4c2a
index e89df09..95484a4 100644
7f4c2a
--- a/libglusterfs/src/event-history.c
7f4c2a
+++ b/libglusterfs/src/event-history.c
7f4c2a
@@ -9,6 +9,7 @@
7f4c2a
 */
7f4c2a
 
7f4c2a
 #include "event-history.h"
7f4c2a
+#include "libglusterfs-messages.h"
7f4c2a
 
7f4c2a
 eh_t *
7f4c2a
 eh_new (size_t buffer_size, gf_boolean_t use_buffer_once,
7f4c2a
@@ -19,14 +20,12 @@ eh_new (size_t buffer_size, gf_boolean_t use_buffer_once,
7f4c2a
 
7f4c2a
         history = GF_CALLOC (1, sizeof (eh_t), gf_common_mt_eh_t);
7f4c2a
         if (!history) {
7f4c2a
-                gf_log ("", GF_LOG_ERROR, "allocating history failed.");
7f4c2a
                 goto out;
7f4c2a
         }
7f4c2a
 
7f4c2a
         buffer = cb_buffer_new (buffer_size, use_buffer_once,
7f4c2a
                                 destroy_buffer_data);
7f4c2a
         if (!buffer) {
7f4c2a
-                gf_log ("", GF_LOG_ERROR, "allocating circular buffer failed");
7f4c2a
                 GF_FREE (history);
7f4c2a
                 history = NULL;
7f4c2a
                 goto out;
7f4c2a
@@ -44,7 +43,7 @@ eh_dump (eh_t *history, void *data,
7f4c2a
          int (dump_fn) (circular_buffer_t *buffer, void *data))
7f4c2a
 {
7f4c2a
         if (!history) {
7f4c2a
-                gf_log ("", GF_LOG_DEBUG, "history is NULL");
7f4c2a
+                gf_msg_debug ("event-history", 0, "history is NULL");
7f4c2a
                 goto out;
7f4c2a
         }
7f4c2a
 
7f4c2a
@@ -68,8 +67,8 @@ int
7f4c2a
 eh_destroy (eh_t *history)
7f4c2a
 {
7f4c2a
         if (!history) {
7f4c2a
-                gf_log ("", GF_LOG_INFO, "history for the xlator is "
7f4c2a
-                        "NULL");
7f4c2a
+                gf_msg ("event-history", GF_LOG_INFO, 0, LG_MSG_INVALID_ARG,
7f4c2a
+                        "history for the xlator is NULL");
7f4c2a
                 return -1;
7f4c2a
         }
7f4c2a
 
7f4c2a
diff --git a/libglusterfs/src/event-poll.c b/libglusterfs/src/event-poll.c
7f4c2a
index 0daceb0..008da10 100644
7f4c2a
--- a/libglusterfs/src/event-poll.c
7f4c2a
+++ b/libglusterfs/src/event-poll.c
7f4c2a
@@ -20,6 +20,7 @@
7f4c2a
 #include "event.h"
7f4c2a
 #include "mem-pool.h"
7f4c2a
 #include "common-utils.h"
7f4c2a
+#include "libglusterfs-messages.h"
7f4c2a
 
7f4c2a
 #ifndef _CONFIG_H
7f4c2a
 #define _CONFIG_H
7f4c2a
@@ -55,9 +56,9 @@ __flush_fd (int fd, int idx, void *data,
7f4c2a
         do {
7f4c2a
                 ret = read (fd, buf, 64);
7f4c2a
                 if (ret == -1 && errno != EAGAIN) {
7f4c2a
-                        gf_log ("poll", GF_LOG_ERROR,
7f4c2a
-                                "read on %d returned error (%s)",
7f4c2a
-                                fd, strerror (errno));
7f4c2a
+                        gf_msg ("poll", GF_LOG_ERROR, errno,
7f4c2a
+                                LG_MSG_FILE_OP_FAILED, "read on %d returned "
7f4c2a
+                                "error", fd);
7f4c2a
                 }
7f4c2a
         } while (ret == 64);
7f4c2a
 
7f4c2a
@@ -121,8 +122,8 @@ event_pool_new_poll (int count, int eventthreadcount)
7f4c2a
         ret = pipe (event_pool->breaker);
7f4c2a
 
7f4c2a
         if (ret == -1) {
7f4c2a
-                gf_log ("poll", GF_LOG_ERROR,
7f4c2a
-                        "pipe creation failed (%s)", strerror (errno));
7f4c2a
+                gf_msg ("poll", GF_LOG_ERROR, errno, LG_MSG_PIPE_CREATE_FAILED,
7f4c2a
+                        "pipe creation failed");
7f4c2a
                 GF_FREE (event_pool->reg);
7f4c2a
                 GF_FREE (event_pool);
7f4c2a
                 return NULL;
7f4c2a
@@ -130,9 +131,8 @@ event_pool_new_poll (int count, int eventthreadcount)
7f4c2a
 
7f4c2a
         ret = fcntl (event_pool->breaker[0], F_SETFL, O_NONBLOCK);
7f4c2a
         if (ret == -1) {
7f4c2a
-                gf_log ("poll", GF_LOG_ERROR,
7f4c2a
-                        "could not set pipe to non blocking mode (%s)",
7f4c2a
-                        strerror (errno));
7f4c2a
+                gf_msg ("poll", GF_LOG_ERROR, errno, LG_MSG_SET_PIPE_FAILED,
7f4c2a
+                        "could not set pipe to non blocking mode");
7f4c2a
                 close (event_pool->breaker[0]);
7f4c2a
                 close (event_pool->breaker[1]);
7f4c2a
                 event_pool->breaker[0] = event_pool->breaker[1] = -1;
7f4c2a
@@ -144,9 +144,8 @@ event_pool_new_poll (int count, int eventthreadcount)
7f4c2a
 
7f4c2a
         ret = fcntl (event_pool->breaker[1], F_SETFL, O_NONBLOCK);
7f4c2a
         if (ret == -1) {
7f4c2a
-                gf_log ("poll", GF_LOG_ERROR,
7f4c2a
-                        "could not set pipe to non blocking mode (%s)",
7f4c2a
-                        strerror (errno));
7f4c2a
+                gf_msg ("poll", GF_LOG_ERROR, errno, LG_MSG_SET_PIPE_FAILED,
7f4c2a
+                        "could not set pipe to non blocking mode");
7f4c2a
 
7f4c2a
                 close (event_pool->breaker[0]);
7f4c2a
                 close (event_pool->breaker[1]);
7f4c2a
@@ -160,7 +159,7 @@ event_pool_new_poll (int count, int eventthreadcount)
7f4c2a
         ret = event_register_poll (event_pool, event_pool->breaker[0],
7f4c2a
                                    __flush_fd, NULL, 1, 0);
7f4c2a
         if (ret == -1) {
7f4c2a
-                gf_log ("poll", GF_LOG_ERROR,
7f4c2a
+                gf_msg ("poll", GF_LOG_ERROR, 0, LG_MSG_REGISTER_PIPE_FAILED,
7f4c2a
                         "could not register pipe fd with poll event loop");
7f4c2a
                 close (event_pool->breaker[0]);
7f4c2a
                 close (event_pool->breaker[1]);
7f4c2a
@@ -172,9 +171,10 @@ event_pool_new_poll (int count, int eventthreadcount)
7f4c2a
         }
7f4c2a
 
7f4c2a
         if (eventthreadcount > 1) {
7f4c2a
-                gf_log ("poll", GF_LOG_INFO,
7f4c2a
-                        "Currently poll does not use multiple event processing"
7f4c2a
-                        " threads, thread count (%d) ignored", eventthreadcount);
7f4c2a
+                gf_msg ("poll", GF_LOG_INFO, 0,
7f4c2a
+                        LG_MSG_POLL_IGNORE_MULTIPLE_THREADS, "Currently poll "
7f4c2a
+                        "does not use multiple event processing threads, "
7f4c2a
+                        "thread count (%d) ignored", eventthreadcount);
7f4c2a
         }
7f4c2a
 
7f4c2a
         return event_pool;
7f4c2a
@@ -221,7 +221,8 @@ event_register_poll (struct event_pool *event_pool, int fd,
7f4c2a
                         /* do nothing */
7f4c2a
                         break;
7f4c2a
                 default:
7f4c2a
-                        gf_log ("poll", GF_LOG_ERROR,
7f4c2a
+                        gf_msg ("poll", GF_LOG_ERROR, 0,
7f4c2a
+                                LG_MSG_INVALID_POLL_IN,
7f4c2a
                                 "invalid poll_in value %d", poll_in);
7f4c2a
                         break;
7f4c2a
                 }
7f4c2a
@@ -237,7 +238,8 @@ event_register_poll (struct event_pool *event_pool, int fd,
7f4c2a
                         /* do nothing */
7f4c2a
                         break;
7f4c2a
                 default:
7f4c2a
-                        gf_log ("poll", GF_LOG_ERROR,
7f4c2a
+                        gf_msg ("poll", GF_LOG_ERROR, 0,
7f4c2a
+                                LG_MSG_INVALID_POLL_OUT,
7f4c2a
                                 "invalid poll_out value %d", poll_out);
7f4c2a
                         break;
7f4c2a
                 }
7f4c2a
@@ -265,7 +267,7 @@ event_unregister_poll (struct event_pool *event_pool, int fd, int idx_hint)
7f4c2a
                 idx = __event_getindex (event_pool, fd, idx_hint);
7f4c2a
 
7f4c2a
                 if (idx == -1) {
7f4c2a
-                        gf_log ("poll", GF_LOG_ERROR,
7f4c2a
+                        gf_msg ("poll", GF_LOG_ERROR, 0, LG_MSG_INDEX_NOT_FOUND,
7f4c2a
                                 "index not found for fd=%d (idx_hint=%d)",
7f4c2a
                                 fd, idx_hint);
7f4c2a
                         errno = ENOENT;
7f4c2a
@@ -310,7 +312,7 @@ event_select_on_poll (struct event_pool *event_pool, int fd, int idx_hint,
7f4c2a
                 idx = __event_getindex (event_pool, fd, idx_hint);
7f4c2a
 
7f4c2a
                 if (idx == -1) {
7f4c2a
-                        gf_log ("poll", GF_LOG_ERROR,
7f4c2a
+                        gf_msg ("poll", GF_LOG_ERROR, 0, LG_MSG_INDEX_NOT_FOUND,
7f4c2a
                                 "index not found for fd=%d (idx_hint=%d)",
7f4c2a
                                 fd, idx_hint);
7f4c2a
                         errno = ENOENT;
7f4c2a
@@ -375,9 +377,9 @@ event_dispatch_poll_handler (struct event_pool *event_pool,
7f4c2a
                 idx = __event_getindex (event_pool, ufds[i].fd, i);
7f4c2a
 
7f4c2a
                 if (idx == -1) {
7f4c2a
-                        gf_log ("poll", GF_LOG_ERROR,
7f4c2a
-                                "index not found for fd=%d (idx_hint=%d)",
7f4c2a
-                                ufds[i].fd, i);
7f4c2a
+                        gf_msg ("poll", GF_LOG_ERROR, 0,
7f4c2a
+                                LG_MSG_INDEX_NOT_FOUND, "index not found for "
7f4c2a
+                                "fd=%d (idx_hint=%d)", ufds[i].fd, i);
7f4c2a
                         goto unlock;
7f4c2a
                 }
7f4c2a
 
7f4c2a
diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c
7f4c2a
index 35564e4..c20355c 100644
7f4c2a
--- a/libglusterfs/src/event.c
7f4c2a
+++ b/libglusterfs/src/event.c
7f4c2a
@@ -20,6 +20,7 @@
7f4c2a
 #include "event.h"
7f4c2a
 #include "mem-pool.h"
7f4c2a
 #include "common-utils.h"
7f4c2a
+#include "libglusterfs-messages.h"
7f4c2a
 
7f4c2a
 #ifndef _CONFIG_H
7f4c2a
 #define _CONFIG_H
7f4c2a
@@ -42,7 +43,7 @@ event_pool_new (int count, int eventthreadcount)
7f4c2a
         if (event_pool) {
7f4c2a
                 event_pool->ops = &event_ops_epoll;
7f4c2a
         } else {
7f4c2a
-                gf_log ("event", GF_LOG_WARNING,
7f4c2a
+                gf_msg ("event", GF_LOG_WARNING, 0, LG_MSG_FALLBACK_TO_POLL,
7f4c2a
                         "falling back to poll based event handling");
7f4c2a
         }
7f4c2a
 #endif
7f4c2a
diff --git a/libglusterfs/src/parse-utils.c b/libglusterfs/src/parse-utils.c
7f4c2a
index f7e9988..304232f 100644
7f4c2a
--- a/libglusterfs/src/parse-utils.c
7f4c2a
+++ b/libglusterfs/src/parse-utils.c
7f4c2a
@@ -20,6 +20,7 @@
7f4c2a
 #include "parse-utils.h"
7f4c2a
 #include "mem-pool.h"
7f4c2a
 #include "common-utils.h"
7f4c2a
+#include "libglusterfs-messages.h"
7f4c2a
 
7f4c2a
 /**
7f4c2a
  * parser_init: Initialize a parser with the a string to parse and
7f4c2a
@@ -46,8 +47,6 @@ parser_init (const char *regex)
7f4c2a
 
7f4c2a
         parser->regex = gf_strdup (regex);
7f4c2a
         if (!parser->regex) {
7f4c2a
-                gf_log (GF_PARSE, GF_LOG_INFO,
7f4c2a
-                        "Failed to duplicate regex string!");
7f4c2a
                 GF_FREE (parser);
7f4c2a
                 parser = NULL;
7f4c2a
                 goto out;
7f4c2a
@@ -55,7 +54,7 @@ parser_init (const char *regex)
7f4c2a
 
7f4c2a
         rc = regcomp (&parser->preg, parser->regex, REG_EXTENDED);
7f4c2a
         if (rc != 0) {
7f4c2a
-                gf_log (GF_PARSE, GF_LOG_INFO,
7f4c2a
+                gf_msg (GF_PARSE, GF_LOG_INFO, 0, LG_MSG_REGEX_OP_FAILED,
7f4c2a
                         "Failed to compile regex pattern.");
7f4c2a
                 parser_deinit (parser);
7f4c2a
                 parser = NULL;
7f4c2a
@@ -160,7 +159,7 @@ parser_get_next_match (struct parser *parser)
7f4c2a
 
7f4c2a
         rc = regexec (&parser->preg, parser->_rstr, 1, parser->pmatch, 0);
7f4c2a
         if (rc != 0) {
7f4c2a
-                gf_log (GF_PARSE, GF_LOG_DEBUG,
7f4c2a
+                gf_msg_debug (GF_PARSE, 0,
7f4c2a
                         "Could not match %s with regex %s",
7f4c2a
                         parser->_rstr, parser->regex);
7f4c2a
                 goto out;
7f4c2a
diff --git a/libglusterfs/src/quota-common-utils.c b/libglusterfs/src/quota-common-utils.c
7f4c2a
index 012f80f..8c528c8 100644
7f4c2a
--- a/libglusterfs/src/quota-common-utils.c
7f4c2a
+++ b/libglusterfs/src/quota-common-utils.c
7f4c2a
@@ -14,6 +14,7 @@
7f4c2a
 #include "byte-order.h"
7f4c2a
 #include "quota-common-utils.h"
7f4c2a
 #include "common-utils.h"
7f4c2a
+#include "libglusterfs-messages.h"
7f4c2a
 
7f4c2a
 int32_t
7f4c2a
 quota_data_to_meta (data_t *data, char *key, quota_meta_t *meta)
7f4c2a
@@ -42,8 +43,9 @@ quota_data_to_meta (data_t *data, char *key, quota_meta_t *meta)
7f4c2a
                  * Older version of glusterfs will not have inode count.
7f4c2a
                  * Return failure, this will be healed as part of lookup
7f4c2a
                  */
7f4c2a
-                gf_log_callingfn ("quota", GF_LOG_DEBUG, "Object quota xattrs "
7f4c2a
-                                  "missing: len = %d", data->len);
7f4c2a
+                gf_msg_callingfn ("quota", GF_LOG_DEBUG, 0,
7f4c2a
+                                  LG_MSG_QUOTA_XATTRS_MISSING, "Object quota "
7f4c2a
+                                  "xattrs missing: len = %d", data->len);
7f4c2a
                 ret = -2;
7f4c2a
                 goto out;
7f4c2a
         }
7f4c2a
@@ -83,8 +85,6 @@ quota_dict_set_meta (dict_t *dict, char *key, const quota_meta_t *meta,
7f4c2a
 
7f4c2a
         value = GF_CALLOC (1, sizeof (quota_meta_t), gf_common_quota_meta_t);
7f4c2a
         if (value == NULL) {
7f4c2a
-                gf_log_callingfn ("quota", GF_LOG_ERROR,
7f4c2a
-                                  "Memory allocation failed");
7f4c2a
                 goto out;
7f4c2a
         }
7f4c2a
 
7f4c2a
@@ -105,7 +105,8 @@ quota_dict_set_meta (dict_t *dict, char *key, const quota_meta_t *meta,
7f4c2a
         }
7f4c2a
 
7f4c2a
         if (ret < 0) {
7f4c2a
-                gf_log_callingfn ("quota", GF_LOG_ERROR, "dict set failed");
7f4c2a
+                gf_msg_callingfn ("quota", GF_LOG_ERROR, 0,
7f4c2a
+                                  LG_MSG_DICT_SET_FAILED, "dict set failed");
7f4c2a
                 GF_FREE (value);
7f4c2a
         }
7f4c2a
 
7f4c2a
@@ -133,7 +134,8 @@ quota_conf_read_header (int fd, char *buf)
7f4c2a
 
7f4c2a
 out:
7f4c2a
         if (ret < 0)
7f4c2a
-                gf_log_callingfn ("quota", GF_LOG_ERROR, "failed to read "
7f4c2a
+                gf_msg_callingfn ("quota", GF_LOG_ERROR, 0,
7f4c2a
+                                  LG_MSG_QUOTA_CONF_ERROR, "failed to read "
7f4c2a
                                   "header from a quota conf");
7f4c2a
 
7f4c2a
         return ret;
7f4c2a
@@ -159,8 +161,9 @@ quota_conf_read_version (int fd, float *version)
7f4c2a
         value = strtof ((buf + strlen(buf) - 3), &tail);
7f4c2a
         if (tail[0] != '\0') {
7f4c2a
                 ret = -1;
7f4c2a
-                gf_log_callingfn ("quota", GF_LOG_ERROR, "invalid quota conf "
7f4c2a
-                                  "version");
7f4c2a
+                gf_msg_callingfn ("quota", GF_LOG_ERROR, 0,
7f4c2a
+                                  LG_MSG_QUOTA_CONF_ERROR, "invalid quota conf"
7f4c2a
+                                  " version");
7f4c2a
                 goto out;
7f4c2a
         }
7f4c2a
 
7f4c2a
@@ -170,8 +173,9 @@ out:
7f4c2a
         if (ret >= 0)
7f4c2a
                 *version = value;
7f4c2a
         else
7f4c2a
-                gf_log_callingfn ("quota", GF_LOG_ERROR, "failed to read "
7f4c2a
-                                  "version from a quota conf header");
7f4c2a
+                gf_msg_callingfn ("quota", GF_LOG_ERROR, 0,
7f4c2a
+                                  LG_MSG_QUOTA_CONF_ERROR, "failed to "
7f4c2a
+                                  "read version from a quota conf header");
7f4c2a
 
7f4c2a
         return ret;
7f4c2a
 }
7f4c2a
@@ -203,8 +207,9 @@ quota_conf_read_gfid (int fd, void *buf, char *type, float version)
7f4c2a
 
7f4c2a
 out:
7f4c2a
         if (ret < 0)
7f4c2a
-                gf_log_callingfn ("quota", GF_LOG_ERROR, "failed to read "
7f4c2a
-                                  "gfid from a quota conf");
7f4c2a
+                gf_msg_callingfn ("quota", GF_LOG_ERROR, 0,
7f4c2a
+                                  LG_MSG_QUOTA_CONF_ERROR, "failed to "
7f4c2a
+                                  "read gfid from a quota conf");
7f4c2a
 
7f4c2a
         return ret;
7f4c2a
 }
7f4c2a
diff --git a/libglusterfs/src/rbthash.c b/libglusterfs/src/rbthash.c
7f4c2a
index 0d7b9e5..47c6d01 100644
7f4c2a
--- a/libglusterfs/src/rbthash.c
7f4c2a
+++ b/libglusterfs/src/rbthash.c
7f4c2a
@@ -14,6 +14,7 @@
7f4c2a
 #include "locking.h"
7f4c2a
 #include "mem-pool.h"
7f4c2a
 #include "logging.h"
7f4c2a
+#include "libglusterfs-messages.h"
7f4c2a
 
7f4c2a
 #include <pthread.h>
7f4c2a
 #include <string.h>
7f4c2a
@@ -57,8 +58,9 @@ __rbthash_init_buckets (rbthash_table_t *tbl, int buckets)
7f4c2a
                 LOCK_INIT (&tbl->buckets[i].bucketlock);
7f4c2a
                 tbl->buckets[i].bucket = rb_create ((rb_comparison_func *)rbthash_comparator, tbl, NULL);
7f4c2a
                 if (!tbl->buckets[i].bucket) {
7f4c2a
-                        gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to create rb"
7f4c2a
-                                " table bucket");
7f4c2a
+                        gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0,
7f4c2a
+                                LG_MSG_RB_TABLE_CREATE_FAILED, "Failed to "
7f4c2a
+                                "create rb table bucket");
7f4c2a
                         ret = -1;
7f4c2a
                         goto err;
7f4c2a
                 }
7f4c2a
@@ -90,18 +92,19 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc,
7f4c2a
         int                     ret = -1;
7f4c2a
 
7f4c2a
         if (!hfunc) {
7f4c2a
-                gf_log (GF_RBTHASH, GF_LOG_ERROR, "Hash function not given");
7f4c2a
+                gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, LG_MSG_HASH_FUNC_ERROR,
7f4c2a
+                        "Hash function not given");
7f4c2a
                 return NULL;
7f4c2a
         }
7f4c2a
 
7f4c2a
         if (!entrypool && !expected_entries) {
7f4c2a
-                gf_log (GF_RBTHASH, GF_LOG_ERROR,
7f4c2a
+                gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY,
7f4c2a
                         "Both mem-pool and expected entries not provided");
7f4c2a
                 return NULL;
7f4c2a
         }
7f4c2a
 
7f4c2a
         if (entrypool && expected_entries) {
7f4c2a
-                gf_log (GF_RBTHASH, GF_LOG_ERROR,
7f4c2a
+                gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY,
7f4c2a
                         "Both mem-pool and expected entries are provided");
7f4c2a
                 return NULL;
7f4c2a
         }
7f4c2a
@@ -122,8 +125,6 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc,
7f4c2a
                 newtab->entrypool =
7f4c2a
                         mem_pool_new (rbthash_entry_t, expected_entries);
7f4c2a
                 if (!newtab->entrypool) {
7f4c2a
-                        gf_log (GF_RBTHASH, GF_LOG_ERROR,
7f4c2a
-                                "Failed to allocate mem-pool");
7f4c2a
                         goto free_buckets;
7f4c2a
                 }
7f4c2a
                 newtab->pool_alloced = _gf_true;
7f4c2a
@@ -137,11 +138,13 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc,
7f4c2a
         ret = __rbthash_init_buckets (newtab, buckets);
7f4c2a
 
7f4c2a
         if (ret == -1) {
7f4c2a
-                gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to init buckets");
7f4c2a
+                gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0,
7f4c2a
+                        LG_MSG_RBTHASH_INIT_BUCKET_FAILED,
7f4c2a
+                        "Failed to init buckets");
7f4c2a
                 if (newtab->pool_alloced)
7f4c2a
                         mem_pool_destroy (newtab->entrypool);
7f4c2a
         } else {
7f4c2a
-                gf_log (GF_RBTHASH, GF_LOG_TRACE, "Inited hash table: buckets:"
7f4c2a
+                gf_msg_trace (GF_RBTHASH, 0, "Inited hash table: buckets:"
7f4c2a
                         " %d", buckets);
7f4c2a
         }
7f4c2a
 
7f4c2a
@@ -172,8 +175,9 @@ rbthash_init_entry (rbthash_table_t *tbl, void *data, void *key, int keylen)
7f4c2a
 
7f4c2a
         entry = mem_get (tbl->entrypool);
7f4c2a
         if (!entry) {
7f4c2a
-                gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to get entry from"
7f4c2a
-                        " mem-pool");
7f4c2a
+                gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0,
7f4c2a
+                        LG_MSG_RBTHASH_GET_ENTRY_FAILED,
7f4c2a
+                        "Failed to get entry from mem-pool");
7f4c2a
                 goto ret;
7f4c2a
         }
7f4c2a
 
7f4c2a
@@ -187,7 +191,7 @@ rbthash_init_entry (rbthash_table_t *tbl, void *data, void *key, int keylen)
7f4c2a
         memcpy (entry->key, key, keylen);
7f4c2a
         entry->keylen = keylen;
7f4c2a
         entry->keyhash = tbl->hashfunc (entry->key, entry->keylen);
7f4c2a
-        gf_log (GF_RBTHASH, GF_LOG_TRACE, "HASH: %u", entry->keyhash);
7f4c2a
+        gf_msg_trace (GF_RBTHASH, 0, "HASH: %u", entry->keyhash);
7f4c2a
 
7f4c2a
         ret = 0;
7f4c2a
 free_entry:
7f4c2a
@@ -233,7 +237,7 @@ rbthash_entry_bucket (rbthash_table_t *tbl, rbthash_entry_t * entry)
7f4c2a
         int     nbucket = 0;
7f4c2a
 
7f4c2a
         nbucket = (entry->keyhash % tbl->numbuckets);
7f4c2a
-        gf_log (GF_RBTHASH, GF_LOG_TRACE, "BUCKET: %d", nbucket);
7f4c2a
+        gf_msg_trace (GF_RBTHASH, 0, "BUCKET: %d", nbucket);
7f4c2a
         return &tbl->buckets[nbucket];
7f4c2a
 }
7f4c2a
 
7f4c2a
@@ -249,7 +253,9 @@ rbthash_insert_entry (rbthash_table_t *tbl, rbthash_entry_t *entry)
7f4c2a
 
7f4c2a
         bucket = rbthash_entry_bucket (tbl, entry);
7f4c2a
         if (!bucket) {
7f4c2a
-                gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to get bucket");
7f4c2a
+                gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0,
7f4c2a
+                        LG_MSG_RBTHASH_GET_BUCKET_FAILED,
7f4c2a
+                        "Failed to get bucket");
7f4c2a
                 goto err;
7f4c2a
         }
7f4c2a
 
7f4c2a
@@ -257,7 +263,8 @@ rbthash_insert_entry (rbthash_table_t *tbl, rbthash_entry_t *entry)
7f4c2a
         LOCK (&bucket->bucketlock);
7f4c2a
         {
7f4c2a
                 if (!rb_probe (bucket->bucket, (void *)entry)) {
7f4c2a
-                        gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to insert"
7f4c2a
+                        gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0,
7f4c2a
+                                LG_MSG_RBTHASH_INSERT_FAILED, "Failed to insert"
7f4c2a
                                 " entry");
7f4c2a
                         ret = -1;
7f4c2a
                 }
7f4c2a
@@ -280,14 +287,18 @@ rbthash_insert (rbthash_table_t *tbl, void *data, void *key, int keylen)
7f4c2a
 
7f4c2a
         entry = rbthash_init_entry (tbl, data, key, keylen);
7f4c2a
         if (!entry) {
7f4c2a
-                gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to init entry");
7f4c2a
+                gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0,
7f4c2a
+                        LG_MSG_RBTHASH_INIT_ENTRY_FAILED,
7f4c2a
+                        "Failed to init entry");
7f4c2a
                 goto err;
7f4c2a
         }
7f4c2a
 
7f4c2a
         ret = rbthash_insert_entry (tbl, entry);
7f4c2a
 
7f4c2a
         if (ret == -1) {
7f4c2a
-                gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to insert entry");
7f4c2a
+                gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0,
7f4c2a
+                        LG_MSG_RBTHASH_INSERT_FAILED,
7f4c2a
+                        "Failed to insert entry");
7f4c2a
                 rbthash_deinit_entry (tbl, entry);
7f4c2a
         }
7f4c2a
 
7f4c2a
@@ -311,9 +322,9 @@ rbthash_key_bucket (rbthash_table_t *tbl, void *key, int keylen)
7f4c2a
                 return NULL;
7f4c2a
 
7f4c2a
         keyhash =  tbl->hashfunc (key, keylen);
7f4c2a
-        gf_log (GF_RBTHASH, GF_LOG_TRACE, "HASH: %u", keyhash);
7f4c2a
+        gf_msg_trace (GF_RBTHASH, 0, "HASH: %u", keyhash);
7f4c2a
         nbucket = (keyhash % tbl->numbuckets);
7f4c2a
-        gf_log (GF_RBTHASH, GF_LOG_TRACE, "BUCKET: %u", nbucket);
7f4c2a
+        gf_msg_trace (GF_RBTHASH, 0, "BUCKET: %u", nbucket);
7f4c2a
 
7f4c2a
         return &tbl->buckets[nbucket];
7f4c2a
 }
7f4c2a
@@ -331,7 +342,8 @@ rbthash_get (rbthash_table_t *tbl, void *key, int keylen)
7f4c2a
 
7f4c2a
         bucket = rbthash_key_bucket (tbl, key, keylen);
7f4c2a
         if (!bucket) {
7f4c2a
-                gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to get bucket");
7f4c2a
+                gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0, LG_MSG_GET_BUCKET_FAILED,
7f4c2a
+                        "Failed to get bucket");
7f4c2a
                 return NULL;
7f4c2a
         }
7f4c2a
 
7f4c2a
@@ -363,7 +375,9 @@ rbthash_remove (rbthash_table_t *tbl, void *key, int keylen)
7f4c2a
 
7f4c2a
         bucket = rbthash_key_bucket (tbl, key, keylen);
7f4c2a
         if (!bucket) {
7f4c2a
-                gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to get bucket");
7f4c2a
+                gf_msg (GF_RBTHASH, GF_LOG_ERROR, 0,
7f4c2a
+                        LG_MSG_RBTHASH_GET_BUCKET_FAILED,
7f4c2a
+                        "Failed to get bucket");
7f4c2a
                 return NULL;
7f4c2a
         }
7f4c2a
 
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a