summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/client_t.c10
-rw-r--r--libglusterfs/src/libglusterfs-messages.h6
-rw-r--r--libglusterfs/src/mem-pool.c36
-rw-r--r--libglusterfs/src/stack.c11
-rw-r--r--libglusterfs/src/stack.h14
-rw-r--r--libglusterfs/src/store.c138
-rw-r--r--libglusterfs/src/syncop-utils.c21
-rw-r--r--libglusterfs/src/syncop.c91
-rw-r--r--libglusterfs/src/timer.c29
9 files changed, 201 insertions, 155 deletions
diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c
index 1b7d0caafc9..4f51de9d885 100644
--- a/libglusterfs/src/client_t.c
+++ b/libglusterfs/src/client_t.c
@@ -590,7 +590,7 @@ clienttable_dump (clienttable_t *clienttable, char *prefix)
{
if (ret) {
gf_msg ("client_t", GF_LOG_WARNING, 0,
- LG_MSG_LOCK_GAIN_FAILED,
+ LG_MSG_LOCK_FAILED,
"Unable to acquire lock");
return;
}
@@ -688,7 +688,7 @@ gf_client_dump_fdtables_to_dict (xlator_t *this, dict_t *dict)
{
if (ret) {
gf_msg ("client_t", GF_LOG_WARNING, 0,
- LG_MSG_LOCK_GAIN_FAILED,
+ LG_MSG_LOCK_FAILED,
"Unable to acquire lock");
return -1;
}
@@ -731,7 +731,7 @@ gf_client_dump_fdtables (xlator_t *this)
{
if (ret) {
gf_msg ("client_t", GF_LOG_WARNING, 0,
- LG_MSG_LOCK_GAIN_FAILED,
+ LG_MSG_LOCK_FAILED,
"Unable to acquire lock");
return -1;
}
@@ -797,7 +797,7 @@ gf_client_dump_inodes_to_dict (xlator_t *this, dict_t *dict)
{
if (ret) {
gf_msg ("client_t", GF_LOG_WARNING, 0,
- LG_MSG_LOCK_GAIN_FAILED,
+ LG_MSG_LOCK_FAILED,
"Unable to acquire lock");
return -1;
}
@@ -859,7 +859,7 @@ gf_client_dump_inodes (xlator_t *this)
{
if (ret) {
gf_msg ("client_t", GF_LOG_WARNING, 0,
- LG_MSG_LOCK_GAIN_FAILED,
+ LG_MSG_LOCK_FAILED,
"Unable to acquire lock");
goto out;
}
diff --git a/libglusterfs/src/libglusterfs-messages.h b/libglusterfs/src/libglusterfs-messages.h
index 8b8af36ad3c..25cca8bac3e 100644
--- a/libglusterfs/src/libglusterfs-messages.h
+++ b/libglusterfs/src/libglusterfs-messages.h
@@ -145,7 +145,7 @@
* @recommendedaction
*
*/
-#define LG_MSG_LOCK_GAIN_FAILED (GLFS_LG_BASE + 14)
+#define LG_MSG_LOCK_FAILED (GLFS_LG_BASE + 14)
/*!
* @messageid
@@ -153,7 +153,7 @@
* @recommendedaction
*
*/
-#define LG_MSG_LOCK_RELEASE_FAILED (GLFS_LG_BASE + 15)
+#define LG_MSG_UNLOCK_FAILED (GLFS_LG_BASE + 15)
/*!
* @messageid
@@ -1198,7 +1198,7 @@
*
*/
-#define LG_MSG_SWAP_FAILED (GLFS_LG_BASE + 137)
+#define LG_MSG_SWAPCONTEXT_FAILED (GLFS_LG_BASE + 137)
/*!
* @messageid
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index 7d95364c4b2..1ed1aba6c2d 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -25,6 +25,7 @@
#define GLUSTERFS_ENV_MEM_ACCT_STR "GLUSTERFS_DISABLE_MEM_ACCT"
#include "unittest/unittest.h"
+#include "libglusterfs-messages.h"
void
gf_mem_acct_enable_set (void *data)
@@ -350,7 +351,8 @@ mem_pool_new_fn (unsigned long sizeof_type,
glusterfs_ctx_t *ctx = NULL;
if (!sizeof_type || !count) {
- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return NULL;
}
padded_sizeof_type = sizeof_type + GF_MEM_POOL_PAD_BOUNDARY;
@@ -411,7 +413,8 @@ mem_get0 (struct mem_pool *mem_pool)
void *ptr = NULL;
if (!mem_pool) {
- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return NULL;
}
@@ -432,7 +435,8 @@ mem_get (struct mem_pool *mem_pool)
struct mem_pool **pool_ptr = NULL;
if (!mem_pool) {
- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return NULL;
}
@@ -503,7 +507,8 @@ static int
__is_member (struct mem_pool *pool, void *ptr)
{
if (!pool || !ptr) {
- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return -1;
}
@@ -528,21 +533,24 @@ mem_put (void *ptr)
struct mem_pool *pool = NULL;
if (!ptr) {
- gf_log_callingfn ("mem-pool", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return;
}
list = head = mem_pool_ptr2chunkhead (ptr);
tmp = mem_pool_from_ptr (head);
if (!tmp) {
- gf_log_callingfn ("mem-pool", GF_LOG_ERROR,
+ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, 0,
+ LG_MSG_PTR_HEADER_CORRUPTED,
"ptr header is corrupted");
return;
}
pool = *tmp;
if (!pool) {
- gf_log_callingfn ("mem-pool", GF_LOG_ERROR,
+ gf_msg_callingfn ("mem-pool", GF_LOG_ERROR, 0,
+ LG_MSG_MEMPOOL_PTR_NULL,
"mem-pool ptr is NULL");
return;
}
@@ -555,9 +563,12 @@ mem_put (void *ptr)
in_use = (head + GF_MEM_POOL_LIST_BOUNDARY +
GF_MEM_POOL_PTR);
if (!is_mem_chunk_in_use(in_use)) {
- gf_log_callingfn ("mem-pool", GF_LOG_CRITICAL,
- "mem_put called on freed ptr %p of mem "
- "pool %p", ptr, pool);
+ gf_msg_callingfn ("mem-pool", GF_LOG_CRITICAL,
+ 0,
+ LG_MSG_MEMPOOL_INVALID_FREE,
+ "mem_put called on freed ptr"
+ " %p of mem pool %p", ptr,
+ pool);
break;
}
pool->hot_count--;
@@ -600,8 +611,9 @@ mem_pool_destroy (struct mem_pool *pool)
if (!pool)
return;
- gf_log (THIS->name, GF_LOG_INFO, "size=%lu max=%d total=%"PRIu64,
- pool->padded_sizeof_type, pool->max_alloc, pool->alloc_count);
+ gf_msg (THIS->name, GF_LOG_INFO, 0, LG_MSG_MEM_POOL_DESTROY, "size=%lu "
+ "max=%d total=%"PRIu64, pool->padded_sizeof_type,
+ pool->max_alloc, pool->alloc_count);
list_del (&pool->global_list);
diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c
index 2488cc7f0ba..6977814ec69 100644
--- a/libglusterfs/src/stack.c
+++ b/libglusterfs/src/stack.c
@@ -10,6 +10,7 @@
#include "statedump.h"
#include "stack.h"
+#include "libglusterfs-messages.h"
call_frame_t *
create_frame (xlator_t *xl, call_pool_t *pool)
@@ -44,8 +45,9 @@ create_frame (xlator_t *xl, call_pool_t *pool)
if (stack->ctx->measure_latency) {
if (gettimeofday (&stack->tv, NULL) == -1)
- gf_log ("stack", GF_LOG_ERROR, "gettimeofday () failed."
- " (%s)", strerror (errno));
+ gf_msg ("stack", GF_LOG_ERROR, errno,
+ LG_MSG_GETTIMEOFDAY_FAILED,
+ "gettimeofday () failed");
memcpy (&frame->begin, &stack->tv, sizeof (stack->tv));
}
@@ -388,8 +390,9 @@ gf_proc_dump_pending_frames_to_dict (call_pool_t *call_pool, dict_t *dict)
ret = TRY_LOCK (&call_pool->lock);
if (ret) {
- gf_log (THIS->name, GF_LOG_WARNING, "Unable to dump call pool"
- " to dict. errno: %d", errno);
+ gf_msg (THIS->name, GF_LOG_WARNING, errno,
+ LG_MSG_LOCK_FAILURE, "Unable to dump call "
+ "pool to dict.");
return;
}
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h
index ffe5c1a1085..5c0655f2ead 100644
--- a/libglusterfs/src/stack.h
+++ b/libglusterfs/src/stack.h
@@ -32,6 +32,7 @@ typedef struct call_pool call_pool_t;
#include "globals.h"
#include "lkowner.h"
#include "client_t.h"
+#include "libglusterfs-messages.h"
#define NFS_PID 1
#define LOW_PRIO_PROC_PID -1
@@ -236,7 +237,6 @@ STACK_RESET (call_stack_t *stack)
\
_new = mem_get0 (frame->root->pool->frame_mem_pool); \
if (!_new) { \
- gf_log ("stack", GF_LOG_ERROR, "alloc failed"); \
break; \
} \
typeof(fn##_cbk) tmp_cbk = rfn; \
@@ -287,7 +287,6 @@ STACK_RESET (call_stack_t *stack)
\
_new = mem_get0 (frame->root->pool->frame_mem_pool); \
if (!_new) { \
- gf_log ("stack", GF_LOG_ERROR, "alloc failed"); \
break; \
} \
typeof(fn##_cbk) tmp_cbk = rfn; \
@@ -323,7 +322,8 @@ STACK_RESET (call_stack_t *stack)
call_frame_t *_parent = NULL; \
xlator_t *old_THIS = NULL; \
if (!frame) { \
- gf_log ("stack", GF_LOG_CRITICAL, "!frame"); \
+ gf_msg ("stack", GF_LOG_CRITICAL, 0, \
+ LG_MSG_FRAME_ERROR, "!frame"); \
break; \
} \
fn = frame->ret; \
@@ -352,7 +352,8 @@ STACK_RESET (call_stack_t *stack)
xlator_t *old_THIS = NULL; \
\
if (!frame) { \
- gf_log ("stack", GF_LOG_CRITICAL, "!frame"); \
+ gf_msg ("stack", GF_LOG_CRITICAL, 0, \
+ LG_MSG_FRAME_ERROR, "!frame"); \
break; \
} \
fn = (fop_##op##_cbk_t )frame->ret; \
@@ -456,8 +457,9 @@ copy_frame (call_frame_t *frame)
if (newstack->ctx->measure_latency) {
if (gettimeofday (&newstack->tv, NULL) == -1)
- gf_log ("stack", GF_LOG_ERROR, "gettimeofday () failed."
- " (%s)", strerror (errno));
+ gf_msg ("stack", GF_LOG_ERROR, errno,
+ LG_MSG_GETTIMEOFDAY_FAILED,
+ "gettimeofday () failed.");
memcpy (&newframe->begin, &newstack->tv,
sizeof (newstack->tv));
}
diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c
index 42d2d75d8aa..84a9df81fd7 100644
--- a/libglusterfs/src/store.c
+++ b/libglusterfs/src/store.c
@@ -15,7 +15,7 @@
#include "store.h"
#include "dict.h"
#include "xlator.h"
-
+#include "libglusterfs-messages.h"
int32_t
gf_store_mkdir (char *path)
{
@@ -24,8 +24,8 @@ gf_store_mkdir (char *path)
ret = mkdir (path, 0777);
if ((-1 == ret) && (EEXIST != errno)) {
- gf_log ("", GF_LOG_ERROR, "mkdir() failed on path %s,"
- "errno: %s", path, strerror (errno));
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_DIR_OP_FAILED, "mkdir()"
+ " failed on path %s.", path);
} else {
ret = 0;
}
@@ -44,8 +44,9 @@ gf_store_handle_create_on_absence (gf_store_handle_t **shandle,
ret = gf_store_handle_new (path, shandle);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to create store"
- " handle for path: %s", path);
+ gf_msg ("", GF_LOG_ERROR, 0,
+ LG_MSG_STORE_HANDLE_CREATE_FAILED, "Unable to"
+ " create store handle for path: %s", path);
}
}
return ret;
@@ -62,8 +63,8 @@ gf_store_mkstemp (gf_store_handle_t *shandle)
snprintf (tmppath, sizeof (tmppath), "%s.tmp", shandle->path);
shandle->tmp_fd = open (tmppath, O_RDWR | O_CREAT | O_TRUNC, 0600);
if (shandle->tmp_fd < 0) {
- gf_log ("", GF_LOG_ERROR, "Failed to open %s, error: %s",
- tmppath, strerror (errno));
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
+ "Failed to open %s.", tmppath);
}
out:
return shandle->tmp_fd;
@@ -87,15 +88,15 @@ gf_store_sync_direntry (char *path)
pdir = dirname (dir);
dirfd = open (pdir, O_RDONLY);
if (dirfd == -1) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to open directory "
- "%s, due to %s", pdir, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno, LG_MSG_DIR_OP_FAILED,
+ "Failed to open directory %s.", pdir);
goto out;
}
ret = fsync (dirfd);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to fsync %s, due to "
- "%s", pdir, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ LG_MSG_DIR_OP_FAILED, "Failed to fsync %s.", pdir);
goto out;
}
@@ -104,8 +105,8 @@ out:
if (dirfd >= 0) {
ret = close (dirfd);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to close "
- "%s, due to %s", pdir, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ LG_MSG_DIR_OP_FAILED, "Failed to close %s", pdir);
}
}
@@ -126,15 +127,16 @@ gf_store_rename_tmppath (gf_store_handle_t *shandle)
ret = fsync (shandle->tmp_fd);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to fsync %s, "
- "error: %s", shandle->path, strerror (errno));
+ gf_msg (THIS->name, GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
+ "Failed to fsync %s", shandle->path);
goto out;
}
snprintf (tmppath, sizeof (tmppath), "%s.tmp", shandle->path);
ret = rename (tmppath, shandle->path);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to rename %s to %s, "
- "error: %s", tmppath, shandle->path, strerror (errno));
+ gf_msg (THIS->name, GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
+ "Failed to rename %s to %s", tmppath,
+ shandle->path);
goto out;
}
@@ -159,8 +161,9 @@ gf_store_unlink_tmppath (gf_store_handle_t *shandle)
snprintf (tmppath, sizeof (tmppath), "%s.tmp", shandle->path);
ret = unlink (tmppath);
if (ret && (errno != ENOENT)) {
- gf_log ("", GF_LOG_ERROR, "Failed to mv %s to %s, error: %s",
- tmppath, shandle->path, strerror (errno));
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
+ "Failed to mv %s to %s", tmppath,
+ shandle->path);
} else {
ret = 0;
}
@@ -243,8 +246,8 @@ gf_store_retrieve_value (gf_store_handle_t *handle, char *key, char **value)
lseek (handle->fd, 0, SEEK_SET);
if (handle->fd == -1) {
- gf_log ("", GF_LOG_ERROR, "Unable to open file %s errno: %s",
- handle->path, strerror (errno));
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
+ "Unable to open file %s", handle->path);
goto out;
}
if (!handle->read)
@@ -253,15 +256,15 @@ gf_store_retrieve_value (gf_store_handle_t *handle, char *key, char **value)
fseek (handle->read, 0, SEEK_SET);
if (!handle->read) {
- gf_log ("", GF_LOG_ERROR, "Unable to open file %s errno: %s",
- handle->path, strerror (errno));
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
+ "Unable to open file %s", handle->path);
goto out;
}
ret = fstat (handle->fd, &st);
if (ret < 0) {
- gf_log ("", GF_LOG_WARNING, "stat on file %s failed",
- handle->path);
+ gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
+ "stat on file %s failed", handle->path);
ret = -1;
store_errno = GD_STORE_STAT_FAILED;
goto out;
@@ -287,16 +290,16 @@ gf_store_retrieve_value (gf_store_handle_t *handle, char *key, char **value)
&iter_key, &iter_val,
&store_errno);
if (ret < 0) {
- gf_log ("", GF_LOG_TRACE, "error while reading key "
- "'%s': %s", key,
- gf_store_strerror (store_errno));
+ gf_msg_trace ("", 0, "error while reading key '%s': "
+ "%s", key,
+ gf_store_strerror (store_errno));
goto out;
}
- gf_log ("", GF_LOG_TRACE, "key %s read", iter_key);
+ gf_msg_trace ("", 0, "key %s read", iter_key);
if (!strcmp (key, iter_key)) {
- gf_log ("", GF_LOG_DEBUG, "key %s found", key);
+ gf_msg_debug ("", 0, "key %s found", key);
ret = 0;
if (iter_val)
*value = gf_strdup (iter_val);
@@ -336,25 +339,25 @@ gf_store_save_value (int fd, char *key, char *value)
fp = fdopen (dup_fd, "a+");
if (fp == NULL) {
- gf_log ("", GF_LOG_WARNING, "fdopen failed.");
+ gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED, "fdopen "
+ "failed.");
ret = -1;
goto out;
}
ret = fprintf (fp, "%s=%s\n", key, value);
if (ret < 0) {
- gf_log ("", GF_LOG_WARNING, "Unable to store key: %s,"
- "value: %s, error: %s", key, value,
- strerror (errno));
+ gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
+ "Unable to store key: %s, value: %s.",
+ key, value);
ret = -1;
goto out;
}
ret = fflush (fp);
if (feof (fp)) {
- gf_log ("", GF_LOG_WARNING,
- "fflush failed, error: %s",
- strerror (errno));
+ gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
+ "fflush failed.");
ret = -1;
goto out;
}
@@ -364,7 +367,7 @@ out:
if (fp)
fclose (fp);
- gf_log ("", GF_LOG_DEBUG, "returning: %d", ret);
+ gf_msg_debug ("", 0, "returning: %d", ret);
return ret;
}
@@ -386,8 +389,8 @@ gf_store_handle_new (const char *path, gf_store_handle_t **handle)
fd = open (path, O_RDWR | O_CREAT | O_APPEND, 0600);
if (fd < 0) {
- gf_log ("", GF_LOG_ERROR, "Failed to open file: %s, error: %s",
- path, strerror (errno));
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
+ "Failed to open file: %s.", path);
goto out;
}
@@ -410,7 +413,7 @@ out:
GF_FREE (shandle);
}
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("", 0, "Returning %d", ret);
return ret;
}
@@ -422,14 +425,13 @@ gf_store_handle_retrieve (char *path, gf_store_handle_t **handle)
ret = stat (path, &statbuf);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Path corresponding to "
- "%s, returned error: (%s)",
- path, strerror (errno));
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_PATH_NOT_FOUND, "Path "
+ "corresponding to %s.", path);
goto out;
}
ret = gf_store_handle_new (path, handle);
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("", 0, "Returning %d", ret);
return ret;
}
@@ -450,7 +452,7 @@ gf_store_handle_destroy (gf_store_handle_t *handle)
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("", 0, "Returning %d", ret);
return ret;
}
@@ -467,8 +469,8 @@ gf_store_iter_new (gf_store_handle_t *shandle, gf_store_iter_t **iter)
fp = fopen (shandle->path, "r");
if (!fp) {
- gf_log ("", GF_LOG_ERROR, "Unable to open file %s errno: %d",
- shandle->path, errno);
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
+ "Unable to open file %s", shandle->path);
goto out;
}
@@ -491,7 +493,7 @@ out:
GF_FREE (tmp_iter);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("", 0, "Returning with %d", ret);
return ret;
}
@@ -506,19 +508,21 @@ gf_store_validate_key_value (char *storepath, char *key, char *val,
if ((key == NULL) && (val == NULL)) {
ret = -1;
- gf_log ("", GF_LOG_ERROR, "Glusterd store may be corrupted, "
- "Invalid key and value (null) in %s", storepath);
+ gf_msg ("", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "Glusterd "
+ "store may be corrupted, Invalid key and value (null)"
+ " in %s", storepath);
*op_errno = GD_STORE_KEY_VALUE_NULL;
} else if (key == NULL) {
ret = -1;
- gf_log ("", GF_LOG_ERROR, "Glusterd store may be corrupted, "
- "Invalid key (null) in %s", storepath);
+ gf_msg ("", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "Glusterd "
+ "store may be corrupted, Invalid key (null) in %s",
+ storepath);
*op_errno = GD_STORE_KEY_NULL;
} else if (val == NULL) {
ret = -1;
- gf_log ("", GF_LOG_ERROR, "Glusterd store may be corrupted, "
- "Invalid value (null) for key %s in %s", key,
- storepath);
+ gf_msg ("", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "Glusterd "
+ "store may be corrupted, Invalid value (null) for key"
+ " %s in %s", key, storepath);
*op_errno = GD_STORE_VALUE_NULL;
} else {
ret = 0;
@@ -545,7 +549,8 @@ gf_store_iter_get_next (gf_store_iter_t *iter, char **key, char **value,
ret = stat (iter->filepath, &st);
if (ret < 0) {
- gf_log ("", GF_LOG_WARNING, "stat on file failed");
+ gf_msg ("", GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
+ "stat on file failed");
ret = -1;
store_errno = GD_STORE_STAT_FAILED;
goto out;
@@ -600,7 +605,7 @@ out:
if (op_errno)
*op_errno = store_errno;
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("", 0, "Returning with %d", ret);
return ret;
}
@@ -641,8 +646,9 @@ gf_store_iter_destroy (gf_store_iter_t *iter)
* being NULL*/
ret = fclose (iter->file);
if (ret)
- gf_log ("", GF_LOG_ERROR, "Unable to close file: %s, ret: %d, "
- "errno: %d" ,iter->filepath, ret, errno);
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, "Unable"
+ " to close file: %s, ret: %d" ,
+ iter->filepath, ret);
GF_FREE (iter);
return ret;
@@ -680,15 +686,15 @@ gf_store_lock (gf_store_handle_t *sh)
sh->fd = open (sh->path, O_RDWR);
if (sh->fd == -1) {
- gf_log ("", GF_LOG_ERROR, "Failed to open '%s': %s", sh->path,
- strerror (errno));
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
+ "Failed to open '%s'", sh->path);
return -1;
}
ret = lockf (sh->fd, F_LOCK, 0);
if (ret)
- gf_log ("", GF_LOG_ERROR, "Failed to gain lock on '%s': %s",
- sh->path, strerror (errno));
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_LOCK_FAILED,
+ "Failed to gain lock on '%s'", sh->path);
else
/* sh->locked is protected by the lockf(sh->fd) above */
sh->locked = F_LOCK;
@@ -706,8 +712,8 @@ gf_store_unlock (gf_store_handle_t *sh)
/* does not matter if this fails, locks are released on close anyway */
if (lockf (sh->fd, F_ULOCK, 0) == -1)
- gf_log ("", GF_LOG_ERROR, "Failed to release lock on '%s': %s",
- sh->path, strerror (errno));
+ gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_UNLOCK_FAILED,
+ "Failed to release lock on '%s'", sh->path);
close (sh->fd);
}
diff --git a/libglusterfs/src/syncop-utils.c b/libglusterfs/src/syncop-utils.c
index 81393136abb..ce60ef0c153 100644
--- a/libglusterfs/src/syncop-utils.c
+++ b/libglusterfs/src/syncop-utils.c
@@ -10,6 +10,7 @@
#include "syncop.h"
#include "common-utils.h"
+#include "libglusterfs-messages.h"
int
syncop_dirfd (xlator_t *subvol, loc_t *loc, fd_t **fd, int pid)
@@ -22,9 +23,9 @@ syncop_dirfd (xlator_t *subvol, loc_t *loc, fd_t **fd, int pid)
dirfd = fd_create (loc->inode, pid);
if (!dirfd) {
- gf_log (subvol->name, GF_LOG_ERROR,
- "fd_create of %s failed: %s",
- uuid_utoa (loc->gfid), strerror(errno));
+ gf_msg (subvol->name, GF_LOG_ERROR, errno,
+ LG_MSG_FD_CREATE_FAILED, "fd_create of %s",
+ uuid_utoa (loc->gfid));
ret = -errno;
goto out;
}
@@ -44,18 +45,18 @@ syncop_dirfd (xlator_t *subvol, loc_t *loc, fd_t **fd, int pid)
fd_unref (dirfd);
dirfd = fd_anonymous (loc->inode);
if (!dirfd) {
- gf_log(subvol->name, GF_LOG_ERROR,
- "fd_anonymous of %s failed: %s",
- uuid_utoa (loc->gfid), strerror(errno));
+ gf_msg (subvol->name, GF_LOG_ERROR, errno,
+ LG_MSG_FD_ANONYMOUS_FAILED, "fd_anonymous of "
+ "%s", uuid_utoa (loc->gfid));
ret = -errno;
goto out;
}
ret = 0;
#else /* GF_LINUX_HOST_OS */
fd_unref (dirfd);
- gf_log (subvol->name, GF_LOG_ERROR,
- "opendir of %s failed: %s",
- uuid_utoa (loc->gfid), strerror(errno));
+ gf_msg (subvol->name, GF_LOG_ERROR, errno,
+ LG_MSG_DIR_OP_FAILED, "opendir of %s",
+ uuid_utoa (loc->gfid));
goto out;
#endif /* GF_LINUX_HOST_OS */
}
@@ -299,7 +300,7 @@ syncop_is_subvol_local (xlator_t *this, loc_t *loc, gf_boolean_t *is_local)
ret = glusterfs_is_local_pathinfo (pathinfo, is_local);
- gf_log (this->name, GF_LOG_DEBUG, "subvol %s is %slocal",
+ gf_msg_debug (this->name, 0, "subvol %s is %slocal",
this->name, is_local ? "" : "not ");
out:
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index efcf2fcfb52..a7a31e492c5 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -9,6 +9,7 @@
*/
#include "syncop.h"
+#include "libglusterfs-messages.h"
int
syncopctx_setfsuid (void *uid)
@@ -257,20 +258,21 @@ __run (struct synctask *task)
case SYNCTASK_SUSPEND:
break;
case SYNCTASK_RUN:
- gf_log (task->xl->name, GF_LOG_DEBUG,
- "re-running already running task");
+ gf_msg_debug (task->xl->name, 0, "re-running already running"
+ " task");
env->runcount--;
break;
case SYNCTASK_WAIT:
env->waitcount--;
break;
case SYNCTASK_DONE:
- gf_log (task->xl->name, GF_LOG_WARNING,
- "running completed task");
+ gf_msg (task->xl->name, GF_LOG_WARNING, 0,
+ LG_MSG_COMPLETED_TASK, "running completed task");
return;
case SYNCTASK_ZOMBIE:
- gf_log (task->xl->name, GF_LOG_WARNING,
- "attempted to wake up zombie!!");
+ gf_msg (task->xl->name, GF_LOG_WARNING, 0,
+ LG_MSG_WAKE_UP_ZOMBIE, "attempted to wake up "
+ "zombie!!");
return;
}
@@ -296,16 +298,19 @@ __wait (struct synctask *task)
env->runcount--;
break;
case SYNCTASK_WAIT:
- gf_log (task->xl->name, GF_LOG_WARNING,
- "re-waiting already waiting task");
+ gf_msg (task->xl->name, GF_LOG_WARNING, 0,
+ LG_MSG_REWAITING_TASK, "re-waiting already waiting "
+ "task");
env->waitcount--;
break;
case SYNCTASK_DONE:
- gf_log (task->xl->name, GF_LOG_WARNING,
+ gf_msg (task->xl->name, GF_LOG_WARNING, 0,
+ LG_MSG_COMPLETED_TASK,
"running completed task");
return;
case SYNCTASK_ZOMBIE:
- gf_log (task->xl->name, GF_LOG_WARNING,
+ gf_msg (task->xl->name, GF_LOG_WARNING, 0,
+ LG_MSG_SLEEP_ZOMBIE,
"attempted to sleep a zombie!!");
return;
}
@@ -331,8 +336,9 @@ synctask_yield (struct synctask *task)
(void) gf_backtrace_save (task->btbuf);
}
if (swapcontext (&task->ctx, &task->proc->sched) < 0) {
- gf_log ("syncop", GF_LOG_ERROR,
- "swapcontext failed (%s)", strerror (errno));
+ gf_msg ("syncop", GF_LOG_ERROR, errno,
+ LG_MSG_SWAPCONTEXT_FAILED, "swapcontext failed (%s)",
+ strerror (errno));
}
THIS = oldTHIS;
@@ -483,16 +489,14 @@ synctask_create (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk,
INIT_LIST_HEAD (&newtask->waitq);
if (getcontext (&newtask->ctx) < 0) {
- gf_log ("syncop", GF_LOG_ERROR,
- "getcontext failed (%s)",
+ gf_msg ("syncop", GF_LOG_ERROR, errno,
+ LG_MSG_GETCONTEXT_FAILED, "getcontext failed (%s)",
strerror (errno));
goto err;
}
newtask->stack = CALLOC (1, env->stacksize);
if (!newtask->stack) {
- gf_log ("syncop", GF_LOG_ERROR,
- "out of memory for stack");
goto err;
}
@@ -643,8 +647,8 @@ synctask_switchto (struct synctask *task)
#endif
if (swapcontext (&task->proc->sched, &task->ctx) < 0) {
- gf_log ("syncop", GF_LOG_ERROR,
- "swapcontext failed (%s)", strerror (errno));
+ gf_msg ("syncop", GF_LOG_ERROR, errno, LG_MSG_SWAPCONTEXT_FAILED,
+ "swapcontext failed");
}
if (task->state == SYNCTASK_DONE) {
@@ -869,22 +873,25 @@ __synclock_lock (struct synclock *lock)
case LOCK_TASK:
if (task == lock->owner) {
lock->lock++;
- gf_log ("", GF_LOG_TRACE, "Recursive lock called by "
- "sync task.owner= %p,lock=%d", lock->owner, lock->lock);
+ gf_msg_trace ("", 0, "Recursive lock called by"
+ " sync task.owner= %p,lock=%d",
+ lock->owner, lock->lock);
return 0;
}
break;
case LOCK_THREAD:
if (pthread_self () == lock->owner_tid) {
lock->lock++;
- gf_log ("", GF_LOG_TRACE, "Recursive lock called by "
- "thread ,owner=%u lock=%d", (unsigned int) lock->owner_tid,
- lock->lock);
+ gf_msg_trace ("", 0, "Recursive lock called by"
+ " thread ,owner=%u lock=%d",
+ (unsigned int) lock->owner_tid,
+ lock->lock);
return 0;
}
break;
default:
- gf_log ("", GF_LOG_CRITICAL, "unknown lock type");
+ gf_msg ("", GF_LOG_CRITICAL, 0,
+ LG_MSG_UNKNOWN_LOCK_TYPE, "unknown lock type");
break;
}
}
@@ -969,7 +976,8 @@ __synclock_unlock (synclock_t *lock)
return -1;
if (lock->lock == 0) {
- gf_log ("", GF_LOG_CRITICAL, "Unlock called before lock ");
+ gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_UNLOCK_BEFORE_LOCK,
+ "Unlock called before lock ");
return -1;
}
curr = synctask_get ();
@@ -981,23 +989,27 @@ __synclock_unlock (synclock_t *lock)
case LOCK_TASK:
if (curr == lock->owner) {
lock->lock--;
- gf_log ("", GF_LOG_TRACE, "Unlock success %p, remaining"
- " locks=%d", lock->owner, lock->lock);
+ gf_msg_trace ("", 0, "Unlock success %p, remaining"
+ " locks=%d", lock->owner, lock->lock);
} else {
- gf_log ("", GF_LOG_WARNING, "Unlock called by %p, but"
- " lock held by %p", curr, lock->owner);
+ gf_msg ("", GF_LOG_WARNING, 0, LG_MSG_LOCK_OWNER_ERROR,
+ "Unlock called by %p, but lock held by %p",
+ curr, lock->owner);
}
break;
case LOCK_THREAD:
if (pthread_self () == lock->owner_tid) {
lock->lock--;
- gf_log ("", GF_LOG_TRACE, "Unlock success %u, remaining"
- " locks=%d", (unsigned int)lock->owner_tid, lock->lock);
+ gf_msg_trace ("", 0, "Unlock success %u, remaining "
+ "locks=%d",
+ (unsigned int)lock->owner_tid,
+ lock->lock);
} else {
- gf_log ("", GF_LOG_WARNING, "Unlock called by %u, but"
- " lock held by %u", (unsigned int) pthread_self(),
- (unsigned int) lock->owner_tid);
+ gf_msg ("", GF_LOG_WARNING, 0, LG_MSG_LOCK_OWNER_ERROR,
+ "Unlock called by %u, but lock held by %u",
+ (unsigned int) pthread_self(),
+ (unsigned int) lock->owner_tid);
}
break;
@@ -1245,9 +1257,8 @@ syncop_readdirp_cbk (call_frame_t *frame,
gf_dirent_free (&(args->entries));
break;
}
- gf_log (this->name, GF_LOG_TRACE,
- "adding entry=%s, count=%d",
- tmp->d_name, count);
+ gf_msg_trace (this->name, 0, "adding entry=%s, "
+ "count=%d", tmp->d_name, count);
list_add_tail (&tmp->list, &(args->entries.list));
count++;
}
@@ -1321,9 +1332,9 @@ syncop_readdir_cbk (call_frame_t *frame,
gf_dirent_free (&(args->entries));
break;
}
- gf_log (this->name, GF_LOG_TRACE,
- "adding entry=%s, count=%d",
- tmp->d_name, count);
+ gf_msg_trace (this->name, 0, "adding "
+ "entry=%s, count=%d", tmp->d_name,
+ count);
list_add_tail (&tmp->list, &(args->entries.list));
count++;
}
diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c
index 1aa2079f097..b406ef613d6 100644
--- a/libglusterfs/src/timer.c
+++ b/libglusterfs/src/timer.c
@@ -13,6 +13,7 @@
#include "common-utils.h"
#include "globals.h"
#include "timespec.h"
+#include "libglusterfs-messages.h"
gf_timer_t *
gf_timer_call_after (glusterfs_ctx_t *ctx,
@@ -27,7 +28,8 @@ gf_timer_call_after (glusterfs_ctx_t *ctx,
if (ctx == NULL)
{
- gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return NULL;
}
@@ -36,14 +38,17 @@ gf_timer_call_after (glusterfs_ctx_t *ctx,
* when cleanup_started is set after checking for it
*/
if (ctx->cleanup_started) {
- gf_log_callingfn ("timer", GF_LOG_INFO, "ctx cleanup started");
+ gf_msg_callingfn ("timer", GF_LOG_INFO, 0,
+ LG_MSG_CTX_CLEANUP_STARTED, "ctx cleanup "
+ "started");
return NULL;
}
reg = gf_timer_registry_init (ctx);
if (!reg) {
- gf_log_callingfn ("timer", GF_LOG_ERROR, "!reg");
+ gf_msg_callingfn ("timer", GF_LOG_ERROR, 0,
+ LG_MSG_TIMER_REGISTER_ERROR, "!reg");
return NULL;
}
@@ -80,7 +85,8 @@ gf_timer_call_stale (gf_timer_registry_t *reg,
{
if (reg == NULL || event == NULL)
{
- gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return 0;
}
@@ -102,13 +108,15 @@ gf_timer_call_cancel (glusterfs_ctx_t *ctx,
if (ctx == NULL || event == NULL)
{
- gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return 0;
}
reg = gf_timer_registry_init (ctx);
if (!reg) {
- gf_log ("timer", GF_LOG_ERROR, "!reg");
+ gf_msg ("timer", GF_LOG_ERROR, 0, LG_MSG_INIT_TIMER_FAILED,
+ "!reg");
GF_FREE (event);
return 0;
}
@@ -140,13 +148,15 @@ gf_timer_proc (void *ctx)
if (ctx == NULL)
{
- gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return NULL;
}
reg = gf_timer_registry_init (ctx);
if (!reg) {
- gf_log ("timer", GF_LOG_ERROR, "!reg");
+ gf_msg ("timer", GF_LOG_ERROR, 0, LG_MSG_INIT_TIMER_FAILED,
+ "!reg");
return NULL;
}
@@ -218,7 +228,8 @@ gf_timer_registry_t *
gf_timer_registry_init (glusterfs_ctx_t *ctx)
{
if (ctx == NULL) {
- gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return NULL;
}