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 | |
| 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>
23 files changed, 1309 insertions, 272 deletions
diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h index 399a94bbfe5..ded41e3cedc 100644 --- a/libglusterfs/src/glfs-message-id.h +++ b/libglusterfs/src/glfs-message-id.h @@ -104,9 +104,9 @@  #define GLFS_MSGID_COMP_RPC_TRANS_SOCKET_END    (GLFS_MSGID_COMP_RPC_TRANS_SOCKET + \                                                  GLFS_MSGID_SEGMENT) -#define GLFS_MSGID_COMP_QUOTA           GLFS_MSGID_COMP_RPC_TRANS_SOCKET_END -#define GLFS_MSGID_COMP_QUOTA_END       (GLFS_MSGID_COMP_QUOTA +\ -                                        GLFS_MSGID_SEGMENT) +#define GLFS_MSGID_COMP_QUOTA              GLFS_MSGID_COMP_RPC_TRANS_SOCKET_END +#define GLFS_MSGID_COMP_QUOTA_END          (GLFS_MSGID_COMP_QUOTA +\ +                                           GLFS_MSGID_SEGMENT)  #define GLFS_MSGID_COMP_CTR                GLFS_MSGID_COMP_QUOTA_END  #define GLFS_MSGID_COMP_CTR_END            (GLFS_MSGID_COMP_CTR+\ @@ -116,6 +116,45 @@  #define GLFS_MSGID_COMP_EC_END           (GLFS_MSGID_COMP_EC +\                                           GLFS_MSGID_SEGMENT) +#define GLFS_MSGID_COMP_IO_CACHE                GLFS_MSGID_COMP_EC_END +#define GLFS_MSGID_COMP_IO_CACHE_END            (GLFS_MSGID_COMP_IO_CACHE+\ +                                                GLFS_MSGID_SEGMENT) + +#define GLFS_MSGID_COMP_IO_THREADS              GLFS_MSGID_COMP_IO_CACHE_END +#define GLFS_MSGID_COMP_IO_THREADS_END          (GLFS_MSGID_COMP_IO_THREADS+\ +                                                GLFS_MSGID_SEGMENT) + +#define GLFS_MSGID_COMP_MD_CACHE                GLFS_MSGID_COMP_IO_THREADS_END +#define GLFS_MSGID_COMP_MD_CACHE_END            (GLFS_MSGID_COMP_MD_CACHE+\ +                                                GLFS_MSGID_SEGMENT) + +#define GLFS_MSGID_COMP_OPEN_BEHIND             GLFS_MSGID_COMP_MD_CACHE_END +#define GLFS_MSGID_COMP_OPEN_BEHIND_END         (GLFS_MSGID_COMP_OPEN_BEHIND+\ +                                                GLFS_MSGID_SEGMENT) + +#define GLFS_MSGID_COMP_QUICK_READ              GLFS_MSGID_COMP_OPEN_BEHIND_END +#define GLFS_MSGID_COMP_QUICK_READ_END          (GLFS_MSGID_COMP_QUICK_READ+\ +                                                GLFS_MSGID_SEGMENT) + +#define GLFS_MSGID_COMP_READ_AHEAD              GLFS_MSGID_COMP_QUICK_READ_END +#define GLFS_MSGID_COMP_READ_AHEAD_END          (GLFS_MSGID_COMP_READ_AHEAD+\ +                                                GLFS_MSGID_SEGMENT) + +#define GLFS_MSGID_COMP_READDIR_AHEAD           GLFS_MSGID_COMP_READ_AHEAD_END +#define GLFS_MSGID_COMP_READDIR_AHEAD_END       (GLFS_MSGID_COMP_READDIR_AHEAD+\ +                                                GLFS_MSGID_SEGMENT) + +#define GLFS_MSGID_COMP_SYMLINK_CACHE           \ +GLFS_MSGID_COMP_READDIR_AHEAD_END +#define GLFS_MSGID_COMP_SYMLINK_CACHE_END \ +(GLFS_MSGID_COMP_SYMLINK_CACHE+ \ +                                                GLFS_MSGID_SEGMENT) + +#define GLFS_MSGID_COMP_WRITE_BEHIND             \ +GLFS_MSGID_COMP_SYMLINK_CACHE_END +#define GLFS_MSGID_COMP_WRITE_BEHIND_END        (GLFS_MSGID_COMP_WRITE_BEHIND+\ +                                                GLFS_MSGID_SEGMENT) +  /* --- new segments for messages goes above this line --- */  #endif /* !_GLFS_MESSAGE_ID_H_ */ diff --git a/xlators/performance/io-cache/src/io-cache-messages.h b/xlators/performance/io-cache/src/io-cache-messages.h new file mode 100644 index 00000000000..5c4fbea46fc --- /dev/null +++ b/xlators/performance/io-cache/src/io-cache-messages.h @@ -0,0 +1,111 @@ +/*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 _IO_CACHE_MESSAGES_H_ +#define _IO_CACHE_MESSAGES_H_ + +#include "glfs-message-id.h" + +/*! \file io-cache-messages.h + *  \brief IO_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_IO_CACHE_BASE                   GLFS_MSGID_COMP_IO_CACHE +#define GLFS_IO_CACHE_NUM_MESSAGES           6 +#define GLFS_MSGID_END  (GLFS_IO_CACHE_BASE + GLFS_IO_CACHE_NUM_MESSAGES + 1) + +/* Messages with message IDs */ +#define glfs_msg_start_x GLFS_IO_CACHE_BASE, "Invalid: Start of messages" + + + + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define IO_CACHE_MSG_ENFORCEMENT_FAILED        (GLFS_IO_CACHE_BASE + 1) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define IO_CACHE_MSG_INVALID_ARGUMENT        (GLFS_IO_CACHE_BASE + 2) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define IO_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED        (GLFS_IO_CACHE_BASE + 3) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define IO_CACHE_MSG_NO_MEMORY        (GLFS_IO_CACHE_BASE + 4) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define IO_CACHE_MSG_VOL_MISCONFIGURED        (GLFS_IO_CACHE_BASE + 5) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define IO_CACHE_MSG_INODE_NULL        (GLFS_IO_CACHE_BASE + 6) + + +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + + +#endif /* _IO_CACHE_MESSAGES_H_ */ diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index 4982a1dd611..ec6fa085dab 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -17,7 +17,7 @@  #include "statedump.h"  #include <assert.h>  #include <sys/time.h> - +#include "io-cache-messages.h"  int ioc_log2_page_size;  uint32_t @@ -267,14 +267,16 @@ ioc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,          local = mem_get0 (this->local_pool);          if (local == NULL) {                  op_errno = ENOMEM; -                gf_log (this->name, GF_LOG_ERROR, "out of memory"); +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        IO_CACHE_MSG_NO_MEMORY, "out of memory");                  goto unwind;          }          ret = loc_copy (&local->file_loc, loc);          if (ret != 0) {                  op_errno = ENOMEM; -                gf_log (this->name, GF_LOG_ERROR, "out of memory"); +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        IO_CACHE_MSG_NO_MEMORY, "out of memory");                  goto unwind;          } @@ -355,9 +357,9 @@ ioc_cache_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          if ((op_ret == -1) ||              ((op_ret >= 0) && !ioc_cache_still_valid(ioc_inode, stbuf))) { -                gf_log (ioc_inode->table->xl->name, GF_LOG_DEBUG, -                        "cache for inode(%p) is invalid. flushing all pages", -                        ioc_inode); +                gf_msg_debug (ioc_inode->table->xl->name, 0, +                              "cache for inode(%p) is invalid. flushing all pages", +                              ioc_inode);                  /* NOTE: only pages with no waiting frames are flushed by                   * ioc_inode_flush. page_fault will be generated for all                   * the pages which have waiting frames by ioc_inode_wakeup() @@ -425,7 +427,8 @@ ioc_wait_on_inode (ioc_inode_t *ioc_inode, ioc_page_t *page)                  waiter = GF_CALLOC (1, sizeof (ioc_waitq_t),                                      gf_ioc_mt_ioc_waitq_t);                  if (waiter == NULL) { -                        gf_log (ioc_inode->table->xl->name, GF_LOG_ERROR, +                        gf_msg (ioc_inode->table->xl->name, GF_LOG_ERROR, +                                ENOMEM, IO_CACHE_MSG_NO_MEMORY,                                  "out of memory");                          ret = -ENOMEM;                          goto out; @@ -463,8 +466,8 @@ ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,                  ret = -1;                  local->op_ret = -1;                  local->op_errno = ENOMEM; -                gf_log (ioc_inode->table->xl->name, GF_LOG_ERROR, -                        "out of memory"); +                gf_msg (ioc_inode->table->xl->name, GF_LOG_ERROR, +                        0, IO_CACHE_MSG_NO_MEMORY, "out of memory");                  goto out;          } @@ -474,8 +477,8 @@ ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,                  local->op_ret = -1;                  local->op_errno = ENOMEM;                  mem_put (validate_local); -                gf_log (ioc_inode->table->xl->name, GF_LOG_ERROR, -                        "out of memory"); +                gf_msg (ioc_inode->table->xl->name, GF_LOG_ERROR, +                        0, IO_CACHE_MSG_NO_MEMORY, "out of memory");                  goto out;          } @@ -555,8 +558,10 @@ ioc_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,                  //TODO: see why inode context is NULL and handle it.                  if (!ioc_inode) { -                        gf_log (this->name, GF_LOG_ERROR, "inode context is " -                                "NULL (%s)", uuid_utoa (fd->inode->gfid)); +                        gf_msg (this->name, GF_LOG_ERROR, +                                EINVAL, IO_CACHE_MSG_ENFORCEMENT_FAILED, +                                "inode context is NULL (%s)", +                                uuid_utoa (fd->inode->gfid));                          goto out;                  } @@ -655,7 +660,8 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                                  && (table->max_file_size < ioc_inode->ia_size))) {                                  ret = fd_ctx_set (fd, this, 1);                                  if (ret) -                                        gf_log (this->name, GF_LOG_WARNING, +                                        gf_msg (this->name, GF_LOG_WARNING, +                                                ENOMEM, IO_CACHE_MSG_NO_MEMORY,                                                  "%s: failed to set fd ctx",                                                  local->file_loc.path);                          } @@ -672,7 +678,8 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                           * as a whole */                          ret = fd_ctx_set (fd, this, 1);                          if (ret) -                                gf_log (this->name, GF_LOG_WARNING, +                                gf_msg (this->name, GF_LOG_WARNING, +                                        ENOMEM, IO_CACHE_MSG_NO_MEMORY,                                          "%s: failed to set fd ctx",                                          local->file_loc.path);                  } @@ -682,7 +689,8 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                          /* we allow a pattern-matched cache disable this way */                          ret = fd_ctx_set (fd, this, 1);                          if (ret) -                                gf_log (this->name, GF_LOG_WARNING, +                                gf_msg (this->name, GF_LOG_WARNING, +                                        ENOMEM, IO_CACHE_MSG_NO_MEMORY,                                          "%s: failed to set fd ctx",                                          local->file_loc.path);                  } @@ -762,14 +770,16 @@ ioc_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,          local = mem_get0 (this->local_pool);          if (local == NULL) {                  op_errno = ENOMEM; -                gf_log (this->name, GF_LOG_ERROR, "out of memory"); +                gf_msg (this->name, GF_LOG_ERROR, +                        0, IO_CACHE_MSG_NO_MEMORY, "out of memory");                  goto unwind;          }          ret = loc_copy (&local->file_loc, loc);          if (ret != 0) {                  op_errno = ENOMEM; -                gf_log (this->name, GF_LOG_ERROR, "out of memory"); +                gf_msg (this->name, GF_LOG_ERROR, +                        0, IO_CACHE_MSG_NO_MEMORY, "out of memory");                  goto unwind;          } @@ -811,7 +821,8 @@ ioc_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,          local = mem_get0 (this->local_pool);          if (local == NULL) { -                gf_log (this->name, GF_LOG_ERROR, "out of memory"); +                gf_msg (this->name, GF_LOG_ERROR, +                        ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory");                  STACK_UNWIND_STRICT (open, frame, -1, ENOMEM, NULL, NULL);                  return 0;          } @@ -847,7 +858,8 @@ ioc_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,          local = mem_get0 (this->local_pool);          if (local == NULL) { -                gf_log (this->name, GF_LOG_ERROR, "out of memory"); +                gf_msg (this->name, GF_LOG_ERROR, +                        ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory");                  STACK_UNWIND_STRICT (create, frame, -1, ENOMEM, NULL, NULL,                                       NULL, NULL, NULL, NULL);                  return 0; @@ -986,8 +998,9 @@ ioc_dispatch_requests (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,                                                            trav_offset);                                  fault = 1;                                  if (!trav) { -                                        gf_log (frame->this->name, +                                        gf_msg (frame->this->name,                                                  GF_LOG_CRITICAL, +                                                ENOMEM, IO_CACHE_MSG_NO_MEMORY,                                                  "out of memory");                                          local->op_ret = -1;                                          local->op_errno = ENOMEM; @@ -1003,10 +1016,13 @@ ioc_dispatch_requests (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,                                  /* page found in cache */                                  if (!might_need_validate && !ioc_inode->waitq) {                                          /* fresh enough */ -                                        gf_log (frame->this->name, GF_LOG_TRACE, -                                                "cache hit for trav_offset=%" -                                                PRId64"/local_offset=%"PRId64"", -                                                trav_offset, local_offset); +                                        gf_msg_trace (frame->this->name, 0, +                                                      "cache hit for " +                                                      "trav_offset=%" +                                                      PRId64"/local_" +                                                      "offset=%"PRId64"", +                                                      trav_offset, +                                                      local_offset);                                          waitq = __ioc_page_wakeup (trav,                                                                     trav->op_errno);                                  } else { @@ -1050,10 +1066,10 @@ ioc_dispatch_requests (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,                  if (need_validate) {                          need_validate = 0; -                        gf_log (frame->this->name, GF_LOG_TRACE, -                                "sending validate request for " -                                "inode(%s) at offset=%"PRId64"", -                                uuid_utoa (fd->inode->gfid), trav_offset); +                        gf_msg_trace (frame->this->name, 0, +                                      "sending validate request for " +                                      "inode(%s) at offset=%"PRId64"", +                                      uuid_utoa (fd->inode->gfid), trav_offset);                          ret = ioc_cache_validate (frame, ioc_inode, fd, trav);                          if (ret == -1) {                                  ioc_inode_lock (ioc_inode); @@ -1123,7 +1139,8 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,          table = this->private;          if (!table) { -                gf_log (this->name, GF_LOG_ERROR, "table is null"); +                gf_msg (this->name, GF_LOG_ERROR, EINVAL, +                        IO_CACHE_MSG_ENFORCEMENT_FAILED, "table is null");                  op_errno = EINVAL;                  goto out;          } @@ -1157,7 +1174,8 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,          local = mem_get0 (this->local_pool);          if (local == NULL) { -                gf_log (this->name, GF_LOG_ERROR, "out of memory"); +                gf_msg (this->name, GF_LOG_ERROR, +                        ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory");                  op_errno = ENOMEM;                  goto out;          } @@ -1171,9 +1189,10 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,          local->size = size;          local->inode = ioc_inode; -        gf_log (this->name, GF_LOG_TRACE, -                "NEW REQ (%p) offset = %"PRId64" && size = %"GF_PRI_SIZET"", -                frame, offset, size); +        gf_msg_trace (this->name, 0, +                      "NEW REQ (%p) offset " +                      "= %"PRId64" && size = %"GF_PRI_SIZET"", +                      frame, offset, size);          weight = ioc_inode->weight; @@ -1243,7 +1262,8 @@ ioc_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,          local = mem_get0 (this->local_pool);          if (local == NULL) { -                gf_log (this->name, GF_LOG_ERROR, "out of memory"); +                gf_msg (this->name, GF_LOG_ERROR, +                        ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory");                  STACK_UNWIND_STRICT (writev, frame, -1, ENOMEM, NULL, NULL, NULL);                  return 0; @@ -1378,8 +1398,8 @@ ioc_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,          inode_ctx_get (fd->inode, this, &tmp_inode);          ioc_inode = (ioc_inode_t *)(long)tmp_inode;          if (!ioc_inode) { -                gf_log (this->name, GF_LOG_DEBUG, -                        "inode context is NULL: returning EBADFD"); +                gf_msg_debug (this->name, EBADFD, +                              "inode context is NULL: returning EBADFD");                  STACK_UNWIND_STRICT (lk, frame, -1, EBADFD, NULL, NULL);                  return 0;          } @@ -1532,10 +1552,9 @@ ioc_get_priority_list (const char *opt_str, struct list_head *first)                          goto out;                  } -                gf_log ("io-cache", GF_LOG_TRACE, -                        "ioc priority : pattern %s : priority %s", -                        pattern, -                        priority); +                gf_msg_trace ("io-cache", 0, +                              "ioc priority : pattern %s : priority %s", +                              pattern, priority);                  curr->pattern = gf_strdup (pattern);                  if (curr->pattern == NULL) { @@ -1583,8 +1602,9 @@ mem_acct_init (xlator_t *this)          ret = xlator_mem_acct_init (this, gf_ioc_mt_end + 1);          if (ret != 0) { -                gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" -                        "failed"); +                gf_msg (this->name, GF_LOG_ERROR, +                        ENOMEM, IO_CACHE_MSG_NO_MEMORY, +                        "Memory accounting init failed");                  return ret;          } @@ -1604,7 +1624,8 @@ check_cache_size_ok (xlator_t *this, uint64_t cache_size)          opt = xlator_volume_option_get (this, "cache-size");          if (!opt) {                  ret = _gf_false; -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, +                        EINVAL, IO_CACHE_MSG_ENFORCEMENT_FAILED,                          "could not get cache-size option");                  goto out;          } @@ -1615,12 +1636,14 @@ check_cache_size_ok (xlator_t *this, uint64_t cache_size)          else                  max_cache_size = total_mem; -        gf_log (this->name, GF_LOG_DEBUG, "Max cache size is %"PRIu64, -                max_cache_size); +        gf_msg_debug (this->name, 0, "Max cache size is %"PRIu64, +                      max_cache_size);          if (cache_size > max_cache_size) {                  ret = _gf_false; -                gf_log (this->name, GF_LOG_ERROR, "Cache size %"PRIu64 +                gf_msg (this->name, GF_LOG_ERROR, +                        0, IO_CACHE_MSG_INVALID_ARGUMENT, +                        "Cache size %"PRIu64                          " is greater than the max size of %"PRIu64,                          cache_size, max_cache_size);                  goto out; @@ -1650,8 +1673,8 @@ reconfigure (xlator_t *this, dict_t *options)                  if (data) {                          char *option_list = data_to_str (data); -                        gf_log (this->name, GF_LOG_TRACE, -                                "option path %s", option_list); +                        gf_msg_trace (this->name, 0, +                                      "option path %s", option_list);                          /* parse the list of pattern:priority */                          table->max_pri = ioc_get_priority_list (option_list,                                                                  &table->priority_list); @@ -1670,7 +1693,8 @@ reconfigure (xlator_t *this, dict_t *options)                  if ((table->max_file_size <= UINT64_MAX) &&                      (table->min_file_size > table->max_file_size)) { -                        gf_log (this->name, GF_LOG_ERROR, "minimum size (%" +                        gf_msg (this->name, GF_LOG_ERROR, 0, +                                IO_CACHE_MSG_INVALID_ARGUMENT, "minimum size (%"                                  PRIu64") of a file that can be cached is "                                  "greater than maximum size (%"PRIu64"). "                                  "Hence Defaulting to old value", @@ -1682,7 +1706,8 @@ reconfigure (xlator_t *this, dict_t *options)                                    options, size_uint64, unlock);                  if (!check_cache_size_ok (this, cache_size_new)) {                          ret = -1; -                        gf_log (this->name, GF_LOG_ERROR, +                        gf_msg (this->name, GF_LOG_ERROR, +                                0, IO_CACHE_MSG_INVALID_ARGUMENT,                                  "Not reconfiguring cache-size");                          goto unlock;                  } @@ -1716,20 +1741,23 @@ init (xlator_t *this)          xl_options = this->options;          if (!this->children || this->children->next) { -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        IO_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED,                          "FATAL: io-cache not configured with exactly "                          "one child");                  goto out;          }          if (!this->parents) { -                gf_log (this->name, GF_LOG_WARNING, +                gf_msg (this->name, GF_LOG_WARNING, 0, +                        IO_CACHE_MSG_VOL_MISCONFIGURED,                          "dangling volume. check volfile ");          }          table = (void *) GF_CALLOC (1, sizeof (*table), gf_ioc_mt_ioc_table_t);          if (table == NULL) { -                gf_log (this->name, GF_LOG_ERROR, "out of memory"); +                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +                        IO_CACHE_MSG_NO_MEMORY, "out of memory");                  goto out;          } @@ -1754,8 +1782,8 @@ init (xlator_t *this)          data = dict_get (xl_options, "priority");          if (data) {                  char *option_list = data_to_str (data); -                gf_log (this->name, GF_LOG_TRACE, -                        "option path %s", option_list); +                gf_msg_trace (this->name, 0, +                              "option path %s", option_list);                  /* parse the list of pattern:priority */                  table->max_pri = ioc_get_priority_list (option_list,                                                          &table->priority_list); @@ -1770,7 +1798,8 @@ init (xlator_t *this)          if ((table->max_file_size <= UINT64_MAX)              && (table->min_file_size > table->max_file_size)) { -                gf_log ("io-cache", GF_LOG_ERROR, "minimum size (%" +                gf_msg ("io-cache", GF_LOG_ERROR, 0, +                        IO_CACHE_MSG_INVALID_ARGUMENT, "minimum size (%"                          PRIu64") of a file that can be cached is "                          "greater than maximum size (%"PRIu64")",                          table->min_file_size, table->max_file_size); @@ -1790,7 +1819,8 @@ init (xlator_t *this)          this->local_pool = mem_pool_new (ioc_local_t, 64);          if (!this->local_pool) {                  ret = -1; -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, +                        ENOMEM, IO_CACHE_MSG_NO_MEMORY,                          "failed to create local_t's memory pool");                  goto out;          } @@ -1804,8 +1834,8 @@ init (xlator_t *this)          table->mem_pool = mem_pool_new (rbthash_entry_t, num_pages);          if (!table->mem_pool) { -                gf_log (this->name, GF_LOG_ERROR, -                        "Unable to allocate mem_pool"); +                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +                        IO_CACHE_MSG_NO_MEMORY, "Unable to allocate mem_pool");                  goto out;          } diff --git a/xlators/performance/io-cache/src/io-cache.h b/xlators/performance/io-cache/src/io-cache.h index c677bcd93f4..d7c823fe962 100644 --- a/xlators/performance/io-cache/src/io-cache.h +++ b/xlators/performance/io-cache/src/io-cache.h @@ -24,6 +24,7 @@  #include "hashfn.h"  #include <sys/time.h>  #include <fnmatch.h> +#include "io-cache-messages.h"  #define IOC_PAGE_SIZE    (1024 * 128)   /* 128KB */  #define IOC_CACHE_SIZE   (32 * 1024 * 1024) @@ -219,64 +220,64 @@ ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset,  #define ioc_inode_lock(ioc_inode)                                       \          do {                                                            \ -                gf_log (ioc_inode->table->xl->name, GF_LOG_TRACE,       \ -                        "locked inode(%p)", ioc_inode);                 \ +                gf_msg_trace (ioc_inode->table->xl->name, 0,            \ +                              "locked inode(%p)", ioc_inode);           \                  pthread_mutex_lock (&ioc_inode->inode_lock);            \          } while (0)  #define ioc_inode_unlock(ioc_inode)                                     \          do {                                                            \ -                gf_log (ioc_inode->table->xl->name, GF_LOG_TRACE,       \ -                        "unlocked inode(%p)", ioc_inode);               \ +                gf_msg_trace (ioc_inode->table->xl->name, 0,            \ +                              "unlocked inode(%p)", ioc_inode);         \                  pthread_mutex_unlock (&ioc_inode->inode_lock);          \          } while (0) -#define ioc_table_lock(table)                                   \ -        do {                                                    \ -                gf_log (table->xl->name, GF_LOG_TRACE,          \ -                        "locked table(%p)", table);             \ -                pthread_mutex_lock (&table->table_lock);        \ +#define ioc_table_lock(table)                                           \ +        do {                                                            \ +                gf_msg_trace (table->xl->name, 0,                       \ +                              "locked table(%p)", table);               \ +                pthread_mutex_lock (&table->table_lock);                \          } while (0) -#define ioc_table_unlock(table)                                 \ -        do {                                                    \ -                gf_log (table->xl->name, GF_LOG_TRACE,          \ -                        "unlocked table(%p)", table);           \ -                pthread_mutex_unlock (&table->table_lock);      \ +#define ioc_table_unlock(table)                                         \ +        do {                                                            \ +                gf_msg_trace (table->xl->name, 0,                       \ +                              "unlocked table(%p)", table);             \ +                pthread_mutex_unlock (&table->table_lock);              \          } while (0)  #define ioc_local_lock(local)                                           \          do {                                                            \ -                gf_log (local->inode->table->xl->name, GF_LOG_TRACE,    \ -                        "locked local(%p)", local);                     \ +                gf_msg_trace (local->inode->table->xl->name, 0,         \ +                              "locked local(%p)", local);               \                  pthread_mutex_lock (&local->local_lock);                \          } while (0)  #define ioc_local_unlock(local)                                         \          do {                                                            \ -                gf_log (local->inode->table->xl->name, GF_LOG_TRACE,    \ -                        "unlocked local(%p)", local);                   \ +                gf_msg_trace (local->inode->table->xl->name, 0,         \ +                              "unlocked local(%p)", local);             \                  pthread_mutex_unlock (&local->local_lock);              \          } while (0)  #define ioc_page_lock(page)                                             \          do {                                                            \ -                gf_log (page->inode->table->xl->name, GF_LOG_TRACE,     \ -                        "locked page(%p)", page);                       \ +                gf_msg_trace (page->inode->table->xl->name, 0,          \ +                              "locked page(%p)", page);                 \                  pthread_mutex_lock (&page->page_lock);                  \          } while (0)  #define ioc_page_unlock(page)                                           \          do {                                                            \ -                gf_log (page->inode->table->xl->name, GF_LOG_TRACE,     \ -                        "unlocked page(%p)", page);                     \ +                gf_msg_trace (page->inode->table->xl->name, 0,          \ +                              "unlocked page(%p)", page);               \                  pthread_mutex_unlock (&page->page_lock);                \          } while (0) diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c index 0d7dee638f3..53bbd0448f2 100644 --- a/xlators/performance/io-cache/src/ioc-inode.c +++ b/xlators/performance/io-cache/src/ioc-inode.c @@ -77,7 +77,8 @@ ioc_inode_wakeup (call_frame_t *frame, ioc_inode_t *ioc_inode,          if (ioc_inode == NULL) {                  local->op_ret = -1;                  local->op_errno = EINVAL; -                gf_log (frame->this->name, GF_LOG_WARNING, "ioc_inode is NULL"); +                gf_msg (frame->this->name, GF_LOG_WARNING, 0, +                        IO_CACHE_MSG_INODE_NULL, "ioc_inode is NULL");                  goto out;          } @@ -125,12 +126,15 @@ ioc_inode_wakeup (call_frame_t *frame, ioc_inode_t *ioc_inode,                                                  waiter_page->ready = 0;                                                  need_fault = 1;                                          } else { -                                                gf_log (frame->this->name, -                                                        GF_LOG_TRACE, -                                                        "validate frame(%p) is " -                                                        "waiting for in-transit" -                                                        " page = %p", frame, -                                                        waiter_page); +                                                gf_msg_trace (frame->this->name, +                                                              0, +                                                              "validate " +                                                              "frame(%p) is " +                                                              "waiting for " +                                                              "in-transit" +                                                              " page = %p", +                                                              frame, +                                                              waiter_page);                                          }                                  }                                  ioc_inode_unlock (ioc_inode); @@ -193,8 +197,8 @@ ioc_inode_update (ioc_table_t *table, inode_t *inode, uint32_t weight)          }          ioc_table_unlock (table); -        gf_log (table->xl->name, GF_LOG_TRACE, -                "adding to inode_lru[%d]", weight); +        gf_msg_trace (table->xl->name, 0, +                      "adding to inode_lru[%d]", weight);  out:          return ioc_inode; diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c index dce883fbd94..a0f01da6d2e 100644 --- a/xlators/performance/io-cache/src/page.c +++ b/xlators/performance/io-cache/src/page.c @@ -16,7 +16,7 @@  #include "ioc-mem-types.h"  #include <assert.h>  #include <sys/time.h> - +#include "io-cache-messages.h"  char  ioc_empty (struct ioc_cache *cache)  { @@ -103,10 +103,10 @@ __ioc_page_destroy (ioc_page_t *page)                                  sizeof (page->offset));                  list_del (&page->page_lru); -                gf_log (page->inode->table->xl->name, GF_LOG_TRACE, -                        "destroying page = %p, offset = %"PRId64" " -                        "&& inode = %p", -                        page, page->offset, page->inode); +                gf_msg_trace (page->inode->table->xl->name, 0, +                              "destroying page = %p, offset = %"PRId64" " +                              "&& inode = %p", +                              page, page->offset, page->inode);                  if (page->vector){                          iobref_unref (page->iobref); @@ -169,10 +169,11 @@ __ioc_inode_prune (ioc_inode_t *curr, uint64_t *size_pruned,                  if (ret != -1)                          table->cache_used -= ret; -                gf_log (table->xl->name, GF_LOG_TRACE, -                        "index = %d && table->cache_used = %"PRIu64" && table->" -                        "cache_size = %"PRIu64, index, table->cache_used, -                        table->cache_size); +                gf_msg_trace (table->xl->name, 0, +                              "index = %d && " +                              "table->cache_used = %"PRIu64" && table->" +                              "cache_size = %"PRIu64, index, table->cache_used, +                              table->cache_size);                  if ((*size_pruned) >= size_to_prune)                          break; @@ -279,8 +280,8 @@ __ioc_page_create (ioc_inode_t *ioc_inode, off_t offset)          page = newpage; -        gf_log ("io-cache", GF_LOG_TRACE, -                "returning new page %p", page); +        gf_msg_trace ("io-cache", 0, +                      "returning new page %p", page);  out:          return page; @@ -310,7 +311,8 @@ __ioc_wait_on_page (ioc_page_t *page, call_frame_t *frame, off_t offset,          if (page == NULL) {                  local->op_ret = -1;                  local->op_errno = ENOMEM; -                gf_log (frame->this->name, GF_LOG_WARNING, +                gf_msg (frame->this->name, GF_LOG_WARNING, +                        0, IO_CACHE_MSG_NO_MEMORY,                          "asked to wait on a NULL page");                  goto out;          } @@ -322,10 +324,10 @@ __ioc_wait_on_page (ioc_page_t *page, call_frame_t *frame, off_t offset,                  goto out;          } -        gf_log (frame->this->name, GF_LOG_TRACE, -                "frame(%p) waiting on page = %p, offset=%"PRId64", " -                "size=%"GF_PRI_SIZET"", -                frame, page, offset, size); +        gf_msg_trace (frame->this->name, 0, +                      "frame(%p) waiting on page = %p, offset=%"PRId64", " +                      "size=%"GF_PRI_SIZET"", +                      frame, page, offset, size);          waitq->data = frame;          waitq->next = page->waitq; @@ -439,9 +441,9 @@ ioc_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                  if (op_ret == -1 || !(zero_filled ||                                        ioc_cache_still_valid(ioc_inode,                                                              stbuf))) { -                        gf_log (ioc_inode->table->xl->name, GF_LOG_TRACE, -                                "cache for inode(%p) is invalid. flushing " -                                "all pages", ioc_inode); +                        gf_msg_trace (ioc_inode->table->xl->name, 0, +                                      "cache for inode(%p) is invalid. flushing " +                                      "all pages", ioc_inode);                          destroy_size = __ioc_inode_flush (ioc_inode);                  } @@ -459,8 +461,8 @@ ioc_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                                  waitq = __ioc_page_error (page, op_ret,                                                            op_errno);                  } else { -                        gf_log (ioc_inode->table->xl->name, GF_LOG_TRACE, -                                "op_ret = %d", op_ret); +                        gf_msg_trace (ioc_inode->table->xl->name, 0, +                                      "op_ret = %d", op_ret);                          page = __ioc_page_get (ioc_inode, offset);                          if (!page) {                                  /* page was flushed */ @@ -495,8 +497,9 @@ ioc_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                                  } else {                                          /* TODO: we have got a response to                                           * our request and no data */ -                                        gf_log (frame->this->name, +                                        gf_msg (frame->this->name,                                                  GF_LOG_CRITICAL, +                                                ENOMEM, IO_CACHE_MSG_NO_MEMORY,                                                  "frame>root>rsp_refs is null");                                  } /* if(frame->root->rsp_refs) */ @@ -548,8 +551,8 @@ unlock:                  ioc_prune (ioc_inode->table);          } -        gf_log (frame->this->name, GF_LOG_TRACE, "fault frame %p returned", -                frame); +        gf_msg_trace (frame->this->name, 0, "fault frame %p returned", +                      frame);          pthread_mutex_destroy (&local->local_lock);          fd_unref (local->fd); @@ -583,7 +586,8 @@ ioc_page_fault (ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,          if (frame == NULL) {                  op_ret = -1;                  op_errno = EINVAL; -                gf_log ("io-cache", GF_LOG_WARNING, +                gf_msg ("io-cache", GF_LOG_WARNING, +                        EINVAL, IO_CACHE_MSG_ENFORCEMENT_FAILED,                          "page fault on a NULL frame");                  goto err;          } @@ -617,9 +621,9 @@ ioc_page_fault (ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,          fault_local->pending_size = table->page_size;          fault_local->inode = ioc_inode; -        gf_log (frame->this->name, GF_LOG_TRACE, -                "stack winding page fault for offset = %"PRId64" with " -                "frame %p", offset, fault_frame); +        gf_msg_trace (frame->this->name, 0, +                      "stack winding page fault for offset = %"PRId64" with " +                      "frame %p", offset, fault_frame);          STACK_WIND (fault_frame, ioc_fault_cbk, FIRST_CHILD(fault_frame->this),                      FIRST_CHILD(fault_frame->this)->fops->readv, fd, @@ -662,7 +666,8 @@ __ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset,          GF_VALIDATE_OR_GOTO (frame->this->name, local, out);          if (page == NULL) { -                gf_log (frame->this->name, GF_LOG_WARNING, +                gf_msg (frame->this->name, GF_LOG_WARNING, 0, +                        IO_CACHE_MSG_ENFORCEMENT_FAILED,                          "NULL page has been provided to serve read request");                  local->op_ret = -1;                  local->op_errno = EINVAL; @@ -671,10 +676,10 @@ __ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset,          ioc_inode = page->inode; -        gf_log (frame->this->name, GF_LOG_TRACE, -                "frame (%p) offset = %"PRId64" && size = %"GF_PRI_SIZET" " -                "&& page->size = %"GF_PRI_SIZET" && wait_count = %d", -                frame, offset, size, page->size, local->wait_count); +        gf_msg_trace (frame->this->name, 0, +                      "frame (%p) offset = %"PRId64" && size = %"GF_PRI_SIZET" " +                      "&& page->size = %"GF_PRI_SIZET" && wait_count = %d", +                      frame, offset, size, page->size, local->wait_count);          /* immediately move this page to the end of the page_lru list */          list_move_tail (&page->page_lru, &ioc_inode->cache.page_lru); @@ -708,10 +713,10 @@ __ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset,                          copy_size = src_offset = 0;                  } -                gf_log (page->inode->table->xl->name, GF_LOG_TRACE, -                        "copy_size = %"GF_PRI_SIZET" && src_offset = " -                        "%"PRId64" && dst_offset = %"PRId64"", -                        copy_size, src_offset, dst_offset); +                gf_msg_trace (page->inode->table->xl->name, 0, +                              "copy_size = %"GF_PRI_SIZET" && src_offset = " +                              "%"PRId64" && dst_offset = %"PRId64"", +                              copy_size, src_offset, dst_offset);                  {                          new = GF_CALLOC (1, sizeof (*new), @@ -809,8 +814,8 @@ ioc_frame_unwind (call_frame_t *frame)          local = frame->local;          if (local == NULL) { -                gf_log (frame->this->name, GF_LOG_WARNING, -                        "local is NULL"); +                gf_msg (frame->this->name, GF_LOG_WARNING, ENOMEM, +                        IO_CACHE_MSG_NO_MEMORY, "local is NULL");                  op_ret = -1;                  op_errno = ENOMEM;                  goto unwind; @@ -830,10 +835,10 @@ ioc_frame_unwind (call_frame_t *frame)          }          if (list_empty (&local->fill_list)) { -                gf_log (frame->this->name, GF_LOG_TRACE, -                        "frame(%p) has 0 entries in local->fill_list " -                        "(offset = %"PRId64" && size = %"GF_PRI_SIZET")", -                        frame, local->offset, local->size); +                gf_msg_trace (frame->this->name, 0, +                              "frame(%p) has 0 entries in local->fill_list " +                              "(offset = %"PRId64" && size = %"GF_PRI_SIZET")", +                              frame, local->offset, local->size);          }          list_for_each_entry (fill, &local->fill_list, list) { @@ -871,8 +876,8 @@ ioc_frame_unwind (call_frame_t *frame)          }  unwind: -        gf_log (frame->this->name, GF_LOG_TRACE, -                "frame(%p) unwinding with op_ret=%d", frame, op_ret); +        gf_msg_trace (frame->this->name, 0, +                      "frame(%p) unwinding with op_ret=%d", frame, op_ret);          //  ioc_local_unlock (local); @@ -946,8 +951,8 @@ __ioc_page_wakeup (ioc_page_t *page, int32_t op_errno)          page->ready = 1; -        gf_log (page->inode->table->xl->name, GF_LOG_TRACE, -                "page is %p && waitq = %p", page, waitq); +        gf_msg_trace (page->inode->table->xl->name, 0, +                      "page is %p && waitq = %p", page, waitq);          for (trav = waitq; trav; trav = trav->next) {                  frame = trav->data; @@ -989,8 +994,8 @@ __ioc_page_error (ioc_page_t *page, int32_t op_ret, int32_t op_errno)          waitq = page->waitq;          page->waitq = NULL; -        gf_log (page->inode->table->xl->name, GF_LOG_DEBUG, -                "page error for page = %p & waitq = %p", page, waitq); +        gf_msg_debug (page->inode->table->xl->name, 0, +                      "page error for page = %p & waitq = %p", page, waitq);          for (trav = waitq; trav; trav = trav->next) { diff --git a/xlators/performance/io-threads/src/io-threads-messages.h b/xlators/performance/io-threads/src/io-threads-messages.h new file mode 100644 index 00000000000..ab1f672756b --- /dev/null +++ b/xlators/performance/io-threads/src/io-threads-messages.h @@ -0,0 +1,103 @@ +/*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 _IO_THREADS_MESSAGES_H_ +#define _IO_THREADS_MESSAGES_H_ + +#include "glfs-message-id.h" + +/*! \file io-threads-messages.h + *  \brief IO_THREADS 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_IO_THREADS_BASE                   GLFS_MSGID_COMP_IO_THREADS +#define GLFS_IO_THREADS_NUM_MESSAGES           5 +#define GLFS_MSGID_END (GLFS_IO_THREADS_BASE + \ +        GLFS_IO_THREADS_NUM_MESSAGES + 1) + +/* Messages with message IDs */ +#define glfs_msg_start_x GLFS_IO_THREADS_BASE, "Invalid: Start of messages" + + + + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define IO_THREADS_MSG_INIT_FAILED        (GLFS_IO_THREADS_BASE + 1) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define IO_THREADS_MSG_XLATOR_CHILD_MISCONFIGURED  (GLFS_IO_THREADS_BASE + 2) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define IO_THREADS_MSG_NO_MEMORY        (GLFS_IO_THREADS_BASE + 3) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define IO_THREADS_MSG_VOL_MISCONFIGURED        (GLFS_IO_THREADS_BASE + 4) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define IO_THREADS_MSG_SIZE_NOT_SET        (GLFS_IO_THREADS_BASE + 5) + + +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + + +#endif /* _IO_THREADS_MESSAGES_H_ */ diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c index fa51b600d1e..ca801499491 100644 --- a/xlators/performance/io-threads/src/io-threads.c +++ b/xlators/performance/io-threads/src/io-threads.c @@ -19,6 +19,7 @@  #include <sys/time.h>  #include <time.h>  #include "locking.h" +#include "io-threads-messages.h"  void *iot_worker (void *arg);  int iot_workers_scale (iot_conf_t *conf); @@ -187,9 +188,9 @@ iot_worker (void *data)                                  if (conf->curr_count > IOT_MIN_THREADS) {                                          conf->curr_count--;                                          bye = 1; -                                        gf_log (conf->this->name, GF_LOG_DEBUG, -                                                "timeout, terminated. conf->curr_count=%d", -                                                conf->curr_count); +                                        gf_msg_debug (conf->this->name, 0, +                                                      "timeout, terminated. conf->curr_count=%d", +                                                      conf->curr_count);                                  } else {                                          timeout = 0;                                  } @@ -341,8 +342,8 @@ iot_schedule (call_frame_t *frame, xlator_t *this, call_stub_t *stub)                  return -EINVAL;          }  out: -        gf_log (this->name, GF_LOG_DEBUG, "%s scheduled as %s fop", -                gf_fop_list[stub->fop], iot_get_pri_meaning (pri)); +        gf_msg_debug (this->name, 0, "%s scheduled as %s fop", +                      gf_fop_list[stub->fop], iot_get_pri_meaning (pri));          ret = do_iot_schedule (this->private, stub, pri);          return ret;  } @@ -763,9 +764,10 @@ __iot_workers_scale (iot_conf_t *conf)                  ret = gf_thread_create (&thread, &conf->w_attr, iot_worker, conf);                  if (ret == 0) {                          conf->curr_count++; -                        gf_log (conf->this->name, GF_LOG_DEBUG, -                                "scaled threads to %d (queue_size=%d/%d)", -                                conf->curr_count, conf->queue_size, scale); +                        gf_msg_debug (conf->this->name, 0, +                                      "scaled threads to %d (queue_size=%d/%d)", +                                      conf->curr_count, +                                      conf->queue_size, scale);                  } else {                          break;                  } @@ -810,11 +812,13 @@ set_stack_size (iot_conf_t *conf)          if (err == EINVAL) {                  err = pthread_attr_getstacksize (&conf->w_attr, &stacksize);                  if (!err) -                        gf_log (this->name, GF_LOG_WARNING, +                        gf_msg (this->name, GF_LOG_WARNING, +                                0, IO_THREADS_MSG_SIZE_NOT_SET,                                  "Using default thread stack size %zd",                                  stacksize);                  else -                        gf_log (this->name, GF_LOG_WARNING, +                        gf_msg (this->name, GF_LOG_WARNING, +                                0, IO_THREADS_MSG_SIZE_NOT_SET,                                  "Using default thread stack size");          } @@ -833,8 +837,9 @@ mem_acct_init (xlator_t *this)          ret = xlator_mem_acct_init (this, gf_iot_mt_end + 1);          if (ret != 0) { -                gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" -                                "failed"); +                gf_msg (this->name, GF_LOG_ERROR, +                        ENOMEM, IO_THREADS_MSG_NO_MEMORY, +                        "Memory accounting init failed");                  return ret;          } @@ -925,32 +930,37 @@ init (xlator_t *this)          int         i    = 0;  	if (!this->children || this->children->next) { -		gf_log ("io-threads", GF_LOG_ERROR, -			"FATAL: iot not configured with exactly one child"); +		gf_msg ("io-threads", GF_LOG_ERROR, 0, +                        IO_THREADS_MSG_XLATOR_CHILD_MISCONFIGURED, +			"FATAL: iot not configured " +                        "with exactly one child");                  goto out;  	}  	if (!this->parents) { -		gf_log (this->name, GF_LOG_WARNING, -			"dangling volume. check volfile "); +		gf_msg (this->name, GF_LOG_WARNING, 0, +			IO_THREADS_MSG_VOL_MISCONFIGURED, +                        "dangling volume. check volfile ");  	}  	conf = (void *) GF_CALLOC (1, sizeof (*conf),                                     gf_iot_mt_iot_conf_t);          if (conf == NULL) { -                gf_log (this->name, GF_LOG_ERROR, -                        "out of memory"); +                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +                        IO_THREADS_MSG_NO_MEMORY, "out of memory");                  goto out;          }          if ((ret = pthread_cond_init(&conf->cond, NULL)) != 0) { -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        IO_THREADS_MSG_INIT_FAILED,                          "pthread_cond_init failed (%d)", ret);                  goto out;          }          if ((ret = pthread_mutex_init(&conf->mutex, NULL)) != 0) { -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        IO_THREADS_MSG_INIT_FAILED,                          "pthread_mutex_init failed (%d)", ret);                  goto out;          } @@ -978,7 +988,8 @@ init (xlator_t *this)  	GF_OPTION_INIT("least-rate-limit", conf->throttle.rate_limit, int32,  		       out);          if ((ret = pthread_mutex_init(&conf->throttle.lock, NULL)) != 0) { -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        IO_THREADS_MSG_INIT_FAILED,                          "pthread_mutex_init failed (%d)", ret);                  goto out;          } @@ -992,7 +1003,8 @@ init (xlator_t *this)  	ret = iot_workers_scale (conf);          if (ret == -1) { -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        IO_THREADS_MSG_INIT_FAILED,                          "cannot initialize worker threads, exiting init");                  goto out;          } diff --git a/xlators/performance/md-cache/src/md-cache-messages.h b/xlators/performance/md-cache/src/md-cache-messages.h new file mode 100644 index 00000000000..2fe8d457a9a --- /dev/null +++ b/xlators/performance/md-cache/src/md-cache-messages.h @@ -0,0 +1,66 @@ +/*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 _MD_CACHE_MESSAGES_H_ +#define _MD_CACHE_MESSAGES_H_ + +#include "glfs-message-id.h" + +/*! \file md-cache-messages.h + *  \brief MD_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_MD_CACHE_BASE                   GLFS_MSGID_COMP_MD_CACHE +#define GLFS_MD_CACHE_NUM_MESSAGES           1 +#define GLFS_MSGID_END  (GLFS_MD_CACHE_BASE + GLFS_MD_CACHE_NUM_MESSAGES + 1) + +/* Messages with message IDs */ +#define glfs_msg_start_x GLFS_MD_CACHE_BASE, "Invalid: Start of messages" + + + + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define MD_CACHE_MSG_NO_MEMORY        (GLFS_MD_CACHE_BASE + 1) + + +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + + +#endif /* _MD_CACHE_MESSAGES_H_ */ diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c index 78cbfb57f96..d5ff10f9f58 100644 --- a/xlators/performance/md-cache/src/md-cache.c +++ b/xlators/performance/md-cache/src/md-cache.c @@ -17,6 +17,7 @@  #include "glusterfs-acl.h"  #include <assert.h>  #include <sys/time.h> +#include "md-cache-messages.h"  /* TODO: @@ -287,8 +288,8 @@ mdc_inode_prep (xlator_t *this, inode_t *inode)                  mdc = GF_CALLOC (sizeof (*mdc), 1, gf_mdc_mt_md_cache_t);                  if (!mdc) { -                        gf_log (this->name, GF_LOG_ERROR, -                                "out of memory :("); +                        gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +                                MD_CACHE_MSG_NO_MEMORY, "out of memory");                          goto unlock;                  } @@ -296,8 +297,8 @@ mdc_inode_prep (xlator_t *this, inode_t *inode)                  ret = __mdc_inode_ctx_set (this, inode, mdc);                  if (ret) { -                        gf_log (this->name, GF_LOG_ERROR, -                                "out of memory :("); +                        gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +                                MD_CACHE_MSG_NO_MEMORY, "out of memory");                          GF_FREE (mdc);                          mdc = NULL;                  } @@ -2242,8 +2243,8 @@ init (xlator_t *this)  	conf = GF_CALLOC (sizeof (*conf), 1, gf_mdc_mt_mdc_conf_t);  	if (!conf) { -		gf_log (this->name, GF_LOG_ERROR, -			"out of memory"); +                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +                        MD_CACHE_MSG_NO_MEMORY, "out of memory");  		return -1;  	} diff --git a/xlators/performance/open-behind/src/open-behind-messages.h b/xlators/performance/open-behind/src/open-behind-messages.h new file mode 100644 index 00000000000..57e63ea4bbb --- /dev/null +++ b/xlators/performance/open-behind/src/open-behind-messages.h @@ -0,0 +1,85 @@ +/*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 _OPEN_BEHIND_MESSAGES_H_ +#define _OPEN_BEHIND_MESSAGES_H_ + +#include "glfs-message-id.h" + +/*! \file open-behind-messages.h + *  \brief OPEN_BEHIND 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_OPEN_BEHIND_BASE                   GLFS_MSGID_COMP_OPEN_BEHIND +#define GLFS_OPEN_BEHIND_NUM_MESSAGES           3 +#define GLFS_MSGID_END  (GLFS_OPEN_BEHIND_BASE + \ +        GLFS_OPEN_BEHIND_NUM_MESSAGES + 1) + +/* Messages with message IDs */ +#define glfs_msg_start_x GLFS_OPEN_BEHIND_BASE, "Invalid: Start of messages" + + + + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define OPEN_BEHIND_MSG_XLATOR_CHILD_MISCONFIGURED (GLFS_OPEN_BEHIND_BASE + 1) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define OPEN_BEHIND_MSG_VOL_MISCONFIGURED        (GLFS_OPEN_BEHIND_BASE + 2) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define OPEN_BEHIND_MSG_NO_MEMORY        (GLFS_OPEN_BEHIND_BASE + 3) + + +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + + +#endif /* _OPEN_BEHIND_MESSAGES_H_ */ diff --git a/xlators/performance/open-behind/src/open-behind.c b/xlators/performance/open-behind/src/open-behind.c index 742e4df3fdf..97c12fab411 100644 --- a/xlators/performance/open-behind/src/open-behind.c +++ b/xlators/performance/open-behind/src/open-behind.c @@ -13,6 +13,7 @@  #include "statedump.h"  #include "call-stub.h"  #include "defaults.h" +#include "open-behind-messages.h"  typedef struct ob_conf {  	gf_boolean_t  use_anonymous_fd; /* use anonymous FDs wherever safe @@ -340,8 +341,8 @@ ob_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,  	return 0;  err: -	gf_log (this->name, GF_LOG_ERROR, "%s: %s", loc->path, -		strerror (op_errno)); +	gf_msg (this->name, GF_LOG_ERROR, op_errno, OPEN_BEHIND_MSG_NO_MEMORY, +                "%s", loc->path);  	STACK_UNWIND_STRICT (open, frame, -1, op_errno, 0, 0); @@ -887,7 +888,9 @@ mem_acct_init (xlator_t *this)          ret = xlator_mem_acct_init (this, gf_ob_mt_end + 1);          if (ret) -                gf_log (this->name, GF_LOG_ERROR, "Memory accounting failed"); +                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +                        OPEN_BEHIND_MSG_NO_MEMORY, +                        "Memory accounting failed");          return ret;  } @@ -920,14 +923,16 @@ init (xlator_t *this)          ob_conf_t    *conf = NULL;          if (!this->children || this->children->next) { -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        OPEN_BEHIND_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, +                gf_msg (this->name, GF_LOG_WARNING, 0, +                        OPEN_BEHIND_MSG_VOL_MISCONFIGURED,                          "dangling volume. check volfile ");          conf = GF_CALLOC (1, sizeof (*conf), gf_ob_mt_conf_t); diff --git a/xlators/performance/quick-read/src/quick-read-messages.h b/xlators/performance/quick-read/src/quick-read-messages.h new file mode 100644 index 00000000000..d7444dd8c8f --- /dev/null +++ b/xlators/performance/quick-read/src/quick-read-messages.h @@ -0,0 +1,119 @@ +/*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 _QUICK_READ_MESSAGES_H_ +#define _QUICK_READ_MESSAGES_H_ + +#include "glfs-message-id.h" + +/*! \file quick-read-messages.h + *  \brief QUICK_READ 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_QUICK_READ_BASE                    GLFS_MSGID_COMP_QUICK_READ +#define GLFS_QUICK_READ_NUM_MESSAGES            7 +#define GLFS_MSGID_END                          (GLFS_QUICK_READ_BASE +\ +                                              GLFS_QUICK_READ_NUM_MESSAGES + 1) + +/* Messages with message IDs */ +#define glfs_msg_start_x GLFS_QUICK_READ_BASE, "Invalid: Start of messages" + + +#define QUICK_READ_MSG_ENFORCEMENT_FAILED       (GLFS_QUICK_READ_BASE + 1) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define QUICK_READ_MSG_INVALID_ARGUMENT         (GLFS_QUICK_READ_BASE + 2) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define QUICK_READ_MSG_XLATOR_CHILD_MISCONFIGURED\ +                                                (GLFS_QUICK_READ_BASE + 3) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define QUICK_READ_MSG_NO_MEMORY                (GLFS_QUICK_READ_BASE + 4) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define QUICK_READ_MSG_VOL_MISCONFIGURED        (GLFS_QUICK_READ_BASE + 5) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define QUICK_READ_MSG_DICT_SET_FAILED          (GLFS_QUICK_READ_BASE + 6) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define QUICK_READ_MSG_INVALID_CONFIG           (GLFS_QUICK_READ_BASE + 7) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + + +#endif /* _QUICK_READ_MESSAGES_H_ */ diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index 53f9a5d44ce..c6913ee471b 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -10,6 +10,7 @@  #include "quick-read.h"  #include "statedump.h" +#include "quick-read-messages.h"  qr_inode_t *qr_inode_ctx_get (xlator_t *this, inode_t *inode);  void __qr_inode_prune (qr_inode_table_t *table, qr_inode_t *qr_inode); @@ -471,8 +472,9 @@ qr_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)  		ret = dict_set (xdata, GF_CONTENT_KEY,  				data_from_uint64 (conf->max_file_size));  	if (ret) -		gf_log (this->name, GF_LOG_WARNING, -			"cannot set key in request dict (%s)", +		gf_msg (this->name, GF_LOG_WARNING, 0, +			QUICK_READ_MSG_DICT_SET_FAILED, +                        "cannot set key in request dict (%s)",  			loc->path);  wind:  	frame->local = inode_ref (loc->inode); @@ -784,8 +786,9 @@ mem_acct_init (xlator_t *this)          ret = xlator_mem_acct_init (this, gf_qr_mt_end + 1);          if (ret != 0) { -                gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" -                        "failed"); +                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +                        QUICK_READ_MSG_NO_MEMORY, +                        "Memory accounting init failed");                  return ret;          } @@ -805,7 +808,8 @@ check_cache_size_ok (xlator_t *this, int64_t cache_size)          opt = xlator_volume_option_get (this, "cache-size");          if (!opt) {                  ret = _gf_false; -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, EINVAL, +                        QUICK_READ_MSG_INVALID_ARGUMENT,                          "could not get cache-size option");                  goto out;          } @@ -816,11 +820,12 @@ check_cache_size_ok (xlator_t *this, int64_t cache_size)          else                  max_cache_size = total_mem; -        gf_log (this->name, GF_LOG_DEBUG, "Max cache size is %"PRIu64, -                max_cache_size); +        gf_msg_debug (this->name, 0, "Max cache size is %"PRIu64, +                      max_cache_size);          if (cache_size > max_cache_size) {                  ret = _gf_false; -                gf_log (this->name, GF_LOG_ERROR, "Cache size %"PRIu64 +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        QUICK_READ_MSG_INVALID_ARGUMENT, "Cache size %"PRIu64                          " is greater than the max size of %"PRIu64,                          cache_size, max_cache_size);                  goto out; @@ -854,7 +859,8 @@ reconfigure (xlator_t *this, dict_t *options)          GF_OPTION_RECONF ("cache-size", cache_size_new, options, size_uint64, out);          if (!check_cache_size_ok (this, cache_size_new)) {                  ret = -1; -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, EINVAL, +                        QUICK_READ_MSG_INVALID_CONFIG,                          "Not reconfiguring cache-size");                  goto out;          } @@ -923,10 +929,9 @@ qr_get_priority_list (const char *opt_str, struct list_head *first)                          goto out;                  } -                gf_log ("quick-read", GF_LOG_TRACE, -                        "quick-read priority : pattern %s : priority %s", -                        pattern, -                        priority); +                gf_msg_trace ("quick-read", 0, +                              "quick-read priority : pattern %s : priority %s", +                              pattern, priority);                  curr->pattern = gf_strdup (pattern);                  if (curr->pattern == NULL) { @@ -972,14 +977,16 @@ init (xlator_t *this)          qr_conf_t    *conf = NULL;          if (!this->children || this->children->next) { -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        QUICK_READ_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, +                gf_msg (this->name, GF_LOG_WARNING, 0, +                        QUICK_READ_MSG_VOL_MISCONFIGURED,                          "dangling volume. check volfile ");          } @@ -1007,8 +1014,8 @@ init (xlator_t *this)          if (dict_get (this->options, "priority")) {                  char *option_list = data_to_str (dict_get (this->options,                                                             "priority")); -                gf_log (this->name, GF_LOG_TRACE, -                        "option path %s", option_list); +                gf_msg_trace (this->name, 0, +                              "option path %s", option_list);                  /* parse the list of pattern:priority */                  conf->max_pri = qr_get_priority_list (option_list,                                                        &conf->priority_list); diff --git a/xlators/performance/read-ahead/src/page.c b/xlators/performance/read-ahead/src/page.c index b1f69119fa3..216e327af74 100644 --- a/xlators/performance/read-ahead/src/page.c +++ b/xlators/performance/read-ahead/src/page.c @@ -14,6 +14,7 @@  #include "xlator.h"  #include "read-ahead.h"  #include <assert.h> +#include "read-ahead-messages.h"  ra_page_t *  ra_page_get (ra_file_t *file, off_t offset) @@ -150,7 +151,8 @@ ra_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          pending_offset = local->pending_offset;          if (file == NULL) { -                gf_log (this->name, GF_LOG_WARNING, +                gf_msg (this->name, GF_LOG_WARNING, EBADF, +                        READ_AHEAD_MSG_FD_CONTEXT_NOT_SET,                          "read-ahead context not set in fd (%p)", fd);                  op_ret = -1;                  op_errno = EBADF; @@ -165,9 +167,10 @@ ra_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                  page = ra_page_get (file, pending_offset);                  if (!page) { -                        gf_log (this->name, GF_LOG_TRACE, -                                "wasted copy: %"PRId64"[+%"PRId64"] file=%p", -                                pending_offset, file->page_size, file); +                        gf_msg_trace (this->name, 0, +                                      "wasted copy: " +                                      "%"PRId64"[+%"PRId64"] file=%p", +                                      pending_offset, file->page_size, file);                          goto unlock;                  } diff --git a/xlators/performance/read-ahead/src/read-ahead-messages.h b/xlators/performance/read-ahead/src/read-ahead-messages.h new file mode 100644 index 00000000000..a205ceeb855 --- /dev/null +++ b/xlators/performance/read-ahead/src/read-ahead-messages.h @@ -0,0 +1,94 @@ +/*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 _READ_AHEAD_MESSAGES_H_ +#define _READ_AHEAD_MESSAGES_H_ + +#include "glfs-message-id.h" + +/*! \file read-ahead-messages.h + *  \brief READ_AHEAD 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_READ_AHEAD_BASE                   GLFS_MSGID_COMP_READ_AHEAD +#define GLFS_READ_AHEAD_NUM_MESSAGES           4 +#define GLFS_MSGID_END  (GLFS_READ_AHEAD_BASE +\ +         GLFS_READ_AHEAD_NUM_MESSAGES + 1) + +/* Messages with message IDs */ +#define glfs_msg_start_x GLFS_READ_AHEAD_BASE, "Invalid: Start of messages" + + + + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define READ_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED   (GLFS_READ_AHEAD_BASE + 1) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define READ_AHEAD_MSG_VOL_MISCONFIGURED        (GLFS_READ_AHEAD_BASE + 2) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define READ_AHEAD_MSG_NO_MEMORY        (GLFS_READ_AHEAD_BASE + 3) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define READ_AHEAD_MSG_FD_CONTEXT_NOT_SET        (GLFS_READ_AHEAD_BASE + 4) + + +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + + +#endif /* _READ_AHEAD_MESSAGES_H_ */ diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c index ec0b0e46f73..923163ab07c 100644 --- a/xlators/performance/read-ahead/src/read-ahead.c +++ b/xlators/performance/read-ahead/src/read-ahead.c @@ -23,6 +23,7 @@  #include "statedump.h"  #include <assert.h>  #include <sys/time.h> +#include "read-ahead-messages.h"  static void  read_ahead (call_frame_t *frame, ra_file_t *file); @@ -84,8 +85,10 @@ ra_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          ret = fd_ctx_set (fd, this, (uint64_t)(long)file);          if (ret == -1) { -                gf_log (frame->this->name, GF_LOG_WARNING, -                        "cannot set read-ahead context information in fd (%p)", +                gf_msg (frame->this->name, GF_LOG_WARNING, +                        0, READ_AHEAD_MSG_NO_MEMORY, +                        "cannot set read-ahead context" +                        "information in fd (%p)",                          fd);                  ra_file_destroy (file);                  op_ret = -1; @@ -156,8 +159,10 @@ ra_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          ret = fd_ctx_set (fd, this, (uint64_t)(long)file);          if (ret == -1) { -                gf_log (this->name, GF_LOG_WARNING, -                        "cannot set read ahead context information in fd (%p)", +                gf_msg (this->name, GF_LOG_WARNING, +                        0, READ_AHEAD_MSG_NO_MEMORY, +                        "cannot set read ahead context" +                        "information in fd (%p)",                          fd);                  ra_file_destroy (file);                  op_ret = -1; @@ -324,8 +329,8 @@ read_ahead (call_frame_t *frame, ra_file_t *file)                  }                  if (fault) { -                        gf_log (frame->this->name, GF_LOG_TRACE, -                                "RA at offset=%"PRId64, trav_offset); +                        gf_msg_trace (frame->this->name, 0, +                                      "RA at offset=%"PRId64, trav_offset);                          ra_page_fault (file, frame, trav_offset);                  }                  trav_offset += file->page_size; @@ -391,14 +396,15 @@ dispatch_requests (call_frame_t *frame, ra_file_t *file)                          trav->dirty = 0;                          if (trav->ready) { -                                gf_log (frame->this->name, GF_LOG_TRACE, -                                        "HIT at offset=%"PRId64".", -                                        trav_offset); +                                gf_msg_trace (frame->this->name, 0, +                                              "HIT at offset=%"PRId64".", +                                              trav_offset);                                  ra_frame_fill (trav, frame);                          } else { -                                gf_log (frame->this->name, GF_LOG_TRACE, -                                        "IN-TRANSIT at offset=%"PRId64".", -                                        trav_offset); +                                gf_msg_trace (frame->this->name, 0, +                                              "IN-TRANSIT at " +                                              "offset=%"PRId64".", +                                              trav_offset);                                  ra_wait_on_page (trav, frame);                                  need_atime_update = 0;                          } @@ -411,9 +417,9 @@ dispatch_requests (call_frame_t *frame, ra_file_t *file)                  }                  if (fault) { -                        gf_log (frame->this->name, GF_LOG_TRACE, -                                "MISS at offset=%"PRId64".", -                                trav_offset); +                        gf_msg_trace (frame->this->name, 0, +                                      "MISS at offset=%"PRId64".", +                                      trav_offset);                          ra_page_fault (file, frame, trav_offset);                  } @@ -471,9 +477,9 @@ ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,          conf = this->private; -        gf_log (this->name, GF_LOG_TRACE, -                "NEW REQ at offset=%"PRId64" for size=%"GF_PRI_SIZET"", -                offset, size); +        gf_msg_trace (this->name, 0, +                      "NEW REQ at offset=%"PRId64" for size=%"GF_PRI_SIZET"", +                      offset, size);          fd_ctx_get (fd, this, &tmp_file);          file = (ra_file_t *)(long)tmp_file; @@ -483,15 +489,16 @@ ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,          }          if (file->offset != offset) { -                gf_log (this->name, GF_LOG_TRACE, -                        "unexpected offset (%"PRId64" != %"PRId64") resetting", -                        file->offset, offset); +                gf_msg_trace (this->name, 0, +                              "unexpected offset (%"PRId64" != %"PRId64") " +                              "resetting", +                              file->offset, offset);                  expected_offset = file->expected = file->page_count = 0;          } else { -                gf_log (this->name, GF_LOG_TRACE, -                        "expected offset (%"PRId64") when page_count=%d", -                        offset, file->page_count); +                gf_msg_trace (this->name, 0, +                              "expected offset (%"PRId64") when page_count=%d", +                              offset, file->page_count);                  if (file->expected < (file->page_size * conf->page_count)) {                          file->expected += size; @@ -1098,7 +1105,8 @@ mem_acct_init (xlator_t *this)          ret = xlator_mem_acct_init (this, gf_ra_mt_end + 1);          if (ret != 0) { -                gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" +                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +                        READ_AHEAD_MSG_NO_MEMORY, "Memory accounting init"                          "failed");          } @@ -1136,14 +1144,16 @@ init (xlator_t *this)          GF_VALIDATE_OR_GOTO ("read-ahead", this, out);          if (!this->children || this->children->next) { -                gf_log (this->name,  GF_LOG_ERROR, +                gf_msg (this->name,  GF_LOG_ERROR, 0, +                        READ_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED,                          "FATAL: read-ahead not configured with exactly one"                          " child");                  goto out;          }          if (!this->parents) { -                gf_log (this->name, GF_LOG_WARNING, +                gf_msg (this->name, GF_LOG_WARNING, 0, +                        READ_AHEAD_MSG_VOL_MISCONFIGURED,                          "dangling volume. check volfile ");          } @@ -1168,7 +1178,8 @@ init (xlator_t *this)          this->local_pool = mem_pool_new (ra_local_t, 64);          if (!this->local_pool) {                  ret = -1; -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, +                        ENOMEM, READ_AHEAD_MSG_NO_MEMORY,                          "failed to create local_t's memory pool");                  goto out;          } diff --git a/xlators/performance/readdir-ahead/src/readdir-ahead-messages.h b/xlators/performance/readdir-ahead/src/readdir-ahead-messages.h new file mode 100644 index 00000000000..0e19348b954 --- /dev/null +++ b/xlators/performance/readdir-ahead/src/readdir-ahead-messages.h @@ -0,0 +1,105 @@ +/*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 _READDIR_AHEAD_MESSAGES_H_ +#define _READDIR_AHEAD_MESSAGES_H_ + +#include "glfs-message-id.h" + +/*! \file readdir-ahead-messages.h + *  \brief READDIR_AHEAD 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_READDIR_AHEAD_BASE                   GLFS_MSGID_COMP_READDIR_AHEAD +#define GLFS_READDIR_AHEAD_NUM_MESSAGES           5 +#define GLFS_MSGID_END          (GLFS_READDIR_AHEAD_BASE +\ +        GLFS_READDIR_AHEAD_NUM_MESSAGES + 1) + +/* Messages with message IDs */ +#define glfs_msg_start_x GLFS_READDIR_AHEAD_BASE, "Invalid: Start of messages" + + + + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define READDIR_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED\ +        (GLFS_READDIR_AHEAD_BASE + 1) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define READDIR_AHEAD_MSG_VOL_MISCONFIGURED        (GLFS_READDIR_AHEAD_BASE + 2) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define READDIR_AHEAD_MSG_NO_MEMORY        (GLFS_READDIR_AHEAD_BASE + 3) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define READDIR_AHEAD_MSG_DIR_RELEASE_PENDING_STUB \ +        (GLFS_READDIR_AHEAD_BASE + 4) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define READDIR_AHEAD_MSG_OUT_OF_SEQUENCE        (GLFS_READDIR_AHEAD_BASE + 5) + + +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + + +#endif /* _READDIR_AHEAD_MESSAGES_H_ */ diff --git a/xlators/performance/readdir-ahead/src/readdir-ahead.c b/xlators/performance/readdir-ahead/src/readdir-ahead.c index ec2d691a303..15f7c29c730 100644 --- a/xlators/performance/readdir-ahead/src/readdir-ahead.c +++ b/xlators/performance/readdir-ahead/src/readdir-ahead.c @@ -29,7 +29,7 @@  #include "readdir-ahead.h"  #include "readdir-ahead-mem-types.h"  #include "defaults.h" - +#include "readdir-ahead-messages.h"  static int rda_fill_fd(call_frame_t *, xlator_t *, fd_t *);  /* @@ -257,8 +257,9 @@ rda_fill_fd_cbk(call_frame_t *frame, void *cookie, xlator_t *this,  	/* Verify that the preload buffer is still pending on this data. */  	if (ctx->next_offset != local->offset) { -		gf_log(this->name, GF_LOG_ERROR, -			"Out of sequence directory preload."); +		gf_msg(this->name, GF_LOG_ERROR, +                       0, READDIR_AHEAD_MSG_OUT_OF_SEQUENCE, +                       "Out of sequence directory preload.");  		ctx->state |= (RDA_FD_BYPASS|RDA_FD_ERROR);  		ctx->op_errno = EUCLEAN; @@ -429,8 +430,9 @@ rda_releasedir(xlator_t *this, fd_t *fd)  		STACK_DESTROY(ctx->fill_frame->root);  	if (ctx->stub) -		gf_log(this->name, GF_LOG_ERROR, -			"released a directory with a pending stub"); +		gf_msg(this->name, GF_LOG_ERROR, 0, +		        READDIR_AHEAD_MSG_DIR_RELEASE_PENDING_STUB, +                       "released a directory with a pending stub");  	GF_FREE(ctx);  	return 0; @@ -447,7 +449,8 @@ mem_acct_init(xlator_t *this)  	ret = xlator_mem_acct_init(this, gf_rda_mt_end + 1);  	if (ret != 0) -		gf_log(this->name, GF_LOG_ERROR, "Memory accounting init" +		gf_msg(this->name, GF_LOG_ERROR, ENOMEM, +                       READDIR_AHEAD_MSG_NO_MEMORY, "Memory accounting init"  		       "failed");  out: @@ -479,14 +482,16 @@ init(xlator_t *this)          GF_VALIDATE_OR_GOTO("readdir-ahead", this, err);          if (!this->children || this->children->next) { -                gf_log(this->name,  GF_LOG_ERROR, +                gf_msg(this->name,  GF_LOG_ERROR, 0, +                        READDIR_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED,                          "FATAL: readdir-ahead not configured with exactly one"                          " child");                  goto err;          }          if (!this->parents) { -                gf_log(this->name, GF_LOG_WARNING, +                gf_msg(this->name, GF_LOG_WARNING, 0, +                        READDIR_AHEAD_MSG_VOL_MISCONFIGURED,                          "dangling volume. check volfile ");          } 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; diff --git a/xlators/performance/write-behind/src/write-behind-messages.h b/xlators/performance/write-behind/src/write-behind-messages.h new file mode 100644 index 00000000000..d0934cff5a4 --- /dev/null +++ b/xlators/performance/write-behind/src/write-behind-messages.h @@ -0,0 +1,121 @@ +/*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 _WRITE_BEHIND_MESSAGES_H_ +#define _WRITE_BEHIND_MESSAGES_H_ + +#include "glfs-message-id.h" + +/*! \file write-behind-messages.h + *  \brief WRITE_BEHIND 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_WRITE_BEHIND_BASE                   GLFS_MSGID_COMP_WRITE_BEHIND +#define GLFS_WRITE_BEHIND_NUM_MESSAGES           7 +#define GLFS_MSGID_END  (GLFS_WRITE_BEHIND_BASE +\ +        GLFS_WRITE_BEHIND_NUM_MESSAGES + 1) + +/* Messages with message IDs */ +#define glfs_msg_start_x GLFS_WRITE_BEHIND_BASE, "Invalid: Start of messages" + + + + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define WRITE_BEHIND_MSG_EXCEEDED_MAX_SIZE        (GLFS_WRITE_BEHIND_BASE + 1) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define WRITE_BEHIND_MSG_INIT_FAILED        (GLFS_WRITE_BEHIND_BASE + 2) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define WRITE_BEHIND_MSG_INVALID_ARGUMENT        (GLFS_WRITE_BEHIND_BASE + 3) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define WRITE_BEHIND_MSG_NO_MEMORY        (GLFS_WRITE_BEHIND_BASE + 4) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define WRITE_BEHIND_MSG_SIZE_NOT_SET        (GLFS_WRITE_BEHIND_BASE + 5) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define WRITE_BEHIND_MSG_VOL_MISCONFIGURED        (GLFS_WRITE_BEHIND_BASE + 6) + +/*! + * @messageid + * @diagnosis + * @recommendedaction  None + * + */ + +#define WRITE_BEHIND_MSG_RES_UNAVAILABLE        (GLFS_WRITE_BEHIND_BASE + 7) + + +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + + +#endif /* _WRITE_BEHIND_MESSAGES_H_ */ diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index 3a735233e22..1adda4eaff4 100644 --- a/xlators/performance/write-behind/src/write-behind.c +++ b/xlators/performance/write-behind/src/write-behind.c @@ -21,6 +21,7 @@  #include "statedump.h"  #include "defaults.h"  #include "write-behind-mem-types.h" +#include "write-behind-messages.h"  #define MAX_VECTOR_COUNT          8  #define WB_AGGREGATE_SIZE         131072 /* 128 KB */ @@ -351,7 +352,8 @@ __wb_request_unref (wb_request_t *req)  	wb_inode = req->wb_inode;          if (req->refcount <= 0) { -                gf_log ("wb-request", GF_LOG_WARNING, +                gf_msg ("wb-request", GF_LOG_WARNING, +                        0, WRITE_BEHIND_MSG_RES_UNAVAILABLE,                          "refcount(%d) is <= 0", req->refcount);                  goto out;          } @@ -417,7 +419,8 @@ __wb_request_ref (wb_request_t *req)          GF_VALIDATE_OR_GOTO ("write-behind", req, out);          if (req->refcount < 0) { -                gf_log ("wb-request", GF_LOG_WARNING, +                gf_msg ("wb-request", GF_LOG_WARNING, 0, +                        WRITE_BEHIND_MSG_RES_UNAVAILABLE,                          "refcount(%d) is < 0", req->refcount);                  req = NULL;                  goto out; @@ -988,7 +991,8 @@ __wb_collapse_small_writes (wb_request_t *holder, wb_request_t *req)                  ret = iobref_add (iobref, iobuf);                  if (ret != 0) { -                        gf_log (req->wb_inode->this->name, GF_LOG_WARNING, +                        gf_msg (req->wb_inode->this->name, GF_LOG_WARNING, +                                -ret, WRITE_BEHIND_MSG_INVALID_ARGUMENT,                                  "cannot add iobuf (%p) into iobref (%p)",                                  iobuf, iobref);                          iobuf_unref (iobuf); @@ -2094,7 +2098,9 @@ mem_acct_init (xlator_t *this)          ret = xlator_mem_acct_init (this, gf_wb_mt_end + 1);          if (ret != 0) { -                gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" +                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, +                        WRITE_BEHIND_MSG_NO_MEMORY, +                        "Memory accounting init"                          "failed");          } @@ -2138,14 +2144,16 @@ init (xlator_t *this)          if ((this->children == NULL)              || this->children->next) { -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        WRITE_BEHIND_MSG_INIT_FAILED,                          "FATAL: write-behind (%s) not configured with exactly "                          "one child", this->name);                  goto out;          }          if (this->parents == NULL) { -                gf_log (this->name, GF_LOG_WARNING, +                gf_msg (this->name, GF_LOG_WARNING, 0, +                        WRITE_BEHIND_MSG_VOL_MISCONFIGURED,                          "dangling volume. check volfilex");          } @@ -2161,7 +2169,8 @@ init (xlator_t *this)          GF_OPTION_INIT ("cache-size", conf->window_size, size_uint64, out);          if (!conf->window_size && conf->aggregate_size) { -                gf_log (this->name, GF_LOG_WARNING, +                gf_msg (this->name, GF_LOG_WARNING, 0, +                        WRITE_BEHIND_MSG_SIZE_NOT_SET,                          "setting window-size to be equal to "                          "aggregate-size(%"PRIu64")",                          conf->aggregate_size); @@ -2169,7 +2178,8 @@ init (xlator_t *this)          }          if (conf->window_size < conf->aggregate_size) { -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        WRITE_BEHIND_MSG_EXCEEDED_MAX_SIZE,                          "aggregate-size(%"PRIu64") cannot be more than "                          "window-size(%"PRIu64")", conf->aggregate_size,                          conf->window_size);  | 
