summaryrefslogtreecommitdiffstats
path: root/xlators/performance/quick-read/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/performance/quick-read/src')
-rw-r--r--xlators/performance/quick-read/src/quick-read-messages.h119
-rw-r--r--xlators/performance/quick-read/src/quick-read.c41
2 files changed, 143 insertions, 17 deletions
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);