summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
diff options
context:
space:
mode:
authorManikandan Selvaganesh <mselvaga@redhat.com>2015-03-20 12:04:32 +0530
committerVenky Shankar <vshankar@redhat.com>2015-06-12 03:28:10 -0700
commit6180d36ff30ecbe84c91b66b23734cf4f45249c5 (patch)
tree66270a059c9ff7109466dc447f72c4fd89275534 /xlators/mgmt/glusterd/src/glusterd-geo-rep.c
parent9e72abb08f37db017a83e0114e9cd07fd5151d30 (diff)
glusterd/geo-rep : porting log messages to a new framework
Change-Id: I1f1b99822c2b301d68eaf392af4bbb475151e2c5 BUG: 1194640 Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com> Reviewed-on: http://review.gluster.org/9952 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kotresh HR <khiremat@redhat.com> Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-geo-rep.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c1128
1 files changed, 748 insertions, 380 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index 5b89ec0972b..2398b6a8c7e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -19,6 +19,7 @@
#include "glusterd-svc-helper.h"
#include "run.h"
#include "syscall.h"
+#include "glusterd-messages.h"
#include <signal.h>
@@ -120,7 +121,8 @@ __glusterd_handle_sys_exec (rpcsvc_request_t *req)
cli_req.dict.dict_len,
&dict);
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to "
"unserialize req-buffer to dictionary");
snprintf (err_str, sizeof (err_str), "Unable to decode "
"the command");
@@ -191,7 +193,8 @@ __glusterd_handle_copy_file (rpcsvc_request_t *req)
cli_req.dict.dict_len,
&dict);
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to"
"unserialize req-buffer to dictionary");
snprintf (err_str, sizeof (err_str), "Unable to decode "
"the command");
@@ -265,7 +268,8 @@ __glusterd_handle_gsync_set (rpcsvc_request_t *req)
cli_req.dict.dict_len,
&dict);
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to "
"unserialize req-buffer to dictionary");
snprintf (err_str, sizeof (err_str), "Unable to decode "
"the command");
@@ -289,15 +293,15 @@ __glusterd_handle_gsync_set (rpcsvc_request_t *req)
ret = dict_get_str (dict, "master", &master);
if (ret < 0) {
- gf_log (this->name, GF_LOG_INFO, "master not found, while "
- "handling "GEOREP" options");
+ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DICT_GET_FAILED,
+ "master not found, while handling "GEOREP" options");
master = "(No Master)";
}
ret = dict_get_str (dict, "slave", &slave);
if (ret < 0) {
- gf_log (this->name, GF_LOG_INFO, "slave not found, while "
- "handling "GEOREP" options");
+ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DICT_GET_FAILED,
+ "slave not found, while handling "GEOREP" options");
slave = "(No Slave)";
}
@@ -305,7 +309,8 @@ __glusterd_handle_gsync_set (rpcsvc_request_t *req)
if (ret < 0) {
snprintf (err_str, sizeof (err_str), "Command type not found "
"while handling "GEOREP" options");
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "%s", err_str);
goto out;
}
@@ -424,6 +429,10 @@ glusterd_urltransform (runner_t *runner, char ***linearrp)
unsigned arr_len = 32;
unsigned arr_idx = 0;
gf_boolean_t error = _gf_false;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
linearr = GF_CALLOC (arr_len, sizeof (char *), gf_gld_mt_linearr);
if (!linearr) {
@@ -433,7 +442,9 @@ glusterd_urltransform (runner_t *runner, char ***linearrp)
runner_redir (runner, STDOUT_FILENO, RUN_PIPE);
if (runner_start (runner) != 0) {
- gf_log ("", GF_LOG_ERROR, "spawning child failed");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SPAWNING_CHILD_FAILED,
+ "spawning child failed");
error = _gf_true;
goto out;
@@ -490,7 +501,9 @@ glusterd_urltransform (runner_t *runner, char ***linearrp)
error = _gf_true;
if (error) {
- gf_log ("", GF_LOG_ERROR, "reading data from child failed");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_READ_CHILD_DATA_FAILED,
+ "reading data from child failed");
glusterd_urltransform_free (linearr, arr_idx);
return -1;
}
@@ -576,10 +589,16 @@ glusterd_query_extutil_generic (char *resbuf, size_t blen, runner_t *runner, voi
int (*fcbk)(char *resbuf, size_t blen, FILE *fp, void *data))
{
int ret = 0;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
runner_redir (runner, STDOUT_FILENO, RUN_PIPE);
if (runner_start (runner) != 0) {
- gf_log ("", GF_LOG_ERROR, "spawning child failed");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SPAWNING_CHILD_FAILED,
+ "spawning child failed");
return -1;
}
@@ -588,7 +607,9 @@ glusterd_query_extutil_generic (char *resbuf, size_t blen, runner_t *runner, voi
ret |= runner_end (runner);
if (ret)
- gf_log ("", GF_LOG_ERROR, "reading data from child failed");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_READ_CHILD_DATA_FAILED,
+ "reading data from child failed");
return ret ? -1 : 0;
}
@@ -819,12 +840,15 @@ gsyncd_getpidfile (char *master, char *slave, char *pidfile,
glusterd_conf_t *priv = NULL;
int ret = -1;
struct stat stbuf = {0,};
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
- GF_ASSERT (THIS);
- GF_ASSERT (THIS->private);
+ GF_ASSERT (this->private);
GF_ASSERT (conf_path);
- priv = THIS->private;
+ priv = this->private;
GF_VALIDATE_OR_GOTO ("gsync", master, out);
GF_VALIDATE_OR_GOTO ("gsync", slave, out);
@@ -834,21 +858,24 @@ gsyncd_getpidfile (char *master, char *slave, char *pidfile,
ret = lstat (conf_path, &stbuf);
if (!ret) {
- gf_log ("", GF_LOG_DEBUG, "Using passed config template(%s).",
+ gf_msg_debug (this->name, 0, "Using passed config template(%s).",
conf_path);
working_conf_path = conf_path;
} else {
- gf_log ("", GF_LOG_WARNING, "Config file (%s) missing. "
- "Looking for template config file (%s)",
- conf_path, temp_conf_path);
+ gf_msg (this->name, GF_LOG_WARNING, ENOENT,
+ GD_MSG_FILE_OP_FAILED,
+ "Config file (%s) missing. Looking for template "
+ "config file (%s)", conf_path, temp_conf_path);
ret = lstat (temp_conf_path, &stbuf);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, ENOENT,
+ GD_MSG_FILE_OP_FAILED,
"Template config file (%s) missing.",
temp_conf_path);
goto out;
}
- gf_log ("", GF_LOG_INFO, "Using default config template(%s).",
+ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DEFAULT_TEMP_CONFIG,
+ "Using default config template(%s).",
temp_conf_path);
working_conf_path = temp_conf_path;
*is_template_in_use = _gf_true;
@@ -860,7 +887,8 @@ fetch_data:
slave, working_conf_path);
if ((ret == -1) || strlen(pidfile) == 0) {
if (*is_template_in_use == _gf_false) {
- gf_log ("", GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_PIDFILE_CREATE_FAILED,
"failed to create the pidfile string. "
"Trying default config template");
working_conf_path = temp_conf_path;
@@ -868,13 +896,15 @@ fetch_data:
goto fetch_data;
} else {
ret = -2;
- gf_log ("", GF_LOG_WARNING,
- "failed to create the pidfile string from template config");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_PIDFILE_CREATE_FAILED, "failed to "
+ "create the pidfile string from template "
+ "config");
goto out;
}
}
- gf_log ("", GF_LOG_DEBUG, "pidfile = %s", pidfile);
+ gf_msg_debug (this->name, 0, "pidfile = %s", pidfile);
ret = open (pidfile, O_RDWR);
out:
@@ -923,16 +953,22 @@ glusterd_gsync_volinfo_dict_set (glusterd_volinfo_t *volinfo,
{
int32_t ret = -1;
char *gsync_status = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
gsync_status = gf_strdup (value);
if (!gsync_status) {
- gf_log ("", GF_LOG_ERROR, "Unable to allocate memory");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, GD_MSG_NO_MEMORY,
+ "Unable to allocate memory");
goto out;
}
ret = dict_set_dynstr (volinfo->dict, key, gsync_status);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set dict");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
+ "Unable to set dict");
goto out;
}
@@ -946,6 +982,10 @@ glusterd_verify_gsyncd_spawn (char *master, char *slave)
{
int ret = 0;
runner_t runner = {0,};
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
runinit (&runner);
runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd",
@@ -955,7 +995,9 @@ glusterd_verify_gsyncd_spawn (char *master, char *slave)
runner_redir (&runner, STDOUT_FILENO, RUN_PIPE);
ret = runner_start (&runner);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "spawning child failed");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SPAWNING_CHILD_FAILED,
+ "spawning child failed");
ret = -1;
goto out;
}
@@ -964,7 +1006,7 @@ glusterd_verify_gsyncd_spawn (char *master, char *slave)
ret = -1;
out:
- gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
+ gf_msg_debug (this->name, 0, "returning %d", ret);
return ret;
}
@@ -984,15 +1026,21 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname)
gf_boolean_t op_match = _gf_true;
gf_boolean_t val_match = _gf_true;
struct gsync_config_opt_vals_ *conf_vals = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
if (dict_get_str (dict, "subop", &subop) != 0) {
- gf_log ("", GF_LOG_WARNING, "missing subop");
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED,
+ "missing subop");
*op_errstr = gf_strdup ("Invalid config request");
return -1;
}
if (dict_get_str (dict, "slave", &slave) != 0) {
- gf_log ("", GF_LOG_WARNING, GEOREP" CONFIG: no slave given");
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED,
+ GEOREP" CONFIG: no slave given");
*op_errstr = gf_strdup ("Slave required");
return -1;
}
@@ -1001,7 +1049,8 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname)
return 0;
if (dict_get_str (dict, "op_name", &op_name) != 0) {
- gf_log ("", GF_LOG_WARNING, "option name missing");
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED,
+ "option name missing");
*op_errstr = gf_strdup ("Option name missing");
return -1;
}
@@ -1009,11 +1058,15 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname)
if (runcmd (GSYNCD_PREFIX"/gsyncd", "--config-check", op_name, NULL)) {
ret = glusterd_verify_gsyncd_spawn (volname, slave);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to spawn gsyncd");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GSYNCD_SPAWN_FAILED, "Unable to spawn "
+ "gsyncd");
return 0;
}
- gf_log ("", GF_LOG_WARNING, "Invalid option %s", op_name);
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ GD_MSG_INVALID_ENTRY,
+ "Invalid option %s", op_name);
*op_errstr = gf_strdup ("Invalid option");
return -1;
@@ -1026,14 +1079,16 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname)
if (!t)
t = strtail (subop, "del");
if (!t || (t[0] && strcmp (t, "-glob") != 0)) {
- gf_log ("", GF_LOG_WARNING, "unknown subop %s", subop);
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_SUBOP_NOT_FOUND,
+ "unknown subop %s", subop);
*op_errstr = gf_strdup ("Invalid config request");
return -1;
}
if (strtail (subop, "set") &&
dict_get_str (dict, "op_value", &op_value) != 0) {
- gf_log ("", GF_LOG_WARNING, "missing value for set");
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED,
+ "missing value for set");
*op_errstr = gf_strdup ("missing value");
}
@@ -1049,7 +1104,9 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname)
banned = _gf_false;
}
if (banned) {
- gf_log ("", GF_LOG_WARNING, "Reserved option %s", op_name);
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_RESERVED_OPTION,
+ "Reserved option %s", op_name);
*op_errstr = gf_strdup ("Reserved option");
return -1;
@@ -1088,7 +1145,8 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr, char *volname)
op_name);
errmsg[ret] = '\0';
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "%s", errmsg);
*op_errstr = gf_strdup (errmsg);
return -1;
}
@@ -1116,16 +1174,22 @@ _get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data)
char conf_path[PATH_MAX] = "";
int ret = -1;
glusterd_conf_t *priv = NULL;
+ xlator_t *this1 = NULL;
+
+ this1 = THIS;
+ GF_ASSERT (this1);
param = (glusterd_gsync_status_temp_t *)data;
GF_ASSERT (param);
GF_ASSERT (param->volinfo);
- if (THIS)
- priv = THIS->private;
+ if (this1)
+ priv = this1->private;
if (priv == NULL) {
- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
+ gf_msg (this1->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLUSTERD_PRIV_NOT_FOUND,
+ "priv of glusterd not present");
goto out;
}
@@ -1138,10 +1202,13 @@ _get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data)
&slave_host, &slave_vol, &errmsg);
if (ret) {
if (errmsg)
- gf_log ("", GF_LOG_ERROR, "Unable to fetch "
- "slave details. Error: %s", errmsg);
+ gf_msg (this1->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVEINFO_FETCH_ERROR,
+ "Unable to fetch slave details. Error: %s",
+ errmsg);
else
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this1->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVEINFO_FETCH_ERROR,
"Unable to fetch slave details.");
ret = -1;
goto out;
@@ -1164,7 +1231,7 @@ out:
if (slave_buf)
GF_FREE(slave_buf);
- gf_log ("", GF_LOG_DEBUG, "Returning %d.", ret);
+ gf_msg_debug (this1->name, 0, "Returning %d.", ret);
return ret;
}
@@ -1189,6 +1256,10 @@ glusterd_remove_slave_in_info (glusterd_volinfo_t *volinfo, char *slave,
int zero_slave_entries = _gf_true;
int ret = 0;
char *slavekey = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (volinfo);
GF_ASSERT (slave);
@@ -1211,7 +1282,7 @@ glusterd_remove_slave_in_info (glusterd_volinfo_t *volinfo, char *slave,
goto out;
}
out:
- gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
+ gf_msg_debug (this->name, 0, "returning %d", ret);
return ret;
}
@@ -1224,6 +1295,10 @@ glusterd_gsync_get_uuid (char *slave, glusterd_volinfo_t *vol,
char *slavekey = NULL;
char *slaveentry = NULL;
char *t = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (vol);
GF_ASSERT (slave);
@@ -1250,7 +1325,7 @@ glusterd_gsync_get_uuid (char *slave, glusterd_volinfo_t *vol,
*t = ':';
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1262,6 +1337,10 @@ glusterd_check_gsync_running_local (char *master, char *slave,
int ret = -1;
int ret_status = 0;
gf_boolean_t is_template_in_use = _gf_false;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (master);
GF_ASSERT (slave);
@@ -1273,13 +1352,13 @@ glusterd_check_gsync_running_local (char *master, char *slave,
if (ret == 0 && ret_status == 0)
*is_run = _gf_true;
else if (ret == -1) {
- gf_log ("", GF_LOG_WARNING, GEOREP" validation "
- " failed");
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_VALIDATE_FAILED,
+ GEOREP" validation failed");
goto out;
}
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1297,6 +1376,10 @@ glusterd_store_slave_in_info (glusterd_volinfo_t *volinfo, char *slave,
char *slaveentry = NULL;
char key[512] = {0, };
char *t = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (volinfo);
GF_ASSERT (slave);
@@ -1324,18 +1407,19 @@ glusterd_store_slave_in_info (glusterd_volinfo_t *volinfo, char *slave,
GF_ASSERT (!t || *t != ':');
if (is_force) {
- gf_log ("", GF_LOG_DEBUG, GEOREP" has already been "
- "invoked for the %s (master) and %s (slave)."
- " Allowing without saving info again due to"
- " force command.", volinfo->volname, slave);
+ gf_msg_debug (this->name, 0, GEOREP" has already "
+ "been invoked for the %s (master) and "
+ "%s (slave). Allowing without saving "
+ "info again due to force command.",
+ volinfo->volname, slave);
ret = 0;
goto out;
}
- gf_log ("", GF_LOG_ERROR, GEOREP" has already been invoked for "
- "the %s (master) and %s (slave) "
- "from a different machine",
- volinfo->volname, slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_INVOKE_ERROR,
+ GEOREP" has already been invoked for "
+ "the %s (master) and %s (slave) from a different "
+ "machine", volinfo->volname, slave);
*op_errstr = gf_strdup (GEOREP" already running in "
"another machine");
ret = -1;
@@ -1385,6 +1469,7 @@ glusterd_op_verify_gsync_start_options (glusterd_volinfo_t *volinfo,
struct stat stbuf = {0,};
this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (volinfo);
GF_ASSERT (slave);
@@ -1405,7 +1490,8 @@ glusterd_op_verify_gsync_start_options (glusterd_volinfo_t *volinfo,
snprintf (msg, sizeof (msg), "Session between %s and %s has"
" not been created. Please create session and retry.",
volinfo->volname, slave);
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, errno, GD_MSG_FILE_OP_FAILED,
+ "%s", msg);
*op_errstr = gf_strdup (msg);
goto out;
}
@@ -1417,7 +1503,9 @@ glusterd_op_verify_gsync_start_options (glusterd_volinfo_t *volinfo,
snprintf (msg, sizeof (msg), "Session between %s and %s has"
" not been created. Please create session and retry.",
volinfo->volname, slave);
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SESSION_CREATE_ERROR,
+ "%s", msg);
goto out;
}
@@ -1450,13 +1538,14 @@ glusterd_op_verify_gsync_start_options (glusterd_volinfo_t *volinfo,
ret = glusterd_verify_gsyncd_spawn (volinfo->volname, slave);
if (ret && !is_force) {
snprintf (msg, sizeof (msg), "Unable to spawn gsyncd");
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_SPAWN_FAILED,
+ "%s", msg);
}
out:
if (ret && (msg[0] != '\0')) {
*op_errstr = gf_strdup (msg);
}
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1504,14 +1593,17 @@ is_geo_rep_active (glusterd_volinfo_t *volinfo, char *slave,
confd = dict_new ();
if (!confd) {
- gf_log ("", GF_LOG_ERROR, "Not able to create dict.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL,
+ "Not able to create dict.");
goto out;
}
ret = glusterd_gsync_get_config (master, slave, conf_path,
confd);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get configuration data "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GET_CONFIG_INFO_FAILED,
+ "Unable to get configuration data "
"for %s(master), %s(slave)", master, slave);
ret = -1;
goto out;
@@ -1519,7 +1611,8 @@ is_geo_rep_active (glusterd_volinfo_t *volinfo, char *slave,
ret = dict_get_param (confd, "state_file", &statefile);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get state_file's name "
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "Unable to get state_file's name "
"for %s(master), %s(slave). Please check gsync "
"config file.", master, slave);
ret = -1;
@@ -1529,8 +1622,10 @@ is_geo_rep_active (glusterd_volinfo_t *volinfo, char *slave,
ret = glusterd_gsync_read_frm_status (statefile, monitor_status,
sizeof (monitor_status));
if (ret <= 0) {
- gf_log ("", GF_LOG_ERROR, "Unable to read the status "
- "file for %s(master), %s(slave)", master, slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STAT_FILE_READ_FAILED,
+ "Unable to read the status file for %s(master), "
+ "%s(slave)", master, slave);
strncpy (monitor_status, "defunct", sizeof (monitor_status));
}
@@ -1589,7 +1684,9 @@ _get_slave_status (dict_t *dict, char *key, data_t *value, void *data)
if (this)
priv = this->private;
if (priv == NULL) {
- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLUSTERD_PRIV_NOT_FOUND,
+ "priv of glusterd not present");
goto out;
}
@@ -1604,10 +1701,12 @@ _get_slave_status (dict_t *dict, char *key, data_t *value, void *data)
&slave_host, &slave_vol, &errmsg);
if (ret) {
if (errmsg)
- gf_log ("", GF_LOG_ERROR, "Unable to fetch "
- "slave details. Error: %s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVEINFO_FETCH_ERROR, "Unable to fetch"
+ " slave details. Error: %s", errmsg);
else
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVEINFO_FETCH_ERROR,
"Unable to fetch slave details.");
ret = -1;
goto out;
@@ -1618,7 +1717,9 @@ _get_slave_status (dict_t *dict, char *key, data_t *value, void *data)
priv->workdir, param->volinfo->volname,
slave_host, slave_vol);
if (ret < 0) {
- gf_log ("", GF_LOG_ERROR, "Unable to assign conf_path.");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_CONF_PATH_ASSIGN_FAILED,
+ "Unable to assign conf_path.");
ret = -1;
goto out;
}
@@ -1661,7 +1762,8 @@ glusterd_check_geo_rep_running (gsync_status_param_t *param, char **op_errstr)
ret = dict_foreach (param->volinfo->gsync_slaves,
_get_slave_status, param);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVEINFO_FETCH_ERROR,
"_get_slave_satus failed");
snprintf (msg, sizeof(msg), GEOREP" Unable to"
" get the status of active "GEOREP""
@@ -1698,6 +1800,10 @@ glusterd_op_verify_gsync_running (glusterd_volinfo_t *volinfo,
char msg[2048] = {0};
char pidfile[PATH_MAX] = {0,};
gf_boolean_t is_template_in_use = _gf_false;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (THIS && THIS->private);
GF_ASSERT (volinfo);
@@ -1715,15 +1821,18 @@ glusterd_op_verify_gsync_running (glusterd_volinfo_t *volinfo,
pfd = gsyncd_getpidfile (volinfo->volname, slave, pidfile,
conf_path, &is_template_in_use);
if (pfd == -2) {
- gf_log ("", GF_LOG_ERROR, GEOREP" stop validation "
- "failed for %s & %s", volinfo->volname, slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_VALIDATE_FAILED,
+ GEOREP" stop validation failed for %s & %s",
+ volinfo->volname, slave);
ret = -1;
goto out;
}
if (gsync_status_byfd (pfd) == -1) {
- snprintf (msg, sizeof (msg), GEOREP" session b/w %s & %s is not"
- " running on this node.", volinfo->volname, slave);
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ snprintf (msg, sizeof (msg), GEOREP" session b/w %s & %s is "
+ "not running on this node.", volinfo->volname,
+ slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_SESSION_INACTIVE,
+ "%s", msg);
ret = -1;
/* monitor gsyncd already dead */
goto out;
@@ -1732,7 +1841,8 @@ glusterd_op_verify_gsync_running (glusterd_volinfo_t *volinfo,
if (is_template_in_use) {
snprintf (msg, sizeof (msg), "pid-file entry missing in "
"the config file(%s).", conf_path);
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PIDFILE_NOT_FOUND,
+ "%s", msg);
ret = -1;
goto out;
}
@@ -1745,7 +1855,7 @@ out:
if (ret && (msg[0] != '\0')) {
*op_errstr = gf_strdup (msg);
}
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1763,11 +1873,17 @@ glusterd_verify_gsync_status_opts (dict_t *dict, char **op_errstr)
char *slave_host = NULL;
char *slave_vol = NULL;
glusterd_conf_t *priv = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
if (THIS)
priv = THIS->private;
if (priv == NULL) {
- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLUSTERD_PRIV_NOT_FOUND,
+ "priv of glusterd not present");
*op_errstr = gf_strdup ("glusterd defunct");
goto out;
}
@@ -1781,7 +1897,8 @@ glusterd_verify_gsync_status_opts (dict_t *dict, char **op_errstr)
exists = glusterd_check_volume_exists (volname);
ret = glusterd_volinfo_find (volname, &volinfo);
if ((ret) || (!exists)) {
- gf_log ("", GF_LOG_WARNING, "volume name does not exist");
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_VOL_NOT_FOUND,
+ "volume name does not exist");
snprintf (errmsg, sizeof(errmsg), "Volume name %s does not"
" exist", volname);
*op_errstr = gf_strdup (errmsg);
@@ -1799,14 +1916,15 @@ glusterd_verify_gsync_status_opts (dict_t *dict, char **op_errstr)
&slave_host, &slave_vol,
&conf_path, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVEINFO_FETCH_ERROR,
"Unable to fetch slave or confpath details.");
ret = -1;
goto out;
}
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1817,13 +1935,18 @@ glusterd_op_gsync_args_get (dict_t *dict, char **op_errstr,
{
int ret = -1;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (dict);
GF_ASSERT (op_errstr);
if (master) {
ret = dict_get_str (dict, "master", master);
if (ret < 0) {
- gf_log ("", GF_LOG_WARNING, "master not found");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_GET_FAILED, "master not found");
*op_errstr = gf_strdup ("master not found");
goto out;
}
@@ -1832,7 +1955,8 @@ glusterd_op_gsync_args_get (dict_t *dict, char **op_errstr,
if (slave) {
ret = dict_get_str (dict, "slave", slave);
if (ret < 0) {
- gf_log ("", GF_LOG_WARNING, "slave not found");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_GET_FAILED, "slave not found");
*op_errstr = gf_strdup ("slave not found");
goto out;
}
@@ -1841,7 +1965,8 @@ glusterd_op_gsync_args_get (dict_t *dict, char **op_errstr,
if (host_uuid) {
ret = dict_get_str (dict, "host-uuid", host_uuid);
if (ret < 0) {
- gf_log ("", GF_LOG_WARNING, "host_uuid not found");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_GET_FAILED, "host_uuid not found");
*op_errstr = gf_strdup ("host_uuid not found");
goto out;
}
@@ -1849,7 +1974,7 @@ glusterd_op_gsync_args_get (dict_t *dict, char **op_errstr,
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1870,7 +1995,8 @@ glusterd_op_stage_sys_exec (dict_t *dict, char **op_errstr)
GF_ASSERT (conf);
if (conf->op_version < 2) {
- gf_log ("", GF_LOG_ERROR, "Op Version not supported.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_UNSUPPORTED_VERSION,
+ "Op Version not supported.");
snprintf (errmsg, sizeof(errmsg), "One or more nodes do not"
" support the required op version.");
*op_errstr = gf_strdup (errmsg);
@@ -1881,7 +2007,7 @@ glusterd_op_stage_sys_exec (dict_t *dict, char **op_errstr)
ret = dict_get_str (dict, "command", &command);
if (ret) {
strcpy (errmsg, "internal error");
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
"Unable to get command from dict");
goto out;
}
@@ -1911,13 +2037,15 @@ out:
command);
else
snprintf (errmsg, sizeof (errmsg), "%s",
- "gsync peer command was not specified");
+ "gsync peer command was not "
+ "specified");
}
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PEER_CMD_ERROR,
+ "%s", errmsg);
}
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1932,17 +2060,24 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr)
int ret = -1;
glusterd_conf_t *priv = NULL;
struct stat stbuf = {0,};
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
if (THIS)
priv = THIS->private;
if (priv == NULL) {
- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLUSTERD_PRIV_NOT_FOUND,
+ "priv of glusterd not present");
*op_errstr = gf_strdup ("glusterd defunct");
goto out;
}
if (priv->op_version < 2) {
- gf_log ("", GF_LOG_ERROR, "Op Version not supported.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_UNSUPPORTED_VERSION,
+ "Op Version not supported.");
snprintf (errmsg, sizeof(errmsg), "One or more nodes do not"
" support the required op version.");
*op_errstr = gf_strdup (errmsg);
@@ -1952,8 +2087,8 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr)
ret = dict_get_str (dict, "host-uuid", &host_uuid);
if (ret < 0) {
- gf_log ("", GF_LOG_ERROR, "Unable to fetch"
- " host-uuid from dict.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "Unable to fetch host-uuid from dict.");
goto out;
}
@@ -1961,8 +2096,9 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr)
if (!strcmp (uuid_str, host_uuid)) {
ret = dict_get_str (dict, "source", &filename);
if (ret < 0) {
- gf_log ("", GF_LOG_ERROR, "Unable to fetch"
- " filename from dict.");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
+ "Unable to fetch filename from dict.");
*op_errstr = gf_strdup ("command unsuccessful");
goto out;
}
@@ -1981,7 +2117,9 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Source file"
" is not a regular file.");
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SRC_FILE_ERROR,
+ "%s", errmsg);
ret = -1;
goto out;
}
@@ -1989,7 +2127,7 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr)
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2006,9 +2144,12 @@ glusterd_get_statefile_name (glusterd_volinfo_t *volinfo, char *slave,
glusterd_conf_t *priv = NULL;
int ret = -1;
struct stat stbuf = {0,};
+ xlator_t *this = NULL;
- GF_ASSERT (THIS);
- GF_ASSERT (THIS->private);
+ this = THIS;
+ GF_ASSERT (this);
+
+ GF_ASSERT (this->private);
GF_ASSERT (volinfo);
GF_ASSERT (conf_path);
GF_ASSERT (is_template_in_use);
@@ -2017,7 +2158,8 @@ glusterd_get_statefile_name (glusterd_volinfo_t *volinfo, char *slave,
confd = dict_new ();
if (!confd) {
- gf_log ("", GF_LOG_ERROR, "Unable to create new dict");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL,
+ "Unable to create new dict");
goto out;
}
@@ -2028,22 +2170,24 @@ glusterd_get_statefile_name (glusterd_volinfo_t *volinfo, char *slave,
ret = lstat (conf_path, &stbuf);
if (!ret) {
- gf_log ("", GF_LOG_INFO, "Using passed config template(%s).",
+ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_CONFIG_INFO,
+ "Using passed config template(%s).",
conf_path);
working_conf_path = conf_path;
} else {
- gf_log ("", GF_LOG_WARNING, "Config file (%s) missing. "
- "Looking for template config file (%s)",
- conf_path, temp_conf_path);
+ gf_msg (this->name, GF_LOG_WARNING, ENOENT,
+ GD_MSG_FILE_OP_FAILED,
+ "Config file (%s) missing. Looking for template config"
+ " file (%s)", conf_path, temp_conf_path);
ret = lstat (temp_conf_path, &stbuf);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
- "Template config file (%s) missing.",
- temp_conf_path);
+ gf_msg (this->name, GF_LOG_ERROR, ENOENT,
+ GD_MSG_FILE_OP_FAILED, "Template "
+ "config file (%s) missing.", temp_conf_path);
goto out;
}
- gf_log ("", GF_LOG_INFO, "Using default config template(%s).",
- temp_conf_path);
+ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DEFAULT_TEMP_CONFIG,
+ "Using default config template(%s).", temp_conf_path);
working_conf_path = temp_conf_path;
*is_template_in_use = _gf_true;
}
@@ -2053,7 +2197,8 @@ fetch_data:
confd);
if (ret) {
if (*is_template_in_use == _gf_false) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GET_CONFIG_INFO_FAILED,
"Unable to get configuration data "
"for %s(master), %s(slave). "
"Trying template config.",
@@ -2062,7 +2207,8 @@ fetch_data:
*is_template_in_use = _gf_true;
goto fetch_data;
} else {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GET_CONFIG_INFO_FAILED,
"Unable to get configuration data "
"for %s(master), %s(slave) from "
"template config",
@@ -2074,14 +2220,16 @@ fetch_data:
ret = dict_get_param (confd, "state_file", &buf);
if (ret) {
if (*is_template_in_use == _gf_false) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get state_file's name. "
"Trying template config.");
working_conf_path = temp_conf_path;
*is_template_in_use = _gf_true;
goto fetch_data;
} else {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GET_STATEFILE_NAME_FAILED,
"Unable to get state_file's "
"name from template.");
goto out;
@@ -2099,7 +2247,7 @@ fetch_data:
if (confd)
dict_destroy (confd);
- gf_log ("", GF_LOG_DEBUG, "Returning %d ", ret);
+ gf_msg_debug (this->name, 0, "Returning %d ", ret);
return ret;
}
@@ -2110,19 +2258,26 @@ glusterd_create_status_file (char *master, char *slave, char *slave_host,
int ret = -1;
runner_t runner = {0,};
glusterd_conf_t *priv = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
if (THIS)
priv = THIS->private;
if (priv == NULL) {
- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLUSTERD_PRIV_NOT_FOUND,
+ "priv of glusterd not present");
goto out;
}
if (!status) {
- gf_log ("", GF_LOG_ERROR, "Status Empty");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_STATUS_NULL,
+ "Status Empty");
goto out;
}
- gf_log ("", GF_LOG_DEBUG, "slave = %s", slave);
+ gf_msg_debug (this->name, 0, "slave = %s", slave);
runinit (&runner);
runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd", "--create",
@@ -2136,14 +2291,16 @@ glusterd_create_status_file (char *master, char *slave, char *slave_host,
ret = runner_run (&runner);
synclock_lock (&priv->big_lock);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Creating status file failed.");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STATUSFILE_CREATE_FAILED,
+ "Creating status file failed.");
ret = -1;
goto out;
}
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
+ gf_msg_debug (this->name, 0, "returning %d", ret);
return ret;
}
@@ -2187,7 +2344,8 @@ glusterd_verify_slave (char *volname, char *slave_url, char *slave_vol,
}
if (!slave_user || !slave_ip) {
- gf_log (this->name, GF_LOG_ERROR, "Invalid slave url.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_SLAVE_URL_INVALID,
+ "Invalid slave url.");
goto out;
}
@@ -2206,12 +2364,13 @@ glusterd_verify_slave (char *volname, char *slave_url, char *slave_vol,
ret = runner_run (&runner);
synclock_lock (&priv->big_lock);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Not a valid slave");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_INVALID_SLAVE,
+ "Not a valid slave");
ret = glusterd_gsync_read_frm_status (log_file_path,
buf, sizeof(buf));
if (ret <= 0) {
- gf_log ("", GF_LOG_ERROR, "Unable to read from %s",
- log_file_path);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_READ_ERROR,
+ "Unable to read from %s", log_file_path);
goto out;
}
@@ -2241,7 +2400,7 @@ glusterd_verify_slave (char *volname, char *slave_url, char *slave_vol,
out:
GF_FREE (slave_url_buf);
unlink (log_file_path);
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2256,6 +2415,10 @@ glusterd_geo_rep_parse_slave (char *slave_url,
char *host = NULL;
char errmsg[PATH_MAX] = "";
char *saved_url = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (slave_url);
GF_ASSERT (*slave_url);
@@ -2280,11 +2443,12 @@ glusterd_geo_rep_parse_slave (char *slave_url,
* actual hostname also has '@' */
host++;
if (strstr (host, "@")) {
- gf_log ("", GF_LOG_DEBUG, "host = %s", host);
+ gf_msg_debug (this->name, 0, "host = %s", host);
ret = snprintf (errmsg, sizeof(errmsg) - 1,
"Invalid Hostname (%s).", host);
errmsg[ret] = '\0';
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "%s", errmsg);
ret = -1;
if (op_errstr)
*op_errstr = gf_strdup (errmsg);
@@ -2313,7 +2477,7 @@ out:
if (ret)
if (hostname)
GF_FREE (*hostname);
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2353,13 +2517,15 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
ret = glusterd_op_gsync_args_get (dict, op_errstr, &volname,
&slave, &host_uuid);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to fetch arguments");
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_ARG_FETCH_ERROR,
+ "Unable to fetch arguments");
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return -1;
}
if (conf->op_version < 2) {
- gf_log ("", GF_LOG_ERROR, "Op Version not supported.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_UNSUPPORTED_VERSION,
+ "Op Version not supported.");
snprintf (errmsg, sizeof(errmsg), "One or more nodes do not"
" support the required op version.");
*op_errstr = gf_strdup (errmsg);
@@ -2370,11 +2536,12 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
exists = glusterd_check_volume_exists (volname);
ret = glusterd_volinfo_find (volname, &volinfo);
if ((ret) || (!exists)) {
- gf_log ("", GF_LOG_WARNING, "volume name does not exist");
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_VOL_NOT_FOUND,
+ "volume name does not exist");
snprintf (errmsg, sizeof(errmsg), "Volume name %s does not"
" exist", volname);
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return -1;
}
@@ -2382,7 +2549,8 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
&slave_host, &slave_vol,
&conf_path, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVEINFO_FETCH_ERROR,
"Unable to fetch slave or confpath details.");
ret = -1;
goto out;
@@ -2401,15 +2569,18 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
" down. Please bring up the peer and"
" retry.", down_peerstr,
volinfo->volname);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_DISCONNECTED,
+ "%s", errmsg);
*op_errstr = gf_strdup (errmsg);
GF_FREE (down_peerstr);
down_peerstr = NULL;
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return -1;
} else if (ret == _gf_false) {
- gf_log ("", GF_LOG_INFO, "Peer %s,"
- " which is a part of %s volume, is"
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_PEER_DISCONNECTED,
+ "Peer %s, which is a part of %s volume, is"
" down. Force creating geo-rep session."
" On bringing up the peer, re-run"
" \"gluster system:: execute"
@@ -2432,12 +2603,18 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
op_errstr, &is_force_blocker);
if (ret) {
if (is_force && !is_force_blocker) {
- gf_log ("", GF_LOG_INFO, "%s is not a valid slave"
- " volume. Error: %s. Force creating geo-rep"
- " session.", slave, *op_errstr);
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_INVALID_SLAVE,
+ "%s is not a valid slave "
+ "volume. Error: %s. Force "
+ "creating geo-rep"
+ " session.", slave,
+ *op_errstr);
} else {
- gf_log ("", GF_LOG_ERROR,
- "%s is not a valid slave volume. Error: %s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_SLAVE,
+ "%s is not a valid slave "
+ "volume. Error: %s",
slave, *op_errstr);
ret = -1;
@@ -2466,7 +2643,9 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
" not present. Please run"
" \"gluster system:: execute"
" gsec_create\"", common_pem_file);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, ENOENT,
+ GD_MSG_FILE_OP_FAILED,
+ "%s", errmsg);
*op_errstr = gf_strdup (errmsg);
ret = -1;
goto out;
@@ -2479,7 +2658,8 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
"for push-pem is not present. "
"Please install the hook-script "
"and retry", hook_script);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, ENOENT,
+ GD_MSG_FILE_OP_FAILED, "%s", errmsg);
*op_errstr = gf_strdup (errmsg);
ret = -1;
goto out;
@@ -2491,7 +2671,8 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
" not a regular file. Please run"
" \"gluster system:: execute"
" gsec_create\"", common_pem_file);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_REG_FILE_MISSING, "%s", errmsg);
ret = -1;
goto out;
}
@@ -2508,14 +2689,16 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
else
snprintf (errmsg, sizeof (errmsg), "Please check gsync "
"config file. Unable to get statefile's name");
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STATEFILE_NAME_NOT_FOUND,
+ "%s", errmsg);
ret = -1;
goto out;
}
ret = dict_set_str (dict, "statefile", statefile);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
"Unable to store statefile path");
goto out;
}
@@ -2525,18 +2708,21 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Session between %s"
" and %s is already created.",
volinfo->volname, slave);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SESSION_ALREADY_EXIST,
+ "%s", errmsg);
ret = -1;
goto out;
} else if (!ret)
- gf_log ("", GF_LOG_INFO, "Session between %s"
- " and %s is already created. Force"
+ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_FORCE_CREATE_SESSION,
+ "Session between %s and %s is already created. Force"
" creating again.", volinfo->volname, slave);
ret = glusterd_verify_gsyncd_spawn (volinfo->volname, slave);
if (ret) {
snprintf (errmsg, sizeof (errmsg), "Unable to spawn gsyncd.");
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_SPAWN_FAILED,
+ "%s", errmsg);
goto out;
}
@@ -2546,7 +2732,7 @@ out:
if (ret && errmsg[0] != '\0')
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2637,7 +2823,8 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr)
ret = dict_get_int32 (dict, "type", &type);
if (ret < 0) {
- gf_log ("", GF_LOG_WARNING, "command type not found");
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_GET_FAILED,
+ "command type not found");
*op_errstr = gf_strdup ("command unsuccessful");
goto out;
}
@@ -2674,7 +2861,8 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr)
&slave_host, &slave_vol,
&conf_path, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVEINFO_FETCH_ERROR,
"Unable to fetch slave or confpath details.");
ret = -1;
goto out;
@@ -2692,12 +2880,14 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr)
ret = -1;
goto out;
} else {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVE_URL_INVALID,
"state_file entry missing in config file (%s)",
conf_path);
if ((type == GF_GSYNC_OPTION_TYPE_STOP) && is_force) {
- gf_log ("", GF_LOG_WARNING, "Allowing stop "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_STOP_FORCE, "Allowing stop "
"force to bypass missing statefile "
"entry in config file (%s), and "
"template file", conf_path);
@@ -2708,7 +2898,8 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr)
} else {
ret = dict_set_str (dict, "statefile", statefile);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Unable to store statefile path");
goto out;
}
@@ -2723,8 +2914,9 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof(errmsg), "Geo-replication"
" session between %s and %s does not exist.",
volinfo->volname, slave);
- gf_log ("", GF_LOG_ERROR, "%s. statefile = %s",
- errmsg, statefile);
+ gf_msg (this->name, GF_LOG_ERROR, ENOENT,
+ GD_MSG_FILE_OP_FAILED,
+ "%s. statefile = %s", errmsg, statefile);
ret = -1;
goto out;
}
@@ -2774,9 +2966,11 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr)
/* gsyncd does a fuse mount to start
* the geo-rep session */
if (!glusterd_is_fuse_available ()) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to "
- "open /dev/fuse (%s), geo-replication "
- "start failed", strerror (errno));
+ gf_msg ("glusterd", GF_LOG_ERROR, errno,
+ GD_MSG_GEO_REP_START_FAILED, "Unable "
+ "to open /dev/fuse (%s), "
+ "geo-replication start failed",
+ strerror (errno));
snprintf (errmsg, sizeof(errmsg),
"fuse unvailable");
ret = -1;
@@ -2899,11 +3093,12 @@ out:
GF_FREE (path_list);
if (ret && errmsg[0] != '\0') {
- gf_log (this->name, GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_ERROR,
+ "%s", errmsg);
*op_errstr = gf_strdup (errmsg);
}
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2939,15 +3134,16 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,
snprintf (errmsg, sizeof(errmsg),
"pid-file entry mising in config file and "
"template config file.");
- gf_log (this->name, GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PIDFILE_NOT_FOUND,
+ "%s", errmsg);
*op_errstr = gf_strdup (errmsg);
ret = -1;
goto out;
}
if (gsync_status_byfd (pfd) == -1) {
- gf_log (this->name, GF_LOG_ERROR, "gsyncd b/w %s & %s is not"
- " running", master, slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_ERROR,
+ "gsyncd b/w %s & %s is not running", master, slave);
/* monitor gsyncd already dead */
goto out;
}
@@ -2958,14 +3154,15 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,
/* Prepare to update status file*/
ret = dict_get_str (dict, "statefile", &statefile);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Pause/Resume Failed:"
- " Unable to fetch statefile path");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "Pause/Resume Failed: Unable to fetch statefile path");
goto out;
}
ret = glusterd_gsync_read_frm_status (statefile, monitor_status,
sizeof (monitor_status));
if (ret <= 0) {
- gf_log (this->name, GF_LOG_ERROR, "Pause/Resume Failed: "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STAT_FILE_READ_FAILED, "Pause/Resume Failed: "
"Unable to read status file for %s(master)"
" %s(slave)", master, slave);
goto out;
@@ -2977,7 +3174,8 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,
if (is_pause) {
ret = kill (-pid, SIGSTOP);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed"
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_PID_KILL_FAIL, "Failed"
" to pause gsyncd. Error: %s",
strerror (errno));
goto out;
@@ -2991,7 +3189,8 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,
slave_host, slave_vol,
"Paused");
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_UPDATE_STATEFILE_FAILED,
"Unable to update state_file."
" Error : %s", strerror (errno));
/* If status cannot be updated resume back */
@@ -3002,9 +3201,11 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,
"Please use 'resume force' to"
" resume back and retry pause"
" to reflect in status");
- gf_log (this->name, GF_LOG_ERROR,
- "Resume back Failed. Error: %s",
- strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR,
+ errno,
+ GD_MSG_PID_KILL_FAIL,
+ "Resume back Failed. Error:"
+ "%s", strerror (errno));
*op_errstr = gf_strdup (errmsg);
}
goto out;
@@ -3015,7 +3216,8 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,
slave_vol,
"Started");
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_UPDATE_STATEFILE_FAILED,
"Resume Failed: Unable to update "
"state_file. Error : %s",
strerror (errno));
@@ -3023,7 +3225,8 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,
}
ret = kill (-pid, SIGCONT);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_PID_KILL_FAIL,
"Resumed Failed: Unable to send"
" SIGCONT. Error: %s",
strerror (errno));
@@ -3040,7 +3243,8 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,
"inconsistent. Please use "
"'resume force' to resume and"
" reach consistent state");
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STATUS_UPDATE_FAILED,
"Updating status back to paused"
" Failed. Error: %s",
strerror (errno));
@@ -3070,9 +3274,12 @@ stop_gsync (char *master, char *slave, char **msg,
char buf [1024] = {0,};
int i = 0;
gf_boolean_t is_template_in_use = _gf_false;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
- GF_ASSERT (THIS);
- GF_ASSERT (THIS->private);
+ GF_ASSERT (this->private);
pfd = gsyncd_getpidfile (master, slave, pidfile,
conf_path, &is_template_in_use);
@@ -3080,14 +3287,16 @@ stop_gsync (char *master, char *slave, char **msg,
snprintf (errmsg, sizeof(errmsg) - 1,
"pid-file entry mising in config file and "
"template config file.");
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PIDFILE_NOT_FOUND,
+ "%s", errmsg);
*op_errstr = gf_strdup (errmsg);
ret = -1;
goto out;
}
if (gsync_status_byfd (pfd) == -1 && !is_force) {
- gf_log ("", GF_LOG_ERROR, "gsyncd b/w %s & %s is not"
- " running", master, slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_ERROR,
+ "gsyncd b/w %s & %s is not running", master,
+ slave);
/* monitor gsyncd already dead */
goto out;
}
@@ -3100,7 +3309,8 @@ stop_gsync (char *master, char *slave, char **msg,
pid = strtol (buf, NULL, 10);
ret = kill (-pid, SIGTERM);
if (ret && !is_force) {
- gf_log ("", GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ GD_MSG_PID_KILL_FAIL,
"failed to kill gsyncd");
goto out;
}
@@ -3148,31 +3358,39 @@ glusterd_gsync_op_already_set (char* master, char* slave, char* conf_path,
int32_t op_val_cli = 0;
int32_t ret = -1;
gf_boolean_t is_bool = _gf_true;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
confd = dict_new ();
if (!confd) {
- gf_log ("", GF_LOG_ERROR, "Not able to create dict.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL,
+ "Not able to create dict.");
return -1;
}
ret = glusterd_gsync_get_config (master, slave, conf_path,
confd);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get configuration data"
- "for %s(master), %s(slave)", master, slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GET_CONFIG_INFO_FAILED,
+ "Unable to get configuration data for %s(master), "
+ "%s(slave)", master, slave);
goto out;
}
ret = dict_get_param (confd, op_name, &op_val_buf);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get op_value "
- "for %s(master), %s(slave). Please check gsync "
- "config file.", master, slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "Unable to get op_value for %s(master), %s(slave). "
+ "Please check gsync config file.", master, slave);
ret = 1;
goto out;
}
- gf_log("",GF_LOG_DEBUG, "val_cli:%s val_conf:%s",op_value,op_val_buf);
+ gf_msg_debug (this->name, 0, "val_cli:%s val_conf:%s", op_value,
+ op_val_buf);
if (!strcmp(op_val_buf,"true") || !strcmp(op_val_buf,"1")
|| !strcmp(op_val_buf,"yes")) {
@@ -3229,6 +3447,10 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,
gf_boolean_t restart_required = _gf_true;
char **resopt = NULL;
gf_boolean_t op_already_set = _gf_false;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (slave);
GF_ASSERT (op_errstr);
@@ -3241,7 +3463,7 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,
if (strcmp (subop, "get") == 0 || strcmp (subop, "get-all") == 0) {
/* deferred to cli */
- gf_log ("", GF_LOG_DEBUG, "Returning 0");
+ gf_msg_debug (this->name, 0, "Returning 0");
return 0;
}
@@ -3258,14 +3480,16 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,
if (THIS)
priv = THIS->private;
if (priv == NULL) {
- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLUSTERD_PRIV_NOT_FOUND,
+ "priv of glusterd not present");
*op_errstr = gf_strdup ("glusterd defunct");
goto out;
}
ret = dict_get_str (dict, "conf_path", &conf_path);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
"Unable to fetch conf file path.");
goto out;
}
@@ -3289,14 +3513,15 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,
ret = glusterd_gsync_op_already_set(master,slave,conf_path,
op_name,op_value);
if (ret == -1) {
- gf_log ("", GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_GSYNCD_OP_SET_FAILED,
"glusterd_gsync_op_already_set failed.");
gf_asprintf (op_errstr, GEOREP" config-%s failed for "
"%s %s", subop, master, slave);
goto out;
}
if (ret == 0) {
- gf_log("", GF_LOG_DEBUG, "op_value is already set");
+ gf_msg_debug (this->name, 0, "op_value is already set");
op_already_set = _gf_true;
goto out;
}
@@ -3306,9 +3531,10 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,
ret = runner_run (&runner);
synclock_lock (&priv->big_lock);
if (ret) {
- gf_log ("", GF_LOG_WARNING, "gsyncd failed to "
- "%s %s option for %s %s peers",
- subop, op_name, master, slave);
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_GSYNCD_ERROR,
+ "gsyncd failed to %s %s option for "
+ "%s %s peers", subop, op_name, master,
+ slave);
gf_asprintf (op_errstr, GEOREP" config-%s failed for %s %s",
subop, master, slave);
@@ -3322,14 +3548,16 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,
if (ret) {
ret = dict_get_str (dict, "slave_host", &slave_host);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch slave host.");
goto out;
}
ret = dict_get_str (dict, "slave_vol", &slave_vol);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch slave volume name.");
goto out;
}
@@ -3340,8 +3568,9 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,
"Switching Status "
"File");
if (ret || lstat (op_value, &stbuf)) {
- gf_log ("", GF_LOG_ERROR, "Unable to create %s"
- ". Error : %s", op_value,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "Unable to "
+ "create %s. Error : %s", op_value,
strerror (errno));
ret = -1;
goto out;
@@ -3371,7 +3600,7 @@ out:
}
}
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -3380,13 +3609,17 @@ glusterd_gsync_read_frm_status (char *path, char *buf, size_t blen)
{
int ret = 0;
int status_fd = -1;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (path);
GF_ASSERT (buf);
status_fd = open (path, O_RDONLY);
if (status_fd == -1) {
- gf_log ("", GF_LOG_ERROR, "Unable to read gsyncd status"
- " file");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_FILE_OP_FAILED,
+ "Unable to read gsyncd status file");
return -1;
}
ret = read (status_fd, buf, blen - 1);
@@ -3401,7 +3634,8 @@ glusterd_gsync_read_frm_status (char *path, char *buf, size_t blen)
*p-- = '\0';
}
} else if (ret < 0)
- gf_log ("", GF_LOG_ERROR, "Status file of gsyncd is corrupt");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_ERROR,
+ "Status file of gsyncd is corrupt");
close (status_fd);
return ret;
@@ -3446,19 +3680,26 @@ glusterd_fetch_values_from_config (char *master, char *slave,
char **socketfile)
{
int ret = 0;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
ret = glusterd_gsync_get_config (master, slave, confpath,
confd);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get configuration data"
- "for %s(master), %s(slave)", master, slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GET_CONFIG_INFO_FAILED,
+ "Unable to get configuration data for %s(master), "
+ "%s(slave)", master, slave);
goto out;
}
if (statefile) {
ret = dict_get_param (confd, "state_file", statefile);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get state_file's name "
"for %s(master), %s(slave). "
"Please check gsync config file.",
@@ -3471,7 +3712,8 @@ glusterd_fetch_values_from_config (char *master, char *slave,
ret = dict_get_param (confd, "georep_session_working_dir",
georep_session_wrkng_dir);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get geo-rep session's "
"working directory name for %s(master), "
"%s(slave). Please check gsync config file.",
@@ -3484,7 +3726,8 @@ glusterd_fetch_values_from_config (char *master, char *slave,
ret = dict_get_param (confd, "state_socket_unencoded",
socketfile);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get socket file's name "
"for %s(master), %s(slave). "
"Please check gsync config file.",
@@ -3495,7 +3738,7 @@ glusterd_fetch_values_from_config (char *master, char *slave,
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -3532,9 +3775,12 @@ glusterd_read_status_file (glusterd_volinfo_t *volinfo, char *slave,
glusterd_conf_t *priv = NULL;
struct stat stbuf = {0,};
dict_t *statusd = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
- GF_ASSERT (THIS);
- GF_ASSERT (THIS->private);
+ GF_ASSERT (this->private);
GF_ASSERT (volinfo);
GF_ASSERT (conf_path);
@@ -3542,7 +3788,8 @@ glusterd_read_status_file (glusterd_volinfo_t *volinfo, char *slave,
confd = dict_new ();
if (!confd) {
- gf_log ("", GF_LOG_ERROR, "Not able to create dict.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL,
+ "Not able to create dict.");
return -1;
}
@@ -3553,22 +3800,24 @@ glusterd_read_status_file (glusterd_volinfo_t *volinfo, char *slave,
ret = lstat (conf_path, &stbuf);
if (!ret) {
- gf_log ("", GF_LOG_INFO, "Using passed config template(%s).",
+ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_CONFIG_INFO,
+ "Using passed config template(%s).",
conf_path);
working_conf_path = conf_path;
} else {
- gf_log ("", GF_LOG_WARNING, "Config file (%s) missing. "
- "Looking for template config file (%s)",
- conf_path, temp_conf_path);
+ gf_msg (this->name, GF_LOG_WARNING, ENOENT,
+ GD_MSG_FILE_OP_FAILED,
+ "Config file (%s) missing. Looking for template "
+ "config file (%s)", conf_path, temp_conf_path);
ret = lstat (temp_conf_path, &stbuf);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
- "Template config file (%s) missing.",
- temp_conf_path);
+ gf_msg (this->name, GF_LOG_ERROR, ENOENT,
+ GD_MSG_FILE_OP_FAILED, "Template "
+ "config file (%s) missing.", temp_conf_path);
goto out;
}
- gf_log ("", GF_LOG_INFO, "Using default config template(%s).",
- temp_conf_path);
+ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DEFAULT_TEMP_CONFIG,
+ "Using default config template(%s).", temp_conf_path);
working_conf_path = temp_conf_path;
is_template_in_use = _gf_true;
}
@@ -3582,7 +3831,8 @@ fetch_data:
&socketfile);
if (ret) {
if (is_template_in_use == _gf_false) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FETCH_CONFIG_VAL_FAILED,
"Unable to fetch config values "
"for %s(master), %s(slave). "
"Trying default config template",
@@ -3591,10 +3841,10 @@ fetch_data:
is_template_in_use = _gf_true;
goto fetch_data;
} else {
- gf_log ("", GF_LOG_ERROR,
- "Unable to fetch config values "
- "for %s(master), %s(slave)",
- master, slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FETCH_CONFIG_VAL_FAILED, "Unable to "
+ "fetch config values for %s(master), "
+ "%s(slave)", master, slave);
goto out;
}
}
@@ -3602,8 +3852,10 @@ fetch_data:
ret = glusterd_gsync_read_frm_status (statefile, monitor_status,
sizeof (monitor_status));
if (ret <= 0) {
- gf_log ("", GF_LOG_ERROR, "Unable to read the status"
- "file for %s(master), %s(slave)", master, slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STAT_FILE_READ_FAILED,
+ "Unable to read the status file for %s(master), "
+ "%s(slave)", master, slave);
strncpy (monitor_status, "defunct", sizeof (monitor_status));
}
@@ -3618,7 +3870,9 @@ fetch_data:
sts_val = GF_CALLOC (1, sizeof(gf_gsync_status_t),
gf_common_mt_gsync_status_t);
if (!sts_val) {
- gf_log ("", GF_LOG_ERROR, "Out Of Memory");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY,
+ "Out Of Memory");
goto out;
}
@@ -3700,7 +3954,9 @@ fetch_data:
brickinfo->path, sts_val);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get status data "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GET_STATUS_DATA_FAIL,
+ "Unable to get status data "
"for %s(master), %s(slave), %s(brick)",
master, slave, brickinfo->path);
ret = -1;
@@ -3812,16 +4068,17 @@ glusterd_check_restart_gsync_session (glusterd_volinfo_t *volinfo, char *slave,
volinfo->gsync_active_slaves,
key, "running");
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set "
- "key:%s value:running in dict. But the "
- "config succeeded.", key);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to set"
+ " key:%s value:running in dict. But "
+ "the config succeeded.", key);
goto out;
}
}
}
out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -3829,11 +4086,16 @@ static int32_t
glusterd_marker_changelog_create_volfile (glusterd_volinfo_t *volinfo)
{
int32_t ret = 0;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
ret = glusterd_create_volfiles_and_notify_services (volinfo);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to create volfile"
- " for setting of marker while '"GEOREP" start'");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_VOLFILE_CREATE_FAIL,
+ "Unable to create volfile for setting of marker "
+ "while '"GEOREP" start'");
ret = -1;
goto out;
}
@@ -3854,13 +4116,16 @@ glusterd_set_gsync_knob (glusterd_volinfo_t *volinfo, char *key, int *vc)
{
int ret = -1;
int conf_enabled = _gf_false;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
- GF_ASSERT (THIS);
- GF_ASSERT (THIS->private);
+ GF_ASSERT (this->private);
conf_enabled = glusterd_volinfo_get_boolean (volinfo, key);
if (conf_enabled == -1) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GET_KEY_FAILED,
"failed to get key %s from volinfo", key);
goto out;
}
@@ -3873,7 +4138,7 @@ glusterd_set_gsync_knob (glusterd_volinfo_t *volinfo, char *key, int *vc)
}
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -3920,37 +4185,44 @@ glusterd_get_gsync_status_mst_slv (glusterd_volinfo_t *volinfo,
int ret = 0;
gf_boolean_t is_template_in_use = _gf_false;
struct stat stbuf = {0, };
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (volinfo);
GF_ASSERT (slave);
- GF_ASSERT (THIS);
- GF_ASSERT (THIS->private);
+ GF_ASSERT (this->private);
- priv = THIS->private;
+ priv = this->private;
ret = glusterd_gsync_get_uuid (slave, volinfo, uuid);
if (ret) {
- gf_log ("", GF_LOG_INFO, "geo-replication status %s %s :"
- "session is not active", volinfo->volname, slave);
+ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_SESSION_INACTIVE,
+ "geo-replication status %s %s : session is not "
+ "active", volinfo->volname, slave);
ret = glusterd_get_statefile_name (volinfo, slave,
conf_path, &statefile,
&is_template_in_use);
if (ret) {
if (!strstr(slave, "::"))
- gf_log ("", GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_SLAVE_URL_INVALID,
"%s is not a valid slave url.", slave);
else
- gf_log ("", GF_LOG_INFO, "Unable to get"
- " statefile's name");
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_GET_STATEFILE_NAME_FAILED,
+ "Unable to get statefile's name");
ret = 0;
goto out;
}
ret = lstat (statefile, &stbuf);
if (ret) {
- gf_log ("", GF_LOG_INFO, "%s statefile not present.",
- statefile);
+ gf_msg (this->name, GF_LOG_INFO, ENOENT,
+ GD_MSG_FILE_OP_FAILED,
+ "%s statefile not present.", statefile);
ret = 0;
goto out;
}
@@ -3962,7 +4234,7 @@ out:
if (statefile)
GF_FREE (statefile);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3989,9 +4261,12 @@ glusterd_get_gsync_status_all (dict_t *rsp_dict, char *node)
int32_t ret = 0;
glusterd_conf_t *priv = NULL;
glusterd_volinfo_t *volinfo = NULL;
+ xlator_t *this = NULL;
- GF_ASSERT (THIS);
- priv = THIS->private;
+ this = THIS;
+ GF_ASSERT (this);
+
+ priv = this->private;
GF_ASSERT (priv);
@@ -4002,7 +4277,7 @@ glusterd_get_gsync_status_all (dict_t *rsp_dict, char *node)
}
out:
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -4018,6 +4293,10 @@ glusterd_get_gsync_status (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
glusterd_volinfo_t *volinfo = NULL;
int ret = 0;
char my_hostname[256] = {0,};
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
ret = gethostname(my_hostname, 256);
if (ret) {
@@ -4034,7 +4313,8 @@ glusterd_get_gsync_status (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
exists = glusterd_check_volume_exists (volname);
ret = glusterd_volinfo_find (volname, &volinfo);
if ((ret) || (!exists)) {
- gf_log ("", GF_LOG_WARNING, "volume name does not exist");
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_VOL_NOT_FOUND,
+ "volume name does not exist");
snprintf (errmsg, sizeof(errmsg), "Volume name %s does not"
" exist", volname);
*op_errstr = gf_strdup (errmsg);
@@ -4052,7 +4332,7 @@ glusterd_get_gsync_status (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_get_str (dict, "conf_path", &conf_path);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
"Unable to fetch conf file path.");
goto out;
}
@@ -4061,7 +4341,7 @@ glusterd_get_gsync_status (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
rsp_dict, my_hostname);
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4077,6 +4357,10 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave,
char *gl_workdir = NULL;
char geo_rep_dir[PATH_MAX] = "";
char *conf_path = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (slave);
GF_ASSERT (slave_host);
@@ -4088,14 +4372,16 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave,
if (THIS)
priv = THIS->private;
if (priv == NULL) {
- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLUSTERD_PRIV_NOT_FOUND,
+ "priv of glusterd not present");
*op_errstr = gf_strdup ("glusterd defunct");
goto out;
}
ret = dict_get_str (dict, "conf_path", &conf_path);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
"Unable to fetch conf file path.");
goto out;
}
@@ -4118,9 +4404,9 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave,
ret = runner_run (&runner);
synclock_lock (&priv->big_lock);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "gsyncd failed to "
- "delete session info for %s and %s peers",
- master, slave);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_SESSION_DEL_FAILED,
+ "gsyncd failed to delete session info for %s and "
+ "%s peers", master, slave);
gf_asprintf (op_errstr, "gsyncd failed to "
"delete session info for %s and %s peers",
@@ -4137,12 +4423,13 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave,
ret = rmdir (geo_rep_dir);
if (ret) {
if (errno == ENOENT)
- gf_log ("", GF_LOG_DEBUG, "Geo Rep Dir(%s) Not Present.",
- geo_rep_dir);
+ gf_msg_debug (this->name, 0, "Geo Rep Dir(%s) Not Present.",
+ geo_rep_dir);
else {
- gf_log ("", GF_LOG_ERROR, "Unable to delete "
- "Geo Rep Dir(%s). Error: %s", geo_rep_dir,
- strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED,
+ "Unable to delete Geo Rep Dir(%s). Error: %s",
+ geo_rep_dir, strerror (errno));
goto out;
}
}
@@ -4152,7 +4439,7 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave,
gf_asprintf (op_errstr, "delete successful");
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4173,6 +4460,10 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
int output_count = 0;
glusterd_conf_t *priv = NULL;
runner_t runner = {0,};
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (dict);
GF_ASSERT (op_errstr);
@@ -4181,28 +4472,33 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (THIS)
priv = THIS->private;
if (priv == NULL) {
- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLUSTERD_PRIV_NOT_FOUND,
+ "priv of glusterd not present");
*op_errstr = gf_strdup ("glusterd defunct");
goto out;
}
ret = dict_get_str (dict, "command", &command);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
"Unable to get command from dict");
goto out;
}
ret = dict_get_int32 (dict, "cmd_args_count", &cmd_args_count);
if (ret)
- gf_log ("", GF_LOG_INFO, "No cmd_args_count");
+ gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_DICT_GET_FAILED,
+ "No cmd_args_count");
if (cmd_args_count) {
cmd_args = GF_CALLOC (cmd_args_count, sizeof (char*),
gf_common_mt_char);
if (!cmd_args) {
- gf_log ("", GF_LOG_ERROR, "Unable to calloc. "
- "Errno = %s", strerror(errno));
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY,
+ "Unable to calloc. Errno = %s",
+ strerror(errno));
goto out;
}
@@ -4212,9 +4508,9 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
"cmd_arg_%d", i);
ret = dict_get_str (dict, cmd_arg_name, &cmd_args[i-1]);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
- "Unable to get %s in dict",
- cmd_arg_name);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get"
+ " %s in dict", cmd_arg_name);
goto out;
}
}
@@ -4232,7 +4528,8 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
"execute command. Error : %s",
strerror (errno));
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_CMD_EXEC_FAIL, "%s",
+ errmsg);
ret = -1;
synclock_lock (&priv->big_lock);
goto out;
@@ -4253,15 +4550,21 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
buf[strlen(buf) - 1] = '\0';
bufp = gf_strdup (buf);
if (!bufp)
- gf_log ("", GF_LOG_ERROR, "gf_strdup failed.");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STRDUP_FAILED,
+ "gf_strdup failed.");
ret = dict_set_dynstr (rsp_dict, output_name, bufp);
if (ret) {
GF_FREE (bufp);
- gf_log ("", GF_LOG_ERROR, "output set failed.");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "output set "
+ "failed.");
}
ret = dict_set_int32 (rsp_dict, "output_count", output_count);
if (ret)
- gf_log ("", GF_LOG_ERROR, "output_count set failed.");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "output_count "
+ "set failed.");
}
} while (ptr);
@@ -4271,7 +4574,8 @@ glusterd_op_sys_exec (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
"end. Error : %s",
strerror (errno));
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_UNABLE_TO_END, "%s",
+ errmsg);
ret = -1;
synclock_lock (&priv->big_lock);
goto out;
@@ -4285,7 +4589,7 @@ out:
cmd_args = NULL;
}
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4308,11 +4612,17 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
glusterd_conf_t *priv = NULL;
struct stat stbuf = {0,};
gf_boolean_t free_contents = _gf_true;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
if (THIS)
priv = THIS->private;
if (priv == NULL) {
- gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLUSTERD_PRIV_NOT_FOUND,
+ "priv of glusterd not present");
*op_errstr = gf_strdup ("glusterd defunct");
goto out;
}
@@ -4323,8 +4633,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
ret = dict_get_str (dict, "source", &filename);
if (ret < 0) {
- gf_log ("", GF_LOG_ERROR, "Unable to fetch"
- " filename from dict.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "Unable to fetch filename from dict.");
*op_errstr = gf_strdup ("command unsuccessful");
goto out;
}
@@ -4338,7 +4648,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Source file"
" does not exist in %s", priv->workdir);
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, ENOENT,
+ GD_MSG_FILE_OP_FAILED, "%s", errmsg);
goto out;
}
@@ -4347,7 +4658,9 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg),
"Unable to allocate memory");
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY,
+ "%s", errmsg);
ret = -1;
goto out;
}
@@ -4357,7 +4670,9 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Unable to open %s",
abs_filename);
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FILE_OP_FAILED,
+ "%s", errmsg);
ret = -1;
goto out;
}
@@ -4375,7 +4690,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Unable to read all "
"the data from %s", abs_filename);
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_READ_ERROR,
+ "%s", errmsg);
ret = -1;
goto out;
}
@@ -4385,7 +4701,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Unable to set"
" contents size in dict.");
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "%s", errmsg);
goto out;
}
@@ -4395,7 +4712,9 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Unable to set"
" file mode in dict.");
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "%s", errmsg);
goto out;
}
@@ -4405,7 +4724,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Unable to set"
" pem contents in dict.");
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "%s", errmsg);
goto out;
}
free_contents = _gf_false;
@@ -4417,7 +4737,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Unable to get"
" pem contents in dict.");
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "%s", errmsg);
goto out;
}
ret = dict_get_int32 (dict, "contents_size", &contents_size);
@@ -4425,7 +4746,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Unable to set"
" contents size in dict.");
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "%s", errmsg);
goto out;
}
@@ -4434,7 +4756,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Unable to get"
" file mode in dict.");
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "%s", errmsg);
goto out;
}
@@ -4443,7 +4766,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Unable to open %s",
abs_filename);
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FILE_OP_FAILED, "%s", errmsg);
ret = -1;
goto out;
}
@@ -4454,7 +4778,8 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
snprintf (errmsg, sizeof (errmsg), "Failed to write"
" to %s", abs_filename);
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FILE_OP_FAILED, "%s", errmsg);
ret = -1;
goto out;
}
@@ -4470,7 +4795,7 @@ out:
if (free_contents)
GF_FREE(contents);
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4525,27 +4850,28 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_get_str (dict, "slave_url", &slave_url);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch slave url.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "Unable to fetch slave url.");
goto out;
}
ret = dict_get_str (dict, "slave_host", &slave_host);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
"Unable to fetch slave hostname.");
goto out;
}
ret = dict_get_str (dict, "slave_vol", &slave_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
"Unable to fetch slave volume name.");
goto out;
}
ret = dict_get_str (dict, "conf_path", &conf_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
"Unable to fetch conf file path.");
goto out;
}
@@ -4553,7 +4879,8 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (dict_get_str (dict, "master", &volname) == 0) {
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Volinfo for"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_GET_FAILED, "Volinfo for"
" %s (master) not found", volname);
goto out;
}
@@ -4567,7 +4894,8 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (!ret) {
ret = dict_set_str (rsp_dict, "conf_path", conf_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Unable to store conf_file_path.");
goto out;
}
@@ -4598,7 +4926,8 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_set_dynstr_with_alloc (volinfo->gsync_active_slaves,
key, "running");
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set key:%s"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to set key:%s"
" value:running in the dict", key);
goto out;
}
@@ -4620,8 +4949,9 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
&is_running);
if (!ret && !is_force && path_list &&
(_gf_true != is_running)) {
- gf_log (this->name, GF_LOG_WARNING, GEOREP" is not set "
- "up for %s(master) and %s(slave)",
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_GSYNCD_OP_SET_FAILED, GEOREP" is not "
+ "set up for %s(master) and %s(slave)",
volname, slave);
*op_errstr = strdup (GEOREP" is not set up");
goto out;
@@ -4633,8 +4963,9 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
conf_path, op_errstr,
_gf_true);
if (ret)
- gf_log(this->name, GF_LOG_ERROR, GEOREP
- " Pause Failed");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_PAUSE_FAILED,
+ GEOREP" Pause Failed");
else
dict_del (volinfo->gsync_active_slaves, key);
@@ -4646,8 +4977,9 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
volinfo->gsync_active_slaves,
key, "running");
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set "
- "key:%s value:running in dict", key);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to set "
+ "key:%s value:running in dict", key);
goto out;
}
@@ -4656,8 +4988,9 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
conf_path, op_errstr,
_gf_false);
if (ret) {
- gf_log(this->name, GF_LOG_ERROR, GEOREP
- " Resume Failed");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_RESUME_FAILED,
+ GEOREP" Resume Failed");
dict_del (volinfo->gsync_active_slaves, key);
}
} else {
@@ -4674,7 +5007,8 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
slave, slave_host,
slave_vol,"Stopped");
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_UPDATE_STATEFILE_FAILED,
"Unable to update state_file. "
"Error : %s", strerror (errno));
}
@@ -4689,7 +5023,7 @@ out:
path_list = NULL;
}
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4703,14 +5037,18 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo,
char confpath[PATH_MAX] = "";
glusterd_conf_t *priv = NULL;
char *slave = NULL;
+ xlator_t *this = NULL;
- GF_ASSERT (THIS);
- priv = THIS->private;
+ this = THIS;
+ GF_ASSERT (this);
+
+ priv = this->private;
GF_ASSERT (priv);
ret = dict_get_str (dict, "slave", &slave);
if (ret || !slave) {
- gf_log ("", GF_LOG_ERROR, "Unable to fetch slave from dict");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "Unable to fetch slave from dict");
ret = -1;
goto out;
}
@@ -4718,7 +5056,8 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo,
ret = glusterd_get_slave_info (slave, slave_url,
slave_host, slave_vol, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVEINFO_FETCH_ERROR,
"Unable to fetch slave details.");
ret = -1;
goto out;
@@ -4726,21 +5065,21 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo,
ret = dict_set_str (dict, "slave_url", *slave_url);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
"Unable to store slave IP.");
goto out;
}
ret = dict_set_str (dict, "slave_host", *slave_host);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
"Unable to store slave hostname");
goto out;
}
ret = dict_set_str (dict, "slave_vol", *slave_vol);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
"Unable to store slave volume name.");
goto out;
}
@@ -4752,7 +5091,7 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo,
confpath[ret] = '\0';
*conf_path = gf_strdup (confpath);
if (!(*conf_path)) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno, GD_MSG_STRDUP_FAILED,
"Unable to gf_strdup. Error: %s", strerror (errno));
ret = -1;
goto out;
@@ -4760,13 +5099,13 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo,
ret = dict_set_str (dict, "conf_path", *conf_path);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
"Unable to store conf_path");
goto out;
}
out:
- gf_log ("", GF_LOG_DEBUG,"Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4793,7 +5132,8 @@ glusterd_get_slave_info (char *slave,
"Invalid Url: %s", slave);
errmsg[ret] = '\0';
*op_errstr = gf_strdup (errmsg);
- gf_log (this->name, GF_LOG_ERROR, "Failed to normalize url");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_NORMALIZE_URL_FAIL,
+ "Failed to normalize url");
goto out;
}
@@ -4803,23 +5143,26 @@ glusterd_get_slave_info (char *slave,
if (slave) {
ret = glusterd_geo_rep_parse_slave (slave, hostname, op_errstr);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVE_URL_INVALID,
"Invalid slave url: %s", *op_errstr);
goto out;
}
- gf_log (this->name, GF_LOG_DEBUG, "Hostname : %s", *hostname);
+ gf_msg_debug (this->name, 0, "Hostname : %s", *hostname);
*slave_url = gf_strdup (slave);
if (!*slave_url) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STRDUP_FAILED,
"Failed to gf_strdup");
ret = -1;
goto out;
}
- gf_log (this->name, GF_LOG_DEBUG, "Slave URL : %s", *slave_url);
+ gf_msg_debug (this->name, 0, "Slave URL : %s", *slave_url);
ret = 0;
} else {
- gf_log (this->name, GF_LOG_ERROR, "Invalid slave name");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Invalid slave name");
goto out;
}
@@ -4827,21 +5170,23 @@ glusterd_get_slave_info (char *slave,
if (slave) {
*slave_vol = gf_strdup (slave);
if (!*slave_vol) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STRDUP_FAILED,
"Failed to gf_strdup");
ret = -1;
GF_FREE (*slave_url);
goto out;
}
- gf_log (this->name, GF_LOG_DEBUG, "Slave Vol : %s", *slave_vol);
+ gf_msg_debug (this->name, 0, "Slave Vol : %s", *slave_vol);
ret = 0;
} else {
- gf_log (this->name, GF_LOG_ERROR, "Invalid slave name");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Invalid slave name");
goto out;
}
out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4861,6 +5206,10 @@ glusterd_check_gsync_present (int *valid_state)
runner_t runner = {0,};
char *ptr = NULL;
int ret = 0;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
runinit (&runner);
runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd", "--version", NULL);
@@ -4868,13 +5217,15 @@ glusterd_check_gsync_present (int *valid_state)
ret = runner_start (&runner);
if (ret == -1) {
if (errno == ENOENT) {
- gf_log ("glusterd", GF_LOG_INFO, GEOREP
- " module not installed in the system");
+ gf_msg ("glusterd", GF_LOG_INFO, ENOENT,
+ GD_MSG_MODULE_NOT_INSTALLED, GEOREP" module "
+ "not installed in the system");
*valid_state = 0;
}
else {
- gf_log ("glusterd", GF_LOG_ERROR, GEOREP
- " module not working as desired");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_MODULE_ERROR,
+ GEOREP" module not working as desired");
*valid_state = -1;
}
goto out;
@@ -4884,15 +5235,16 @@ glusterd_check_gsync_present (int *valid_state)
if (ptr) {
if (!strstr (buff, "gsyncd")) {
ret = -1;
- gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not "
- "working as desired");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_MODULE_ERROR,
+ GEOREP" module not working as desired");
*valid_state = -1;
goto out;
}
} else {
ret = -1;
- gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not "
- "working as desired");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0, GD_MSG_MODULE_ERROR,
+ GEOREP" module not working as desired");
*valid_state = -1;
goto out;
}
@@ -4902,7 +5254,7 @@ glusterd_check_gsync_present (int *valid_state)
runner_end (&runner);
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -5125,15 +5477,19 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict,
char errmsg[PATH_MAX] = "";
glusterd_conf_t *conf = NULL;
struct stat stbuf = {0,};
+ xlator_t *this = NULL;
- GF_ASSERT (THIS);
- conf = THIS->private;
+ this = THIS;
+ GF_ASSERT (this);
+
+ conf = this->private;
ret = dict_get_str (dict, "conf_path", &conf_path);
if (ret) {
snprintf (errmsg, sizeof (errmsg),
"Unable to fetch conf file path.");
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "%s", errmsg);
goto out;
}
@@ -5141,7 +5497,8 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict,
if (ret) {
snprintf (errmsg, sizeof (errmsg),
"Unable to fetch statefile path.");
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "%s", errmsg);
goto out;
}
@@ -5153,7 +5510,8 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict,
snprintf (errmsg, sizeof (errmsg), "Unable to create %s"
". Error : %s", buf, strerror (errno));
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, errno, GD_MSG_DIR_OP_FAILED,
+ "%s", errmsg);
goto out;
}
@@ -5165,28 +5523,30 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict,
snprintf (errmsg, sizeof (errmsg), "Unable to create %s"
". Error : %s", buf, strerror (errno));
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, errno, GD_MSG_DIR_OP_FAILED,
+ "%s", errmsg);
goto out;
}
ret = lstat (conf_path, &stbuf);
if (!ret) {
- gf_log ("", GF_LOG_DEBUG, "Session already running."
- " Not creating config file again.");
+ gf_msg_debug (this->name, 0, "Session already running."
+ " Not creating config file again.");
} else {
ret = create_conf_file (conf, conf_path);
if (ret || lstat (conf_path, &stbuf)) {
snprintf (errmsg, sizeof (errmsg), "Failed to create"
" config file(%s).", conf_path);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "%s", errmsg);
goto out;
}
}
ret = lstat (statefile, &stbuf);
if (!ret) {
- gf_log ("", GF_LOG_DEBUG, "Session already running."
- " Not creating status file again.");
+ gf_msg_debug (this->name, 0, "Session already running."
+ " Not creating status file again.");
goto out;
} else {
ret = glusterd_create_status_file (volinfo->volname, slave,
@@ -5196,14 +5556,15 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict,
snprintf (errmsg, sizeof (errmsg), "Unable to create %s"
". Error : %s", statefile, strerror (errno));
*op_errstr = gf_strdup (errmsg);
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "%s", errmsg);
ret = -1;
goto out;
}
}
out:
- gf_log ("", GF_LOG_DEBUG,"Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -5249,8 +5610,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Volinfo for %s"
- " (master) not found", volname);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_VOL_NOT_FOUND,
+ "Volinfo for %s (master) not found", volname);
goto out;
}
@@ -5258,7 +5619,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (ret) {
snprintf (errmsg, sizeof (errmsg),
"Unable to fetch slave volume name.");
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "%s", errmsg);
goto out;
}
@@ -5266,7 +5628,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (ret) {
snprintf (errmsg, sizeof (errmsg),
"Unable to fetch slave IP.");
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "%s", errmsg);
ret = -1;
goto out;
}
@@ -5288,7 +5651,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
}
if (!slave_user || !slave_ip) {
- gf_log (this->name, GF_LOG_ERROR, "Invalid slave url.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_SLAVE_URL_INVALID,
+ "Invalid slave url.");
ret = -1;
goto out;
}
@@ -5297,7 +5661,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (ret) {
snprintf (errmsg, sizeof (errmsg),
"Unable to fetch slave host");
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "%s", errmsg);
ret = -1;
goto out;
}
@@ -5308,8 +5673,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (!strcmp (uuid_str, host_uuid)) {
ret = dict_get_int32 (dict, "push_pem", &is_pem_push);
if (!ret && is_pem_push) {
- gf_log ("", GF_LOG_DEBUG, "Trying to setup"
- " pem files in slave");
+ gf_msg_debug (this->name, 0, "Trying to setup"
+ " pem files in slave");
is_pem_push = 1;
} else
is_pem_push = 0;
@@ -5324,8 +5689,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
arg_buf = gf_strdup (hooks_args);
if (!arg_buf) {
- gf_log ("", GF_LOG_ERROR, "Failed to"
- " gf_strdup");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_STRDUP_FAILED,
+ "Failed to gf_strdup");
if (is_force) {
ret = 0;
goto create_essentials;
@@ -5336,8 +5701,8 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_set_str (dict, "hooks_args", arg_buf);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Failed to set"
- " hooks_args in dict.");
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
+ "Failed to set hooks_args in dict.");
if (is_force) {
ret = 0;
goto create_essentials;
@@ -5359,14 +5724,17 @@ create_essentials:
if (ret) {
snprintf (errmsg, sizeof (errmsg), "Unable to store"
" slave info.");
- gf_log ("", GF_LOG_ERROR, "%s", errmsg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SLAVEINFO_STORE_ERROR,
+ "%s", errmsg);
goto out;
}
/* Enable marker and changelog */
ret = glusterd_set_gsync_confs (volinfo);
if (ret != 0) {
- gf_log (this->name, GF_LOG_WARNING, "marker/changelog"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_MARKER_START_FAIL, "marker/changelog"
" start failed");
*op_errstr = gf_strdup ("Index initialization failed");
ret = -1;
@@ -5375,6 +5743,6 @@ create_essentials:
out:
GF_FREE (slave_url_buf);
- gf_log ("", GF_LOG_DEBUG,"Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}