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