diff options
author | arao <arao@redhat.com> | 2015-06-22 11:10:05 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2015-06-29 02:21:53 -0700 |
commit | f6385aeb2f69b36fd02498259258f013582f706f (patch) | |
tree | 204f03a8f058e2ad7750814bb4af3d3b3955fb00 /xlators/performance/symlink-cache | |
parent | 10dfc9b4d4d04314ccd0f6a4eb0ee0341fd91e0d (diff) |
Logging: Porting the performance translator
logs to new logging framework
> Change-Id: Ie6aaf8d30bd4457bb73c48e23e6b1dea27598644
> BUG: 1194640
> Signed-off-by: arao <arao@redhat.com>
BUG: 1217722
Change-Id: I0856c43dbf8c0a1aa084d4478c9bdf3f41dfc0b8
Signed-off-by: arao <arao@redhat.com>
Reviewed-on: http://review.gluster.org/11442
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/performance/symlink-cache')
3 files changed, 135 insertions, 33 deletions
diff --git a/xlators/performance/symlink-cache/src/Makefile.am b/xlators/performance/symlink-cache/src/Makefile.am index 4091c329325..0b973ac1998 100644 --- a/xlators/performance/symlink-cache/src/Makefile.am +++ b/xlators/performance/symlink-cache/src/Makefile.am @@ -1,13 +1,15 @@ xlator_LTLIBRARIES = symlink-cache.la xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/testing/performance -symlink_cache_la_LDFLAGS = -module -avoid-version +symlink_cache_la_LDFLAGS = -module -avoid-version symlink_cache_la_SOURCES = symlink-cache.c symlink_cache_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la +noinst_HEADERS = symlink-cache-messages.h + AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src AM_CFLAGS = -Wall $(GF_CFLAGS) -CLEANFILES = +CLEANFILES = diff --git a/xlators/performance/symlink-cache/src/symlink-cache-messages.h b/xlators/performance/symlink-cache/src/symlink-cache-messages.h new file mode 100644 index 00000000000..89ea118d6b3 --- /dev/null +++ b/xlators/performance/symlink-cache/src/symlink-cache-messages.h @@ -0,0 +1,93 @@ +/*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 _SYMLINK_CACHE_MESSAGES_H_ +#define _SYMLINK_CACHE_MESSAGES_H_ + +#include "glfs-message-id.h" + +/*! \file symlink_cache-messages.h + * \brief SYMLINK_CACHE 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 redability 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_SYMLINK_CACHE_BASE GLFS_MSGID_COMP_SYMLINK_CACHE +#define GLFS_SYMLINK_CACHE_NUM_MESSAGES 5 +#define GLFS_MSGID_END (GLFS_SYMLINK_CACHE_BASE +\ + GLFS_SYMLINK_CACHE_NUM_MESSAGES + 1) + +/* Messages with message IDs */ +#define glfs_msg_start_x GLFS_SYMLINK_CACHE_BASE, "Invalid: Start of messages" + +#define SYMLINK_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED\ + (GLFS_SYMLINK_CACHE_BASE + 1) + +/*! + * @messageid + * @diagnosis + * @recommendedaction None + * + */ + +#define SYMLINK_CACHE_MSG_VOL_MISCONFIGURED (GLFS_SYMLINK_CACHE_BASE + 2) + +/*! + * @messageid + * @diagnosis + * @recommendedaction None + * + */ + +#define SYMLINK_CACHE_MSG_NO_MEMORY (GLFS_SYMLINK_CACHE_BASE + 3) + +/*! + * @messageid + * @diagnosis + * @recommendedaction None + * + */ + +#define SYMLINK_CACHE_MSG_DICT_GET_FAILED (GLFS_SYMLINK_CACHE_BASE + 4) + +/*! + * @messageid + * @diagnosis + * @recommendedaction None + * + */ + +#define SYMLINK_CACHE_MSG_DICT_SET_FAILED (GLFS_SYMLINK_CACHE_BASE + 5) + +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + + +#endif /* _SYMLINK_CACHE_MESSAGES_H_ */ diff --git a/xlators/performance/symlink-cache/src/symlink-cache.c b/xlators/performance/symlink-cache/src/symlink-cache.c index c65629b6993..6ecfad41a21 100644 --- a/xlators/performance/symlink-cache/src/symlink-cache.c +++ b/xlators/performance/symlink-cache/src/symlink-cache.c @@ -22,6 +22,7 @@ #include "compat.h" #include "compat-errno.h" #include "common-utils.h" +#include "symlink-cache-messages.h" struct symlink_cache { time_t ctime; @@ -36,7 +37,8 @@ symlink_inode_ctx_get (inode_t *inode, xlator_t *this, void **ctx) uint64_t tmp_ctx = 0; ret = inode_ctx_get (inode, this, &tmp_ctx); if (-1 == ret) - gf_log (this->name, GF_LOG_ERROR, "dict get failed"); + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + SYMLINK_CACHE_MSG_DICT_GET_FAILED, "dict get failed"); else *ctx = (void *)(long)tmp_ctx; @@ -50,7 +52,8 @@ symlink_inode_ctx_set (inode_t *inode, xlator_t *this, void *ctx) int ret = 0; ret = inode_ctx_put (inode, this, (uint64_t)(long) ctx); if (-1 == ret) - gf_log (this->name, GF_LOG_ERROR, "dict set failed"); + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + SYMLINK_CACHE_MSG_DICT_SET_FAILED, "dict set failed"); return 0; } @@ -66,15 +69,15 @@ sc_cache_update (xlator_t *this, inode_t *inode, const char *link) return 0; if (!sc->readlink) { - gf_log (this->name, GF_LOG_DEBUG, - "updating cache: %s", link); + gf_msg_debug (this->name, 0, + "updating cache: %s", link); sc->readlink = strdup (link); - } else { - gf_log (this->name, GF_LOG_DEBUG, - "not updating existing cache: %s with %s", - sc->readlink, link); - } + } else + gf_msg_debug (this->name, 0, + "not updating existing cache: %s with %s", + sc->readlink, link); + return 0; } @@ -94,16 +97,17 @@ sc_cache_set (xlator_t *this, inode_t *inode, struct iatt *buf, need_set = 1; sc = CALLOC (1, sizeof (*sc)); if (!sc) { - gf_log (this->name, GF_LOG_ERROR, - "out of memory :("); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + SYMLINK_CACHE_MSG_NO_MEMORY, + "out of memory :("); goto err; } } if (sc->readlink) { - gf_log (this->name, GF_LOG_DEBUG, - "replacing old cache: %s with new cache: %s", - sc->readlink, link); + gf_msg_debug (this->name, 0, + "replacing old cache: %s with new cache: %s", + sc->readlink, link); FREE (sc->readlink); sc->readlink = NULL; } @@ -111,24 +115,25 @@ sc_cache_set (xlator_t *this, inode_t *inode, struct iatt *buf, if (link) { sc->readlink = strdup (link); if (!sc->readlink) { - gf_log (this->name, GF_LOG_ERROR, - "out of memory :("); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + SYMLINK_CACHE_MSG_NO_MEMORY, + "out of memory :("); goto err; } } sc->ctime = buf->ia_ctime; - gf_log (this->name, GF_LOG_DEBUG, - "setting symlink cache: %s", link); + gf_msg_debug (this->name, 0, + "setting symlink cache: %s", link); if (need_set) { ret = symlink_inode_ctx_set (inode, this, sc); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "could not set inode context (%s)", - strerror (-ret)); + gf_msg (this->name, GF_LOG_ERROR, + -ret, SYMLINK_CACHE_MSG_NO_MEMORY, + "could not set inode context "); goto err; } } @@ -156,8 +161,8 @@ sc_cache_flush (xlator_t *this, inode_t *inode) return 0; if (sc->readlink) { - gf_log (this->name, GF_LOG_DEBUG, - "flushing cache: %s", sc->readlink); + gf_msg_debug (this->name, 0, + "flushing cache: %s", sc->readlink); FREE (sc->readlink); sc->readlink = NULL; @@ -199,8 +204,8 @@ sc_cache_validate (xlator_t *this, inode_t *inode, struct iatt *buf) /* STALE */ if (sc->readlink) { - gf_log (this->name, GF_LOG_DEBUG, - "flushing cache: %s", sc->readlink); + gf_msg_debug (this->name, 0, + "flushing cache: %s", sc->readlink); FREE (sc->readlink); sc->readlink = NULL; @@ -257,9 +262,9 @@ sc_readlink (call_frame_t *frame, xlator_t *this, if (link) { /* cache hit */ - gf_log (this->name, GF_LOG_DEBUG, - "cache hit %s -> %s", - loc->path, link); + gf_msg_debug (this->name, 0, + "cache hit %s -> %s", + loc->path, link); /* libglusterfsclient, nfs or any other translators @@ -361,15 +366,17 @@ init (xlator_t *this) { if (!this->children || this->children->next) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + SYMLINK_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED, "FATAL: volume (%s) not configured with exactly one " "child", this->name); return -1; } if (!this->parents) { - gf_log (this->name, GF_LOG_WARNING, - "dangling volume. check volfile "); + gf_msg (this->name, GF_LOG_WARNING, 0, + SYMLINK_CACHE_MSG_VOL_MISCONFIGURED, + "dangling volume. check volfile "); } return 0; |