From 3abdb22c4d9b3ba8738bfb565fb02b5d38b222b4 Mon Sep 17 00:00:00 2001
From: Mohamed Ashiq <ashiq333@gmail.com>
Date: Wed, 27 May 2015 15:20:59 +0530
Subject: [PATCH 152/190] changetimerecorder : Porting to new logging framework
Change-Id: I66e7ccc5e62482c3ecf0aab302568e6c9ecdc05d
BUG: 1231797
Signed-off-by: Mohamed Ashiq Liyazudeen <mliyazud@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/51210
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Tested-by: Dan Lambright <dlambrig@redhat.com>
---
libglusterfs/src/Makefile.am | 2 +-
libglusterfs/src/ctr-messages.h | 501 ++++++++++++++++++++
libglusterfs/src/glfs-message-id.h | 3 +
.../changetimerecorder/src/changetimerecorder.c | 213 +++++----
.../features/changetimerecorder/src/ctr-helper.c | 32 +-
.../features/changetimerecorder/src/ctr-helper.h | 40 +-
.../changetimerecorder/src/ctr-xlator-ctx.c | 38 +-
7 files changed, 703 insertions(+), 126 deletions(-)
create mode 100644 libglusterfs/src/ctr-messages.h
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am
index ed441d0..3862328 100644
--- a/libglusterfs/src/Makefile.am
+++ b/libglusterfs/src/Makefile.am
@@ -44,7 +44,7 @@ noinst_HEADERS = common-utils.h defaults.h dict.h glusterfs.h hashfn.h timespec.
run.h options.h lkowner.h fd-lk.h circ-buff.h event-history.h \
gidcache.h client_t.h glusterfs-acl.h glfs-message-id.h \
template-component-messages.h strfd.h syncop-utils.h parse-utils.h \
- libglusterfs-messages.h \
+ libglusterfs-messages.h ctr-messages.h \
$(CONTRIBDIR)/mount/mntent_compat.h lvm-defaults.h \
$(CONTRIBDIR)/libexecinfo/execinfo_compat.h \
unittest/unittest.h quota-common-utils.h rot-buffs.h \
diff --git a/libglusterfs/src/ctr-messages.h b/libglusterfs/src/ctr-messages.h
new file mode 100644
index 0000000..27de07a
--- /dev/null
+++ b/libglusterfs/src/ctr-messages.h
@@ -0,0 +1,501 @@
+/*
+ Copyright (c) 2013 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 _component_MESSAGES_H_
+#define _component_MESSAGES_H_
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "glfs-message-id.h"
+
+/* 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_COMP_BASE GLFS_MSGID_COMP_CTR
+#define GLFS_NUM_MESSAGES 56
+#define GLFS_MSGID_END (GLFS_COMP_BASE + GLFS_NUM_MESSAGES + 1)
+/* Messaged with message IDs */
+#define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages"
+/*------------*/
+
+#define CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND (GLFS_COMP_BASE + 1)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND (GLFS_COMP_BASE + 2)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_FILL_CTR_LOCAL_ERROR_WIND (GLFS_COMP_BASE + 3)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_LINK_WIND_FAILED (GLFS_COMP_BASE + 4)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_WRITEV_WIND_FAILED (GLFS_COMP_BASE + 5)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_WRITEV_UNWIND_FAILED (GLFS_COMP_BASE + 6)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_SETATTR_WIND_FAILED (GLFS_COMP_BASE + 7)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_SETATTR_UNWIND_FAILED (GLFS_COMP_BASE + 8)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_FREMOVEXATTR_UNWIND_FAILED (GLFS_COMP_BASE + 9)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_FREMOVEXATTR_WIND_FAILED (GLFS_COMP_BASE + 10)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_REMOVEXATTR_WIND_FAILED (GLFS_COMP_BASE + 11)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_REMOVEXATTR_UNWIND_FAILED (GLFS_COMP_BASE + 12)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_TRUNCATE_WIND_FAILED (GLFS_COMP_BASE + 13)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_TRUNCATE_UNWIND_FAILED (GLFS_COMP_BASE + 14)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_FTRUNCATE_UNWIND_FAILED (GLFS_COMP_BASE + 15)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_FTRUNCATE_WIND_FAILED (GLFS_COMP_BASE + 16)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_RENAME_WIND_FAILED (GLFS_COMP_BASE + 17)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_RENAME_UNWIND_FAILED (GLFS_COMP_BASE + 18)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED (GLFS_COMP_BASE + 19)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_ADD_HARDLINK_FAILED (GLFS_COMP_BASE + 20)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_DELETE_HARDLINK_FAILED (GLFS_COMP_BASE + 21)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_UPDATE_HARDLINK_FAILED (GLFS_COMP_BASE + 22)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_GET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED (GLFS_COMP_BASE + 23)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_SET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED (GLFS_COMP_BASE + 24)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_UNLINK_UNWIND_FAILED (GLFS_COMP_BASE + 25)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_UNLINK_WIND_FAILED (GLFS_COMP_BASE + 26)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_XDATA_NULL (GLFS_COMP_BASE + 27)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_FSYNC_WIND_FAILED (GLFS_COMP_BASE + 28)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_FSYNC_UNWIND_FAILED (GLFS_COMP_BASE + 29)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_MKNOD_UNWIND_FAILED (GLFS_COMP_BASE + 30)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_MKNOD_WIND_FAILED (GLFS_COMP_BASE + 31)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_CREATE_WIND_FAILED (GLFS_COMP_BASE + 32)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_CREATE_UNWIND_FAILED (GLFS_COMP_BASE + 33)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_RECORD_WIND_FAILED (GLFS_COMP_BASE + 34)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INSERT_READV_WIND_FAILED (GLFS_COMP_BASE + 35)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_GET_GFID_FROM_DICT_FAILED (GLFS_COMP_BASE + 36)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_SET (GLFS_COMP_BASE + 37)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_FATAL_ERROR (GLFS_COMP_BASE + 38)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_DANGLING_VOLUME (GLFS_COMP_BASE + 39)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_CALLOC_FAILED (GLFS_COMP_BASE + 40)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_EXTRACT_CTR_XLATOR_OPTIONS_FAILED (GLFS_COMP_BASE + 41)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INIT_DB_PARAMS_FAILED (GLFS_COMP_BASE + 42)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_CREATE_LOCAL_MEMORY_POOL_FAILED (GLFS_COMP_BASE + 43)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_MEM_ACC_INIT_FAILED (GLFS_COMP_BASE + 44)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_CLOSE_DB_CONN_FAILED (GLFS_COMP_BASE + 45)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_FILL_UNWIND_TIME_REC_ERROR (GLFS_COMP_BASE + 46)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_WRONG_FOP_PATH (GLFS_COMP_BASE + 47)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_CONSTRUCT_DB_PATH_FAILED (GLFS_COMP_BASE + 48)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED (GLFS_COMP_BASE + 49)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_XLATOR_DISABLED (GLFS_COMP_BASE + 50)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_HARDLINK_MISSING_IN_LIST (GLFS_COMP_BASE + 51)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_ADD_HARDLINK_TO_LIST_FAILED (GLFS_COMP_BASE + 52)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_INIT_LOCK_FAILED (GLFS_COMP_BASE + 53)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_COPY_FAILED (GLFS_COMP_BASE + 54)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_EXTRACT_DB_PARAM_OPTIONS_FAILED (GLFS_COMP_BASE + 55)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED (GLFS_COMP_BASE + 56)
+
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+/*------------*/
+#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
+
+#endif /* !_component_MESSAGES_H_ */
diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h
index 69ed188..242e487 100644
--- a/libglusterfs/src/glfs-message-id.h
+++ b/libglusterfs/src/glfs-message-id.h
@@ -113,6 +113,9 @@
#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+\
+ GLFS_MSGID_SEGMENT)
/* --- new segments for messages goes above this line --- */
diff --git a/xlators/features/changetimerecorder/src/changetimerecorder.c b/xlators/features/changetimerecorder/src/changetimerecorder.c
index dc23132..1fdeb7c 100644
--- a/xlators/features/changetimerecorder/src/changetimerecorder.c
+++ b/xlators/features/changetimerecorder/src/changetimerecorder.c
@@ -12,6 +12,7 @@
#include "gfdb_sqlite3.h"
#include "ctr-helper.h"
+#include "ctr-messages.h"
/*******************************inode forget***********************************/
@@ -99,7 +100,8 @@ ctr_lookup_wind(call_frame_t *frame,
frame->local = init_ctr_local_t (this);
if (!frame->local) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND,
"WIND: Error while creating ctr local");
goto out;
};
@@ -169,8 +171,9 @@ ctr_lookup_unwind (call_frame_t *frame,
ret = insert_record(_priv->_db_conn,
&ctr_local->gfdb_db_record);
if (ret == -1) {
- gf_log(this->name, GF_LOG_ERROR, "UNWIND: Error"
- "filling ctr local");
+ gf_msg(this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND,
+ "UNWIND: Error filling ctr local");
goto out;
}
}
@@ -204,8 +207,8 @@ ctr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* if the lookup failed lookup dont do anything*/
if (op_ret == -1) {
- gf_log (this->name, GF_LOG_TRACE, "lookup failed with %s",
- strerror (op_errno));
+ gf_msg_trace (this->name, 0, "lookup failed with %s",
+ strerror (op_errno));
goto out;
}
@@ -238,7 +241,7 @@ ctr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* Add hard link to the list */
ret = add_hard_link_ctx (frame, this, inode);
if (ret < 0) {
- gf_log (this->name, GF_LOG_TRACE, "Failed adding hard link");
+ gf_msg_trace (this->name, 0, "Failed adding hard link");
goto out;
}
@@ -247,8 +250,7 @@ ctr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
* created by ctr_lookup_wind */
ret = ctr_lookup_unwind(frame, this);
if (ret) {
- gf_log (this->name, GF_LOG_TRACE,
- "Failed inserting link wind");
+ gf_msg_trace (this->name, 0, "Failed inserting link wind");
}
@@ -302,8 +304,9 @@ ctr_lookup (call_frame_t *frame, xlator_t *this,
* No writing to the db yet */
ret = ctr_lookup_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting link wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_LINK_WIND_FAILED,
+ "Failed inserting link wind");
}
out:
@@ -329,7 +332,8 @@ ctr_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = ctr_insert_unwind(frame, this,
GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_WRITEV_UNWIND_FAILED,
"Failed inserting writev unwind");
}
@@ -362,8 +366,9 @@ ctr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting writev wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_WRITEV_WIND_FAILED,
+ "Failed inserting writev wind");
}
out:
@@ -390,7 +395,8 @@ ctr_setattr_cbk (call_frame_t *frame,
ret = ctr_insert_unwind(frame, this,
GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_SETATTR_UNWIND_FAILED,
"Failed inserting setattr unwind");
}
@@ -422,8 +428,9 @@ ctr_setattr (call_frame_t *frame,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting setattr wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_SETATTR_WIND_FAILED,
+ "Failed inserting setattr wind");
}
out:
@@ -448,7 +455,8 @@ ctr_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = ctr_insert_unwind(frame, this,
GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_FREMOVEXATTR_UNWIND_FAILED,
"Failed inserting fremovexattr unwind");
}
@@ -478,8 +486,9 @@ ctr_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting fremovexattr wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_FREMOVEXATTR_WIND_FAILED,
+ "Failed inserting fremovexattr wind");
}
out:
@@ -504,7 +513,8 @@ ctr_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = ctr_insert_unwind(frame, this,
GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_REMOVEXATTR_UNWIND_FAILED,
"Failed inserting removexattr unwind");
}
@@ -534,8 +544,9 @@ ctr_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting removexattr wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_REMOVEXATTR_WIND_FAILED,
+ "Failed inserting removexattr wind");
}
out:
@@ -560,7 +571,8 @@ ctr_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = ctr_insert_unwind(frame, this,
GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_TRUNCATE_UNWIND_FAILED,
"Failed inserting truncate unwind");
}
@@ -591,8 +603,9 @@ ctr_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting truncate wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_TRUNCATE_WIND_FAILED,
+ "Failed inserting truncate wind");
}
out:
STACK_WIND (frame, ctr_truncate_cbk, FIRST_CHILD (this),
@@ -615,7 +628,8 @@ ctr_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = ctr_insert_unwind(frame, this,
GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_FTRUNCATE_UNWIND_FAILED,
"Failed inserting ftruncate unwind");
}
@@ -645,8 +659,9 @@ ctr_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting ftruncate wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_FTRUNCATE_WIND_FAILED,
+ "Failed inserting ftruncate wind");
}
out:
@@ -672,7 +687,8 @@ ctr_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = ctr_insert_unwind(frame, this,
GFDB_FOP_DENTRY_WRITE, GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_RENAME_UNWIND_FAILED,
"Failed inserting rename unwind");
}
@@ -715,16 +731,17 @@ ctr_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting rename wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_RENAME_WIND_FAILED,
+ "Failed inserting rename wind");
} else {
/* We are doing updation of hard link in inode context in wind
* As we dont get the "inode" in the call back for rename */
ret = update_hard_link_ctx (frame, this, oldloc->inode);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed updating hard link in"
- "ctr inode context");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_UPDATE_HARDLINK_FAILED, "Failed "
+ "updating hard link in ctr inode context");
}
}
@@ -757,7 +774,8 @@ ctr_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = dict_get_uint32 (xdata , CTR_RESPONSE_LINK_COUNT_XDATA,
&remaining_links);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_GET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED,
"Failed to getting CTR_RESPONSE_LINK_COUNT_XDATA");
remaining_links = -1;
}
@@ -768,7 +786,8 @@ ctr_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = ctr_insert_unwind(frame, this, GFDB_FOP_DENTRY_WRITE,
GFDB_FOP_UNDEL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_UNLINK_UNWIND_FAILED,
"Failed inserting unlink unwind");
}
}
@@ -777,7 +796,8 @@ ctr_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = ctr_insert_unwind(frame, this, GFDB_FOP_DENTRY_WRITE,
GFDB_FOP_UNDEL_ALL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_UNLINK_UNWIND_FAILED,
"Failed inserting unlink unwind");
}
}
@@ -818,16 +838,17 @@ ctr_unlink (call_frame_t *frame, xlator_t *this,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting unlink wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_UNLINK_UNWIND_FAILED,
+ "Failed inserting unlink wind");
} else {
/* We are doing delete of hard link in inode context in wind
* As we dont get the "inode" in the call back for rename */
ret = delete_hard_link_ctx (frame, this, loc->inode);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed deleting hard link from ctr "
- "inode context");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_DELETE_HARDLINK_FAILED, "Failed "
+ "deleting hard link from ctr inode context");
}
}
@@ -843,17 +864,17 @@ ctr_unlink (call_frame_t *frame, xlator_t *this,
is_xdata_created = (xdata) ? _gf_true : _gf_false;
}
if (!xdata) {
- gf_log (this->name, GF_LOG_ERROR,
- "xdata is NULL :"
- "Cannot send CTR_REQUEST_LINK_COUNT_XDATA"
- "to posix");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_XDATA_NULL, "xdata is NULL :Cannot send "
+ "CTR_REQUEST_LINK_COUNT_XDATA to posix");
goto out;
}
ret = dict_set_int32 (xdata, CTR_REQUEST_LINK_COUNT_XDATA, 1);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed setting CTR_REQUEST_LINK_COUNT_XDATA");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_SET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED,
+ "Failed setting CTR_REQUEST_LINK_COUNT_XDATA");
if (is_xdata_created) {
dict_unref (xdata);
}
@@ -884,7 +905,8 @@ ctr_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE,
GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_FSYNC_UNWIND_FAILED,
"Failed inserting fsync unwind");
}
@@ -914,8 +936,9 @@ ctr_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting fsync wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_FSYNC_WIND_FAILED,
+ "Failed inserting fsync wind");
}
out:
@@ -938,7 +961,8 @@ ctr_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE,
GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_FSYNC_UNWIND_FAILED,
"Failed inserting fsync unwind");
}
@@ -968,8 +992,9 @@ ctr_setxattr (call_frame_t *frame, xlator_t *this,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting setxattr wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_SETATTR_WIND_FAILED,
+ "Failed inserting setxattr wind");
}
out:
@@ -995,13 +1020,14 @@ ctr_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* Add hard link to the list */
ret = add_hard_link_ctx (frame, this, inode);
if (ret) {
- gf_log (this->name, GF_LOG_TRACE, "Failed adding hard link");
+ gf_msg_trace (this->name, 0, "Failed adding hard link");
}
ret = ctr_insert_unwind(frame, this, GFDB_FOP_CREATE_WRITE,
GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_MKNOD_UNWIND_FAILED,
"Failed inserting mknod unwind");
}
@@ -1034,8 +1060,7 @@ ctr_mknod (call_frame_t *frame, xlator_t *this,
/*get gfid from xdata dict*/
ret = dict_get_ptr (xdata, "gfid-req", &uuid_req);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
- "failed to get gfid from dict");
+ gf_msg_debug (this->name, 0, "failed to get gfid from dict");
goto out;
}
gf_uuid_copy (gfid, uuid_req);
@@ -1054,8 +1079,9 @@ ctr_mknod (call_frame_t *frame, xlator_t *this,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting mknod wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_MKNOD_WIND_FAILED,
+ "Failed inserting mknod wind");
}
out:
@@ -1080,13 +1106,16 @@ ctr_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = add_hard_link_ctx (frame, this, inode);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed adding hard link");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_ADD_HARDLINK_FAILED,
+ "Failed adding hard link");
}
ret = ctr_insert_unwind(frame, this, GFDB_FOP_CREATE_WRITE,
GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_CREATE_UNWIND_FAILED,
"Failed inserting create unwind");
}
@@ -1120,7 +1149,8 @@ ctr_create (call_frame_t *frame, xlator_t *this,
/*Get GFID from Xdata dict*/
ret = dict_get_ptr (xdata, "gfid-req", &uuid_req);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_GET_GFID_FROM_DICT_FAILED,
"failed to get gfid from dict");
goto out;
}
@@ -1140,8 +1170,9 @@ ctr_create (call_frame_t *frame, xlator_t *this,
/*record into the database*/
ret = ctr_insert_wind(frame, this, &ctr_inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting create wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_CREATE_WIND_FAILED,
+ "Failed inserting create wind");
}
out:
STACK_WIND (frame, ctr_create_cbk, FIRST_CHILD (this),
@@ -1165,13 +1196,14 @@ ctr_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* Add hard link to the list */
ret = add_hard_link_ctx (frame, this, inode);
if (ret) {
- gf_log (this->name, GF_LOG_TRACE, "Failed adding hard link");
+ gf_msg_trace (this->name, 0, "Failed adding hard link");
}
ret = ctr_insert_unwind(frame, this, GFDB_FOP_DENTRY_WRITE,
GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_CREATE_UNWIND_FAILED,
"Failed inserting create unwind");
}
@@ -1211,8 +1243,9 @@ ctr_link (call_frame_t *frame, xlator_t *this,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting link wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_LINK_WIND_FAILED,
+ "Failed inserting link wind");
}
out:
@@ -1235,7 +1268,8 @@ int ctr_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_READ,
GFDB_FOP_UNWIND);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_CREATE_UNWIND_FAILED,
"Failed inserting create unwind");
}
@@ -1265,8 +1299,9 @@ ctr_readv (call_frame_t *frame, xlator_t *this,
/*record into the database*/
ret = ctr_insert_wind(frame, this, _inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed inserting readv wind");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_READV_WIND_FAILED,
+ "Failed inserting readv wind");
}
out:
@@ -1287,7 +1322,7 @@ reconfigure (xlator_t *this, dict_t *options)
_priv = this->private;
if (dict_get_str(options, "changetimerecorder.frequency",
&temp_str)) {
- gf_log(this->name, GF_LOG_INFO, "set!");
+ gf_msg(this->name, GF_LOG_INFO, 0, CTR_MSG_SET, "set!");
}
GF_OPTION_RECONF ("ctr-enabled", _priv->enabled, options,
@@ -1322,19 +1357,22 @@ init (xlator_t *this)
GF_VALIDATE_OR_GOTO ("ctr", this, error);
if (!this->children || this->children->next) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_FATAL_ERROR,
"FATAL: ctr should have exactly one child");
goto error;
}
if (!this->parents) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ CTR_MSG_DANGLING_VOLUME,
"dangling volume. check volfile ");
}
_priv = GF_CALLOC (1, sizeof (*_priv), gf_ctr_mt_private_t);
if (!_priv) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ CTR_MSG_CALLOC_FAILED,
"Calloc didnt work!!!");
goto error;
}
@@ -1351,14 +1389,16 @@ init (xlator_t *this)
/*Extract ctr xlator options*/
ret_db = extract_ctr_options (this, _priv);
if (ret_db) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_EXTRACT_CTR_XLATOR_OPTIONS_FAILED,
"Failed extracting ctr xlator options");
goto error;
}
params_dict = dict_new ();
if (!params_dict) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INIT_DB_PARAMS_FAILED,
"DB Params cannot initialized!");
goto error;
}
@@ -1366,7 +1406,8 @@ init (xlator_t *this)
/*Extract db params options*/
ret_db = extract_db_params(this, params_dict, _priv->gfdb_db_type);
if (ret_db) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_EXTRACT_DB_PARAM_OPTIONS_FAILED,
"Failed extracting db params options");
goto error;
}
@@ -1374,7 +1415,8 @@ init (xlator_t *this)
/*Create a memory pool for ctr xlator*/
this->local_pool = mem_pool_new (gf_ctr_local_t, 64);
if (!this->local_pool) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_CREATE_LOCAL_MEMORY_POOL_FAILED,
"failed to create local memory pool");
goto error;
}
@@ -1382,7 +1424,8 @@ init (xlator_t *this)
/*Initialize Database Connection*/
_priv->_db_conn = init_db(params_dict, _priv->gfdb_db_type);
if (!_priv->_db_conn) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_FATAL_ERROR,
"FATAL: Failed initializing data base");
goto error;
}
@@ -1425,7 +1468,8 @@ mem_acct_init (xlator_t *this)
ret = xlator_mem_acct_init (this, gf_ctr_mt_end + 1);
if (ret != 0) {
- gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_MEM_ACC_INIT_FAILED, "Memory accounting init"
"failed");
return ret;
}
@@ -1443,8 +1487,9 @@ fini (xlator_t *this)
if (priv) {
if (fini_db (priv->_db_conn)) {
- gf_log (this->name, GF_LOG_WARNING, "Failed closing "
- "db connection");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ CTR_MSG_CLOSE_DB_CONN_FAILED, "Failed closing "
+ "db connection");
}
GF_FREE (priv->ctr_db_path);
}
diff --git a/xlators/features/changetimerecorder/src/ctr-helper.c b/xlators/features/changetimerecorder/src/ctr-helper.c
index 005f909..c4d9769 100644
--- a/xlators/features/changetimerecorder/src/ctr-helper.c
+++ b/xlators/features/changetimerecorder/src/ctr-helper.c
@@ -10,7 +10,7 @@
#include "gfdb_sqlite3.h"
#include "ctr-helper.h"
-
+#include "ctr-messages.h"
/*******************************************************************************
*
@@ -35,8 +35,8 @@ fill_db_record_for_unwind(xlator_t *this,
/*If not unwind path error*/
if (!isunwindpath(fop_path)) {
- gf_log (this->name, GF_LOG_ERROR, "Wrong fop_path."
- "Should be unwind");
+ gf_msg (this->name, GF_LOG_ERROR, 0, CTR_MSG_WRONG_FOP_PATH,
+ "Wrong fop_path. Should be unwind");
goto out;
}
@@ -46,8 +46,9 @@ fill_db_record_for_unwind(xlator_t *this,
ret = gettimeofday (ctr_uwtime, NULL);
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "Error filling unwind time record %s",
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CTR_MSG_FILL_UNWIND_TIME_REC_ERROR, "Error "
+ "filling unwind time record %s",
strerror(errno));
goto out;
}
@@ -89,7 +90,8 @@ fill_db_record_for_wind (xlator_t *this,
/*if not wind path error!*/
if (!iswindpath(ctr_inode_cx->fop_path)) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_WRONG_FOP_PATH,
"Wrong fop_path. Should be wind");
goto out;
}
@@ -101,7 +103,8 @@ fill_db_record_for_wind (xlator_t *this,
ret = gettimeofday (ctr_wtime, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ CTR_MSG_FILL_UNWIND_TIME_REC_ERROR,
"Error filling wind time record %s",
strerror(errno));
goto out;
@@ -182,8 +185,9 @@ extract_sql_params(xlator_t *this, dict_t *params_dict)
/*Construct full path of the db*/
ret = gf_asprintf(&db_full_path, "%s/%s", db_path, db_name);
if (ret < 0) {
- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR,
- "Construction of full db path failed!");
+ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0,
+ CTR_MSG_CONSTRUCT_DB_PATH_FAILED,
+ "Construction of full db path failed!");
goto out;
}
@@ -194,8 +198,9 @@ extract_sql_params(xlator_t *this, dict_t *params_dict)
/*Extact rest of the sql params*/
ret = gfdb_set_sql_params(this->name, this->options, params_dict);
if (ret) {
- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR,
- "Failed setting values to sql param dict!");
+ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0,
+ CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED,
+ "Failed setting values to sql param dict!");
}
ret = 0;
@@ -246,8 +251,9 @@ int extract_ctr_options (xlator_t *this, gf_ctr_private_t *_priv) {
_priv->enabled = _gf_false;
GF_OPTION_INIT ("ctr-enabled", _priv->enabled, bool, out);
if (!_priv->enabled) {
- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR,
- "CTR Xlator is disabled.");
+ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0,
+ CTR_MSG_XLATOR_DISABLED,
+ "CTR Xlator is disabled.");
ret = 0;
goto out;
}
diff --git a/xlators/features/changetimerecorder/src/ctr-helper.h b/xlators/features/changetimerecorder/src/ctr-helper.h
index 87b80e6..a3df971 100644
--- a/xlators/features/changetimerecorder/src/ctr-helper.h
+++ b/xlators/features/changetimerecorder/src/ctr-helper.h
@@ -29,6 +29,7 @@
#include "gfdb_data_store.h"
#include "ctr-xlator-ctx.h"
+#include "ctr-messages.h"
/*CTR Xlator Private structure*/
typedef struct gf_ctr_private {
@@ -103,7 +104,8 @@ init_ctr_local_t (xlator_t *this) {
ctr_local = mem_get0 (this->local_pool);
if (!ctr_local) {
- gf_log (GFDB_DATA_STORE, GF_LOG_ERROR,
+ gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0,
+ CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND,
"Error while creating ctr local");
goto out;
}
@@ -346,7 +348,8 @@ ctr_insert_wind (call_frame_t *frame,
if (_priv->ctr_record_wind && ctr_inode_cx->ia_type != IA_IFDIR) {
frame->local = init_ctr_local_t (this);
if (!frame->local) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND,
"WIND: Error while creating ctr local");
goto out;
};
@@ -378,7 +381,8 @@ ctr_insert_wind (call_frame_t *frame,
/*Fill the db record for insertion*/
ret = fill_db_record_for_wind (this, ctr_local, ctr_inode_cx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_FILL_CTR_LOCAL_ERROR_WIND,
"WIND: Error filling ctr local");
goto out;
}
@@ -387,7 +391,8 @@ ctr_insert_wind (call_frame_t *frame,
ret = insert_record (_priv->_db_conn,
&ctr_local->gfdb_db_record);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_INSERT_RECORD_WIND_FAILED,
"WIND: Inserting of record failed!");
goto out;
}
@@ -443,16 +448,18 @@ ctr_insert_unwind (call_frame_t *frame,
ret = fill_db_record_for_unwind(this, ctr_local, fop_type,
fop_path);
if (ret == -1) {
- gf_log(this->name, GF_LOG_ERROR, "UNWIND: Error"
- "filling ctr local");
+ gf_msg(this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND,
+ "UNWIND: Error filling ctr local");
goto out;
}
ret = insert_record(_priv->_db_conn,
&ctr_local->gfdb_db_record);
if (ret == -1) {
- gf_log(this->name, GF_LOG_ERROR, "UNWIND: Error"
- "filling ctr local");
+ gf_msg(this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND,
+ "UNWIND: Error filling ctr local");
goto out;
}
}
@@ -486,7 +493,8 @@ add_hard_link_ctx (call_frame_t *frame,
ctr_xlator_ctx = init_ctr_xlator_ctx (this, inode);
if (!ctr_xlator_ctx) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED,
"Failed accessing ctr inode context");
goto out;
}
@@ -510,7 +518,8 @@ add_hard_link_ctx (call_frame_t *frame,
CTR_DB_REC(ctr_local).pargfid,
CTR_DB_REC(ctr_local).file_name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED,
"Failed to add hardlink to the ctr inode context");
goto unlock;
}
@@ -551,7 +560,9 @@ delete_hard_link_ctx (call_frame_t *frame,
CTR_DB_REC(ctr_local).pargfid,
CTR_DB_REC(ctr_local).file_name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to delete hard link");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_DELETE_HARDLINK_FAILED,
+ "Failed to delete hard link");
goto out;
}
@@ -581,7 +592,8 @@ update_hard_link_ctx (call_frame_t *frame,
ctr_xlator_ctx = init_ctr_xlator_ctx (this, inode);
if (!ctr_xlator_ctx) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED,
"Failed accessing ctr inode context");
goto out;
}
@@ -592,7 +604,9 @@ update_hard_link_ctx (call_frame_t *frame,
CTR_DB_REC(ctr_local).old_pargfid,
CTR_DB_REC(ctr_local).old_file_name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to delete hard link");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_DELETE_HARDLINK_FAILED,
+ "Failed to delete hard link");
goto out;
}
diff --git a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c
index 927c854..a91a2bb 100644
--- a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c
+++ b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c
@@ -9,6 +9,7 @@
*/
#include "ctr-xlator-ctx.h"
+#include "ctr-messages.h"
#define IS_THE_ONLY_HARDLINK(ctr_hard_link)\
(ctr_hard_link->list.next == ctr_hard_link->list.prev)
@@ -79,8 +80,9 @@ ctr_add_hard_link (xlator_t *this,
ctr_hard_link = GF_CALLOC (1, sizeof (*ctr_hard_link),
gf_ctr_mt_hard_link_t);
if (!ctr_hard_link) {
- gf_log (this->name, GF_LOG_ERROR, "Failed allocating "
- "ctr_hard_link");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ CTR_MSG_CALLOC_FAILED, "Failed allocating "
+ "ctr_hard_link");
goto out;
}
@@ -90,8 +92,9 @@ ctr_add_hard_link (xlator_t *this,
gf_uuid_copy (ctr_hard_link->pgfid, pgfid);
ret = gf_asprintf(&ctr_hard_link->base_name, "%s", base_name);
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR, "Failed copying basename"
- "to ctr_hard_link");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_COPY_FAILED, "Failed copying basename"
+ "to ctr_hard_link");
goto error;
}
@@ -139,8 +142,9 @@ ctr_delete_hard_link (xlator_t *this,
ctr_hard_link = ctr_search_hard_link_ctx (this, ctr_xlator_ctx,
pgfid, base_name);
if (!ctr_hard_link) {
- gf_log (this->name, GF_LOG_ERROR, "Hard link doesnt exist"
- " in the list");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_HARDLINK_MISSING_IN_LIST,
+ "Hard link doesnt exist in the list");
goto out;
}
@@ -178,15 +182,16 @@ ctr_update_hard_link (xlator_t *this,
ctr_hard_link = ctr_search_hard_link_ctx (this, ctr_xlator_ctx,
old_pgfid, old_base_name);
if (!ctr_hard_link) {
- gf_log (this->name, GF_LOG_TRACE, "Hard link doesnt exist"
- " in the list");
+ gf_msg_trace (this->name, 0, "Hard link doesnt exist"
+ " in the list");
/* Since the hard link is not present in the list
* we add it to the list */
ret = ctr_add_hard_link (this, ctr_xlator_ctx,
pgfid, base_name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed adding"
- "hard link to the list");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_ADD_HARDLINK_TO_LIST_FAILED,
+ "Failed adding hard link to the list");
goto out;
}
ret = 0;
@@ -198,7 +203,8 @@ ctr_update_hard_link (xlator_t *this,
GF_FREE (&ctr_hard_link->base_name);
ret = gf_asprintf(&ctr_hard_link->base_name, "%s", base_name);
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR, "Failed copying basename"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ CTR_MSG_COPY_FAILED, "Failed copying basename"
"to ctr_hard_link");
/* delete the corrupted entry */
__delete_hard_link_from_list (&ctr_hard_link);
@@ -296,8 +302,9 @@ init_ctr_xlator_ctx (xlator_t *this,
ret = LOCK_INIT (&ctr_xlator_ctx->lock);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed init lock %s", strerror(ret));
+ gf_msg (this->name, GF_LOG_ERROR, ret,
+ CTR_MSG_INIT_LOCK_FAILED,
+ "Failed init lock %s", strerror(ret));
goto out;
}
_addr = (uint64_t) ctr_xlator_ctx;
@@ -342,8 +349,9 @@ fini_ctr_xlator_ctx (xlator_t *this,
ret = ctr_delete_all_hard_link (this, ctr_xlator_ctx);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING , "Failed deleting all hard"
- " links from inode context");
+ gf_msg (this->name, GF_LOG_WARNING , 0,
+ CTR_MSG_DELETE_HARDLINK_FAILED, "Failed deleting all "
+ "hard links from inode context");
}
LOCK_DESTROY (&ctr_xlator_ctx->lock);
--
1.7.1