|
|
cb8e9e |
From 8b74a04e2f030e8b1bad6004103d99c9d2b866ee Mon Sep 17 00:00:00 2001
|
|
|
cb8e9e |
From: Mohamed Ashiq <ashiq333@gmail.com>
|
|
|
cb8e9e |
Date: Tue, 19 May 2015 15:40:30 +0530
|
|
|
cb8e9e |
Subject: [PATCH 167/190] defaults,globals,iobuf,latency,logging,options,xlator/libglusterfs : porting to a new logging framework
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Change-Id: If6a55186cddc3d1c4d22e3d56b45358b84feeb49
|
|
|
cb8e9e |
BUG: 1231792
|
|
|
cb8e9e |
Signed-off-by: Mohamed Ashiq Liyazudeen <mliyazud@redhat.com>
|
|
|
cb8e9e |
Reviewed-on: http://review.gluster.org/10826
|
|
|
cb8e9e |
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
cb8e9e |
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
|
|
|
cb8e9e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/51693
|
|
|
cb8e9e |
Reviewed-by: Venky Shankar <vshankar@redhat.com>
|
|
|
cb8e9e |
Tested-by: Venky Shankar <vshankar@redhat.com>
|
|
|
cb8e9e |
---
|
|
|
cb8e9e |
libglusterfs/src/defaults.c | 10 ++-
|
|
|
cb8e9e |
libglusterfs/src/globals.c | 23 ++++---
|
|
|
cb8e9e |
libglusterfs/src/iobuf.c | 59 ++++++++++-------
|
|
|
cb8e9e |
libglusterfs/src/latency.c | 5 +-
|
|
|
cb8e9e |
libglusterfs/src/logging.c | 41 ++++++-----
|
|
|
cb8e9e |
libglusterfs/src/options.c | 156 +++++++++++++++++++++++++------------------
|
|
|
cb8e9e |
libglusterfs/src/options.h | 31 +++++----
|
|
|
cb8e9e |
libglusterfs/src/xlator.c | 85 ++++++++++++-----------
|
|
|
cb8e9e |
8 files changed, 231 insertions(+), 179 deletions(-)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/libglusterfs/src/defaults.c b/libglusterfs/src/defaults.c
|
|
|
cb8e9e |
index 1414da9..b617c43 100644
|
|
|
cb8e9e |
--- a/libglusterfs/src/defaults.c
|
|
|
cb8e9e |
+++ b/libglusterfs/src/defaults.c
|
|
|
cb8e9e |
@@ -27,6 +27,7 @@
|
|
|
cb8e9e |
|
|
|
cb8e9e |
#include "xlator.h"
|
|
|
cb8e9e |
#include "defaults.h"
|
|
|
cb8e9e |
+#include "libglusterfs-messages.h"
|
|
|
cb8e9e |
|
|
|
cb8e9e |
/* FAILURE_CBK function section */
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -2196,7 +2197,8 @@ default_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata)
|
|
|
cb8e9e |
int32_t
|
|
|
cb8e9e |
default_forget (xlator_t *this, inode_t *inode)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
- gf_log_callingfn (this->name, GF_LOG_WARNING, "xlator does not "
|
|
|
cb8e9e |
+ gf_msg_callingfn (this->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_XLATOR_DOES_NOT_IMPLEMENT, "xlator does not "
|
|
|
cb8e9e |
"implement forget_cbk");
|
|
|
cb8e9e |
return 0;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -2205,7 +2207,8 @@ default_forget (xlator_t *this, inode_t *inode)
|
|
|
cb8e9e |
int32_t
|
|
|
cb8e9e |
default_releasedir (xlator_t *this, fd_t *fd)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
- gf_log_callingfn (this->name, GF_LOG_WARNING, "xlator does not "
|
|
|
cb8e9e |
+ gf_msg_callingfn (this->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_XLATOR_DOES_NOT_IMPLEMENT, "xlator does not "
|
|
|
cb8e9e |
"implement releasedir_cbk");
|
|
|
cb8e9e |
return 0;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -2213,7 +2216,8 @@ default_releasedir (xlator_t *this, fd_t *fd)
|
|
|
cb8e9e |
int32_t
|
|
|
cb8e9e |
default_release (xlator_t *this, fd_t *fd)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
- gf_log_callingfn (this->name, GF_LOG_WARNING, "xlator does not "
|
|
|
cb8e9e |
+ gf_msg_callingfn (this->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_XLATOR_DOES_NOT_IMPLEMENT, "xlator does not "
|
|
|
cb8e9e |
"implement release_cbk");
|
|
|
cb8e9e |
return 0;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c
|
|
|
cb8e9e |
index bd1165e..8943637 100644
|
|
|
cb8e9e |
--- a/libglusterfs/src/globals.c
|
|
|
cb8e9e |
+++ b/libglusterfs/src/globals.c
|
|
|
cb8e9e |
@@ -20,6 +20,7 @@
|
|
|
cb8e9e |
#include "xlator.h"
|
|
|
cb8e9e |
#include "mem-pool.h"
|
|
|
cb8e9e |
#include "syncop.h"
|
|
|
cb8e9e |
+#include "libglusterfs-messages.h"
|
|
|
cb8e9e |
|
|
|
cb8e9e |
const char *gf_fop_list[GF_FOP_MAXVALUE] = {
|
|
|
cb8e9e |
[GF_FOP_NULL] = "NULL",
|
|
|
cb8e9e |
@@ -113,7 +114,9 @@ glusterfs_this_init ()
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = pthread_key_create (&this_xlator_key, glusterfs_this_destroy);
|
|
|
cb8e9e |
if (ret != 0) {
|
|
|
cb8e9e |
- gf_log ("", GF_LOG_WARNING, "failed to create the pthread key");
|
|
|
cb8e9e |
+ gf_msg ("", GF_LOG_WARNING, ret,
|
|
|
cb8e9e |
+ LG_MSG_PTHREAD_KEY_CREATE_FAILED, "failed to create "
|
|
|
cb8e9e |
+ "the pthread key");
|
|
|
cb8e9e |
return ret;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -338,43 +341,43 @@ gf_globals_init_once ()
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = glusterfs_this_init ();
|
|
|
cb8e9e |
if (ret) {
|
|
|
cb8e9e |
- gf_log ("", GF_LOG_CRITICAL,
|
|
|
cb8e9e |
+ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_TRANSLATOR_INIT_FAILED,
|
|
|
cb8e9e |
"ERROR: glusterfs-translator init failed");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = glusterfs_uuid_buf_init ();
|
|
|
cb8e9e |
if(ret) {
|
|
|
cb8e9e |
- gf_log ("", GF_LOG_CRITICAL,
|
|
|
cb8e9e |
+ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_UUID_BUF_INIT_FAILED,
|
|
|
cb8e9e |
"ERROR: glusterfs uuid buffer init failed");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = glusterfs_lkowner_buf_init ();
|
|
|
cb8e9e |
if(ret) {
|
|
|
cb8e9e |
- gf_log ("", GF_LOG_CRITICAL,
|
|
|
cb8e9e |
+ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_LKOWNER_BUF_INIT_FAILED,
|
|
|
cb8e9e |
"ERROR: glusterfs lkowner buffer init failed");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = synctask_init ();
|
|
|
cb8e9e |
if (ret) {
|
|
|
cb8e9e |
- gf_log ("", GF_LOG_CRITICAL,
|
|
|
cb8e9e |
+ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_SYNCTASK_INIT_FAILED,
|
|
|
cb8e9e |
"ERROR: glusterfs synctask init failed");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = syncopctx_init ();
|
|
|
cb8e9e |
if (ret) {
|
|
|
cb8e9e |
- gf_log ("", GF_LOG_CRITICAL,
|
|
|
cb8e9e |
+ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_SYNCOPCTX_INIT_FAILED,
|
|
|
cb8e9e |
"ERROR: glusterfs syncopctx init failed");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (ret) {
|
|
|
cb8e9e |
- gf_log ("", GF_LOG_CRITICAL, "Exiting as global "
|
|
|
cb8e9e |
- "initialization failed");
|
|
|
cb8e9e |
+ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_GLOBAL_INIT_FAILED,
|
|
|
cb8e9e |
+ "Exiting as global initialization failed");
|
|
|
cb8e9e |
exit (ret);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -389,8 +392,8 @@ glusterfs_globals_init (glusterfs_ctx_t *ctx)
|
|
|
cb8e9e |
ret = pthread_once (&globals_inited, gf_globals_init_once);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (ret)
|
|
|
cb8e9e |
- gf_log ("", GF_LOG_CRITICAL, "pthread_once failed with: %d",
|
|
|
cb8e9e |
- ret);
|
|
|
cb8e9e |
+ gf_msg ("", GF_LOG_CRITICAL, ret, LG_MSG_PTHREAD_FAILED,
|
|
|
cb8e9e |
+ "pthread_once failed");
|
|
|
cb8e9e |
|
|
|
cb8e9e |
return ret;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c
|
|
|
cb8e9e |
index 9dbf19b..a4d3669 100644
|
|
|
cb8e9e |
--- a/libglusterfs/src/iobuf.c
|
|
|
cb8e9e |
+++ b/libglusterfs/src/iobuf.c
|
|
|
cb8e9e |
@@ -12,7 +12,7 @@
|
|
|
cb8e9e |
#include "iobuf.h"
|
|
|
cb8e9e |
#include "statedump.h"
|
|
|
cb8e9e |
#include <stdio.h>
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
+#include "libglusterfs-messages.h"
|
|
|
cb8e9e |
|
|
|
cb8e9e |
/*
|
|
|
cb8e9e |
TODO: implement destroy margins and prefetching of arenas
|
|
|
cb8e9e |
@@ -119,7 +119,8 @@ __iobuf_arena_destroy_iobufs (struct iobuf_arena *iobuf_arena)
|
|
|
cb8e9e |
iobuf_cnt = iobuf_arena->page_count;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!iobuf_arena->iobufs) {
|
|
|
cb8e9e |
- gf_log_callingfn (THIS->name, GF_LOG_ERROR, "iobufs not found");
|
|
|
cb8e9e |
+ gf_msg_callingfn (THIS->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
+ LG_MSG_IOBUFS_NOT_FOUND, "iobufs not found");
|
|
|
cb8e9e |
return;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -192,7 +193,8 @@ __iobuf_arena_alloc (struct iobuf_pool *iobuf_pool, size_t page_size,
|
|
|
cb8e9e |
PROT_READ|PROT_WRITE,
|
|
|
cb8e9e |
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
|
|
|
cb8e9e |
if (iobuf_arena->mem_base == MAP_FAILED) {
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_WARNING, "maping failed");
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_MAPPING_FAILED,
|
|
|
cb8e9e |
+ "mapping failed");
|
|
|
cb8e9e |
goto err;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -205,7 +207,8 @@ __iobuf_arena_alloc (struct iobuf_pool *iobuf_pool, size_t page_size,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
__iobuf_arena_init_iobufs (iobuf_arena);
|
|
|
cb8e9e |
if (!iobuf_arena->iobufs) {
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_ERROR, "init failed");
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_ERROR, 0, LG_MSG_INIT_IOBUF_FAILED,
|
|
|
cb8e9e |
+ "init failed");
|
|
|
cb8e9e |
goto err;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -232,9 +235,9 @@ __iobuf_arena_unprune (struct iobuf_pool *iobuf_pool, size_t page_size)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
index = gf_iobuf_get_arena_index (page_size);
|
|
|
cb8e9e |
if (index == -1) {
|
|
|
cb8e9e |
- gf_log ("iobuf", GF_LOG_ERROR, "page_size (%zu) of "
|
|
|
cb8e9e |
- "iobufs in arena being added is greater than max "
|
|
|
cb8e9e |
- "available", page_size);
|
|
|
cb8e9e |
+ gf_msg ("iobuf", GF_LOG_ERROR, 0, LG_MSG_PAGE_SIZE_EXCEEDED,
|
|
|
cb8e9e |
+ "page_size (%zu) of iobufs in arena being added is "
|
|
|
cb8e9e |
+ "greater than max available", page_size);
|
|
|
cb8e9e |
return NULL;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -257,9 +260,9 @@ __iobuf_pool_add_arena (struct iobuf_pool *iobuf_pool, size_t page_size,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
index = gf_iobuf_get_arena_index (page_size);
|
|
|
cb8e9e |
if (index == -1) {
|
|
|
cb8e9e |
- gf_log ("iobuf", GF_LOG_ERROR, "page_size (%zu) of "
|
|
|
cb8e9e |
- "iobufs in arena being added is greater than max "
|
|
|
cb8e9e |
- "available", page_size);
|
|
|
cb8e9e |
+ gf_msg ("iobuf", GF_LOG_ERROR, 0, LG_MSG_PAGE_SIZE_EXCEEDED,
|
|
|
cb8e9e |
+ "page_size (%zu) of iobufs in arena being added is "
|
|
|
cb8e9e |
+ "greater than max available", page_size);
|
|
|
cb8e9e |
return NULL;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -270,7 +273,8 @@ __iobuf_pool_add_arena (struct iobuf_pool *iobuf_pool, size_t page_size,
|
|
|
cb8e9e |
num_pages);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!iobuf_arena) {
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_WARNING, "arena not found");
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_ARENA_NOT_FOUND,
|
|
|
cb8e9e |
+ "arena not found");
|
|
|
cb8e9e |
return NULL;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
list_add (&iobuf_arena->list, &iobuf_pool->arenas[index]);
|
|
|
cb8e9e |
@@ -499,9 +503,9 @@ __iobuf_select_arena (struct iobuf_pool *iobuf_pool, size_t page_size)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
index = gf_iobuf_get_arena_index (page_size);
|
|
|
cb8e9e |
if (index == -1) {
|
|
|
cb8e9e |
- gf_log ("iobuf", GF_LOG_ERROR, "page_size (%zu) of "
|
|
|
cb8e9e |
- "iobufs in arena being added is greater than max "
|
|
|
cb8e9e |
- "available", page_size);
|
|
|
cb8e9e |
+ gf_msg ("iobuf", GF_LOG_ERROR, 0, LG_MSG_PAGE_SIZE_EXCEEDED,
|
|
|
cb8e9e |
+ "page_size (%zu) of iobufs in arena being added is "
|
|
|
cb8e9e |
+ "greater than max available", page_size);
|
|
|
cb8e9e |
return NULL;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -570,8 +574,9 @@ __iobuf_get (struct iobuf_arena *iobuf_arena, size_t page_size)
|
|
|
cb8e9e |
if (iobuf_arena->passive_cnt == 0) {
|
|
|
cb8e9e |
index = gf_iobuf_get_arena_index (page_size);
|
|
|
cb8e9e |
if (index == -1) {
|
|
|
cb8e9e |
- gf_log ("iobuf", GF_LOG_ERROR, "page_size (%zu) of "
|
|
|
cb8e9e |
- "iobufs in arena being added is greater "
|
|
|
cb8e9e |
+ gf_msg ("iobuf", GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
+ LG_MSG_PAGE_SIZE_EXCEEDED, "page_size (%zu) of"
|
|
|
cb8e9e |
+ " iobufs in arena being added is greater "
|
|
|
cb8e9e |
"than max available", page_size);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -645,7 +650,7 @@ iobuf_get2 (struct iobuf_pool *iobuf_pool, size_t page_size)
|
|
|
cb8e9e |
memory allocations */
|
|
|
cb8e9e |
iobuf = iobuf_get_from_stdalloc (iobuf_pool, page_size);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- gf_log ("iobuf", GF_LOG_DEBUG, "request for iobuf of size %zu "
|
|
|
cb8e9e |
+ gf_msg_debug ("iobuf", 0, "request for iobuf of size %zu "
|
|
|
cb8e9e |
"is serviced using standard calloc() (%p) as it "
|
|
|
cb8e9e |
"exceeds the maximum available buffer size",
|
|
|
cb8e9e |
page_size, iobuf);
|
|
|
cb8e9e |
@@ -687,14 +692,16 @@ iobuf_get (struct iobuf_pool *iobuf_pool)
|
|
|
cb8e9e |
iobuf_arena = __iobuf_select_arena (iobuf_pool,
|
|
|
cb8e9e |
iobuf_pool->default_page_size);
|
|
|
cb8e9e |
if (!iobuf_arena) {
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_WARNING, "arena not found");
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_ARENA_NOT_FOUND, "arena not found");
|
|
|
cb8e9e |
goto unlock;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
iobuf = __iobuf_get (iobuf_arena,
|
|
|
cb8e9e |
iobuf_pool->default_page_size);
|
|
|
cb8e9e |
if (!iobuf) {
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_WARNING, "iobuf not found");
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_IOBUF_NOT_FOUND, "iobuf not found");
|
|
|
cb8e9e |
goto unlock;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -720,7 +727,7 @@ __iobuf_put (struct iobuf *iobuf, struct iobuf_arena *iobuf_arena)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
index = gf_iobuf_get_arena_index (iobuf_arena->page_size);
|
|
|
cb8e9e |
if (index == -1) {
|
|
|
cb8e9e |
- gf_log ("iobuf", GF_LOG_DEBUG, "freeing the iobuf (%p) "
|
|
|
cb8e9e |
+ gf_msg_debug ("iobuf", 0, "freeing the iobuf (%p) "
|
|
|
cb8e9e |
"allocated with standard calloc()", iobuf);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
/* free up properly without bothering about lists and all */
|
|
|
cb8e9e |
@@ -761,13 +768,15 @@ iobuf_put (struct iobuf *iobuf)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
iobuf_arena = iobuf->iobuf_arena;
|
|
|
cb8e9e |
if (!iobuf_arena) {
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_WARNING, "arena not found");
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_ARENA_NOT_FOUND,
|
|
|
cb8e9e |
+ "arena not found");
|
|
|
cb8e9e |
return;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
iobuf_pool = iobuf_arena->iobuf_pool;
|
|
|
cb8e9e |
if (!iobuf_pool) {
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_WARNING, "iobuf pool not found");
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_POOL_NOT_FOUND, "iobuf pool not found");
|
|
|
cb8e9e |
return;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -1040,12 +1049,14 @@ iobuf_size (struct iobuf *iobuf)
|
|
|
cb8e9e |
GF_VALIDATE_OR_GOTO ("iobuf", iobuf, out);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!iobuf->iobuf_arena) {
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_WARNING, "arena not found");
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_ARENA_NOT_FOUND,
|
|
|
cb8e9e |
+ "arena not found");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!iobuf->iobuf_arena->iobuf_pool) {
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_WARNING, "pool not found");
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_WARNING, 0, LG_MSG_POOL_NOT_FOUND,
|
|
|
cb8e9e |
+ "pool not found");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/libglusterfs/src/latency.c b/libglusterfs/src/latency.c
|
|
|
cb8e9e |
index b22f729..6116159 100644
|
|
|
cb8e9e |
--- a/libglusterfs/src/latency.c
|
|
|
cb8e9e |
+++ b/libglusterfs/src/latency.c
|
|
|
cb8e9e |
@@ -19,7 +19,7 @@
|
|
|
cb8e9e |
#include "xlator.h"
|
|
|
cb8e9e |
#include "common-utils.h"
|
|
|
cb8e9e |
#include "statedump.h"
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
+#include "libglusterfs-messages.h"
|
|
|
cb8e9e |
|
|
|
cb8e9e |
void
|
|
|
cb8e9e |
gf_set_fop_from_fn_pointer (call_frame_t *frame, struct xlator_fops *fops, void *fn)
|
|
|
cb8e9e |
@@ -182,7 +182,8 @@ gf_latency_toggle (int signum, glusterfs_ctx_t *ctx)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
if (ctx) {
|
|
|
cb8e9e |
ctx->measure_latency = !ctx->measure_latency;
|
|
|
cb8e9e |
- gf_log ("[core]", GF_LOG_INFO,
|
|
|
cb8e9e |
+ gf_msg ("[core]", GF_LOG_INFO, 0,
|
|
|
cb8e9e |
+ LG_MSG_LATENCY_MEASUREMENT_STATE,
|
|
|
cb8e9e |
"Latency measurement turned %s",
|
|
|
cb8e9e |
ctx->measure_latency ? "on" : "off");
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
|
|
|
cb8e9e |
index 774dd09..61b986c 100644
|
|
|
cb8e9e |
--- a/libglusterfs/src/logging.c
|
|
|
cb8e9e |
+++ b/libglusterfs/src/logging.c
|
|
|
cb8e9e |
@@ -44,6 +44,7 @@
|
|
|
cb8e9e |
#include "defaults.h"
|
|
|
cb8e9e |
#include "glusterfs.h"
|
|
|
cb8e9e |
#include "timer.h"
|
|
|
cb8e9e |
+#include "libglusterfs-messages.h"
|
|
|
cb8e9e |
|
|
|
cb8e9e |
/* Do not replace gf_log in TEST_LOG with gf_msg, as there is a slight chance
|
|
|
cb8e9e |
* that it could lead to an infinite recursion.*/
|
|
|
cb8e9e |
@@ -381,17 +382,18 @@ gf_log_rotate(glusterfs_ctx_t *ctx)
|
|
|
cb8e9e |
fd = open (ctx->log.filename,
|
|
|
cb8e9e |
O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR);
|
|
|
cb8e9e |
if (fd < 0) {
|
|
|
cb8e9e |
- gf_log ("logrotate", GF_LOG_ERROR,
|
|
|
cb8e9e |
- "%s", strerror (errno));
|
|
|
cb8e9e |
+ gf_msg ("logrotate", GF_LOG_ERROR, errno,
|
|
|
cb8e9e |
+ LG_MSG_FILE_OP_FAILED, "failed to open "
|
|
|
cb8e9e |
+ "logfile");
|
|
|
cb8e9e |
return;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
close (fd);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
new_logfile = fopen (ctx->log.filename, "a");
|
|
|
cb8e9e |
if (!new_logfile) {
|
|
|
cb8e9e |
- gf_log ("logrotate", GF_LOG_CRITICAL,
|
|
|
cb8e9e |
- "failed to open logfile %s (%s)",
|
|
|
cb8e9e |
- ctx->log.filename, strerror (errno));
|
|
|
cb8e9e |
+ gf_msg ("logrotate", GF_LOG_CRITICAL, errno,
|
|
|
cb8e9e |
+ LG_MSG_FILE_OP_FAILED, "failed to open logfile"
|
|
|
cb8e9e |
+ " %s", ctx->log.filename);
|
|
|
cb8e9e |
return;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -2171,17 +2173,19 @@ _gf_log (const char *domain, const char *file, const char *function, int line,
|
|
|
cb8e9e |
fd = open (ctx->log.filename,
|
|
|
cb8e9e |
O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR);
|
|
|
cb8e9e |
if (fd < 0) {
|
|
|
cb8e9e |
- gf_log ("logrotate", GF_LOG_ERROR,
|
|
|
cb8e9e |
- "%s", strerror (errno));
|
|
|
cb8e9e |
+ gf_msg ("logrotate", GF_LOG_ERROR, errno,
|
|
|
cb8e9e |
+ LG_MSG_FILE_OP_FAILED,
|
|
|
cb8e9e |
+ "failed to open logfile");
|
|
|
cb8e9e |
return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
close (fd);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
new_logfile = fopen (ctx->log.filename, "a");
|
|
|
cb8e9e |
if (!new_logfile) {
|
|
|
cb8e9e |
- gf_log ("logrotate", GF_LOG_CRITICAL,
|
|
|
cb8e9e |
- "failed to open logfile %s (%s)",
|
|
|
cb8e9e |
- ctx->log.filename, strerror (errno));
|
|
|
cb8e9e |
+ gf_msg ("logrotate", GF_LOG_CRITICAL, errno,
|
|
|
cb8e9e |
+ LG_MSG_FILE_OP_FAILED,
|
|
|
cb8e9e |
+ "failed to open logfile %s",
|
|
|
cb8e9e |
+ ctx->log.filename);
|
|
|
cb8e9e |
goto log;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -2323,15 +2327,13 @@ gf_cmd_log_init (const char *filename)
|
|
|
cb8e9e |
ctx = this->ctx;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!filename){
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_CRITICAL, "gf_cmd_log_init: no "
|
|
|
cb8e9e |
- "filename specified\n");
|
|
|
cb8e9e |
+ gf_msg (this->name, GF_LOG_CRITICAL, 0, LG_MSG_INVALID_ENTRY,
|
|
|
cb8e9e |
+ "gf_cmd_log_init: no filename specified\n");
|
|
|
cb8e9e |
return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ctx->log.cmd_log_filename = gf_strdup (filename);
|
|
|
cb8e9e |
if (!ctx->log.cmd_log_filename) {
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_CRITICAL,
|
|
|
cb8e9e |
- "gf_cmd_log_init: strdup error\n");
|
|
|
cb8e9e |
return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
/* close and reopen cmdlogfile for log rotate*/
|
|
|
cb8e9e |
@@ -2343,17 +2345,18 @@ gf_cmd_log_init (const char *filename)
|
|
|
cb8e9e |
fd = open (ctx->log.cmd_log_filename,
|
|
|
cb8e9e |
O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR);
|
|
|
cb8e9e |
if (fd < 0) {
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_CRITICAL,
|
|
|
cb8e9e |
- "%s", strerror (errno));
|
|
|
cb8e9e |
+ gf_msg (this->name, GF_LOG_CRITICAL, errno,
|
|
|
cb8e9e |
+ LG_MSG_FILE_OP_FAILED, "failed to open cmd_log_file");
|
|
|
cb8e9e |
return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
close (fd);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ctx->log.cmdlogfile = fopen (ctx->log.cmd_log_filename, "a");
|
|
|
cb8e9e |
if (!ctx->log.cmdlogfile){
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_CRITICAL,
|
|
|
cb8e9e |
+ gf_msg (this->name, GF_LOG_CRITICAL, errno,
|
|
|
cb8e9e |
+ LG_MSG_FILE_OP_FAILED,
|
|
|
cb8e9e |
"gf_cmd_log_init: failed to open logfile \"%s\" "
|
|
|
cb8e9e |
- "(%s)\n", ctx->log.cmd_log_filename, strerror (errno));
|
|
|
cb8e9e |
+ "\n", ctx->log.cmd_log_filename);
|
|
|
cb8e9e |
return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
return 0;
|
|
|
cb8e9e |
@@ -2378,7 +2381,7 @@ gf_cmd_log (const char *domain, const char *fmt, ...)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!domain || !fmt) {
|
|
|
cb8e9e |
- gf_log ("glusterd", GF_LOG_TRACE,
|
|
|
cb8e9e |
+ gf_msg_trace ("glusterd", 0,
|
|
|
cb8e9e |
"logging: invalid argument\n");
|
|
|
cb8e9e |
return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c
|
|
|
cb8e9e |
index 75dce0e..4786a27 100644
|
|
|
cb8e9e |
--- a/libglusterfs/src/options.c
|
|
|
cb8e9e |
+++ b/libglusterfs/src/options.c
|
|
|
cb8e9e |
@@ -17,6 +17,7 @@
|
|
|
cb8e9e |
|
|
|
cb8e9e |
#include "xlator.h"
|
|
|
cb8e9e |
#include "defaults.h"
|
|
|
cb8e9e |
+#include "libglusterfs-messages.h"
|
|
|
cb8e9e |
|
|
|
cb8e9e |
#define GF_OPTION_LIST_EMPTY(_opt) (_opt->value[0] == NULL)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -32,7 +33,8 @@ xlator_option_validate_path (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
snprintf (errstr, 256,
|
|
|
cb8e9e |
"invalid path given '%s'",
|
|
|
cb8e9e |
value);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -42,7 +44,8 @@ xlator_option_validate_path (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
"option %s %s: '%s' is not an "
|
|
|
cb8e9e |
"absolute path name",
|
|
|
cb8e9e |
key, value, value);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -67,7 +70,8 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
snprintf (errstr, 256,
|
|
|
cb8e9e |
"invalid number format \"%s\" in option \"%s\"",
|
|
|
cb8e9e |
value, key);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -76,15 +80,15 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
snprintf (errstr, 256,
|
|
|
cb8e9e |
"invalid number format \"%s\" in option \"%s\"",
|
|
|
cb8e9e |
value, key);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if ((opt->min == 0) && (opt->max == 0) &&
|
|
|
cb8e9e |
(opt->validate == GF_OPT_VALIDATE_BOTH)) {
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_TRACE,
|
|
|
cb8e9e |
- "no range check required for 'option %s %s'",
|
|
|
cb8e9e |
- key, value);
|
|
|
cb8e9e |
+ gf_msg_trace (xl->name, 0, "no range check required for "
|
|
|
cb8e9e |
+ "'option %s %s'", key, value);
|
|
|
cb8e9e |
ret = 0;
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -95,7 +99,8 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
"'%lld' in 'option %s %s' is smaller than "
|
|
|
cb8e9e |
"minimum value '%.0f'", inputll, key,
|
|
|
cb8e9e |
value, opt->min);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
+ LG_MSG_INVALID_ENTRY, "%s", errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
} else if (opt->validate == GF_OPT_VALIDATE_MAX) {
|
|
|
cb8e9e |
@@ -104,7 +109,8 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
"'%lld' in 'option %s %s' is greater than "
|
|
|
cb8e9e |
"maximum value '%.0f'", inputll, key,
|
|
|
cb8e9e |
value, opt->max);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
+ LG_MSG_INVALID_ENTRY, "%s", errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
} else if ((inputll < opt->min) || (inputll > opt->max)) {
|
|
|
cb8e9e |
@@ -112,7 +118,8 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
"'%lld' in 'option %s %s' is out of range "
|
|
|
cb8e9e |
"[%.0f - %.0f]",
|
|
|
cb8e9e |
inputll, key, value, opt->min, opt->max);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_OUT_OF_RANGE, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -137,15 +144,15 @@ xlator_option_validate_sizet (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
snprintf (errstr, 256,
|
|
|
cb8e9e |
"invalid number format \"%s\" in option \"%s\"",
|
|
|
cb8e9e |
value, key);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
ret = -1;
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if ((opt->min == 0) && (opt->max == 0)) {
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_TRACE,
|
|
|
cb8e9e |
- "no range check required for 'option %s %s'",
|
|
|
cb8e9e |
- key, value);
|
|
|
cb8e9e |
+ gf_msg_trace (xl->name, 0, "no range check required for "
|
|
|
cb8e9e |
+ "'option %s %s'", key, value);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -155,13 +162,15 @@ xlator_option_validate_sizet (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
snprintf (errstr, 256, "Cache size %" GF_PRI_SIZET " is out of "
|
|
|
cb8e9e |
"range [%.0f - %.0f]",
|
|
|
cb8e9e |
size, opt->min, opt->max);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_WARNING, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_OUT_OF_RANGE, "%s", errstr);
|
|
|
cb8e9e |
} else {
|
|
|
cb8e9e |
snprintf (errstr, 256,
|
|
|
cb8e9e |
"'%" GF_PRI_SIZET "' in 'option %s %s' "
|
|
|
cb8e9e |
"is out of range [%.0f - %.0f]",
|
|
|
cb8e9e |
size, key, value, opt->min, opt->max);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
+ LG_MSG_OUT_OF_RANGE, "%s", errstr);
|
|
|
cb8e9e |
ret = -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -189,7 +198,8 @@ xlator_option_validate_bool (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
snprintf (errstr, 256,
|
|
|
cb8e9e |
"option %s %s: '%s' is not a valid boolean value",
|
|
|
cb8e9e |
key, value, value);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -227,7 +237,8 @@ xlator_option_validate_xlator (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
snprintf (errstr, 256,
|
|
|
cb8e9e |
"option %s %s: '%s' is not a valid volume name",
|
|
|
cb8e9e |
key, value, value);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -326,7 +337,8 @@ xlator_option_validate_str (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
if (ret) {
|
|
|
cb8e9e |
set_error_str (errstr, sizeof (errstr), opt, key, value);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
if (op_errstr)
|
|
|
cb8e9e |
*op_errstr = gf_strdup (errstr);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -347,7 +359,8 @@ xlator_option_validate_percent (xlator_t *xl, const char *key, const char *value
|
|
|
cb8e9e |
snprintf (errstr, 256,
|
|
|
cb8e9e |
"invalid percent format \"%s\" in \"option %s\"",
|
|
|
cb8e9e |
value, key);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -355,7 +368,8 @@ xlator_option_validate_percent (xlator_t *xl, const char *key, const char *value
|
|
|
cb8e9e |
snprintf (errstr, 256,
|
|
|
cb8e9e |
"'%lf' in 'option %s %s' is out of range [0 - 100]",
|
|
|
cb8e9e |
percent, key, value);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_OUT_OF_RANGE, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -401,7 +415,8 @@ xlator_option_validate_percent_or_sizet (xlator_t *xl, const char *key,
|
|
|
cb8e9e |
"'%lf' in 'option %s %s' is out"
|
|
|
cb8e9e |
" of range [0 - 100]", size, key,
|
|
|
cb8e9e |
value);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
+ LG_MSG_OUT_OF_RANGE, "%s", errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
ret = 0;
|
|
|
cb8e9e |
@@ -415,16 +430,15 @@ xlator_option_validate_percent_or_sizet (xlator_t *xl, const char *key,
|
|
|
cb8e9e |
" %s' should not be fractional value. Use "
|
|
|
cb8e9e |
"valid unsigned integer value.", size, key,
|
|
|
cb8e9e |
value);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
+ LG_MSG_INVALID_ENTRY, "%s", errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
/* Check the range */
|
|
|
cb8e9e |
if ((opt->min == 0) && (opt->max == 0)) {
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_TRACE,
|
|
|
cb8e9e |
- "no range check required for "
|
|
|
cb8e9e |
- "'option %s %s'",
|
|
|
cb8e9e |
- key, value);
|
|
|
cb8e9e |
+ gf_msg_trace (xl->name, 0, "no range check required "
|
|
|
cb8e9e |
+ "for 'option %s %s'", key, value);
|
|
|
cb8e9e |
ret = 0;
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -433,7 +447,8 @@ xlator_option_validate_percent_or_sizet (xlator_t *xl, const char *key,
|
|
|
cb8e9e |
"'%lf' in 'option %s %s'"
|
|
|
cb8e9e |
" is out of range [%.0f - %.0f]",
|
|
|
cb8e9e |
size, key, value, opt->min, opt->max);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_OUT_OF_RANGE,
|
|
|
cb8e9e |
+ "%s", errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
ret = 0;
|
|
|
cb8e9e |
@@ -445,7 +460,7 @@ xlator_option_validate_percent_or_sizet (xlator_t *xl, const char *key,
|
|
|
cb8e9e |
snprintf (errstr, 256,
|
|
|
cb8e9e |
"invalid number format \"%s\" in \"option %s\"",
|
|
|
cb8e9e |
value, key);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", errstr);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
@@ -469,15 +484,14 @@ xlator_option_validate_time (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
"invalid time format \"%s\" in "
|
|
|
cb8e9e |
"\"option %s\"",
|
|
|
cb8e9e |
value, key);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if ((opt->min == 0) && (opt->max == 0)) {
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_TRACE,
|
|
|
cb8e9e |
- "no range check required for "
|
|
|
cb8e9e |
- "'option %s %s'",
|
|
|
cb8e9e |
- key, value);
|
|
|
cb8e9e |
+ gf_msg_trace (xl->name, 0, "no range check required for "
|
|
|
cb8e9e |
+ "'option %s %s'", key, value);
|
|
|
cb8e9e |
ret = 0;
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -488,7 +502,8 @@ xlator_option_validate_time (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
"out of range [%.0f - %.0f]",
|
|
|
cb8e9e |
input_time, key, value,
|
|
|
cb8e9e |
opt->min, opt->max);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_OUT_OF_RANGE, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -513,15 +528,15 @@ xlator_option_validate_double (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
snprintf (errstr, 256,
|
|
|
cb8e9e |
"invalid number format \"%s\" in option \"%s\"",
|
|
|
cb8e9e |
value, key);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if ((opt->min == 0) && (opt->max == 0) &&
|
|
|
cb8e9e |
(opt->validate == GF_OPT_VALIDATE_BOTH)) {
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_TRACE,
|
|
|
cb8e9e |
- "no range check required for 'option %s %s'",
|
|
|
cb8e9e |
- key, value);
|
|
|
cb8e9e |
+ gf_msg_trace (xl->name, 0, "no range check required for "
|
|
|
cb8e9e |
+ "'option %s %s'", key, value);
|
|
|
cb8e9e |
ret = 0;
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -532,7 +547,8 @@ xlator_option_validate_double (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
"'%f' in 'option %s %s' is smaller than "
|
|
|
cb8e9e |
"minimum value '%f'", input, key,
|
|
|
cb8e9e |
value, opt->min);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
+ LG_MSG_INVALID_ENTRY, "%s", errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
} else if (opt->validate == GF_OPT_VALIDATE_MAX) {
|
|
|
cb8e9e |
@@ -541,7 +557,8 @@ xlator_option_validate_double (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
"'%f' in 'option %s %s' is greater than "
|
|
|
cb8e9e |
"maximum value '%f'", input, key,
|
|
|
cb8e9e |
value, opt->max);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
+ LG_MSG_INVALID_ENTRY, "%s", errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
} else if ((input < opt->min) || (input > opt->max)) {
|
|
|
cb8e9e |
@@ -549,7 +566,8 @@ xlator_option_validate_double (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
"'%f' in 'option %s %s' is out of range "
|
|
|
cb8e9e |
"[%f - %f]",
|
|
|
cb8e9e |
input, key, value, opt->min, opt->max);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_OUT_OF_RANGE, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -573,7 +591,8 @@ xlator_option_validate_addr (xlator_t *xl, const char *key, const char *value,
|
|
|
cb8e9e |
"option %s %s: '%s' is not a valid internet-address,"
|
|
|
cb8e9e |
" it does not conform to standards.",
|
|
|
cb8e9e |
key, value, value);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
if (op_errstr)
|
|
|
cb8e9e |
*op_errstr = gf_strdup (errstr);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -613,7 +632,8 @@ out:
|
|
|
cb8e9e |
if (ret) {
|
|
|
cb8e9e |
snprintf (errstr, sizeof (errstr), "option %s %s: '%s' is not "
|
|
|
cb8e9e |
"a valid internet-address-list", key, value, value);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
if (op_errstr)
|
|
|
cb8e9e |
*op_errstr = gf_strdup (errstr);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -652,7 +672,8 @@ out:
|
|
|
cb8e9e |
if (ret) {
|
|
|
cb8e9e |
snprintf (errstr, sizeof (errstr), "option %s %s: '%s' is not "
|
|
|
cb8e9e |
"a valid mount-auth-address", key, value, value);
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s",
|
|
|
cb8e9e |
+ errstr);
|
|
|
cb8e9e |
if (op_errstr)
|
|
|
cb8e9e |
*op_errstr = gf_strdup (errstr);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -678,7 +699,7 @@ gf_validate_size (const char *sizestr, volume_option_t *opt)
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
|
|
|
cb8e9e |
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
|
|
|
cb8e9e |
return ret;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -722,9 +743,9 @@ validate_list_elements (const char *string, volume_option_t *opt,
|
|
|
cb8e9e |
if (!key ||
|
|
|
cb8e9e |
(key_validator && key_validator(key))) {
|
|
|
cb8e9e |
ret = -1;
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_WARNING,
|
|
|
cb8e9e |
- "invalid list '%s', key '%s' not valid.",
|
|
|
cb8e9e |
- string, key);
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_INVALID_ENTRY, "invalid list '%s', key "
|
|
|
cb8e9e |
+ "'%s' not valid.", string, key);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -732,9 +753,9 @@ validate_list_elements (const char *string, volume_option_t *opt,
|
|
|
cb8e9e |
if (!value ||
|
|
|
cb8e9e |
(value_validator && value_validator(value, opt))) {
|
|
|
cb8e9e |
ret = -1;
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_WARNING,
|
|
|
cb8e9e |
- "invalid list '%s', value '%s' not valid.",
|
|
|
cb8e9e |
- string, key);
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_INVALID_ENTRY, "invalid list '%s', "
|
|
|
cb8e9e |
+ "value '%s' not valid.", string, key);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -744,7 +765,7 @@ validate_list_elements (const char *string, volume_option_t *opt,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
GF_FREE (dup_string);
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
|
|
|
cb8e9e |
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
|
|
|
cb8e9e |
return ret;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -836,7 +857,7 @@ xlator_option_validate (xlator_t *xl, char *key, char *value,
|
|
|
cb8e9e |
};
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (opt->type > GF_OPTION_TYPE_MAX) {
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR,
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY,
|
|
|
cb8e9e |
"unknown option type '%d'", opt->type);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -923,17 +944,17 @@ xl_opt_validate (dict_t *dict, char *key, data_t *value, void *data)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = xlator_option_validate (xl, key, value->data, opt, &errstr);
|
|
|
cb8e9e |
if (ret)
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_WARNING, "validate of %s returned %d",
|
|
|
cb8e9e |
- key, ret);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_WARNING, 0, LG_MSG_VALIDATE_RETURNS,
|
|
|
cb8e9e |
+ "validate of %s returned %d", key, ret);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (errstr)
|
|
|
cb8e9e |
/* possible small leak of previously set stub->errstr */
|
|
|
cb8e9e |
stub->errstr = errstr;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (fnmatch (opt->key[0], key, FNM_NOESCAPE) != 0) {
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_WARNING, "option '%s' is deprecated, "
|
|
|
cb8e9e |
- "preferred is '%s', continuing with correction",
|
|
|
cb8e9e |
- key, opt->key[0]);
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_WARNING, 0, LG_MSG_INVALID_ENTRY,
|
|
|
cb8e9e |
+ "option '%s' is deprecated, preferred is '%s', "
|
|
|
cb8e9e |
+ "continuing with correction", key, opt->key[0]);
|
|
|
cb8e9e |
dict_set (dict, opt->key[0], value);
|
|
|
cb8e9e |
dict_del (dict, key);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -975,7 +996,7 @@ xlator_options_validate (xlator_t *xl, dict_t *options, char **op_errstr)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!xl) {
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_DEBUG, "'this' not a valid ptr");
|
|
|
cb8e9e |
+ gf_msg_debug (THIS->name, 0, "'this' not a valid ptr");
|
|
|
cb8e9e |
ret = -1;
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -1005,7 +1026,9 @@ xlator_validate_rec (xlator_t *xlator, char **op_errstr)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
while (trav) {
|
|
|
cb8e9e |
if (xlator_validate_rec (trav->xlator, op_errstr)) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_WARNING, "validate_rec failed");
|
|
|
cb8e9e |
+ gf_msg ("xlator", GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_VALIDATE_REC_FAILED, "validate_rec "
|
|
|
cb8e9e |
+ "failed");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -1013,7 +1036,7 @@ xlator_validate_rec (xlator_t *xlator, char **op_errstr)
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (xlator_dynload (xlator))
|
|
|
cb8e9e |
- gf_log (xlator->name, GF_LOG_DEBUG, "Did not load the symbols");
|
|
|
cb8e9e |
+ gf_msg_debug (xlator->name, 0, "Did not load the symbols");
|
|
|
cb8e9e |
|
|
|
cb8e9e |
old_THIS = THIS;
|
|
|
cb8e9e |
THIS = xlator;
|
|
|
cb8e9e |
@@ -1029,11 +1052,12 @@ xlator_validate_rec (xlator_t *xlator, char **op_errstr)
|
|
|
cb8e9e |
THIS = old_THIS;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (ret) {
|
|
|
cb8e9e |
- gf_log (xlator->name, GF_LOG_INFO, "%s", *op_errstr);
|
|
|
cb8e9e |
+ gf_msg (xlator->name, GF_LOG_INFO, 0, LG_MSG_INVALID_ENTRY,
|
|
|
cb8e9e |
+ "%s", *op_errstr);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- gf_log (xlator->name, GF_LOG_DEBUG, "Validated options");
|
|
|
cb8e9e |
+ gf_msg_debug (xlator->name, 0, "Validated options");
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = 0;
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
@@ -1076,7 +1100,7 @@ xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl)
|
|
|
cb8e9e |
if (ret)
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- gf_log (trav1->xlator->name, GF_LOG_DEBUG, "reconfigured");
|
|
|
cb8e9e |
+ gf_msg_debug (trav1->xlator->name, 0, "reconfigured");
|
|
|
cb8e9e |
|
|
|
cb8e9e |
trav1 = trav1->next;
|
|
|
cb8e9e |
trav2 = trav2->next;
|
|
|
cb8e9e |
@@ -1093,7 +1117,7 @@ xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl)
|
|
|
cb8e9e |
if (ret)
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
} else {
|
|
|
cb8e9e |
- gf_log (old_xl->name, GF_LOG_DEBUG, "No reconfigure() found");
|
|
|
cb8e9e |
+ gf_msg_debug (old_xl->name, 0, "No reconfigure() found");
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = 0;
|
|
|
cb8e9e |
diff --git a/libglusterfs/src/options.h b/libglusterfs/src/options.h
|
|
|
cb8e9e |
index 05a3d43..fa798db 100644
|
|
|
cb8e9e |
--- a/libglusterfs/src/options.h
|
|
|
cb8e9e |
+++ b/libglusterfs/src/options.h
|
|
|
cb8e9e |
@@ -21,6 +21,7 @@
|
|
|
cb8e9e |
#include <inttypes.h>
|
|
|
cb8e9e |
|
|
|
cb8e9e |
#include "xlator.h"
|
|
|
cb8e9e |
+#include "libglusterfs-messages.h"
|
|
|
cb8e9e |
/* Add possible new type of option you may need */
|
|
|
cb8e9e |
typedef enum {
|
|
|
cb8e9e |
GF_OPTION_TYPE_ANY = 0,
|
|
|
cb8e9e |
@@ -133,7 +134,8 @@ xlator_option_init_##type (xlator_t *this, dict_t *options, char *key, \
|
|
|
cb8e9e |
\
|
|
|
cb8e9e |
opt = xlator_volume_option_get (this, key); \
|
|
|
cb8e9e |
if (!opt) { \
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_WARNING, \
|
|
|
cb8e9e |
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL, \
|
|
|
cb8e9e |
+ LG_MSG_INVALID_ENTRY, \
|
|
|
cb8e9e |
"unknown option: %s", key); \
|
|
|
cb8e9e |
ret = -1; \
|
|
|
cb8e9e |
return ret; \
|
|
|
cb8e9e |
@@ -146,27 +148,26 @@ xlator_option_init_##type (xlator_t *this, dict_t *options, char *key, \
|
|
|
cb8e9e |
if (set_value) \
|
|
|
cb8e9e |
value = set_value; \
|
|
|
cb8e9e |
if (!value) { \
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_TRACE, "option %s not set", \
|
|
|
cb8e9e |
+ gf_msg_trace (this->name, 0, "option %s not set", \
|
|
|
cb8e9e |
key); \
|
|
|
cb8e9e |
*val_p = (type_t)0; \
|
|
|
cb8e9e |
return 0; \
|
|
|
cb8e9e |
} \
|
|
|
cb8e9e |
if (value == def_value) { \
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_TRACE, \
|
|
|
cb8e9e |
- "option %s using default value %s", \
|
|
|
cb8e9e |
- key, value); \
|
|
|
cb8e9e |
+ gf_msg_trace (this->name, 0, "option %s using default" \
|
|
|
cb8e9e |
+ " value %s", key, value); \
|
|
|
cb8e9e |
} else { \
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_DEBUG, \
|
|
|
cb8e9e |
- "option %s using set value %s", \
|
|
|
cb8e9e |
- key, value); \
|
|
|
cb8e9e |
+ gf_msg_debug (this->name, 0, "option %s using set" \
|
|
|
cb8e9e |
+ " value %s", key, value); \
|
|
|
cb8e9e |
} \
|
|
|
cb8e9e |
old_THIS = THIS; \
|
|
|
cb8e9e |
THIS = this; \
|
|
|
cb8e9e |
ret = conv (value, val_p); \
|
|
|
cb8e9e |
THIS = old_THIS; \
|
|
|
cb8e9e |
if (ret) { \
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_INFO, \
|
|
|
cb8e9e |
- "option %s convertion failed value %s", \
|
|
|
cb8e9e |
+ gf_msg (this->name, GF_LOG_INFO, 0, \
|
|
|
cb8e9e |
+ LG_MSG_CONVERSION_FAILED, \
|
|
|
cb8e9e |
+ "option %s conversion failed value %s", \
|
|
|
cb8e9e |
key, value); \
|
|
|
cb8e9e |
return ret; \
|
|
|
cb8e9e |
} \
|
|
|
cb8e9e |
@@ -219,7 +220,8 @@ xlator_option_reconf_##type (xlator_t *this, dict_t *options, char *key, \
|
|
|
cb8e9e |
\
|
|
|
cb8e9e |
opt = xlator_volume_option_get (this, key); \
|
|
|
cb8e9e |
if (!opt) { \
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_WARNING, \
|
|
|
cb8e9e |
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL, \
|
|
|
cb8e9e |
+ LG_MSG_INVALID_ENTRY, \
|
|
|
cb8e9e |
"unknown option: %s", key); \
|
|
|
cb8e9e |
ret = -1; \
|
|
|
cb8e9e |
return ret; \
|
|
|
cb8e9e |
@@ -232,17 +234,16 @@ xlator_option_reconf_##type (xlator_t *this, dict_t *options, char *key, \
|
|
|
cb8e9e |
if (set_value) \
|
|
|
cb8e9e |
value = set_value; \
|
|
|
cb8e9e |
if (!value) { \
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_TRACE, "option %s not set", \
|
|
|
cb8e9e |
- key); \
|
|
|
cb8e9e |
+ gf_msg_trace (this->name, 0, "option %s not set", key); \
|
|
|
cb8e9e |
*val_p = (type_t)0; \
|
|
|
cb8e9e |
return 0; \
|
|
|
cb8e9e |
} \
|
|
|
cb8e9e |
if (value == def_value) { \
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_TRACE, \
|
|
|
cb8e9e |
+ gf_msg_trace (this->name, 0, \
|
|
|
cb8e9e |
"option %s using default value %s", \
|
|
|
cb8e9e |
key, value); \
|
|
|
cb8e9e |
} else { \
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_DEBUG, \
|
|
|
cb8e9e |
+ gf_msg_debug (this->name, 0, \
|
|
|
cb8e9e |
"option %s using set value %s", \
|
|
|
cb8e9e |
key, value); \
|
|
|
cb8e9e |
} \
|
|
|
cb8e9e |
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
|
|
|
cb8e9e |
index 628f349..52f96c9 100644
|
|
|
cb8e9e |
--- a/libglusterfs/src/xlator.c
|
|
|
cb8e9e |
+++ b/libglusterfs/src/xlator.c
|
|
|
cb8e9e |
@@ -18,6 +18,7 @@
|
|
|
cb8e9e |
#include <netdb.h>
|
|
|
cb8e9e |
#include <fnmatch.h>
|
|
|
cb8e9e |
#include "defaults.h"
|
|
|
cb8e9e |
+#include "libglusterfs-messages.h"
|
|
|
cb8e9e |
|
|
|
cb8e9e |
#define SET_DEFAULT_FOP(fn) do { \
|
|
|
cb8e9e |
if (!xl->fops->fn) \
|
|
|
cb8e9e |
@@ -34,7 +35,8 @@ static void
|
|
|
cb8e9e |
fill_defaults (xlator_t *xl)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
if (xl == NULL) {
|
|
|
cb8e9e |
- gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
|
|
|
cb8e9e |
+ gf_msg_callingfn ("xlator", GF_LOG_WARNING, EINVAL,
|
|
|
cb8e9e |
+ LG_MSG_INVALID_ARG, "invalid argument");
|
|
|
cb8e9e |
return;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -128,23 +130,23 @@ xlator_volopt_dynload (char *xlator_type, void **dl_handle,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, xlator_type);
|
|
|
cb8e9e |
if (-1 == ret) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_ERROR, "asprintf failed");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = -1;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_TRACE, "attempt to load file %s", name);
|
|
|
cb8e9e |
+ gf_msg_trace ("xlator", 0, "attempt to load file %s", name);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
handle = dlopen (name, RTLD_NOW|RTLD_GLOBAL);
|
|
|
cb8e9e |
if (!handle) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_WARNING, "%s", dlerror ());
|
|
|
cb8e9e |
+ gf_msg ("xlator", GF_LOG_WARNING, 0, LG_MSG_DLOPEN_FAILED,
|
|
|
cb8e9e |
+ "%s", dlerror ());
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!(opt_list->given_opt = dlsym (handle, "options"))) {
|
|
|
cb8e9e |
dlerror ();
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_ERROR,
|
|
|
cb8e9e |
+ gf_msg ("xlator", GF_LOG_ERROR, 0, LG_MSG_LOAD_FAILED,
|
|
|
cb8e9e |
"Failed to load xlator opt table");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -158,7 +160,7 @@ xlator_volopt_dynload (char *xlator_type, void **dl_handle,
|
|
|
cb8e9e |
if (handle)
|
|
|
cb8e9e |
dlclose (handle);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_DEBUG, "Returning %d", ret);
|
|
|
cb8e9e |
+ gf_msg_debug ("xlator", 0, "Returning %d", ret);
|
|
|
cb8e9e |
return ret;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -179,30 +181,30 @@ xlator_dynload (xlator_t *xl)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, xl->type);
|
|
|
cb8e9e |
if (-1 == ret) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_ERROR, "asprintf failed");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = -1;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_TRACE, "attempt to load file %s", name);
|
|
|
cb8e9e |
+ gf_msg_trace ("xlator", 0, "attempt to load file %s", name);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
handle = dlopen (name, RTLD_NOW|RTLD_GLOBAL);
|
|
|
cb8e9e |
if (!handle) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_WARNING, "%s", dlerror ());
|
|
|
cb8e9e |
+ gf_msg ("xlator", GF_LOG_WARNING, 0, LG_MSG_DLOPEN_FAILED,
|
|
|
cb8e9e |
+ "%s", dlerror ());
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
xl->dlhandle = handle;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!(xl->fops = dlsym (handle, "fops"))) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_WARNING, "dlsym(fops) on %s",
|
|
|
cb8e9e |
- dlerror ());
|
|
|
cb8e9e |
+ gf_msg ("xlator", GF_LOG_WARNING, 0, LG_MSG_DLSYM_ERROR,
|
|
|
cb8e9e |
+ "dlsym(fops) on %s", dlerror ());
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!(xl->cbks = dlsym (handle, "cbks"))) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_WARNING, "dlsym(cbks) on %s",
|
|
|
cb8e9e |
- dlerror ());
|
|
|
cb8e9e |
+ gf_msg ("xlator", GF_LOG_WARNING, 0, LG_MSG_DLSYM_ERROR,
|
|
|
cb8e9e |
+ "dlsym(cbks) on %s", dlerror ());
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -220,39 +222,38 @@ xlator_dynload (xlator_t *xl)
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
else {
|
|
|
cb8e9e |
if (!(*VOID(&xl->init) = dlsym (handle, "init"))) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_WARNING, "dlsym(init) on %s",
|
|
|
cb8e9e |
+ gf_msg ("xlator", GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_DLSYM_ERROR, "dlsym(init) on %s",
|
|
|
cb8e9e |
dlerror ());
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!(*VOID(&(xl->fini)) = dlsym (handle, "fini"))) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_WARNING, "dlsym(fini) on %s",
|
|
|
cb8e9e |
+ gf_msg ("xlator", GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_DLSYM_ERROR, "dlsym(fini) on %s",
|
|
|
cb8e9e |
dlerror ());
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
if (!(*VOID(&(xl->reconfigure)) = dlsym (handle,
|
|
|
cb8e9e |
"reconfigure"))) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_TRACE,
|
|
|
cb8e9e |
- "dlsym(reconfigure) on %s -- neglecting",
|
|
|
cb8e9e |
- dlerror());
|
|
|
cb8e9e |
+ gf_msg_trace ("xlator", 0, "dlsym(reconfigure) on %s "
|
|
|
cb8e9e |
+ "-- neglecting", dlerror());
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
if (!(*VOID(&(xl->notify)) = dlsym (handle, "notify"))) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_TRACE,
|
|
|
cb8e9e |
- "dlsym(notify) on %s -- neglecting",
|
|
|
cb8e9e |
- dlerror ());
|
|
|
cb8e9e |
+ gf_msg_trace ("xlator", 0, "dlsym(notify) on %s -- "
|
|
|
cb8e9e |
+ "neglecting", dlerror ());
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!(xl->dumpops = dlsym (handle, "dumpops"))) {
|
|
|
cb8e9e |
- gf_log ("xlator", GF_LOG_TRACE,
|
|
|
cb8e9e |
- "dlsym(dumpops) on %s -- neglecting", dlerror ());
|
|
|
cb8e9e |
+ gf_msg_trace ("xlator", 0, "dlsym(dumpops) on %s -- "
|
|
|
cb8e9e |
+ "neglecting", dlerror ());
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!(*VOID(&(xl->mem_acct_init)) = dlsym (handle, "mem_acct_init"))) {
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_TRACE,
|
|
|
cb8e9e |
- "dlsym(mem_acct_init) on %s -- neglecting",
|
|
|
cb8e9e |
- dlerror ());
|
|
|
cb8e9e |
+ gf_msg_trace (xl->name, 0, "dlsym(mem_acct_init) on %s -- "
|
|
|
cb8e9e |
+ "neglecting", dlerror ());
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t),
|
|
|
cb8e9e |
@@ -264,8 +265,8 @@ xlator_dynload (xlator_t *xl)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!(vol_opt->given_opt = dlsym (handle, "options"))) {
|
|
|
cb8e9e |
dlerror ();
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_TRACE,
|
|
|
cb8e9e |
- "Strict option validation not enforced -- neglecting");
|
|
|
cb8e9e |
+ gf_msg_trace (xl->name, 0, "Strict option validation not "
|
|
|
cb8e9e |
+ "enforced -- neglecting");
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
INIT_LIST_HEAD (&vol_opt->list);
|
|
|
cb8e9e |
list_add_tail (&vol_opt->list, &xl->volume_options);
|
|
|
cb8e9e |
@@ -299,8 +300,9 @@ xlator_set_inode_lru_limit (xlator_t *this, void *data)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (this->itable) {
|
|
|
cb8e9e |
if (!data) {
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_WARNING, "input data is "
|
|
|
cb8e9e |
- "NULL. Cannot update the lru limit of the inode"
|
|
|
cb8e9e |
+ gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ LG_MSG_INVALID_ENTRY, "input data is NULL. "
|
|
|
cb8e9e |
+ "Cannot update the lru limit of the inode"
|
|
|
cb8e9e |
" table. Continuing with older value");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -413,17 +415,17 @@ xlator_init (xlator_t *xl)
|
|
|
cb8e9e |
xl->mem_acct_init (xl);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!xl->init) {
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_WARNING, "No init() found");
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_WARNING, 0, LG_MSG_INIT_FAILED,
|
|
|
cb8e9e |
+ "No init() found");
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = __xlator_init (xl);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (ret) {
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_ERROR,
|
|
|
cb8e9e |
+ gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR,
|
|
|
cb8e9e |
"Initialization of volume '%s' failed,"
|
|
|
cb8e9e |
- " review your volfile again",
|
|
|
cb8e9e |
- xl->name);
|
|
|
cb8e9e |
+ " review your volfile again", xl->name);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -451,7 +453,7 @@ xlator_fini_rec (xlator_t *xl)
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
xlator_fini_rec (trav->xlator);
|
|
|
cb8e9e |
- gf_log (trav->xlator->name, GF_LOG_DEBUG, "fini done");
|
|
|
cb8e9e |
+ gf_msg_debug (trav->xlator->name, 0, "fini done");
|
|
|
cb8e9e |
trav = trav->next;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -467,7 +469,7 @@ xlator_fini_rec (xlator_t *xl)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
THIS = old_THIS;
|
|
|
cb8e9e |
} else {
|
|
|
cb8e9e |
- gf_log (xl->name, GF_LOG_DEBUG, "No fini() found");
|
|
|
cb8e9e |
+ gf_msg_debug (xl->name, 0, "No fini() found");
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
xl->init_succeeded = 0;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
@@ -646,7 +648,8 @@ xlator_tree_free_members (xlator_t *tree)
|
|
|
cb8e9e |
xlator_t *prev = tree;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!tree) {
|
|
|
cb8e9e |
- gf_log ("parser", GF_LOG_ERROR, "Translator tree not found");
|
|
|
cb8e9e |
+ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_TREE_NOT_FOUND,
|
|
|
cb8e9e |
+ "Translator tree not found");
|
|
|
cb8e9e |
return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -666,7 +669,8 @@ xlator_tree_free_memacct (xlator_t *tree)
|
|
|
cb8e9e |
xlator_t *prev = tree;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (!tree) {
|
|
|
cb8e9e |
- gf_log ("parser", GF_LOG_ERROR, "Translator tree not found");
|
|
|
cb8e9e |
+ gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_TREE_NOT_FOUND,
|
|
|
cb8e9e |
+ "Translator tree not found");
|
|
|
cb8e9e |
return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -1042,8 +1046,9 @@ glusterd_check_log_level (const char *value)
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (log_level == -1)
|
|
|
cb8e9e |
- gf_log (THIS->name, GF_LOG_ERROR, "Invalid log-level. possible values "
|
|
|
cb8e9e |
- "are DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE");
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_ERROR, 0, LG_MSG_INIT_FAILED,
|
|
|
cb8e9e |
+ "Invalid log-level. possible values are "
|
|
|
cb8e9e |
+ "DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE");
|
|
|
cb8e9e |
|
|
|
cb8e9e |
return log_level;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
--
|
|
|
cb8e9e |
1.7.1
|
|
|
cb8e9e |
|