summaryrefslogtreecommitdiffstats
path: root/xlators/features/changelog/lib/src
diff options
context:
space:
mode:
authorAnusha Rao <anusha91rao@gmail.com>2015-05-04 12:34:09 +0530
committerVenky Shankar <vshankar@redhat.com>2015-08-11 22:36:44 -0700
commit64e6836ac8fb96f38a859eea0d8525cd9bd2693f (patch)
treeeb00359a9dd7be26f90f9147330a8e2c6fa83232 /xlators/features/changelog/lib/src
parent0dcdc8d9d797ed43d305fb3e3437c2576305ac46 (diff)
features/changelog: Porting log messages to new logging framework
Change-Id: Ic7f842acca52908fd88e0796dc90b82650405b25 BUG: 1194640 Signed-off-by: Anusha Rao <anusha91rao@gmail.com> Reviewed-on: http://review.gluster.org/10532 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com> Reviewed-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'xlators/features/changelog/lib/src')
-rw-r--r--xlators/features/changelog/lib/src/Makefile.am2
-rw-r--r--xlators/features/changelog/lib/src/changelog-lib-messages.h287
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-api.c15
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-helpers.c10
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-journal-handler.c104
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-reborp.c30
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog.c23
-rw-r--r--xlators/features/changelog/lib/src/gf-history-changelog.c108
8 files changed, 462 insertions, 117 deletions
diff --git a/xlators/features/changelog/lib/src/Makefile.am b/xlators/features/changelog/lib/src/Makefile.am
index 7da4f7c78ae..8d3edb4d63f 100644
--- a/xlators/features/changelog/lib/src/Makefile.am
+++ b/xlators/features/changelog/lib/src/Makefile.am
@@ -23,7 +23,7 @@ libgfchangelog_la_SOURCES = gf-changelog.c gf-changelog-journal-handler.c gf-cha
gf-changelog-api.c gf-history-changelog.c gf-changelog-rpc.c gf-changelog-reborp.c \
$(top_srcdir)/xlators/features/changelog/src/changelog-rpc-common.c
-noinst_HEADERS = gf-changelog-helpers.h gf-changelog-rpc.h gf-changelog-journal.h
+noinst_HEADERS = gf-changelog-helpers.h gf-changelog-rpc.h gf-changelog-journal.h changelog-lib-messages.h
CLEANFILES =
diff --git a/xlators/features/changelog/lib/src/changelog-lib-messages.h b/xlators/features/changelog/lib/src/changelog-lib-messages.h
new file mode 100644
index 00000000000..976c67f61a9
--- /dev/null
+++ b/xlators/features/changelog/lib/src/changelog-lib-messages.h
@@ -0,0 +1,287 @@
+/*
+ Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+ */
+
+#ifndef _CHANGELOG_LIB_MESSAGES_H_
+#define _CHANGELOG_LIB_MESSAGES_H_
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "glfs-message-id.h"
+
+/*! \file changelog-lib-messages.h
+ * \brief CHANGELOG_LIB log-message IDs and their descriptions.
+ */
+
+/* NOTE: Rules for message additions
+ * 1) Each instance of a message is _better_ left with a unique message ID, even
+ * if the message format is the same. Reasoning is that, if the message
+ * format needs to change in one instance, the other instances are not
+ * impacted or the new change does not change the ID of the instance being
+ * modified.
+ * 2) Addition of a message,
+ * - Should increment the GLFS_NUM_MESSAGES
+ * - Append to the list of messages defined, towards the end
+ * - Retain macro naming as glfs_msg_X (for readability across developers)
+ * NOTE: Rules for message format modifications
+ * 3) Check acorss the code if the message ID macro in question is reused
+ * anywhere. If reused then then the modifications should ensure correctness
+ * everywhere, or needs a new message ID as (1) above was not adhered to. If
+ * not used anywhere, proceed with the required modification.
+ * NOTE: Rules for message deletion
+ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used
+ * anywhere, then can be deleted, but will leave a hole by design, as
+ * addition rules specify modification to the end of the list and not filling
+ * holes.
+ */
+
+#define GLFS_COMP_BASE_CHANGELOG_LIB GLFS_MSGID_COMP_CHANGELOG_LIB
+#define GLFS_NUM_MESSAGES 28
+#define GLFS_MSGID_END (GLFS_COMP_BASE_CHANGELOG_LIB + GLFS_NUM_MESSAGES + 1)
+
+#define glfs_msg_start_x GLFS_COMP_BASE_CHANGELOG_LIB,\
+ "Invalid: Start of messages"
+
+/*!
+ * @messageid
+ * @diagnosis open/opendir failed on a brick.
+ * @recommended action Error number in the log should give the reason why it
+ * failed. Also observe brick logs for more information.
+ */
+#define CHANGELOG_LIB_MSG_OPEN_FAILED (GLFS_COMP_BASE_CHANGELOG_LIB + 1)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_FAILED_TO_RMDIR (GLFS_COMP_BASE_CHANGELOG_LIB + 2)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_SCRATCH_DIR_ENTRIES_CREATION_ERROR \
+(GLFS_COMP_BASE_CHANGELOG_LIB + 3)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_THREAD_CREATION_FAILED \
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 4)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_OPENDIR_ERROR (GLFS_COMP_BASE_CHANGELOG_LIB + 5)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_RENAME_FAILED (GLFS_COMP_BASE_CHANGELOG_LIB + 6)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_READ_ERROR (GLFS_COMP_BASE_CHANGELOG_LIB + 7)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_HTIME_ERROR (GLFS_COMP_BASE_CHANGELOG_LIB + 8)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_GET_TIME_ERROR (GLFS_COMP_BASE_CHANGELOG_LIB + 9)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_WRITE_FAILED (GLFS_COMP_BASE_CHANGELOG_LIB + 10)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_PTHREAD_ERROR (GLFS_COMP_BASE_CHANGELOG_LIB + 11)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_MMAP_FAILED (GLFS_COMP_BASE_CHANGELOG_LIB + 12)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_MUNMAP_FAILED (GLFS_COMP_BASE_CHANGELOG_LIB + 13)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_ASCII_ERROR (GLFS_COMP_BASE_CHANGELOG_LIB + 14)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_STAT_FAILED (GLFS_COMP_BASE_CHANGELOG_LIB + 15)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_GET_XATTR_FAILED \
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 16)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_PUBLISH_ERROR (GLFS_COMP_BASE_CHANGELOG_LIB + 17)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_PARSE_ERROR (GLFS_COMP_BASE_CHANGELOG_LIB + 18)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_TOTAL_LOG_INFO (GLFS_COMP_BASE_CHANGELOG_LIB + 19)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_CLEANUP_ERROR (GLFS_COMP_BASE_CHANGELOG_LIB + 20)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_UNLINK_FAILED (GLFS_COMP_BASE_CHANGELOG_LIB + 21)
+
+/*!
+ @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_NOTIFY_REGISTER_FAILED\
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 22)
+
+/*!
+ @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_INVOKE_RPC_FAILED\
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 23)
+
+/*!
+ @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_DRAINING_EVENT_INFO\
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 24)
+
+/*!
+ @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_CLEANING_BRICK_ENTRY_INFO \
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 25)
+
+/*!
+ @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_FREEING_ENTRY_INFO \
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 26)
+
+/*!
+ @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_XDR_DECODING_FAILED \
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 27)
+
+/*!
+ @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_NOTIFY_REGISTER_INFO \
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 28)
+
+/*!
+ @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_THREAD_CLEANUP_WARNING \
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 29)
+
+/*!
+ @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_COPY_FROM_BUFFER_FAILED \
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 30)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommended action
+*/
+#define CHANGELOG_LIB_MSG_PTHREAD_JOIN_FAILED \
+ (GLFS_COMP_BASE_CHANGELOG_LIB + 20)
+
+
+#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
+#endif /* !_CHANGELOG_MESSAGES_H_ */
diff --git a/xlators/features/changelog/lib/src/gf-changelog-api.c b/xlators/features/changelog/lib/src/gf-changelog-api.c
index eee3ad1eefd..63c0098d248 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-api.c
+++ b/xlators/features/changelog/lib/src/gf-changelog-api.c
@@ -15,6 +15,7 @@
#include "gf-changelog-helpers.h"
#include "gf-changelog-journal.h"
#include "changelog-mem-types.h"
+#include "changelog-lib-messages.h"
int
gf_changelog_done (char *file)
@@ -49,13 +50,14 @@ gf_changelog_done (char *file)
(void) snprintf (to_path, PATH_MAX, "%s%s",
jnl->jnl_processed_dir, basename (buffer));
- gf_log (this->name, GF_LOG_DEBUG,
- "moving %s to processed directory", file);
+ gf_msg_debug (this->name, 0,
+ "moving %s to processed directory", file);
ret = rename (buffer, to_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "cannot move %s to %s (reason: %s)",
- file, to_path, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_RENAME_FAILED,
+ "cannot move %s to %s",
+ file, to_path);
goto out;
}
@@ -205,7 +207,8 @@ gf_changelog_scan ()
GF_CHANGELOG_FILL_BUFFER ("\n", buffer, off, 1);
if (gf_changelog_write (tracker_fd, buffer, off) != off) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_WRITE_FAILED,
"error writing changelog filename"
" to tracker file");
break;
diff --git a/xlators/features/changelog/lib/src/gf-changelog-helpers.c b/xlators/features/changelog/lib/src/gf-changelog-helpers.c
index 6bf709dc664..d6245743437 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-helpers.c
+++ b/xlators/features/changelog/lib/src/gf-changelog-helpers.c
@@ -10,6 +10,7 @@
#include "changelog-mem-types.h"
#include "gf-changelog-helpers.h"
+#include "changelog-lib-messages.h"
ssize_t gf_changelog_read_path (int fd, char *buffer, size_t bufsize)
{
@@ -187,20 +188,23 @@ gf_thread_cleanup (xlator_t *this, pthread_t thread)
ret = pthread_cancel (thread);
if (ret != 0) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ CHANGELOG_LIB_MSG_THREAD_CLEANUP_WARNING,
"Failed to send cancellation to thread");
goto error_return;
}
ret = pthread_join (thread, &res);
if (ret != 0) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ CHANGELOG_LIB_MSG_THREAD_CLEANUP_WARNING,
"failed to join thread");
goto error_return;
}
if (res != PTHREAD_CANCELED) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ CHANGELOG_LIB_MSG_THREAD_CLEANUP_WARNING,
"Thread could not be cleaned up");
goto error_return;
}
diff --git a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
index f07d341ddef..f04117298a9 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
+++ b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c
@@ -11,6 +11,7 @@
#include "compat-uuid.h"
#include "globals.h"
#include "glusterfs.h"
+#include "compat-errno.h"
#include "gf-changelog-helpers.h"
@@ -19,6 +20,7 @@
#include "changelog-mem-types.h"
#include "gf-changelog-journal.h"
+#include "changelog-lib-messages.h"
extern int byebye;
@@ -167,8 +169,9 @@ gf_changelog_parse_binary (xlator_t *this,
start = mmap (NULL, nleft, PROT_READ, MAP_PRIVATE, from_fd, 0);
if (start == MAP_FAILED) {
- gf_log (this->name, GF_LOG_ERROR,
- "mmap() error (reason: %s)", strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_MMAP_FAILED,
+ "mmap() error");
goto out;
}
@@ -223,10 +226,10 @@ gf_changelog_parse_binary (xlator_t *this,
GF_CHANGELOG_FILL_BUFFER ("\n", ascii, off, 1);
if (gf_changelog_write (to_fd, ascii, off) != off) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_ASCII_ERROR,
"processing binary changelog failed due to "
- " error in writing ascii change (reason: %s)",
- strerror (errno));
+ " error in writing ascii change");
break;
}
@@ -237,8 +240,9 @@ gf_changelog_parse_binary (xlator_t *this,
ret = 0;
if (munmap (start, stbuf->st_size))
- gf_log (this->name, GF_LOG_ERROR,
- "munmap() error (reason: %s)", strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_MUNMAP_FAILED,
+ "munmap() error");
out:
return ret;
}
@@ -274,8 +278,9 @@ gf_changelog_parse_ascii (xlator_t *this,
start = mmap (NULL, nleft, PROT_READ, MAP_PRIVATE, from_fd, 0);
if (start == MAP_FAILED) {
- gf_log (this->name, GF_LOG_ERROR,
- "mmap() error (reason: %s)", strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_MMAP_FAILED,
+ "mmap() error");
goto out;
}
@@ -404,10 +409,10 @@ gf_changelog_parse_ascii (xlator_t *this,
GF_CHANGELOG_FILL_BUFFER ("\n", ascii, off, 1);
if (gf_changelog_write (to_fd, ascii, off) != off) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_ASCII_ERROR,
"processing ascii changelog failed due to "
- " error in writing change (reason: %s)",
- strerror (errno));
+ " error in writing change");
break;
}
@@ -419,8 +424,9 @@ gf_changelog_parse_ascii (xlator_t *this,
ret = 0;
if (munmap (start, stbuf->st_size))
- gf_log (this->name, GF_LOG_ERROR,
- "munmap() error (reason: %s)", strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_MUNMAP_FAILED,
+ "munmap() error");
out:
return ret;
@@ -440,7 +446,8 @@ gf_changelog_copy (xlator_t *this, int from_fd, int to_fd)
if (gf_changelog_write (to_fd,
buffer, size) != size) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_COPY_FROM_BUFFER_FAILED,
"error processing ascii changlog");
size = -1;
break;
@@ -544,9 +551,10 @@ gf_changelog_publish (xlator_t *this,
ret = rename (to_path, dest);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "error moving %s to processing dir"
- " (reason: %s)", to_path, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_RENAME_FAILED,
+ "error moving %s to processing dir",
+ to_path);
}
out:
@@ -569,16 +577,18 @@ gf_changelog_consume (xlator_t *this,
ret = stat (from_path, &stbuf);
if (ret || !S_ISREG(stbuf.st_mode)) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_STAT_FAILED,
"stat failed on changelog file: %s", from_path);
goto out;
}
fd1 = open (from_path, O_RDONLY);
if (fd1 < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "cannot open changelog file: %s (reason: %s)",
- from_path, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_OPEN_FAILED,
+ "cannot open changelog file: %s",
+ from_path);
goto out;
}
@@ -590,9 +600,10 @@ gf_changelog_consume (xlator_t *this,
fd2 = open (to_path, O_CREAT | O_TRUNC | O_RDWR,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd2 < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "cannot create ascii changelog file %s (reason %s)",
- to_path, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_OPEN_FAILED,
+ "cannot create ascii changelog file %s",
+ to_path);
goto close_fd;
} else {
ret = gf_changelog_decode (this, jnl, fd1,
@@ -607,10 +618,10 @@ gf_changelog_consume (xlator_t *this,
goto close_fd;
ret = rename (to_path, dest);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
- "error moving %s to processing dir"
- " (reason: %s)", to_path,
- strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_RENAME_FAILED,
+ "error moving %s to processing dir",
+ to_path);
}
/* remove it from .current if it's an empty file */
@@ -618,9 +629,10 @@ gf_changelog_consume (xlator_t *this,
/* zerob changelogs must be unlinked */
ret = unlink (to_path);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
- "could not unlink %s (reason: %s)",
- to_path, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_UNLINK_FAILED,
+ "could not unlink %s",
+ to_path);
}
}
@@ -757,7 +769,8 @@ gf_changelog_cleanup_processor (gf_changelog_journal_t *jnl)
ret = gf_thread_cleanup (this, jnl_proc->processor);
if (ret != 0) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_CLEANUP_ERROR,
"failed to cleanup processor thread");
goto error_return;
}
@@ -840,9 +853,10 @@ gf_changelog_open_dirs (xlator_t *this, gf_changelog_journal_t *jnl)
jnl->jnl_working_dir);
ret = recursive_rmdir (jnl->jnl_current_dir);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to rmdir: %s, err: %s",
- jnl->jnl_current_dir, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_FAILED_TO_RMDIR,
+ "Failed to rmdir: %s",
+ jnl->jnl_current_dir);
goto out;
}
ret = mkdir_p (jnl->jnl_current_dir, 0600, _gf_false);
@@ -863,9 +877,10 @@ gf_changelog_open_dirs (xlator_t *this, gf_changelog_journal_t *jnl)
jnl->jnl_working_dir);
ret = recursive_rmdir (jnl->jnl_processing_dir);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to rmdir: %s, err: %s",
- jnl->jnl_processing_dir, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_FAILED_TO_RMDIR,
+ "Failed to rmdir: %s",
+ jnl->jnl_processing_dir);
goto out;
}
@@ -875,8 +890,9 @@ gf_changelog_open_dirs (xlator_t *this, gf_changelog_journal_t *jnl)
dir = opendir (jnl->jnl_processing_dir);
if (!dir) {
- gf_log ("", GF_LOG_ERROR,
- "opendir() error [reason: %s]", strerror (errno));
+ gf_msg ("", GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_OPENDIR_ERROR,
+ "opendir() error");
goto out;
}
@@ -930,7 +946,8 @@ gf_changelog_init_history (xlator_t *this,
ret = gf_changelog_open_dirs (this, jnl->hist_jnl);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_OPENDIR_ERROR,
"could not create entries in history scratch dir");
goto dealloc_hist;
}
@@ -1002,7 +1019,8 @@ gf_changelog_journal_init (void *xl, struct gf_brick_spec *brick)
ret = gf_changelog_open_dirs (this, jnl);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_OPENDIR_ERROR,
"could not create entries in scratch dir");
goto dealloc_private;
}
diff --git a/xlators/features/changelog/lib/src/gf-changelog-reborp.c b/xlators/features/changelog/lib/src/gf-changelog-reborp.c
index 2a1e56ae79e..e6bb19e3696 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-reborp.c
+++ b/xlators/features/changelog/lib/src/gf-changelog-reborp.c
@@ -13,6 +13,7 @@
#include "gf-changelog-helpers.h"
#include "changelog-rpc-common.h"
+#include "changelog-lib-messages.h"
/**
* Reverse socket: actual data transfer handler. Connection
@@ -52,7 +53,8 @@ gf_changelog_connection_janitor (void *arg)
drained = 0;
ev = &entry->event;
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ CHANGELOG_LIB_MSG_CLEANING_BRICK_ENTRY_INFO,
"Cleaning brick entry for brick %s", entry->brick);
/* 0x0: disbale rpc-clnt */
@@ -67,7 +69,8 @@ gf_changelog_connection_janitor (void *arg)
while (!list_empty (&ev->events)) {
event = list_first_entry (&ev->events,
struct gf_event, list);
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ CHANGELOG_LIB_MSG_DRAINING_EVENT_INFO,
"Draining event [Seq: %lu, Payload: %d]",
event->seq, event->count);
@@ -75,11 +78,14 @@ gf_changelog_connection_janitor (void *arg)
drained++;
}
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ CHANGELOG_LIB_MSG_DRAINING_EVENT_INFO,
"Drained %lu events", drained);
/* 0x3: freeup brick entry */
- gf_log (this->name, GF_LOG_INFO, "freeing entry %p", entry);
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ CHANGELOG_LIB_MSG_FREEING_ENTRY_INFO,
+ "freeing entry %p", entry);
LOCK_DESTROY (&entry->statelock);
GF_FREE (entry);
}
@@ -158,7 +164,9 @@ gf_changelog_reborp_rpcsvc_notify (rpcsvc_t *rpc, void *mydata,
case RPCSVC_EVENT_ACCEPT:
ret = unlink (RPC_SOCK(entry));
if (ret != 0)
- gf_log (this->name, GF_LOG_WARNING, "failed to unlink "
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ CHANGELOG_LIB_MSG_UNLINK_FAILED,
+ "failed to unlink "
"reverse socket %s", RPC_SOCK (entry));
if (entry->connected)
GF_CHANGELOG_INVOKE_CBK (this, entry->connected,
@@ -361,7 +369,9 @@ gf_changelog_event_handler (rpcsvc_request_t *req,
len = xdr_to_generic (req->msg[0],
&rpc_req, (xdrproc_t)xdr_changelog_event_req);
if (len < 0) {
- gf_log (this->name, GF_LOG_ERROR, "xdr decoding failed");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_XDR_DECODING_FAILED,
+ "xdr decoding failed");
req->rpc_err = GARBAGE_ARGS;
goto handle_xdr_error;
}
@@ -400,10 +410,10 @@ gf_changelog_event_handler (rpcsvc_request_t *req,
req->msg[i].iov_base, req->msg[i].iov_len);
}
- gf_log (this->name, GF_LOG_DEBUG,
- "seq: %lu [%s] (time: %lu.%lu), (vec: %d, len: %ld)",
- rpc_req.seq, entry->brick, rpc_req.tv_sec,
- rpc_req.tv_usec, payloadcnt, payloadlen);
+ gf_msg_debug (this->name, 0,
+ "seq: %lu [%s] (time: %lu.%lu), (vec: %d, len: %ld)",
+ rpc_req.seq, entry->brick, rpc_req.tv_sec,
+ rpc_req.tv_usec, payloadcnt, payloadlen);
/* dispatch event */
entry->queueevent (ev, event);
diff --git a/xlators/features/changelog/lib/src/gf-changelog.c b/xlators/features/changelog/lib/src/gf-changelog.c
index 874ffd0d13b..5972e7052d8 100644
--- a/xlators/features/changelog/lib/src/gf-changelog.c
+++ b/xlators/features/changelog/lib/src/gf-changelog.c
@@ -34,6 +34,7 @@
/* from the changelog translator */
#include "changelog-misc.h"
#include "changelog-mem-types.h"
+#include "changelog-lib-messages.h"
/**
* Global singleton xlator pointer for the library, initialized
@@ -243,7 +244,8 @@ gf_changelog_setup_rpc (xlator_t *this,
*/
ret = gf_changelog_invoke_rpc (this, entry, proc);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_INVOKE_RPC_FAILED,
"Could not initiate probe RPC, bailing out!!!");
goto error_return;
}
@@ -261,10 +263,10 @@ gf_cleanup_event (xlator_t *this, struct gf_event_list *ev)
ret = gf_thread_cleanup (this, ev->invoker);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
- "cannot cleanup callback invoker thread "
- " [reason: %s]. Not freeing resources",
- strerror (-ret));
+ gf_msg (this->name, GF_LOG_WARNING, -ret,
+ CHANGELOG_LIB_MSG_CLEANUP_ERROR,
+ "cannot cleanup callback invoker thread."
+ " Not freeing resources");
return -1;
}
@@ -395,7 +397,7 @@ gf_setup_brick_connection (xlator_t *this,
cleanup_event:
(void) gf_cleanup_event (this, &entry->event);
free_entry:
- gf_log (this->name, GF_LOG_DEBUG, "freeing entry %p", entry);
+ gf_msg_debug (this->name, 0, "freeing entry %p", entry);
list_del (&entry->list); /* FIXME: kludge for now */
GF_FREE (entry);
error_return:
@@ -459,7 +461,8 @@ gf_changelog_set_master (xlator_t *master, void *xl)
NULL, changelog_rpc_poller, THIS);
if (ret != 0) {
GF_FREE (priv);
- gf_log (master->name, GF_LOG_ERROR,
+ gf_msg (master->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_THREAD_CREATION_FAILED,
"failed to spawn poller thread");
goto restore_this;
}
@@ -537,13 +540,15 @@ gf_changelog_register_generic (struct gf_brick_spec *bricks, int count,
brick = bricks;
while (count--) {
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ CHANGELOG_LIB_MSG_NOTIFY_REGISTER_INFO,
"Registering brick: %s [notify filter: %d]",
brick->brick_path, brick->filter);
ret = gf_changelog_register_brick (this, brick, need_order, xl);
if (ret != 0) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_NOTIFY_REGISTER_FAILED,
"Error registering with changelog xlator");
break;
}
diff --git a/xlators/features/changelog/lib/src/gf-history-changelog.c b/xlators/features/changelog/lib/src/gf-history-changelog.c
index ba312e3b10f..fffe48780c1 100644
--- a/xlators/features/changelog/lib/src/gf-history-changelog.c
+++ b/xlators/features/changelog/lib/src/gf-history-changelog.c
@@ -18,6 +18,7 @@
/* from the changelog translator */
#include "changelog-misc.h"
+#include "changelog-lib-messages.h"
#include "changelog-mem-types.h"
/**
@@ -72,13 +73,14 @@ gf_history_changelog_done (char *file)
(void) snprintf (to_path, PATH_MAX, "%s%s",
hist_jnl->jnl_processed_dir, basename (buffer));
- gf_log (this->name, GF_LOG_DEBUG,
- "moving %s to processed directory", file);
+ gf_msg_debug (this->name, 0,
+ "moving %s to processed directory", file);
ret = rename (buffer, to_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "cannot move %s to %s (reason: %s)",
- file, to_path, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_RENAME_FAILED,
+ "cannot move %s to %s",
+ file, to_path);
goto out;
}
@@ -283,7 +285,8 @@ gf_history_changelog_scan ()
GF_CHANGELOG_FILL_BUFFER ("\n", buffer, off, 1);
if (gf_changelog_write (tracker_fd, buffer, off) != off) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_WRITE_FAILED,
"error writing changelog filename"
" to tracker file");
break;
@@ -293,9 +296,9 @@ gf_history_changelog_scan ()
GF_FREE (entryp);
- gf_log (this->name, GF_LOG_DEBUG,
- "hist_done %d, is_last_scan: %d", hist_jnl->hist_done,
- is_last_scan);
+ gf_msg_debug (this->name, 0,
+ "hist_done %d, is_last_scan: %d",
+ hist_jnl->hist_done, is_last_scan);
if (!result) {
if (gf_lseek (tracker_fd, 0, SEEK_SET) != -1) {
@@ -335,7 +338,8 @@ gf_history_get_timestamp (int fd, int index, int len,
n_read = pread (fd, path_buf, len, offset);
if (n_read < 0 ) {
ret = -1;
- gf_log ( this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_READ_ERROR,
"could not read from htime file");
goto out;
}
@@ -522,9 +526,9 @@ gf_changelog_consume_wrap (void* data)
nread = pread (ccd->fd, ccd->changelog, PATH_MAX, ccd->offset);
if (nread < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "cannot read from history metadata file (reason %s)",
- strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_READ_ERROR,
+ "cannot read from history metadata file");
goto out;
}
@@ -534,8 +538,10 @@ gf_changelog_consume_wrap (void* data)
ret = gf_changelog_consume (ccd->this,
ccd->jnl, ccd->changelog, _gf_true);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "could not parse changelog: %s", ccd->changelog);
+ gf_msg (this->name, GF_LOG_ERROR,
+ 0, CHANGELOG_LIB_MSG_PARSE_ERROR,
+ "could not parse changelog: %s",
+ ccd->changelog);
goto out;
}
}
@@ -621,9 +627,9 @@ gf_history_consume (void * data)
ret = pthread_create (&th_id[iter], NULL,
gf_changelog_consume_wrap, curr);
if (ret) {
- gf_log ( this->name, GF_LOG_ERROR,
- "could not create consume-thread"
- " reason (%s)", strerror (ret));
+ gf_msg (this->name, GF_LOG_ERROR, ret,
+ CHANGELOG_LIB_MSG_THREAD_CREATION_FAILED
+ , "could not create consume-thread");
ret = -1;
goto sync;
} else
@@ -637,9 +643,9 @@ gf_history_consume (void * data)
ret = pthread_join (th_id[iter], NULL);
if (ret) {
publish = _gf_false;
- gf_log (this->name, GF_LOG_ERROR,
- "pthread_join() error %s",
- strerror (ret));
+ gf_msg (this->name, GF_LOG_ERROR, ret,
+ CHANGELOG_LIB_MSG_PTHREAD_JOIN_FAILED,
+ "pthread_join() error");
/* try to join the rest */
continue;
}
@@ -650,7 +656,8 @@ gf_history_consume (void * data)
curr = &ccd[iter];
if (ccd->retval) {
publish = _gf_false;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR,
+ 0, CHANGELOG_LIB_MSG_PARSE_ERROR,
"parsing error, ceased publishing...");
continue;
}
@@ -659,7 +666,8 @@ gf_history_consume (void * data)
curr->jnl, curr->changelog);
if (ret) {
publish = _gf_false;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_PUBLISH_ERROR,
"publish error, ceased publishing...");
}
}
@@ -723,9 +731,10 @@ gf_changelog_extract_min_max (const char *dname, const char *htime_dir,
ret = stat (htime_file, &stbuf);
if (ret) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
- "stat() failed on htime file %s (reason %s)",
- htime_file, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_HTIME_ERROR,
+ "stat() failed on htime file %s",
+ htime_file);
goto out;
}
@@ -738,9 +747,10 @@ gf_changelog_extract_min_max (const char *dname, const char *htime_dir,
*fd = open (htime_file, O_RDONLY);
if (*fd < 0) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
- "open() failed for htime %s (reasong %s)",
- htime_file, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_HTIME_ERROR,
+ "open() failed for htime %s",
+ htime_file);
goto out;
}
@@ -748,14 +758,16 @@ gf_changelog_extract_min_max (const char *dname, const char *htime_dir,
ret = sys_fgetxattr (*fd, HTIME_KEY, x_value, sizeof (x_value));
if (ret < 0) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_GET_XATTR_FAILED,
"error extracting max timstamp from htime file"
- " %s (reason %s)", htime_file, strerror (errno));
+ " %s", htime_file);
goto out;
}
sscanf (x_value, "%lu:%lu", max_ts, total);
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ CHANGELOG_LIB_MSG_TOTAL_LOG_INFO,
"MIN: %lu, MAX: %lu, TOTAL CHANGELOGS: %lu",
*min_ts, *max_ts, *total);
@@ -831,9 +843,10 @@ gf_history_changelog (char* changelog_dir, unsigned long start,
dirp = opendir (htime_dir);
if (dirp == NULL) {
- gf_log (this->name, GF_LOG_ERROR,
- "open dir on htime failed : %s (reason: %s)",
- htime_dir, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_HTIME_ERROR,
+ "open dir on htime failed : %s",
+ htime_dir);
ret = -1;
goto out;
}
@@ -855,7 +868,8 @@ gf_history_changelog (char* changelog_dir, unsigned long start,
n_read = read (fd, buffer, PATH_MAX);
if (n_read < 0) {
ret = -1;
- gf_log ( this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CHANGELOG_LIB_MSG_READ_ERROR,
"unable to read htime file");
goto out;
}
@@ -872,7 +886,8 @@ gf_history_changelog (char* changelog_dir, unsigned long start,
/* ensuring correctness of gf_b_search */
if (gf_history_check (fd, from, start, len) != 0) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_GET_TIME_ERROR,
"wrong result for start: %lu idx: %lu",
start, from);
goto out;
@@ -888,7 +903,8 @@ gf_history_changelog (char* changelog_dir, unsigned long start,
if (gf_history_check (fd, to, end2, len) != 0) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CHANGELOG_LIB_MSG_GET_TIME_ERROR,
"wrong result for start: %lu idx: %lu",
end2, to);
goto out;
@@ -902,7 +918,8 @@ gf_history_changelog (char* changelog_dir, unsigned long start,
if (ret == -1)
goto out;
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ CHANGELOG_LIB_MSG_TOTAL_LOG_INFO,
"FINAL: from: %lu, to: %lu, changes: %lu",
ts1, ts2, (to - from + 1));
@@ -920,10 +937,10 @@ gf_history_changelog (char* changelog_dir, unsigned long start,
ret = pthread_attr_setdetachstate
(&attr, PTHREAD_CREATE_DETACHED);
if (ret != 0) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, ret,
+ CHANGELOG_LIB_MSG_PTHREAD_ERROR,
"unable to sets the detach"
- " state attribute, reason(%s)",
- strerror (ret));
+ " state attribute");
ret = -1;
goto out;
}
@@ -932,9 +949,10 @@ gf_history_changelog (char* changelog_dir, unsigned long start,
ret = pthread_create (&consume_th, &attr,
gf_history_consume, hist_data);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "creation of consume parent-thread"
- " failed. reason(%s)", strerror (ret));
+ gf_msg (this->name, GF_LOG_ERROR, ret,
+ CHANGELOG_LIB_MSG_THREAD_CREATION_FAILED
+ , "creation of consume parent-thread"
+ " failed.");
ret = -1;
goto out;
}