diff options
| author | Mohamed Ashiq <ashiq333@gmail.com> | 2015-04-17 17:33:49 +0530 | 
|---|---|---|
| committer | Venky Shankar <vshankar@redhat.com> | 2015-07-01 23:18:37 -0700 | 
| commit | b5d5ae55a1d6a2dc290b23c9f6b640fcece48118 (patch) | |
| tree | 9ad0cca45c1e4bf90d054df1118cc6b786b6385a /xlators/features/bit-rot/src/stub/bit-rot-stub.c | |
| parent | 8e4cc51e36514db9bf1ca2beac993091c95c649a (diff) | |
bit-rot : New logging framework for bit-rot log message
        Backport of http://review.gluster.org/10297
Cherry picked from 2f0d36d16c241365760aaa6d857b7a4d438e1042
>Change-Id: I83c494f2bb60d29495cd643659774d430325af0a
>BUG: 1194640
>Signed-off-by: Mohamed Ashiq <ashiq333@gmail.com>
>Reviewed-on: http://review.gluster.org/10297
>Tested-by: Venky Shankar <vshankar@redhat.com>
>Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
>Reviewed-by: Gaurav Kumar Garg <ggarg@redhat.com>
>Tested-by: NetBSD Build System <jenkins@build.gluster.org>
>Reviewed-by: Venky Shankar <vshankar@redhat.com>
Change-Id: I83c494f2bb60d29495cd643659774d430325af0a
BUG: 1217722
Signed-off-by: Mohamed Ashiq <ashiq333@gmail.com>
Reviewed-on: http://review.gluster.org/11379
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/features/bit-rot/src/stub/bit-rot-stub.c')
| -rw-r--r-- | xlators/features/bit-rot/src/stub/bit-rot-stub.c | 116 | 
1 files changed, 66 insertions, 50 deletions
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c index d4aecdc5b57..600eb80cd65 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c @@ -25,7 +25,7 @@  #include "bit-rot-stub.h"  #include "bit-rot-stub-mem-types.h" - +#include "bit-rot-stub-messages.h"  #include "bit-rot-common.h"  #define BR_STUB_REQUEST_COOKIE  0x1 @@ -51,8 +51,8 @@ mem_acct_init (xlator_t *this)          ret = xlator_mem_acct_init (this, gf_br_stub_mt_end + 1);          if (ret != 0) { -                gf_log (this->name, GF_LOG_WARNING, "Memory accounting" -                        " init failed"); +                gf_msg (this->name, GF_LOG_WARNING, 0, BRS_MSG_MEM_ACNT_FAILED, +                        "Memory accounting init failed");                  return ret;          } @@ -65,12 +65,13 @@ init (xlator_t *this)          int32_t ret = 0;          char *tmp = NULL;          struct timeval tv = {0,}; -	br_stub_private_t *priv = NULL; +        br_stub_private_t *priv = NULL; -	if (!this->children) { -		gf_log (this->name, GF_LOG_ERROR, "FATAL: no children"); -		goto error_return; -	} +        if (!this->children) { +                gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_NO_CHILD, +                        "FATAL: no children"); +                goto error_return; +        }          priv = GF_CALLOC (1, sizeof (*priv), gf_br_stub_mt_private_t);          if (!priv) @@ -99,7 +100,7 @@ init (xlator_t *this)          if (ret != 0)                  goto cleanup_lock; -        gf_log (this->name, GF_LOG_DEBUG, "bit-rot stub loaded"); +        gf_msg_debug (this->name, 0, "bit-rot stub loaded");  	this->private = priv;          return 0; @@ -127,7 +128,8 @@ fini (xlator_t *this)          ret = gf_thread_cleanup_xint (priv->signth);          if (ret) { -                gf_log (this->name, GF_LOG_ERROR, +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        BRS_MSG_CANCEL_SIGN_THREAD_FAILED,                          "Could not cancel sign serializer thread");                  goto out;          } @@ -340,8 +342,9 @@ br_stub_need_versioning (xlator_t *this,          ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr);          if (ret < 0) { -                gf_log (this->name, GF_LOG_ERROR, "failed to get the inode " -                        "context for the inode %s", +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " +                        "inode context for the inode %s",                          uuid_utoa (fd->inode->gfid));                  goto error_return;          } @@ -375,8 +378,9 @@ br_stub_anon_fd_ctx (xlator_t *this, fd_t *fd, br_stub_inode_ctx_t *ctx)          if (!br_stub_fd) {                  ret = br_stub_add_fd_to_inode (this, fd, ctx);                  if (ret) { -                        gf_log (this->name, GF_LOG_ERROR, "failed to " -                                "add fd to the inode (gfid: %s)", +                        gf_msg (this->name, GF_LOG_ERROR, 0, +                                BRS_MSG_ADD_FD_TO_INODE, "failed to add fd to " +                                "the inode (gfid: %s)",                                  uuid_utoa (fd->inode->gfid));                          goto out;                  } @@ -397,8 +401,9 @@ br_stub_versioning_prep (call_frame_t *frame,          local = br_stub_alloc_local (this);          if (!local) { -                gf_log (this->name, GF_LOG_ERROR, "local allocation failed " -                        "(gfid: %s)", uuid_utoa (fd->inode->gfid)); +                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRS_MSG_NO_MEMORY, +                        "local allocation failed (gfid: %s)", +                        uuid_utoa (fd->inode->gfid));                  goto error_return;          } @@ -693,9 +698,10 @@ br_stub_compare_sign_version (xlator_t *this,                  if (ctx->currentversion < sbuf->signedversion) {                          invalid = _gf_true;                  } else if (ctx->currentversion > sbuf->signedversion) { -                        gf_log (this->name, GF_LOG_DEBUG, "\"Signing version\" " -                                "(%lu) lower than \"Current version \" (%lu)", -                                ctx->currentversion, sbuf->signedversion); +                        gf_msg_debug (this->name, 0, "\"Signing version\" " +                                      "(%lu) lower than \"Current version \" " +                                      "(%lu)", ctx->currentversion, +                                      sbuf->signedversion);                          *fakesuccess = 1;                  }          } @@ -703,9 +709,10 @@ br_stub_compare_sign_version (xlator_t *this,          if (invalid) {                  ret = -1; -                gf_log (this->name, GF_LOG_WARNING, -                        "Signing version exceeds current version [%lu > %lu]", -                        sbuf->signedversion, ctx->currentversion); +                gf_msg (this->name, GF_LOG_WARNING, 0, +                        BRS_MSG_SIGN_VERSION_ERROR, "Signing version exceeds " +                        "current version [%lu > %lu]", sbuf->signedversion, +                        ctx->currentversion);          }   out: @@ -875,9 +882,9 @@ br_stub_handle_object_reopen (call_frame_t *frame,          stub = fop_fsetxattr_cbk_stub (frame, br_stub_fsetxattr_resume,                                         0, 0, NULL);          if (!stub) { -                gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " -                        "fsetxattr fop (gfid: %s), unwinding", -                        uuid_utoa (fd->inode->gfid)); +                gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, +                        "failed to allocate stub for fsetxattr fop (gfid: %s)," +                        " unwinding", uuid_utoa (fd->inode->gfid));                  goto cleanup_local;          } @@ -1003,8 +1010,9 @@ br_stub_is_object_stale (xlator_t *this, call_frame_t *frame, inode_t *inode,          ret = br_stub_get_inode_ctx (this, inode, &ctx_addr);          if (ret) { -                gf_log (this->name, GF_LOG_ERROR, "failed to get the inode " -                        "context for %s", uuid_utoa (inode->gfid)); +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " +                        "inode context for %s", uuid_utoa (inode->gfid));                  goto out;          } @@ -1389,9 +1397,9 @@ br_stub_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,                                  offset, flags, iobref, xdata);          if (!stub) { -                gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " -                        "write fop (gfid: %s), unwinding", -                        uuid_utoa (fd->inode->gfid)); +                gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, +                        "failed to allocate stub for write fop (gfid: %s), " +                        "unwinding", uuid_utoa (fd->inode->gfid));                  goto cleanup_local;          } @@ -1496,9 +1504,9 @@ br_stub_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd,          stub = fop_ftruncate_stub (frame, br_stub_ftruncate_resume, fd, offset,                                     xdata);          if (!stub) { -                gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " -                        "ftruncate fop (gfid: %s), unwinding", -                        uuid_utoa (fd->inode->gfid)); +                gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, +                        "failed to allocate stub for ftruncate fop (gfid: %s)," +                        " unwinding", uuid_utoa (fd->inode->gfid));                  goto cleanup_local;          } @@ -1597,8 +1605,10 @@ br_stub_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc,          fd = fd_anonymous (loc->inode);          if (!fd) { -                gf_log (this->name, GF_LOG_ERROR, "failed to create anonymous " -                        "fd for the inode %s", uuid_utoa (loc->inode->gfid)); +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        BRS_MSG_CREATE_ANONYMOUS_FD_FAILED, "failed to create " +                        "anonymous fd for the inode %s", +                        uuid_utoa (loc->inode->gfid));                  goto unwind;          } @@ -1624,9 +1634,9 @@ br_stub_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc,          stub = fop_truncate_stub (frame, br_stub_truncate_resume, loc, offset,                                    xdata);          if (!stub) { -                gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " -                        "truncate fop (gfid: %s), unwinding", -                        uuid_utoa (fd->inode->gfid)); +                gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, +                        "failed to allocate stub for truncate fop (gfid: %s), " +                        "unwinding", uuid_utoa (fd->inode->gfid));                  goto cleanup_local;          } @@ -1690,8 +1700,9 @@ br_stub_open (call_frame_t *frame, xlator_t *this,          ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr);          if (ret) { -                gf_log (this->name, GF_LOG_ERROR, "failed to get the inode " -                        "context for the file %s (gfid: %s)", loc->path, +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " +                        "inode context for the file %s (gfid: %s)", loc->path,                          uuid_utoa (fd->inode->gfid));                  goto unwind;          } @@ -1702,8 +1713,10 @@ br_stub_open (call_frame_t *frame, xlator_t *this,          ret = br_stub_add_fd_to_inode (this, fd, ctx);          if (ret) { -                gf_log (this->name, GF_LOG_ERROR, "failed add fd to the list " -                        "(gfid: %s)", uuid_utoa (fd->inode->gfid)); +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        BRS_MSG_ADD_FD_TO_LIST_FAILED, +                        "failed add fd to the list (gfid: %s)", +                        uuid_utoa (fd->inode->gfid));                  goto unwind;          } @@ -1735,7 +1748,8 @@ br_stub_add_fd_to_inode (xlator_t *this, fd_t *fd, br_stub_inode_ctx_t *ctx)          ret = br_stub_require_release_call (this, fd, &br_stub_fd);          if (ret) { -                gf_log (this->name, GF_LOG_ERROR, "failed to set the fd " +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        BRS_MSG_SET_FD_CONTEXT_FAILED, "failed to set the fd "                          "context for the file (gfid: %s)",                          uuid_utoa (fd->inode->gfid));                  goto out; @@ -2123,7 +2137,7 @@ br_stub_send_ipc_fop (xlator_t *this, fd_t *fd, unsigned long releaseversion,          xdata = dict_new ();          if (!xdata) { -                gf_log (this->name, GF_LOG_WARNING, +                gf_msg (this->name, GF_LOG_WARNING, ENOMEM, BRS_MSG_NO_MEMORY,                          "dict allocation failed: cannot send IPC FOP "                          "to changelog");                  goto out; @@ -2132,14 +2146,16 @@ br_stub_send_ipc_fop (xlator_t *this, fd_t *fd, unsigned long releaseversion,          ret = dict_set_static_bin (xdata,                                     "RELEASE-EVENT", &ev, CHANGELOG_EV_SIZE);          if (ret) { -                gf_log (this->name, GF_LOG_WARNING, +                gf_msg (this->name, GF_LOG_WARNING, 0, BRS_MSG_SET_EVENT_FAILED,                          "cannot set release event in dict");                  goto dealloc_dict;          }          frame = create_frame (this, this->ctx->pool);          if (!frame) { -                gf_log (this->name, GF_LOG_WARNING, "create_frame() failure"); +                gf_msg (this->name, GF_LOG_WARNING, 0, +                        BRS_MSG_CREATE_FRAME_FAILED, +                        "create_frame() failure");                  goto dealloc_dict;          } @@ -2245,10 +2261,10 @@ br_stub_release (xlator_t *this, fd_t *fd)          UNLOCK (&inode->lock);          if (ret) { -                gf_log (this->name, GF_LOG_DEBUG, -                        "releaseversion: %lu | flags: %d | signinfo: %d", -                        (unsigned long) ntohl (releaseversion), -                        flags, ntohl(signinfo)); +                gf_msg_debug (this->name, 0, "releaseversion: %lu | flags: %d " +                              "| signinfo: %d", +                              (unsigned long) ntohl (releaseversion), flags, +                              ntohl(signinfo));                  br_stub_send_ipc_fop (this, fd, releaseversion, signinfo);          }  | 
