diff options
author | Anusha Rao <anusha91rao@gmail.com> | 2015-05-04 12:34:09 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2015-08-11 22:36:44 -0700 |
commit | 64e6836ac8fb96f38a859eea0d8525cd9bd2693f (patch) | |
tree | eb00359a9dd7be26f90f9147330a8e2c6fa83232 | |
parent | 0dcdc8d9d797ed43d305fb3e3437c2576305ac46 (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>
18 files changed, 1328 insertions, 376 deletions
diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h index ded41e3cedc..025ff5b24eb 100644 --- a/libglusterfs/src/glfs-message-id.h +++ b/libglusterfs/src/glfs-message-id.h @@ -155,6 +155,10 @@ GLFS_MSGID_COMP_SYMLINK_CACHE_END #define GLFS_MSGID_COMP_WRITE_BEHIND_END (GLFS_MSGID_COMP_WRITE_BEHIND+\ GLFS_MSGID_SEGMENT) +#define GLFS_MSGID_COMP_CHANGELOG_LIB GLFS_MSGID_COMP_WRITE_BEHIND_END +#define GLFS_MSGID_COMP_CHANGELOG_LIB_END (GLFS_MSGID_COMP_CHANGELOG_LIB+\ + GLFS_MSGID_SEGMENT) + /* --- new segments for messages goes above this line --- */ #endif /* !_GLFS_MESSAGE_ID_H_ */ 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; } diff --git a/xlators/features/changelog/src/Makefile.am b/xlators/features/changelog/src/Makefile.am index 8712b9d059f..f70e5f8e707 100644 --- a/xlators/features/changelog/src/Makefile.am +++ b/xlators/features/changelog/src/Makefile.am @@ -4,7 +4,8 @@ xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features noinst_HEADERS = changelog-helpers.h changelog-mem-types.h changelog-rt.h \ changelog-rpc-common.h changelog-misc.h changelog-encoders.h \ - changelog-rpc-common.h changelog-rpc.h changelog-ev-handle.h + changelog-rpc-common.h changelog-rpc.h changelog-ev-handle.h \ + changelog-messages.h changelog_la_LDFLAGS = -module -avoid-version diff --git a/xlators/features/changelog/src/changelog-barrier.c b/xlators/features/changelog/src/changelog-barrier.c index 22cfa617e1b..ac1eb0e4397 100644 --- a/xlators/features/changelog/src/changelog-barrier.c +++ b/xlators/features/changelog/src/changelog-barrier.c @@ -9,6 +9,7 @@ */ #include "changelog-helpers.h" +#include "changelog-messages.h" #include "call-stub.h" /* Enqueue a stub*/ @@ -52,13 +53,15 @@ chlog_barrier_dequeue_all (xlator_t *this, struct list_head *queue) { call_stub_t *stub = NULL; - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Dequeuing all the changelog barriered fops"); while ((stub = __chlog_barrier_dequeue (this, queue))) call_resume (stub); - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Dequeuing changelog barriered fops is finished"); return; } @@ -77,7 +80,8 @@ chlog_barrier_timeout (void *data) INIT_LIST_HEAD (&queue); - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_BARRIER_ERROR, "Disabling changelog barrier because of the timeout."); LOCK (&priv->lock); @@ -117,7 +121,8 @@ __chlog_barrier_enable (xlator_t *this, changelog_priv_t *priv) priv->timer = gf_timer_call_after (this->ctx, priv->timeout, chlog_barrier_timeout, (void *)this); if (!priv->timer) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, 0, + CHANGELOG_MSG_BARRIER_ERROR, "Couldn't add changelog barrier timeout event."); goto out; } diff --git a/xlators/features/changelog/src/changelog-ev-handle.c b/xlators/features/changelog/src/changelog-ev-handle.c index ca7443cfd22..5167b56ed88 100644 --- a/xlators/features/changelog/src/changelog-ev-handle.c +++ b/xlators/features/changelog/src/changelog-ev-handle.c @@ -199,8 +199,10 @@ changelog_ev_connector (void *data) crpc->sock, changelog_rpc_notify); if (!crpc->rpc) { - gf_log (this->name, GF_LOG_ERROR, "failed to " - "connect back.. <%s>", crpc->sock); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_RPC_CONNECT_ERROR, + "failed to connect back.. <%s>", + crpc->sock); crpc->cleanup (crpc); goto mutex_unlock; } @@ -338,7 +340,8 @@ changelog_ev_dispatch (void *data) &opaque, sequencer, c_clnt); if (ret != RBUF_CONSUMABLE) { if (ret != RBUF_EMPTY) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_BUFFER_STARVATION_ERROR, "Failed to get buffer for RPC dispatch " "[rbuf retval: %d]", ret); continue; @@ -347,7 +350,8 @@ changelog_ev_dispatch (void *data) ret = rbuf_wait_for_completion (c_clnt->rbuf, opaque, _dispatcher, c_clnt); if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_PUT_BUFFER_FAILED, "failed to put buffer after consumption"); } diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c index a3a1289d792..d67be6f9838 100644 --- a/xlators/features/changelog/src/changelog-helpers.c +++ b/xlators/features/changelog/src/changelog-helpers.c @@ -17,6 +17,7 @@ #include "changelog-helpers.h" #include "changelog-encoders.h" #include "changelog-mem-types.h" +#include "changelog-messages.h" #include "changelog-encoders.h" #include "changelog-rpc-common.h" @@ -40,17 +41,17 @@ changelog_thread_cleanup (xlator_t *this, pthread_t thr_id) /* send a cancel request to the thread */ ret = pthread_cancel (thr_id); if (ret != 0) { - gf_log (this->name, GF_LOG_ERROR, - "could not cancel thread (reason: %s)", - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_CANCEL_FAILED, + "could not cancel thread"); goto out; } ret = pthread_join (thr_id, &retval); if ((ret != 0) || (retval != PTHREAD_CANCELED)) { - gf_log (this->name, GF_LOG_ERROR, - "cancel request not adhered as expected" - " (reason: %s)", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_CANCEL_FAILED, + "cancel request not adhered as expected"); } out: @@ -86,9 +87,9 @@ changelog_ev_selected (xlator_t *this, int idx = 0; idx = changelog_selector_index (selector); - gf_log (this->name, GF_LOG_DEBUG, - "selector ref count for %d (idx: %d): %d", - selector, idx, selection->ref[idx]); + gf_msg_debug (this->name, 0, + "selector ref count for %d (idx: %d): %d", + selector, idx, selection->ref[idx]); /* this can be lockless */ return (idx < CHANGELOG_EV_SELECTION_RANGE && (selection->ref[idx] > 0)); @@ -107,8 +108,8 @@ changelog_select_event (xlator_t *this, idx = changelog_selector_index (selector); if (idx < CHANGELOG_EV_SELECTION_RANGE) { selection->ref[idx]++; - gf_log (this->name, GF_LOG_DEBUG, - "selecting event %d", idx); + gf_msg_debug (this->name, 0, + "selecting event %d", idx); } selector &= ~(1 << idx); } @@ -129,8 +130,8 @@ changelog_deselect_event (xlator_t *this, idx = changelog_selector_index (selector); if (idx < CHANGELOG_EV_SELECTION_RANGE) { selection->ref[idx]--; - gf_log (this->name, GF_LOG_DEBUG, - "de-selecting event %d", idx); + gf_msg_debug (this->name, 0, + "de-selecting event %d", idx); } selector &= ~(1 << idx); } @@ -171,7 +172,8 @@ changelog_cleanup_event_selection (xlator_t *this, { while (j--) { if (selection->ref[j] > 0) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_CLEANUP_ON_ACTIVE_REF, "changelog event selection cleaning up " " on active references"); } @@ -190,8 +192,10 @@ changelog_perform_dispatch (xlator_t *this, buf = rbuf_reserve_write_area (priv->rbuf, size, &opaque); if (!buf) { - gf_log_callingfn (this->name, - GF_LOG_WARNING, "failed to dispatch event"); + gf_msg_callingfn (this->name, + GF_LOG_WARNING, 0, + CHANGELOG_MSG_DISPATCH_EVENT_FAILED, + "failed to dispatch event"); return; } @@ -281,7 +285,8 @@ htime_update (xlator_t *this, int ret = 0; if (priv->htime_fd ==-1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_HTIME_ERROR, "Htime fd not available for updation"); ret = -1; goto out; @@ -291,7 +296,8 @@ htime_update (xlator_t *this, changelog_path[len] = '\0'; /* redundant */ if (changelog_write (priv->htime_fd, (void*) changelog_path, len+1 ) < 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_HTIME_ERROR, "Htime file content write failed"); ret =-1; goto out; @@ -301,17 +307,17 @@ htime_update (xlator_t *this, if (sys_fsetxattr (priv->htime_fd, HTIME_KEY, x_value, strlen (x_value), XATTR_REPLACE)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_HTIME_ERROR, "Htime xattr updation failed with XATTR_REPLACE " - "Changelog: %s Reason (%s)", changelog_path, - strerror (errno)); + "Changelog: %s", changelog_path); if (sys_fsetxattr (priv->htime_fd, HTIME_KEY, x_value, strlen (x_value), 0)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_HTIME_ERROR, "Htime xattr updation failed " - "Changelog: %s Reason (%s)", changelog_path, - strerror (errno)); + "Changelog: %s", changelog_path); ret = -1; goto out; } @@ -344,15 +350,17 @@ cl_is_empty (xlator_t *this, int fd) ret = fstat (fd, &stbuf); if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "Could not stat (CHANGELOG)"); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSTAT_OP_FAILED, + "Could not stat (CHANGELOG)"); goto out; } ret = lseek (fd, 0, SEEK_SET); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, - "Could not lseek (CHANGELOG)"); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_LSEEK_OP_FAILED, + "Could not lseek (CHANGELOG)"); goto out; } @@ -389,8 +397,9 @@ update_path (xlator_t *this, char *cl_path) found = strstr(cl_path, up_cl); if (found == NULL) { - gf_log (this->name, GF_LOG_ERROR, - "Could not find CHANGELOG in changelog path"); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_LSEEK_OP_FAILED, + "Could not find CHANGELOG in changelog path"); goto out; } else { strncpy(found, low_cl, strlen(low_cl)); @@ -415,17 +424,18 @@ changelog_rollover_changelog (xlator_t *this, if (priv->changelog_fd != -1) { ret = fsync (priv->changelog_fd); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "fsync failed (reason: %s)", - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSYNC_OP_FAILED, + "fsync failed"); } ret = cl_is_empty (this, priv->changelog_fd); if (ret == 1) { cl_empty_flag = 1; } else if (ret == -1) { /* Log error but proceed as usual */ - gf_log (this->name, GF_LOG_WARNING, - "Error detecting empty changelog"); + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_DETECT_EMPTY_CHANGELOG_FAILED, + "Error detecting empty changelog"); } close (priv->changelog_fd); priv->changelog_fd = -1; @@ -440,9 +450,10 @@ changelog_rollover_changelog (xlator_t *this, if (cl_empty_flag == 1) { ret = unlink (ofile); if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "error unlinking(empty cl) %s (reason %s)", - ofile, strerror(errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_UNLINK_OP_FAILED, + "error unlinking(empty cl) %s)", + ofile); ret = 0; /* Error in unlinking empty changelog should not break further changelog operation, so reset return value to 0*/ @@ -455,14 +466,19 @@ changelog_rollover_changelog (xlator_t *this, goto out; } if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "error renaming %s -> %s (reason %s)", - ofile, nfile, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_RENAME_ERROR, + "error renaming %s -> %s", + ofile, nfile); } } if (!ret && (cl_empty_flag == 0)) { notify = 1; + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_RENAME_ERROR, + "error renaming %s -> %s", + ofile, nfile); } if (!ret) { @@ -471,7 +487,8 @@ changelog_rollover_changelog (xlator_t *this, } ret = htime_update (this, priv, ts, nfile); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, + 0, CHANGELOG_MSG_HTIME_ERROR, "could not update htime file"); goto out; } @@ -496,10 +513,13 @@ changelog_rollover_changelog (xlator_t *this, { if (ret) { priv->bn.bnotify_error = _gf_true; - gf_log (this->name, GF_LOG_ERROR, "Fail " - "snapshot because of previous errors"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_EXPLICIT_ROLLOVER_FAILED, + "Fail snapshot because of " + "previous errors"); } else { - gf_log (this->name, GF_LOG_INFO, "Explicit " + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BNOTIFY_INFO, "Explicit " "rollover changelog: %s signaling " "bnotify", nfile); } @@ -548,23 +568,26 @@ find_current_htime (int ht_dir_fd, const char *ht_dir_path, char *ht_file_bname) cnt = scandir (ht_dir_path, &namelist, filter_cur_par_dirs, alphasort); if (cnt < 0) { - gf_log (this->name, GF_LOG_ERROR, - "scandir failed: %s", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_SCAN_DIR_FAILED, + "scandir failed"); } else if (cnt > 0) { strncpy (ht_file_bname, namelist[cnt - 1]->d_name, NAME_MAX); ht_file_bname[NAME_MAX - 1] = 0; if (sys_fsetxattr (ht_dir_fd, HTIME_CURRENT, ht_file_bname, strlen (ht_file_bname), 0)) { - gf_log (this->name, GF_LOG_ERROR, "fsetxattr failed:" - " HTIME_CURRENT: %s", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSETXATTR_FAILED, + "fsetxattr failed: HTIME_CURRENT"); ret = -1; goto out; } if (fsync (ht_dir_fd) < 0) { - gf_log (this->name, GF_LOG_ERROR, - "fsync failed (reason: %s)", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSYNC_OP_FAILED, + "fsync failed"); ret = -1; goto out; } @@ -607,8 +630,9 @@ htime_open (xlator_t *this, /* Open htime directory to get HTIME_CURRENT */ ht_dir_fd = open (ht_dir_path, O_RDONLY); if (ht_dir_fd == -1) { - gf_log (this->name, GF_LOG_ERROR, "open failed: %s : %s", - ht_dir_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, "open failed: %s", + ht_dir_path); ret = -1; goto out; } @@ -616,6 +640,10 @@ htime_open (xlator_t *this, size = sys_fgetxattr (ht_dir_fd, HTIME_CURRENT, ht_file_bname, sizeof (ht_file_bname)); if (size < 0) { + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FGETXATTR_FAILED, "Error extracting" + " HTIME_CURRENT."); + /* If upgrade scenario, find the latest HTIME.TSTAMP file * and use the same. If error, create a new HTIME.TSTAMP * file. @@ -623,17 +651,20 @@ htime_open (xlator_t *this, cnt = find_current_htime (ht_dir_fd, ht_dir_path, ht_file_bname); if (cnt <= 0) { - gf_log (this->name, GF_LOG_INFO, - "HTIME_CURRENT not found: %s. Changelog enabled" - " before init", strerror (errno)); + gf_msg (this->name, GF_LOG_INFO, errno, + CHANGELOG_MSG_HTIME_INFO, + "HTIME_CURRENT not found. Changelog enabled" + " before init"); return htime_create (this, priv, ts); } - gf_log (this->name, GF_LOG_ERROR, "Error extracting" - " HTIME_CURRENT: %s.", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_HTIME_ERROR, "Error extracting" + " HTIME_CURRENT."); } - gf_log (this->name, GF_LOG_INFO, "HTIME_CURRENT: %s", ht_file_bname); + gf_msg (this->name, GF_LOG_INFO, 0, CHANGELOG_MSG_HTIME_INFO, + "HTIME_CURRENT: %s", ht_file_bname); (void) snprintf (ht_file_path, PATH_MAX, "%s/%s", ht_dir_path, ht_file_bname); @@ -642,9 +673,10 @@ htime_open (xlator_t *this, ht_file_fd = open (ht_file_path, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (ht_file_fd < 0) { - gf_log (this->name, GF_LOG_ERROR, - "unable to open htime file: %s" - "(reason: %s)", ht_file_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, + "unable to open htime file: %s", + ht_file_path); ret = -1; goto out; } @@ -655,15 +687,18 @@ htime_open (xlator_t *this, /* Initialize rollover-number in priv to current number */ size = sys_fgetxattr (ht_file_fd, HTIME_KEY, x_value, sizeof (x_value)); if (size < 0) { - gf_log (this->name, GF_LOG_ERROR, "error extracting max" - " timstamp from htime file %s (reason %s)", - ht_file_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FGETXATTR_FAILED, "error extracting max" + " timstamp from htime file %s", + ht_file_path); ret = -1; goto out; } sscanf (x_value, "%lu:%lu", &max_ts, &total); - gf_log (this->name, GF_LOG_INFO, "INIT CASE: MIN: %lu, MAX: %lu," + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_TOTAL_LOG_INFO, + "INIT CASE: MIN: %lu, MAX: %lu," " TOTAL CHANGELOGS: %lu", min_ts, max_ts, total); priv->rollover_count = total + 1; @@ -688,7 +723,8 @@ htime_create (xlator_t *this, char ht_file_bname[NAME_MAX + 1] = {0,}; int flags = 0; - gf_log (this->name, GF_LOG_INFO, "Changelog enable: Creating new " + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_HTIME_INFO, "Changelog enable: Creating new " "HTIME.%lu file", ts); CHANGELOG_FILL_HTIME_DIR(priv->changelog_dir, ht_dir_path); @@ -701,16 +737,18 @@ htime_create (xlator_t *this, ht_file_fd = open (ht_file_path, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (ht_file_fd < 0) { - gf_log (this->name, GF_LOG_ERROR, - "unable to create htime file: %s" - "(reason: %s)", ht_file_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, + "unable to create htime file: %s", + ht_file_path); ret = -1; goto out; } if (sys_fsetxattr (ht_file_fd, HTIME_KEY, HTIME_INITIAL_VALUE, sizeof (HTIME_INITIAL_VALUE)-1, 0)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSETXATTR_FAILED, "Htime xattr initialization failed"); ret = -1; goto out; @@ -718,16 +756,18 @@ htime_create (xlator_t *this, ret = fsync (ht_file_fd); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "fsync failed (reason: %s)", - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSYNC_OP_FAILED, + "fsync failed"); goto out; } /* Set xattr HTIME_CURRENT on htime directory to htime filename */ ht_dir_fd = open (ht_dir_path, O_RDONLY); if (ht_dir_fd == -1) { - gf_log (this->name, GF_LOG_ERROR, "open of %s failed: %s", - ht_dir_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, "open of %s failed", + ht_dir_path); ret = -1; goto out; } @@ -736,16 +776,18 @@ htime_create (xlator_t *this, HTIME_FILE_NAME, ts); if (sys_fsetxattr (ht_dir_fd, HTIME_CURRENT, ht_file_bname, strlen (ht_file_bname), 0)) { - gf_log (this->name, GF_LOG_ERROR, "fsetxattr failed:" - " HTIME_CURRENT: %s", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSETXATTR_FAILED, "fsetxattr failed:" + " HTIME_CURRENT"); ret = -1; goto out; } ret = fsync (ht_dir_fd); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "fsync failed (reason: %s)", - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSYNC_OP_FAILED, + "fsync failed"); goto out; } @@ -790,9 +832,9 @@ changelog_snap_open (xlator_t *this, fd = open (c_snap_path, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { - gf_log (this->name, GF_LOG_ERROR, - "unable to open %s file " - "reason:(%s)", c_snap_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, "unable to open %s file ", + c_snap_path); ret = -1; goto out; } @@ -827,7 +869,8 @@ changelog_snap_logging_start (xlator_t *this, int ret = 0; ret = changelog_snap_open (this, priv); - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_SNAP_INFO, "Now starting to log in call path"); return ret; @@ -849,8 +892,9 @@ changelog_snap_logging_stop (xlator_t *this, close (priv->c_snap_fd); priv->c_snap_fd = -1; - gf_log (this->name, GF_LOG_INFO, - "Stopped to log in call path"); + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_SNAP_INFO, + "Stopped to log in call path"); return ret; } @@ -876,10 +920,11 @@ changelog_open_journal (xlator_t *this, fd = open (changelog_path, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { - gf_log (this->name, GF_LOG_ERROR, - "unable to open/create changelog file %s" - " (reason: %s). change-logging will be" - " inactive", changelog_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, + "unable to open/create changelog file %s." + " change-logging will be" + " inactive", changelog_path); goto out; } @@ -998,10 +1043,11 @@ changelog_snap_handle_ascii_change (xlator_t *this, ret = changelog_snap_write_change (priv, buffer, off); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "error writing csnap to disk"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_WRITE_FAILED, + "error writing csnap to disk"); } - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, CHANGELOG_MSG_SNAP_INFO, "Successfully wrote to csnap"); ret = 0; out: @@ -1020,7 +1066,8 @@ changelog_handle_change (xlator_t *this, cld->cld_roll_time, cld->cld_finale); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_GET_TIME_OP_FAILED, "Problem rolling over changelog(s)"); goto out; } @@ -1035,16 +1082,17 @@ changelog_handle_change (xlator_t *this, if (CHANGELOG_TYPE_IS_FSYNC (cld->cld_type)) { ret = fsync (priv->changelog_fd); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "fsync failed (reason: %s)", - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSYNC_OP_FAILED, + "fsync failed"); } goto out; } ret = priv->ce->encode (this, cld); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_WRITE_FAILED, "error writing changelog to disk"); } @@ -1066,7 +1114,8 @@ changelog_local_init (xlator_t *this, inode_t *inode, * not blindly use local->inode. */ if (!update_flag && !inode) { - gf_log_callingfn (this->name, GF_LOG_WARNING, + gf_msg_callingfn (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_INODE_NOT_FOUND, "inode needed for version checking !!!"); goto out; } @@ -1136,27 +1185,31 @@ changelog_drain_black_fops (xlator_t *this, changelog_priv_t *priv) &priv->dm.drain_black_mutex); ret = pthread_mutex_lock (&priv->dm.drain_black_mutex); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread error:" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_ERROR, "pthread error:" " Error:%d", ret); while (priv->dm.black_fop_cnt > 0) { - gf_log (this->name, GF_LOG_DEBUG, - "Condtional wait on black fops: %ld", - priv->dm.black_fop_cnt); + gf_msg_debug (this->name, 0, + "Condtional wait on black fops: %ld", + priv->dm.black_fop_cnt); priv->dm.drain_wait_black = _gf_true; ret = pthread_cond_wait (&priv->dm.drain_black_cond, &priv->dm.drain_black_mutex); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread" - " cond wait failed: Error:%d", ret); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_COND_WAIT_FAILED, + "pthread cond wait failed: Error:%d", + ret); } priv->dm.drain_wait_black = _gf_false; ret = pthread_mutex_unlock (&priv->dm.drain_black_mutex); - pthread_cleanup_pop (0); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread error:" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_ERROR, "pthread error:" " Error:%d", ret); - gf_log (this->name, GF_LOG_DEBUG, - "Woke up: Conditional wait on black fops"); + pthread_cleanup_pop (0); + gf_msg_debug (this->name, 0, + "Woke up: Conditional wait on black fops"); } /* Wait till all the white fops are drained */ @@ -1173,27 +1226,31 @@ changelog_drain_white_fops (xlator_t *this, changelog_priv_t *priv) &priv->dm.drain_white_mutex); ret = pthread_mutex_lock (&priv->dm.drain_white_mutex); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread error:" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_ERROR, "pthread error:" " Error:%d", ret); while (priv->dm.white_fop_cnt > 0) { - gf_log (this->name, GF_LOG_DEBUG, - "Condtional wait on white fops : %ld", + gf_msg_debug (this->name, 0, + "Condtional wait on white fops : %ld", priv->dm.white_fop_cnt); priv->dm.drain_wait_white = _gf_true; ret = pthread_cond_wait (&priv->dm.drain_white_cond, &priv->dm.drain_white_mutex); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread" - " cond wait failed: Error:%d", ret); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_COND_WAIT_FAILED, + "pthread cond wait failed: Error:%d", + ret); } priv->dm.drain_wait_white = _gf_false; ret = pthread_mutex_unlock (&priv->dm.drain_white_mutex); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread error:" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_ERROR, "pthread error:" " Error:%d", ret); pthread_cleanup_pop (0); - gf_log (this->name, GF_LOG_DEBUG, - "Woke up: Conditional wait on white fops"); + gf_msg_debug (this->name, 0, + "Woke up: Conditional wait on white fops"); } /** @@ -1237,28 +1294,32 @@ changelog_rollover (void *data) ret = select (max_fd, &rset, NULL, NULL, &tv); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, - "select failed: %s", strerror(errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_SELECT_FAILED, + "select failed"); continue; } else if (ret && FD_ISSET(priv->cr.rfd, &rset)) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Explicit wakeup of select on barrier notify"); len = read(priv->cr.rfd, buf, 1); if (len == 0) { - gf_log (this->name, GF_LOG_ERROR, "BUG: Got EOF" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_READ_ERROR, "BUG: Got EOF" " from reconfigure notification pipe"); continue; } if (len < 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_READ_ERROR, "Failed to read wakeup data"); continue; } /* Lock is not required as same thread is modifying.*/ priv->explicit_rollover = _gf_true; } else { - gf_log (this->name, GF_LOG_DEBUG, - "select wokeup on timeout"); + gf_msg_debug (this->name, 0, + "select wokeup on timeout"); } /* Reading curent_color without lock is fine here @@ -1268,15 +1329,17 @@ changelog_rollover (void *data) LOCK(&priv->lock); priv->current_color = FOP_COLOR_WHITE; UNLOCK(&priv->lock); - gf_log (this->name, GF_LOG_DEBUG, "Black fops" - " to be drained:%ld",priv->dm.black_fop_cnt); + gf_msg_debug (this->name, 0, "Black fops" + " to be drained:%ld", + priv->dm.black_fop_cnt); changelog_drain_black_fops (this, priv); } else { LOCK(&priv->lock); priv->current_color = FOP_COLOR_BLACK; UNLOCK(&priv->lock); - gf_log (this->name, GF_LOG_DEBUG, "White fops" - " to be drained:%ld",priv->dm.white_fop_cnt); + gf_msg_debug (this->name, 0, "White fops" + " to be drained:%ld", + priv->dm.white_fop_cnt); changelog_drain_white_fops (this, priv); } @@ -1306,7 +1369,8 @@ changelog_rollover (void *data) ret = changelog_fill_rollover_data (&cld, _gf_false); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_GET_TIME_OP_FAILED, "failed to fill rollover data"); continue; } @@ -1353,7 +1417,8 @@ changelog_fsync_thread (void *data) ret = changelog_inject_single_event (this, priv, &cld); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_INJECT_FSYNC_FAILED, "failed to inject fsync event"); _unmask_cancellation (); @@ -1682,8 +1747,9 @@ changelog_dec_fop_cnt (xlator_t *this, changelog_priv_t *priv, &priv->dm.drain_black_cond); CHANGELOG_PTHREAD_ERROR_HANDLE_0 (ret, out); - gf_log (this->name, GF_LOG_DEBUG, - "Signalled draining of black"); + gf_msg_debug (this->name, 0, + "Signalled " + "draining of black"); } } ret = pthread_mutex_unlock(&priv->dm.drain_black_mutex); @@ -1699,8 +1765,9 @@ changelog_dec_fop_cnt (xlator_t *this, changelog_priv_t *priv, &priv->dm.drain_white_cond); CHANGELOG_PTHREAD_ERROR_HANDLE_0 (ret, out); - gf_log (this->name, GF_LOG_DEBUG, - "Signalled draining of white"); + gf_msg_debug (this->name, 0, + "Signalled " + "draining of white"); } } ret = pthread_mutex_unlock(&priv->dm.drain_white_mutex); @@ -1775,21 +1842,25 @@ changelog_fill_entry_buf (call_frame_t *frame, xlator_t *this, parent = inode_parent (loc->inode, 0, 0); if (!parent) { - gf_log (this->name, GF_LOG_ERROR, "Parent inode not found" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_INODE_NOT_FOUND, "Parent inode not found" " for gfid: %s", uuid_utoa (loc->inode->gfid)); goto err; } CHANGELOG_INIT_NOCHECK (this, *local, loc->inode, loc->inode->gfid, 5); if (!(*local)) { - gf_log (this->name, GF_LOG_ERROR, "changelog local" + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_LOCAL_INIT_FAILED, "changelog local" " initiatilization failed"); goto err; } co = changelog_get_usable_buffer (*local); if (!co) { - gf_log (this->name, GF_LOG_ERROR, "Failed to get buffer"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_NO_MEMORY, + "Failed to get buffer"); goto err; } @@ -1886,9 +1957,10 @@ resolve_pargfid_to_path (xlator_t *this, uuid_t pargfid, len = readlink (dir_handle, linkname, PATH_MAX); if (len < 0) { - gf_log (this->name, GF_LOG_ERROR, "could not read the " - "link from the gfid handle %s (%s)", dir_handle, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_READLINK_OP_FAILED, + "could not read the " + "link from the gfid handle %s", dir_handle); ret = -1; goto out; } diff --git a/xlators/features/changelog/src/changelog-helpers.h b/xlators/features/changelog/src/changelog-helpers.h index 6219d8d9a4b..4427e93f601 100644 --- a/xlators/features/changelog/src/changelog-helpers.h +++ b/xlators/features/changelog/src/changelog-helpers.h @@ -24,6 +24,7 @@ #include "changelog-ev-handle.h" #include "changelog.h" +#include "changelog-messages.h" /** * the changelog entry @@ -644,7 +645,8 @@ resolve_pargfid_to_path (xlator_t *this, uuid_t gfid, char **path, char *bname); #define CHANGELOG_NOT_ON_THEN_GOTO(priv, ret, label) do { \ if (!priv->active) { \ - gf_log (this->name, GF_LOG_WARNING, \ + gf_msg (this->name, GF_LOG_WARNING, 0, \ + CHANGELOG_MSG_NOT_ACTIVE, \ "Changelog is not active, return success"); \ ret = 0; \ goto label; \ @@ -654,17 +656,19 @@ resolve_pargfid_to_path (xlator_t *this, uuid_t gfid, char **path, char *bname); /* Log pthread error and goto label */ #define CHANGELOG_PTHREAD_ERROR_HANDLE_0(ret, label) do { \ if (ret) { \ - gf_log (this->name, GF_LOG_ERROR, \ + gf_msg (this->name, GF_LOG_ERROR, \ + 0, CHANGELOG_MSG_PTHREAD_ERROR, \ "pthread error: Error: %d", ret); \ ret = -1; \ goto label; \ } \ - } while (0) + } while (0); /* Log pthread error, set flag and goto label */ #define CHANGELOG_PTHREAD_ERROR_HANDLE_1(ret, label, flag) do { \ if (ret) { \ - gf_log (this->name, GF_LOG_ERROR, \ + gf_msg (this->name, GF_LOG_ERROR, 0, \ + CHANGELOG_MSG_PTHREAD_ERROR, \ "pthread error: Error: %d", ret); \ ret = -1; \ flag = _gf_true; \ diff --git a/xlators/features/changelog/src/changelog-messages.h b/xlators/features/changelog/src/changelog-messages.h new file mode 100644 index 00000000000..e65a457b7c0 --- /dev/null +++ b/xlators/features/changelog/src/changelog-messages.h @@ -0,0 +1,450 @@ +/* + 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_MESSAGES_H_ +#define _CHANGELOG_MESSAGES_H_ + +#ifndef _CONFIG_H +#define _CONFIG_H +#include "config.h" +#endif + +#include "glfs-message-id.h" + +/*! \file changelog-messages.h + * \brief CHANGELOG 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 GLFS_MSGID_COMP_CHANGELOG +#define GLFS_NUM_MESSAGES 54 +#define GLFS_MSGID_END (GLFS_COMP_BASE_CHANGELOG + GLFS_NUM_MESSAGES + 1) + +#define glfs_msg_start_x GLFS_COMP_BASE_CHANGELOG, "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_MSG_OPEN_FAILED (GLFS_COMP_BASE_CHANGELOG + 1) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_NO_MEMORY (GLFS_COMP_BASE_CHANGELOG + 2) +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_VOL_MISCONFIGURED (GLFS_COMP_BASE_CHANGELOG + 3) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_RENAME_ERROR (GLFS_COMP_BASE_CHANGELOG + 4) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_READ_ERROR (GLFS_COMP_BASE_CHANGELOG + 5) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_HTIME_ERROR (GLFS_COMP_BASE_CHANGELOG + 6) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PTHREAD_MUTEX_INIT_FAILED (GLFS_COMP_BASE_CHANGELOG + 7) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PTHREAD_COND_INIT_FAILED (GLFS_COMP_BASE_CHANGELOG + 8) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_CHILD_MISCONFIGURED (GLFS_COMP_BASE_CHANGELOG + 9) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_DIR_OPTIONS_NOT_SET (GLFS_COMP_BASE_CHANGELOG + 10) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_CLOSE_ERROR (GLFS_COMP_BASE_CHANGELOG + 11) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PIPE_CREATION_ERROR (GLFS_COMP_BASE_CHANGELOG + 12) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_DICT_GET_FAILED (GLFS_COMP_BASE_CHANGELOG + 13) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_BARRIER_INFO (GLFS_COMP_BASE_CHANGELOG + 14) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_BARRIER_ERROR (GLFS_COMP_BASE_CHANGELOG + 15) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_GET_TIME_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 16) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_WRITE_FAILED (GLFS_COMP_BASE_CHANGELOG + 17) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PTHREAD_ERROR (GLFS_COMP_BASE_CHANGELOG + 18) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_INODE_NOT_FOUND (GLFS_COMP_BASE_CHANGELOG + 19) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FSYNC_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 20) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_TOTAL_LOG_INFO (GLFS_COMP_BASE_CHANGELOG + 21) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_SNAP_INFO (GLFS_COMP_BASE_CHANGELOG + 22) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_SELECT_FAILED (GLFS_COMP_BASE_CHANGELOG + 23) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FCNTL_FAILED (GLFS_COMP_BASE_CHANGELOG + 24) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_BNOTIFY_INFO (GLFS_COMP_BASE_CHANGELOG + 25) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_ENTRY_BUF_INFO (GLFS_COMP_BASE_CHANGELOG + 26) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_NOT_ACTIVE (GLFS_COMP_BASE_CHANGELOG + 27) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_LOCAL_INIT_FAILED (GLFS_COMP_BASE_CHANGELOG + 28) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_NOTIFY_REGISTER_FAILED (GLFS_COMP_BASE_CHANGELOG + 28) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PROGRAM_NAME_REG_FAILED (GLFS_COMP_BASE_CHANGELOG + 29) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_HANDLE_PROBE_ERROR (GLFS_COMP_BASE_CHANGELOG + 30) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_SET_FD_CONTEXT (GLFS_COMP_BASE_CHANGELOG + 31) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FREEUP_FAILED (GLFS_COMP_BASE_CHANGELOG + 32) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_HTIME_INFO (GLFS_COMP_BASE_CHANGELOG + 33) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_RPC_SUBMIT_REPLY_FAILED (GLFS_COMP_BASE_CHANGELOG + 34) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_RPC_BUILD_ERROR (GLFS_COMP_BASE_CHANGELOG + 35) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_RPC_CONNECT_ERROR (GLFS_COMP_BASE_CHANGELOG + 36) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_RPC_START_ERROR (GLFS_COMP_BASE_CHANGELOG + 37) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_BUFFER_STARVATION_ERROR (GLFS_COMP_BASE_CHANGELOG + 3) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_SCAN_DIR_FAILED (GLFS_COMP_BASE_CHANGELOG + 39) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FSETXATTR_FAILED (GLFS_COMP_BASE_CHANGELOG + 40) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FGETXATTR_FAILED (GLFS_COMP_BASE_CHANGELOG + 41) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_CLEANUP_ON_ACTIVE_REF \ + (GLFS_COMP_BASE_CHANGELOG + 42) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_DISPATCH_EVENT_FAILED (GLFS_COMP_BASE_CHANGELOG + 43) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PUT_BUFFER_FAILED (GLFS_COMP_BASE_CHANGELOG + 44) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PTHREAD_COND_WAIT_FAILED (GLFS_COMP_BASE_CHANGELOG + 45) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PTHREAD_CANCEL_FAILED (GLFS_COMP_BASE_CHANGELOG + 46) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_INJECT_FSYNC_FAILED (GLFS_COMP_BASE_CHANGELOG + 47) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_CREATE_FRAME_FAILED (GLFS_COMP_BASE_CHANGELOG + 48) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FSTAT_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 49) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_LSEEK_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 50) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_STRSTR_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 51) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_UNLINK_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 52) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_DETECT_EMPTY_CHANGELOG_FAILED \ + (GLFS_COMP_BASE_CHANGELOG + 53) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_READLINK_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 54) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_EXPLICIT_ROLLOVER_FAILED (GLFS_COMP_BASE_CHANGELOG + 55) + + + +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" +#endif /* !_CHANGELOG_MESSAGES_H_ */ diff --git a/xlators/features/changelog/src/changelog-rpc-common.c b/xlators/features/changelog/src/changelog-rpc-common.c index de3a730534e..7d2ec1de988 100644 --- a/xlators/features/changelog/src/changelog-rpc-common.c +++ b/xlators/features/changelog/src/changelog-rpc-common.c @@ -9,7 +9,7 @@ */ #include "changelog-rpc-common.h" - +#include "changelog-messages.h" /** ***************************************************** Client Interface @@ -47,7 +47,8 @@ changelog_rpc_client_init (xlator_t *this, void *cbkdata, ret = rpc_transport_unix_options_build (&options, sockfile, 0); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_RPC_BUILD_ERROR, "failed to build rpc options"); goto dealloc_dict; } @@ -58,13 +59,17 @@ changelog_rpc_client_init (xlator_t *this, void *cbkdata, ret = rpc_clnt_register_notify (rpc, fn, cbkdata); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "failed to register notify"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_NOTIFY_REGISTER_FAILED, + "failed to register notify"); goto dealloc_rpc_clnt; } ret = rpc_clnt_start (rpc); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "failed to start rpc"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_RPC_START_ERROR, + "failed to start rpc"); goto dealloc_rpc_clnt; } @@ -158,7 +163,9 @@ changelog_invoke_rpc (xlator_t *this, struct rpc_clnt *rpc, frame = create_frame (this, this->ctx->pool); if (!frame) { - gf_log (this->name, GF_LOG_ERROR, "failed to create frame"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_CREATE_FRAME_FAILED, + "failed to create frame"); goto error_return; } @@ -229,7 +236,9 @@ changelog_rpc_sumbit_reply (rpcsvc_request_t *req, iob = __changelog_rpc_serialize_reply (req, arg, &iov, xdrproc); if (!iob) - gf_log ("", GF_LOG_ERROR, "failed to serialize reply"); + gf_msg ("", GF_LOG_ERROR, 0, + CHANGELOG_MSG_RPC_SUBMIT_REPLY_FAILED, + "failed to serialize reply"); else iobref_add (iobref, iob); @@ -290,21 +299,24 @@ changelog_rpc_server_init (xlator_t *this, char *sockfile, void *cbkdata, rpc = rpcsvc_init (this, this->ctx, options, 8); if (rpc == NULL) { - gf_log (this->name, GF_LOG_ERROR, "failed to init rpc"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_RPC_START_ERROR, + "failed to init rpc"); goto dealloc_dict; } ret = rpcsvc_register_notify (rpc, fn, cbkdata); if (ret) { - gf_log (this->name, - GF_LOG_ERROR, "failed to register notify function"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_NOTIFY_REGISTER_FAILED, + "failed to register notify function"); goto dealloc_rpc; } ret = rpcsvc_create_listeners (rpc, options, this->name); if (ret != 1) { - gf_log (this->name, - GF_LOG_DEBUG, "failed to create listeners"); + gf_msg_debug (this->name, + 0, "failed to create listeners"); goto dealloc_rpc; } @@ -312,8 +324,9 @@ changelog_rpc_server_init (xlator_t *this, char *sockfile, void *cbkdata, prog = *progs; ret = rpcsvc_program_register (rpc, prog); if (ret) { - gf_log (this->name, - GF_LOG_ERROR, "cannot register program " + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_PROGRAM_NAME_REG_FAILED, + "cannot register program " "(name: %s, prognum: %d, pogver: %d)", prog->progname, prog->prognum, prog->progver); goto dealloc_rpc; diff --git a/xlators/features/changelog/src/changelog-rpc.c b/xlators/features/changelog/src/changelog-rpc.c index c7c0fffa9f5..76052a27a9c 100644 --- a/xlators/features/changelog/src/changelog-rpc.c +++ b/xlators/features/changelog/src/changelog-rpc.c @@ -246,7 +246,9 @@ changelog_handle_probe (rpcsvc_request_t *req) ret = xdr_to_generic (req->msg[0], &rpc_req, (xdrproc_t)xdr_changelog_probe_req); if (ret < 0) { - gf_log ("", GF_LOG_ERROR, "xdr decoding error"); + gf_msg ("", GF_LOG_ERROR, 0, + CHANGELOG_MSG_HANDLE_PROBE_ERROR, + "xdr decoding error"); req->rpc_err = GARBAGE_ARGS; goto handle_xdr_error; } diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c index e88306b8f21..acd0d42323a 100644 --- a/xlators/features/changelog/src/changelog.c +++ b/xlators/features/changelog/src/changelog.c @@ -17,10 +17,12 @@ #include "changelog-encoders.h" #include "changelog-mem-types.h" +#include "changelog-messages.h" #include <pthread.h> #include "changelog-rpc.h" +#include "errno.h" static struct changelog_bootstrap cb_bootstrap[] = { @@ -71,8 +73,9 @@ changelog_rmdir_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeue rmdir"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeue rmdir"); + changelog_color_fop_and_inc_cnt (this, priv, + frame->local); STACK_WIND (frame, changelog_rmdir_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->rmdir, loc, xflags, xdata); @@ -143,13 +146,14 @@ changelog_rmdir (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueue rmdir"); + gf_msg_debug (this->name, 0, "Enqueue rmdir"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: rmdir, ERROR: %s", strerror (ENOMEM)); + "FOP: rmdir"); chlog_barrier_dequeue_all (this, &queue); } @@ -195,8 +199,9 @@ changelog_unlink_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeue unlink"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeue unlink"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_unlink_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->unlink, loc, xflags, xdata); @@ -296,13 +301,14 @@ changelog_unlink (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueue unlink"); + gf_msg_debug (this->name, 0, "Enqueue unlink"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: unlink, ERROR: %s", strerror (ENOMEM)); + "FOP: unlink"); chlog_barrier_dequeue_all (this, &queue); } @@ -349,8 +355,9 @@ changelog_rename_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeue rename"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeue rename"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_rename_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->rename, oldloc, newloc, xdata); @@ -420,13 +427,14 @@ changelog_rename (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueue rename"); + gf_msg_debug (this->name, 0, "Enqueue rename"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: rename, ERROR: %s", strerror (ENOMEM)); + "FOP: rename"); chlog_barrier_dequeue_all (this, &queue); } /* changelog barrier */ @@ -477,8 +485,9 @@ changelog_link_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeuing link"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeuing link"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_link_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->link, oldloc, newloc, xdata); @@ -535,14 +544,15 @@ changelog_link (call_frame_t *frame, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueued link"); + gf_msg_debug (this->name, 0, "Enqueued link"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: link, ERROR: %s", strerror (ENOMEM)); + "FOP: link"); chlog_barrier_dequeue_all (this, &queue); } wind: @@ -592,8 +602,9 @@ changelog_mkdir_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeuing mkdir"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeuing mkdir"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_mkdir_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->mkdir, loc, mode, umask, xdata); @@ -621,8 +632,8 @@ changelog_mkdir (call_frame_t *frame, xlator_t *this, ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, - "failed to get gfid from dict"); + gf_msg_debug (this->name, 0, + "failed to get gfid from dict"); goto wind; } gf_uuid_copy (gfid, uuid_req); @@ -668,14 +679,15 @@ changelog_mkdir (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueued mkdir"); + gf_msg_debug (this->name, 0, "Enqueued mkdir"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: mkdir, ERROR: %s", strerror (ENOMEM)); + "FOP: mkdir"); chlog_barrier_dequeue_all (this, &queue); } @@ -727,8 +739,9 @@ changelog_symlink_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeuing symlink"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeuing symlink"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_symlink_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->symlink, linkname, loc, umask, xdata); @@ -757,8 +770,8 @@ changelog_symlink (call_frame_t *frame, xlator_t *this, ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, - "failed to get gfid from dict"); + gf_msg_debug (this->name, 0, + "failed to get gfid from dict"); goto wind; } gf_uuid_copy (gfid, uuid_req); @@ -796,14 +809,15 @@ changelog_symlink (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueued symlink"); + gf_msg_debug (this->name, 0, "Enqueued symlink"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: symlink, ERROR: %s", strerror (ENOMEM)); + "FOP: symlink"); chlog_barrier_dequeue_all (this, &queue); } @@ -854,8 +868,9 @@ changelog_mknod_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeuing mknod"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeuing mknod"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_mknod_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->mknod, loc, mode, rdev, umask, xdata); @@ -885,8 +900,8 @@ changelog_mknod (call_frame_t *frame, ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, - "failed to get gfid from dict"); + gf_msg_debug (this->name, 0, + "failed to get gfid from dict"); goto wind; } gf_uuid_copy (gfid, uuid_req); @@ -932,14 +947,15 @@ changelog_mknod (call_frame_t *frame, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueued mknod"); + gf_msg_debug (this->name, 0, "Enqueued mknod"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: mknod, ERROR: %s", strerror (ENOMEM)); + "FOP: mknod"); chlog_barrier_dequeue_all (this, &queue); } @@ -981,7 +997,8 @@ changelog_create_cbk (call_frame_t *frame, (this, &priv->ev_selection, CHANGELOG_OP_TYPE_RELEASE)) { ret = fd_ctx_set (fd, this, (uint64_t)(long) 0x1); if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_SET_FD_CONTEXT, "could not set fd context (for release cbk)"); } @@ -1008,8 +1025,9 @@ changelog_create_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeuing create"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeuing create"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_create_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->create, loc, flags, mode, umask, fd, xdata); @@ -1039,8 +1057,8 @@ changelog_create (call_frame_t *frame, xlator_t *this, ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, - "failed to get gfid from dict"); + gf_msg_debug (this->name, 0, + "failed to get gfid from dict"); goto wind; } gf_uuid_copy (gfid, uuid_req); @@ -1090,14 +1108,15 @@ changelog_create (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueued create"); + gf_msg_debug (this->name, 0, "Enqueued create"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: create, ERROR: %s", strerror (ENOMEM)); + "FOP: create"); chlog_barrier_dequeue_all (this, &queue); } @@ -1408,7 +1427,9 @@ changelog_handle_virtual_xattr (call_frame_t *frame, xlator_t *this, if (valid) { ret = changelog_fill_entry_buf (frame, this, loc, &local); if (ret) { - gf_log (this->name, GF_LOG_INFO, "Entry cannot be" + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_ENTRY_BUF_INFO, + "Entry cannot be" " captured for gfid: %s. Capturing DATA" " entry.", uuid_utoa (loc->inode->gfid)); goto unwind; @@ -1737,7 +1758,8 @@ changelog_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, (this, &priv->ev_selection, CHANGELOG_OP_TYPE_RELEASE)) { ret = fd_ctx_set (fd, this, (uint64_t)(long) 0x1); if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_SET_FD_CONTEXT, "could not set fd context (for release cbk)"); } @@ -1882,9 +1904,9 @@ changelog_cleanup_helper_threads (xlator_t *this, changelog_priv_t *priv) priv->cr.rollover_th = 0; ret = close (priv->cr_wfd); if (ret) - gf_log (this->name, GF_LOG_ERROR, - "error closing write end of rollover pipe" - " (reason: %s)", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_CLOSE_ERROR, + "error closing write end of rollover pipe"); } if (priv->cf.fsync_th) { @@ -1915,8 +1937,9 @@ changelog_spawn_helper_threads (xlator_t *this, changelog_priv_t *priv) ret = pipe (pipe_fd); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, - "Cannot create pipe (reason: %s)", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, + errno, CHANGELOG_MSG_PIPE_CREATION_ERROR, + "Cannot create pipe"); goto out; } @@ -1926,7 +1949,8 @@ changelog_spawn_helper_threads (xlator_t *this, changelog_priv_t *priv) ret = fcntl (pipe_fd[1], F_SETFL, flags); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FCNTL_FAILED, "failed to set O_NONBLOCK flag"); goto out; } @@ -1979,13 +2003,15 @@ notify (xlator_t *this, int event, void *data, ...) switch (barrier) { case DICT_ERROR: - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_DICT_GET_FAILED, "Barrier dict_get_str_boolean failed"); ret = -1; goto out; case BARRIER_OFF: - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Barrier off notification"); CHANGELOG_NOT_ON_THEN_GOTO(priv, ret, out); @@ -2003,9 +2029,10 @@ notify (xlator_t *this, int event, void *data, ...) UNLOCK (&priv->bflags.lock); if (ret == -1 ) { - gf_log (this->name, GF_LOG_ERROR, "Received" - " another barrier off notification" - " while already off"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_BARRIER_ERROR, + "Received another barrier off" + " notification while already off"); goto out; } @@ -2023,10 +2050,12 @@ notify (xlator_t *this, int event, void *data, ...) */ if (ret == 0) { chlog_barrier_dequeue_all(this, &queue); - gf_log(this->name, GF_LOG_INFO, + gf_msg(this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Disabled changelog barrier"); } else { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_BARRIER_ERROR, "Changelog barrier already disabled"); } @@ -2039,7 +2068,8 @@ notify (xlator_t *this, int event, void *data, ...) goto out; case BARRIER_ON: - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Barrier on notification"); CHANGELOG_NOT_ON_THEN_GOTO(priv, ret, out); @@ -2059,9 +2089,11 @@ notify (xlator_t *this, int event, void *data, ...) UNLOCK (&priv->bflags.lock); if (ret == -1 ) { - gf_log (this->name, GF_LOG_ERROR, "Received" - " another barrier on notification when" - " last one is not served yet"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_BARRIER_ERROR, + "Received another barrier on" + "notification when last one is" + "not served yet"); goto out; } @@ -2086,12 +2118,14 @@ notify (xlator_t *this, int event, void *data, ...) goto out; } - gf_log(this->name, GF_LOG_INFO, - "Enabled changelog barrier"); + gf_msg(this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, + "Enabled changelog barrier"); ret = changelog_barrier_notify(priv, buf); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_WRITE_FAILED, "Explicit roll over: write failed"); changelog_barrier_cleanup (this, priv, &queue); ret = -1; @@ -2121,19 +2155,22 @@ notify (xlator_t *this, int event, void *data, ...) ret1 = pthread_mutex_unlock (&priv->bn.bnotify_mutex); CHANGELOG_PTHREAD_ERROR_HANDLE_1 (ret1, out, bclean_req); - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BNOTIFY_INFO, "Woke up: bnotify conditional wait"); goto out; case DICT_DEFAULT: - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_DICT_GET_FAILED, "barrier key not found"); ret = -1; goto out; default: - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + CHANGELOG_MSG_DICT_GET_FAILED, "Something went bad in dict_get_str_boolean"); ret = -1; goto out; @@ -2160,7 +2197,8 @@ mem_acct_init (xlator_t *this) ret = xlator_mem_acct_init (this, gf_changelog_mt_end + 1); if (ret != 0) { - gf_log (this->name, GF_LOG_WARNING, "Memory accounting" + gf_msg (this->name, GF_LOG_WARNING, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Memory accounting" " init failed"); return ret; } @@ -2178,7 +2216,8 @@ changelog_init (xlator_t *this, changelog_priv_t *priv) ret = gettimeofday (&tv, NULL); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_GET_TIME_OP_FAILED, "gettimeofday() failure"); goto out; } @@ -2239,7 +2278,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) int ret = 0; if ((ret = pthread_mutex_init(&priv->bn.bnotify_mutex, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_MUTEX_INIT_FAILED, "bnotify pthread_mutex_init failed (%d)", ret); ret = -1; goto out; @@ -2247,7 +2287,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) bn_mutex_init = _gf_true; if ((ret = pthread_cond_init(&priv->bn.bnotify_cond, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_COND_INIT_FAILED, "bnotify pthread_cond_init failed (%d)", ret); ret = -1; goto out; @@ -2256,7 +2297,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) if ((ret = pthread_mutex_init(&priv->dm.drain_black_mutex, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_MUTEX_INIT_FAILED, "drain_black pthread_mutex_init failed (%d)", ret); ret = -1; goto out; @@ -2264,7 +2306,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) dm_mutex_black_init = _gf_true; if ((ret = pthread_cond_init(&priv->dm.drain_black_cond, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_COND_INIT_FAILED, "drain_black pthread_cond_init failed (%d)", ret); ret = -1; goto out; @@ -2273,7 +2316,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) if ((ret = pthread_mutex_init(&priv->dm.drain_white_mutex, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_MUTEX_INIT_FAILED, "drain_white pthread_mutex_init failed (%d)", ret); ret = -1; goto out; @@ -2281,7 +2325,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) dm_mutex_white_init = _gf_true; if ((ret = pthread_cond_init(&priv->dm.drain_white_cond, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_COND_INIT_FAILED, "drain_white pthread_cond_init failed (%d)", ret); ret = -1; goto out; @@ -2345,7 +2390,8 @@ reconfigure (xlator_t *this, dict_t *options) GF_OPTION_RECONF ("changelog-dir", tmp, options, str, out); if (!tmp) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_DIR_OPTIONS_NOT_SET, "\"changelog-dir\" option is not set"); goto out; } @@ -2419,10 +2465,12 @@ reconfigure (xlator_t *this, dict_t *options) if (active_now) { if (!active_earlier) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_HTIME_INFO, "Reconfigure: Changelog Enable"); if (gettimeofday(&tv, NULL) ) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_HTIME_ERROR, "unable to fetch htime"); ret = -1; goto out; @@ -2437,8 +2485,8 @@ reconfigure (xlator_t *this, dict_t *options) if (ret) { /* TODO */ } else { - gf_log (this->name, GF_LOG_DEBUG, - "changelog reconfigured"); + gf_msg_debug (this->name, 0, + "changelog reconfigured"); if (active_now && priv) priv->active = _gf_true; } @@ -2453,7 +2501,8 @@ changelog_freeup_options (xlator_t *this, changelog_priv_t *priv) ret = priv->cb->dtor (this, &priv->cd); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_FREEUP_FAILED, "could not cleanup bootstrapper"); GF_FREE (priv->changelog_brick); GF_FREE (priv->changelog_dir); @@ -2601,13 +2650,15 @@ init (xlator_t *this) GF_VALIDATE_OR_GOTO ("changelog", this, error_return); if (!this->children || this->children->next) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_CHILD_MISCONFIGURED, "translator needs a single subvolume"); goto error_return; } if (!this->parents) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_VOL_MISCONFIGURED, "dangling volume. please check volfile"); goto error_return; } @@ -2618,7 +2669,8 @@ init (xlator_t *this) this->local_pool = mem_pool_new (changelog_local_t, 64); if (!this->local_pool) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "failed to create local memory pool"); goto cleanup_priv; } @@ -2659,7 +2711,8 @@ init (xlator_t *this) ret = changelog_init (this, priv); if (ret) goto cleanup_rpc; - gf_log (this->name, GF_LOG_DEBUG, "changelog translator loaded"); + + gf_msg_debug (this->name, 0, "changelog translator loaded"); this->private = priv; return 0; @@ -2698,7 +2751,6 @@ fini (xlator_t *this) /* deallocate mempool */ mem_pool_destroy (this->local_pool); - /* finally, dealloac private variable */ GF_FREE (priv); } |