summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster/afr/src')
-rw-r--r--xlators/cluster/afr/src/Makefile.am2
-rw-r--r--xlators/cluster/afr/src/afr-common.c19
-rw-r--r--xlators/cluster/afr/src/afr-lk-common.c4
-rw-r--r--xlators/cluster/afr/src/afr-messages.h61
-rw-r--r--xlators/cluster/afr/src/afr-open.c4
-rw-r--r--xlators/cluster/afr/src/afr-read-txn.c7
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c3
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-name.c3
-rw-r--r--xlators/cluster/afr/src/afr-transaction.c5
-rw-r--r--xlators/cluster/afr/src/afr.c5
-rw-r--r--xlators/cluster/afr/src/afr.h1
11 files changed, 93 insertions, 21 deletions
diff --git a/xlators/cluster/afr/src/Makefile.am b/xlators/cluster/afr/src/Makefile.am
index ea5a90abbdb..ac66bf3bb11 100644
--- a/xlators/cluster/afr/src/Makefile.am
+++ b/xlators/cluster/afr/src/Makefile.am
@@ -21,7 +21,7 @@ pump_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
noinst_HEADERS = afr.h afr-transaction.h afr-inode-write.h afr-inode-read.h \
afr-dir-read.h afr-dir-write.h afr-self-heal.h afr-mem-types.h \
afr-common.c afr-self-heald.h pump.h \
- $(top_builddir)/xlators/lib/src/libxlator.h
+ $(top_builddir)/xlators/lib/src/libxlator.h afr-messages.h
AM_CPPFLAGS = $(GF_CPPFLAGS) \
-I$(top_srcdir)/libglusterfs/src -I$(top_srcdir)/xlators/lib/src \
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index 4c7692bd671..11aae4617e7 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -46,7 +46,7 @@
#include "afr-transaction.h"
#include "afr-self-heal.h"
#include "afr-self-heald.h"
-
+#include "afr-messages.h"
call_frame_t *
afr_copy_frame (call_frame_t *base)
@@ -3178,8 +3178,8 @@ afr_notify (xlator_t *this, int32_t event,
*/
idx = find_child_index (this, data);
if (idx < 0) {
- gf_log (this->name, GF_LOG_ERROR, "Received child_up "
- "from invalid subvolume");
+ gf_msg (this->name, GF_LOG_ERROR, 0, AFR_MSG_INVALID_CHILD_UP,
+ "Received child_up from invalid subvolume");
goto out;
}
@@ -3207,7 +3207,8 @@ afr_notify (xlator_t *this, int32_t event,
if (priv->child_up[i] == 1)
up_children++;
if (up_children == 1) {
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ AFR_MSG_SUBVOL_UP,
"Subvolume '%s' came back up; "
"going online.", ((xlator_t *)data)->name);
} else {
@@ -3245,7 +3246,8 @@ afr_notify (xlator_t *this, int32_t event,
if (priv->child_up[i] == 0)
down_children++;
if (down_children == priv->child_count) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ AFR_MSG_ALL_SUBVOLS_DOWN,
"All subvolumes are down. Going offline "
"until atleast one of them comes back up.");
} else {
@@ -3286,10 +3288,11 @@ afr_notify (xlator_t *this, int32_t event,
if (priv->quorum_count) {
has_quorum = afr_has_quorum (priv->child_up, this);
if (!had_quorum && has_quorum)
- gf_log (this->name, GF_LOG_INFO, "Client-quorum"
- " is met");
+ gf_msg (this->name, GF_LOG_INFO, 0, AFR_MSG_QUORUM_MET,
+ "Client-quorum is met");
if (had_quorum && !has_quorum)
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ AFR_MSG_QUORUM_FAIL,
"Client-quorum is not met");
}
diff --git a/xlators/cluster/afr/src/afr-lk-common.c b/xlators/cluster/afr/src/afr-lk-common.c
index a2a758f35af..e3e70007706 100644
--- a/xlators/cluster/afr/src/afr-lk-common.c
+++ b/xlators/cluster/afr/src/afr-lk-common.c
@@ -654,7 +654,9 @@ afr_unlock_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;
if (op_ret < 0 && op_errno != ENOTCONN && op_errno != EBADFD) {
- gf_log (this->name, GF_LOG_INFO, "%s: unlock failed on subvolume %s "
+ gf_msg (this->name, GF_LOG_INFO, op_errno,
+ AFR_MSG_ENTRY_UNLOCK_FAIL,
+ "%s: unlock failed on subvolume %s "
"with lock owner %s", local->loc.path,
priv->children[child_index]->name,
lkowner_utoa (&frame->root->lk_owner));
diff --git a/xlators/cluster/afr/src/afr-messages.h b/xlators/cluster/afr/src/afr-messages.h
new file mode 100644
index 00000000000..a076161aa9c
--- /dev/null
+++ b/xlators/cluster/afr/src/afr-messages.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (c) 2014 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 _AFR_MESSAGES_H_
+#define _AFR_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_AFR GLFS_MSGID_COMP_AFR
+#define GLFS_NUM_MESSAGES 9
+#define GLFS_MSGID_END (GLFS_COMP_BASE_AFR + GLFS_NUM_MESSAGES + 1)
+
+#define glfs_msg_start_x GLFS_COMP_BASE_AFR, "Invalid: Start of messages"
+
+#define AFR_MSG_QUORUM_FAIL (GLFS_COMP_BASE_AFR + 1)
+#define AFR_MSG_QUORUM_MET (GLFS_COMP_BASE_AFR + 2)
+#define AFR_MSG_QUORUM_OVERRIDE (GLFS_COMP_BASE_AFR + 3)
+#define AFR_MSG_INVALID_CHILD_UP (GLFS_COMP_BASE_AFR + 4)
+#define AFR_MSG_SUBVOL_UP (GLFS_COMP_BASE_AFR + 5)
+#define AFR_MSG_ALL_SUBVOLS_DOWN (GLFS_COMP_BASE_AFR + 6)
+#define AFR_MSG_ENTRY_UNLOCK_FAIL (GLFS_COMP_BASE_AFR + 7)
+#define AFR_MSG_SPLIT_BRAIN (GLFS_COMP_BASE_AFR + 8)
+#define AFR_MSG_OPEN_FAIL (GLFS_COMP_BASE_AFR + 9)
+
+#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
+
+#endif /* !_AFR_MESSAGES_H_ */
diff --git a/xlators/cluster/afr/src/afr-open.c b/xlators/cluster/afr/src/afr-open.c
index 83da86053f4..f96f41c0dd9 100644
--- a/xlators/cluster/afr/src/afr-open.c
+++ b/xlators/cluster/afr/src/afr-open.c
@@ -186,8 +186,8 @@ afr_openfd_fix_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
"successfully on subvolume %s", local->loc.path,
priv->children[child_index]->name);
} else {
- gf_log (this->name, GF_LOG_ERROR, "Failed to open %s "
- "on subvolume %s", local->loc.path,
+ gf_msg (this->name, GF_LOG_ERROR, op_errno, AFR_MSG_OPEN_FAIL,
+ "Failed to open %s on subvolume %s", local->loc.path,
priv->children[child_index]->name);
}
diff --git a/xlators/cluster/afr/src/afr-read-txn.c b/xlators/cluster/afr/src/afr-read-txn.c
index 186f68c3359..2585c443e1c 100644
--- a/xlators/cluster/afr/src/afr-read-txn.c
+++ b/xlators/cluster/afr/src/afr-read-txn.c
@@ -212,9 +212,10 @@ afr_read_txn (call_frame_t *frame, xlator_t *this, inode_t *inode,
local->readable);
if (read_subvol < 0 || read_subvol > priv->child_count) {
- gf_log (this->name, GF_LOG_WARNING, "Unreadable subvolume %d "
- "found with event generation %d", read_subvol,
- event_generation);
+ gf_msg (this->name, GF_LOG_WARNING, 0, AFR_MSG_SPLIT_BRAIN,
+ "Unreadable subvolume %d found with event generation "
+ "%d. (Possible split-brain)",
+ read_subvol, event_generation);
goto refresh;
}
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index df14cbb0fb7..56691e27752 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -844,7 +844,8 @@ afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this,
}
if (!IA_EQUAL (first, replies[i].poststat, type)) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ AFR_MSG_SPLIT_BRAIN,
"TYPE mismatch %d vs %d on %s for gfid:%s",
(int) first.ia_type,
(int) replies[i].poststat.ia_type,
diff --git a/xlators/cluster/afr/src/afr-self-heal-name.c b/xlators/cluster/afr/src/afr-self-heal-name.c
index ce80b8da393..e3ff705e315 100644
--- a/xlators/cluster/afr/src/afr-self-heal-name.c
+++ b/xlators/cluster/afr/src/afr-self-heal-name.c
@@ -215,7 +215,8 @@ __afr_selfheal_name_do (call_frame_t *frame, xlator_t *this, inode_t *parent,
if (gfid_idx != -1 &&
(sources[gfid_idx] || source == -1) &&
uuid_compare (gfid, replies[i].poststat.ia_gfid)) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ AFR_MSG_SPLIT_BRAIN,
"GFID mismatch for <gfid:%s>/%s "
"%s on %s and %s on %s",
uuid_utoa (pargfid), bname,
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index 270e2212913..a2eab3494e3 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -548,8 +548,9 @@ afr_handle_quorum (call_frame_t *frame)
file = local->loc.path;
}
- gf_log (frame->this->name, GF_LOG_WARNING, "%s: Failing %s as quorum "
- "is not met", file, gf_fop_list[local->op]);
+ gf_msg (frame->this->name, GF_LOG_WARNING, 0, AFR_MSG_QUORUM_FAIL,
+ "%s: Failing %s as quorum is not met",
+ file, gf_fop_list[local->op]);
for (i = 0; i < priv->child_count; i++) {
if (local->transaction.pre_op[i])
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 6af136e9163..2c0ff05fd78 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -85,7 +85,7 @@ void
fix_quorum_options (xlator_t *this, afr_private_t *priv, char *qtype)
{
if (priv->quorum_count && strcmp(qtype,"fixed")) {
- gf_log(this->name,GF_LOG_WARNING,
+ gf_msg (this->name,GF_LOG_WARNING, 0, AFR_MSG_QUORUM_OVERRIDE,
"quorum-type %s overriding quorum-count %u",
qtype, priv->quorum_count);
}
@@ -181,7 +181,8 @@ reconfigure (xlator_t *this, dict_t *options)
uint32, out);
fix_quorum_options(this,priv,qtype);
if (priv->quorum_count && !afr_has_quorum (priv->child_up, this))
- gf_log (this->name, GF_LOG_WARNING, "Client-quorum is not met");
+ gf_msg (this->name, GF_LOG_WARNING, 0, AFR_MSG_QUORUM_FAIL,
+ "Client-quorum is not met");
GF_OPTION_RECONF ("post-op-delay-secs", priv->post_op_delay_secs, options,
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 674ea0bf72e..c5b326cee06 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -26,6 +26,7 @@
#include "syncop.h"
#include "afr-self-heald.h"
+#include "afr-messages.h"
#define AFR_XATTR_PREFIX "trusted.afr"
#define AFR_PATHINFO_HEADER "REPLICATE:"