diff options
author | arao <arao@redhat.com> | 2015-06-22 11:10:05 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2015-06-27 02:29:27 -0700 |
commit | 3741804bec65a33d400af38dcc80700c8a668b81 (patch) | |
tree | a10008485e263087a52764d2d1ae413bf58c9240 /xlators/performance/symlink-cache/src | |
parent | 911e9228f31e89fe5df6e2282ce449b2a94c42b1 (diff) |
Logging: Porting the performance translator
logs to new logging framework.
Change-Id: Ie6aaf8d30bd4457bb73c48e23e6b1dea27598644
BUG: 1194640
Signed-off-by: arao <arao@redhat.com>
Reviewed-on: http://review.gluster.org/9822
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>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/performance/symlink-cache/src')
-rw-r--r-- | xlators/performance/symlink-cache/src/symlink-cache-messages.h | 93 | ||||
-rw-r--r-- | xlators/performance/symlink-cache/src/symlink-cache.c | 69 |
2 files changed, 131 insertions, 31 deletions
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 bd9f805e2c8..973565cd93e 100644 --- a/xlators/performance/symlink-cache/src/symlink-cache.c +++ b/xlators/performance/symlink-cache/src/symlink-cache.c @@ -17,6 +17,7 @@ #include "compat.h" #include "compat-errno.h" #include "common-utils.h" +#include "symlink-cache-messages.h" struct symlink_cache { time_t ctime; @@ -31,7 +32,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; @@ -45,7 +47,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; } @@ -61,15 +64,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; } @@ -89,16 +92,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; } @@ -106,24 +110,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; } } @@ -151,8 +156,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; @@ -194,8 +199,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; @@ -252,9 +257,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 @@ -356,15 +361,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; |