From 0cbf7b0fadc426fe877b4926cba851069cc48ead Mon Sep 17 00:00:00 2001
From: Nandaja Varma <nandaja.varma@gmail.com>
Date: Wed, 18 Mar 2015 15:17:45 +0530
Subject: [PATCH 087/101] sm/glusterd: Porting messages to new logging framework
Backport of http://review.gluster.org/#/c/9927/
(cherry picked from commit 72a7a6ea78289b2897f9846dc4e111f442dd2788)
>Change-Id: I391d1ac6a7b312461187c2e8c6f14d09a0238950
>BUG: 1194640
>Signed-off-by: Nandaja Varma <nandaja.varma@gmail.com>
>Reviewed-on: http://review.gluster.org/9927
>Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
>Tested-by: NetBSD Build System <jenkins@build.gluster.org>
>Tested-by: Gluster Build System <jenkins@build.gluster.com>
>Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Change-Id: I391d1ac6a7b312461187c2e8c6f14d09a0238950
BUG: 1231771
Signed-off-by: Nandaja Varma <nandaja.varma@gmail.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/50890
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
xlators/mgmt/glusterd/src/glusterd-op-sm.c | 711 ++++++++++++++++++----------
xlators/mgmt/glusterd/src/glusterd-sm.c | 107 +++--
2 files changed, 524 insertions(+), 294 deletions(-)
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 6cf200d..8fca680 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -205,12 +205,13 @@ glusterd_generate_txn_id (dict_t *dict, uuid_t **txn_id)
ret = dict_set_bin (dict, "transaction_id",
*txn_id, sizeof (**txn_id));
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Failed to set transaction id.");
goto out;
}
- gf_log ("", GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Transaction_id = %s", uuid_utoa (**txn_id));
out:
if (ret && *txn_id) {
@@ -254,13 +255,13 @@ glusterd_get_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo)
(*opinfo) = opinfo_obj->opinfo;
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Successfully got opinfo for transaction ID : %s",
uuid_utoa (*txn_id));
ret = 0;
out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -308,7 +309,7 @@ glusterd_set_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo)
opinfo_obj->opinfo = (*opinfo);
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Successfully set opinfo for transaction ID : %s",
uuid_utoa (*txn_id));
ret = 0;
@@ -317,7 +318,7 @@ out:
if (opinfo_obj)
GF_FREE (opinfo_obj);
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -335,14 +336,18 @@ glusterd_clear_txn_opinfo (uuid_t *txn_id)
GF_ASSERT (priv);
if (!txn_id) {
- gf_log ("", GF_LOG_ERROR, "Empty transaction id received.");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_TRANS_ID_GET_FAIL,
+ "Empty transaction id received.");
ret = -1;
goto out;
}
ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Transaction opinfo not found");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_TRANS_OPINFO_GET_FAIL,
+ "Transaction opinfo not found");
goto out;
}
@@ -351,13 +356,13 @@ glusterd_clear_txn_opinfo (uuid_t *txn_id)
dict_del(priv->glusterd_txn_opinfo, uuid_utoa (*txn_id));
- gf_log ("", GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Successfully cleared opinfo for transaction ID : %s",
uuid_utoa (*txn_id));
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -438,7 +443,7 @@ glusterd_op_sm_inject_all_acc (uuid_t *txn_id)
{
int32_t ret = -1;
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACC, txn_id, NULL);
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -627,7 +632,7 @@ glusterd_brick_op_build_payload (glusterd_op_t op, glusterd_brickinfo_t *brickin
out:
if (ret && brick_req)
GF_FREE (brick_req);
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -681,7 +686,7 @@ glusterd_node_op_build_payload (glusterd_op_t op, gd1_mgmt_brick_op_req **req,
out:
if (ret && brick_req)
GF_FREE (brick_req);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -831,7 +836,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
ret = dict_get_uint32 (dict, "new-op-version",
&new_op_version);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Failed to get new_op_version");
goto out;
}
@@ -842,7 +848,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
snprintf (errstr, sizeof (errstr),
"Required op_version (%d) is not "
"supported", new_op_version);
- gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_UNSUPPORTED_VERSION, "%s",
+ errstr);
goto out;
}
}
@@ -850,7 +858,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
ret = dict_get_int32 (dict, "count", &dict_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Count(dict),not set in Volume-Set");
goto out;
}
@@ -868,14 +877,16 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
goto out;
#else
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MODULE_NOT_INSTALLED,
"libxml not present in the system");
*op_errstr = gf_strdup ("Error: xml libraries not "
"present to produce xml-output");
goto out;
#endif
}
- gf_log (this->name, GF_LOG_ERROR, "No options received ");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_OPTIONS_GIVEN, "No options received ");
*op_errstr = gf_strdup ("Options not specified");
ret = -1;
goto out;
@@ -883,7 +894,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
+ "Unable to get volume name");
goto out;
}
@@ -892,14 +905,16 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
if (!exists) {
snprintf (errstr, sizeof (errstr),
FMTSTR_CHECK_VOL_EXISTS, volname);
- gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "%s", errstr);
ret = -1;
goto out;
}
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND,
FMTSTR_CHECK_VOL_EXISTS, volname);
goto out;
}
@@ -923,21 +938,22 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
sprintf (str, "value%d", count);
ret = dict_get_str (dict, str, &value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"invalid key,value pair in 'volume set'");
ret = -1;
goto out;
}
if (strcmp (key, "config.memory-accounting") == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"enabling memory accounting for volume %s",
volname);
ret = 0;
}
if (strcmp (key, "config.transport") == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"changing transport-type for volume %s",
volname);
ret = 0;
@@ -975,7 +991,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
}
if (!exists) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY,
"Option with name: %s does not exist", key);
ret = snprintf (errstr, sizeof (errstr),
"option : %s does not exist",
@@ -1019,7 +1036,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
snprintf (errstr, sizeof (errstr), "invalid "
"number format \"%s\" in option "
"\"%s\"", value, key);
- gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "%s", errstr);
goto out;
}
@@ -1029,7 +1047,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
snprintf (errstr, sizeof (errstr),
"Required op_version (%d) is not "
"supported", local_key_op_version);
- gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VERSION_UNSUPPORTED,
+ "%s", errstr);
goto out;
}
if (local_key_op_version > local_new_op_version)
@@ -1051,14 +1071,16 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
if (origin_glusterd) {
ret = dict_set_uint32 (dict, str, local_key_op_version);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Failed to set key-op-version in dict");
goto out;
}
} else if (check_op_version) {
ret = dict_get_uint32 (dict, str, &key_op_version);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Failed to get key-op-version from"
" dict");
goto out;
@@ -1068,7 +1090,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
snprintf (errstr, sizeof (errstr),
"option: %s op-version mismatch",
key);
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_OP_VERSION_MISMATCH,
"%s, required op-version = %"PRIu32", "
"available op-version = %"PRIu32,
errstr, key_op_version,
@@ -1103,7 +1126,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
if (strchr (value, '/')) {
snprintf (errstr, sizeof (errstr),
"Path is not allowed as option");
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_SET_FAIL,
"Unable to set the options in 'volume "
"set': %s", errstr);
ret = -1;
@@ -1126,17 +1150,24 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
/* Checks whether a directory with
given option exists or not */
if (!stat(trash_path, &stbuf)) {
- snprintf (errstr, sizeof (errstr),
- "Path %s exists", value);
- gf_log (this->name, GF_LOG_ERROR,
- "Unable to set the options in "
- "'volume set': %s", errstr);
+ snprintf (errstr,
+ sizeof (errstr),
+ "Path %s exists",
+ value);
+ gf_msg (this->name,
+ GF_LOG_ERROR,
+ 0, GD_MSG_VOL_SET_FAIL,
+ "Unable to set the "
+ "options in "
+ "'volume set': %s",
+ errstr);
ret = -1;
goto out;
} else {
- gf_log (this->name, GF_LOG_DEBUG,
- "Directory with given name "
- "does not exists, continuing");
+ gf_msg_debug (this->name, 0,
+ "Directory with given "
+ "name does not exists,"
+ " continuing");
}
if (volinfo->status == GLUSTERD_STATUS_STARTED
@@ -1145,9 +1176,13 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
whether bricks are online */
snprintf (errstr, sizeof (errstr),
"One or more bricks are down");
- gf_log (this->name, GF_LOG_ERROR,
- "Unable to set the options in "
- "'volume set': %s", errstr);
+ gf_msg (this->name,
+ GF_LOG_ERROR, 0,
+ GD_MSG_VOL_SET_FAIL,
+ "Unable to set the "
+ "options in "
+ "'volume set': %s",
+ errstr);
ret = -1;
goto out;
}
@@ -1162,7 +1197,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
snprintf (errstr, sizeof (errstr),
"Trash translator is not enabled. Use "
"volume set %s trash on", volname);
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_SET_FAIL,
"Unable to set the options in 'volume "
"set': %s", errstr);
ret = -1;
@@ -1171,7 +1207,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
ret = dict_set_str (val_dict, key, value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Unable to set the options in 'volume set'");
ret = -1;
goto out;
@@ -1193,7 +1230,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
}
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not create "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
+ "Could not create "
"temp volfile, some option failed: %s",
*op_errstr);
goto out;
@@ -1218,7 +1257,8 @@ cont:
ret = dict_set_uint32 (dict, "new-op-version",
local_new_op_version);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Failed to set new-op-version in dict");
goto out;
}
@@ -1231,7 +1271,8 @@ cont:
ret = dict_set_uint32 (dict, "check-op-version",
_gf_true);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Failed to set check-op-version in dict");
goto out;
}
@@ -1253,11 +1294,11 @@ out:
if (ret) {
if (!(*op_errstr)) {
*op_errstr = gf_strdup ("Error, Validation Failed");
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Error, Cannot Validate option :%s",
*op_errstr);
} else {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Error, Cannot Validate option");
}
}
@@ -1282,7 +1323,8 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
goto out;
}
@@ -1308,7 +1350,8 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr)
ret = dict_get_str (dict, "key", &key);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get option key");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get option key");
goto out;
}
if (strcmp(key, "all")) {
@@ -1342,7 +1385,7 @@ out:
*op_errstr = gf_strdup (msg);
}
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1408,7 +1451,7 @@ glusterd_op_stage_sync_volume (dict_t *dict, char **op_errstr)
}
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -1464,7 +1507,8 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
goto out;
}
@@ -1574,7 +1618,7 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr)
*op_errstr = gf_strdup ("Validation Failed for Status");
}
- gf_log (this->name, GF_LOG_DEBUG, "Returning: %d", ret);
+ gf_msg_debug (this->name, 0, "Returning: %d", ret);
return ret;
}
@@ -1659,7 +1703,8 @@ glusterd_op_stage_stats_volume (dict_t *dict, char **op_errstr)
if (_gf_false == glusterd_is_volume_started (volinfo)) {
snprintf (msg, sizeof (msg), "Volume %s is not started.",
volinfo->volname);
- gf_log ("glusterd", GF_LOG_ERROR, "%s", msg);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_STARTED, "%s", msg);
ret = -1;
goto out;
}
@@ -1670,7 +1715,7 @@ out:
gf_log ("glusterd", GF_LOG_ERROR, "%s", msg);
*op_errstr = gf_strdup (msg);
}
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -1696,7 +1741,7 @@ _delete_reconfig_opt (dict_t *this, char *key, data_t *value, void *data)
}
}
- gf_log ("", GF_LOG_DEBUG, "deleting dict with key=%s,value=%s",
+ gf_msg_debug ("glusterd", 0, "deleting dict with key=%s,value=%s",
key, value->data);
dict_del (this, key);
/**Delete scrubber (pause/resume) option from the dictionary if bitrot
@@ -1753,7 +1798,7 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key,
} else {
value = dict_get (volinfo->dict, key);
if (!value) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"no value set for option %s", key);
goto out;
}
@@ -1772,7 +1817,9 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key,
ret = glusterd_create_volfiles_and_notify_services (volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to create volfile for"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
+ "Unable to create volfile for"
" 'volume reset'");
ret = -1;
goto out;
@@ -1792,7 +1839,7 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key,
out:
GF_FREE (key_fixed);
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1814,7 +1861,8 @@ glusterd_op_reset_all_volume_options (xlator_t *this, dict_t *dict)
conf = this->private;
ret = dict_get_str (dict, "key", &key);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get key");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get key");
goto out;
}
@@ -1825,7 +1873,8 @@ glusterd_op_reset_all_volume_options (xlator_t *this, dict_t *dict)
if (strcmp (key, "all")) {
ret = glusterd_check_option_exists (key, &key_fixed);
if (ret <= 0) {
- gf_log (this->name, GF_LOG_ERROR, "Option %s does not "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "Option %s does not "
"exist", key);
ret = -1;
goto out;
@@ -1891,7 +1940,7 @@ out:
if (dup_opt)
dict_unref (dup_opt);
- gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret);
+ gf_msg_debug (this->name, 0, "returning %d", ret);
if (quorum_action)
glusterd_do_quorum_action ();
GF_FREE (next_version);
@@ -1913,7 +1962,8 @@ glusterd_op_reset_volume (dict_t *dict, char **op_rspstr)
this = THIS;
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name" );
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
goto out;
}
@@ -1928,20 +1978,23 @@ glusterd_op_reset_volume (dict_t *dict, char **op_rspstr)
ret = dict_get_str (dict, "key", &key);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get option key");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get option key");
goto out;
}
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS,
volname);
goto out;
}
if (strcmp (key, "all") &&
glusterd_check_option_exists (key, &key_fixed) != 1) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY,
"volinfo dict inconsistency: option %s not found",
key);
ret = -1;
@@ -1982,7 +2035,7 @@ out:
if (quorum_action)
glusterd_do_quorum_action ();
- gf_log (this->name, GF_LOG_DEBUG, "'volume reset' returning %d", ret);
+ gf_msg_debug (this->name, 0, "'volume reset' returning %d", ret);
return ret;
}
@@ -2012,7 +2065,8 @@ glusterd_start_bricks (glusterd_volinfo_t *volinfo)
cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
ret = glusterd_brick_start (volinfo, brickinfo, _gf_false);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_DISCONNECTED,
"Failed to start %s:%s for %s",
brickinfo->hostname, brickinfo->path,
volinfo->volname);
@@ -2047,14 +2101,16 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
ret = dict_get_str (dict, "value1", &value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"invalid key,value pair in 'volume set'");
goto out;
}
ret = glusterd_check_option_exists (key, &key_fixed);
if (ret <= 0) {
- gf_log (this->name, GF_LOG_ERROR, "Invalid key %s", key);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_UNKNOWN_KEY, "Invalid key %s", key);
ret = -1;
goto out;
}
@@ -2083,7 +2139,8 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict,
conf->op_version = op_version;
ret = glusterd_store_global_info (this);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_OP_VERS_STORE_FAIL,
"Failed to store op-version.");
}
}
@@ -2139,7 +2196,7 @@ out:
if (dup_opt)
dict_unref (dup_opt);
- gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret);
+ gf_msg_debug (this->name, 0, "returning %d", ret);
if (quorum_action)
glusterd_do_quorum_action ();
GF_FREE (next_version);
@@ -2253,14 +2310,17 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
ret = dict_get_int32 (dict, "count", &dict_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Count(dict),not set in Volume-Set");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
+ "Count(dict),not set in Volume-Set");
goto out;
}
if (dict_count == 0) {
ret = glusterd_volset_help (NULL, &op_errstr);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_SET_FAIL, "%s",
(op_errstr)? op_errstr:
"Volume set help internal error");
}
@@ -2271,7 +2331,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
goto out;
}
@@ -2283,7 +2344,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS,
volname);
goto out;
}
@@ -2295,7 +2357,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
if (check_op_version) {
ret = dict_get_uint32 (dict, "new-op-version", &new_op_version);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get new op-version from dict");
goto out;
}
@@ -2311,7 +2374,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
sprintf (str, "value%d", count);
ret = dict_get_str (dict, str, &value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"invalid key,value pair in 'volume set'");
ret = -1;
goto out;
@@ -2363,7 +2427,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
value = gf_strdup (value);
if (!value) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_SET_FAIL,
"Unable to set the options in 'volume set'");
ret = -1;
goto out;
@@ -2397,7 +2462,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
}
if (count == 1) {
- gf_log (this->name, GF_LOG_ERROR, "No options received ");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_OPTIONS_GIVEN, "No options received ");
ret = -1;
goto out;
}
@@ -2409,7 +2475,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
priv->op_version = new_op_version;
ret = glusterd_store_global_info (this);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_OP_VERS_STORE_FAIL,
"Failed to store op-version");
goto out;
}
@@ -2425,7 +2492,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
}
ret = glusterd_create_volfiles_and_notify_services (volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"Unable to create volfile for"
" 'volume set'");
ret = -1;
@@ -2439,7 +2507,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
if (GLUSTERD_STATUS_STARTED == volinfo->status) {
ret = glusterd_svcs_reconfigure (volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SVC_RESTART_FAIL,
"Unable to restart services");
goto out;
}
@@ -2460,7 +2529,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
ret = glusterd_create_volfiles_and_notify_services (volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"Unable to create volfile for"
" 'volume set'");
ret = -1;
@@ -2475,7 +2545,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
if (GLUSTERD_STATUS_STARTED == volinfo->status) {
ret = glusterd_svcs_reconfigure (volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_NFS_SERVER_START_FAIL,
"Unable to restart NFS-Server");
goto out;
}
@@ -2485,7 +2556,7 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)
out:
GF_FREE (key_fixed);
- gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret);
+ gf_msg_debug (this->name, 0, "returning %d", ret);
if (quorum_action)
glusterd_do_quorum_action ();
return ret;
@@ -2529,7 +2600,8 @@ glusterd_op_sync_volume (dict_t *dict, char **op_errstr,
if (!ret) {
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Volume with name: %s "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "Volume with name: %s "
"not exists", volname);
goto out;
}
@@ -2558,7 +2630,7 @@ glusterd_op_sync_volume (dict_t *dict, char **op_errstr,
ret = dict_set_int32 (rsp_dict, "count", vol_count);
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -2577,7 +2649,8 @@ glusterd_add_profile_volume_options (glusterd_volinfo_t *volinfo)
ret = dict_set_str (volinfo->dict, latency_key, "on");
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "failed to set the volume %s "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "failed to set the volume %s "
"option %s value %s",
volinfo->volname, latency_key, "on");
goto out;
@@ -2585,13 +2658,14 @@ glusterd_add_profile_volume_options (glusterd_volinfo_t *volinfo)
ret = dict_set_str (volinfo->dict, fd_stats_key, "on");
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "failed to set the volume %s "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "failed to set the volume %s "
"option %s value %s",
volinfo->volname, fd_stats_key, "on");
goto out;
}
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -2621,7 +2695,8 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr,
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "volume name get failed");
goto out;
}
@@ -2630,13 +2705,15 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr,
snprintf (msg, sizeof (msg), "Volume %s does not exists",
volname);
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "%s", msg);
goto out;
}
ret = dict_get_int32 (dict, "op", &stats_op);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "volume profile op get failed");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "volume profile op get failed");
goto out;
}
@@ -2658,7 +2735,8 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr,
break;
default:
GF_ASSERT (0);
- gf_log ("glusterd", GF_LOG_ERROR, "Invalid profile op: %d",
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "Invalid profile op: %d",
stats_op);
ret = -1;
goto out;
@@ -2667,8 +2745,10 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr,
ret = glusterd_create_volfiles_and_notify_services (volinfo);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to create volfile for"
- " 'volume set'");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
+ "Unable to create volfile for"
+ " 'volume set'");
ret = -1;
goto out;
}
@@ -2684,7 +2764,7 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr,
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -2710,7 +2790,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo,
ret = dict_get_int32 (volinfo->rebal.dict, "count", &count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Failed to get brick count");
goto out;
}
@@ -2718,7 +2799,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo,
snprintf (dict_key, sizeof (dict_key), "%s.count", prefix);
ret = dict_set_int32 (dict, dict_key, count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Failed to set brick count in dict");
goto out;
}
@@ -2729,7 +2811,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo,
ret = dict_get_str (volinfo->rebal.dict, brick_key, &brick);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get %s", brick_key);
goto out;
}
@@ -2739,7 +2822,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo,
brick_key);
ret = dict_set_str (dict, dict_key, brick);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Failed to add brick to dict");
goto out;
}
@@ -2774,7 +2858,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index)
snprintf (key, sizeof (key), "task%d", index);
ret = _add_remove_bricks_to_dict (dict, volinfo, key);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_ADD_REMOVE_BRICK_FAIL,
"Failed to add remove bricks to dict");
goto out;
}
@@ -2785,7 +2870,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index)
default:
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "%s operation doesn't have a"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_TASK_ID, "%s operation doesn't have a"
" task_id", gd_op_list[op]);
goto out;
}
@@ -2793,7 +2879,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index)
snprintf (key, sizeof (key), "task%d.type", index);
ret = dict_set_str (dict, key, (char *)gd_op_list[op]);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Error setting task type in dict");
goto out;
}
@@ -2805,7 +2892,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index)
goto out;
ret = dict_set_dynstr (dict, key, uuid_str);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Error setting task id in dict");
goto out;
}
@@ -2815,7 +2903,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index)
snprintf (key, sizeof (key), "task%d.status", index);
ret = dict_set_int32 (dict, key, status);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Error setting task status in dict");
goto out;
}
@@ -2840,7 +2929,8 @@ glusterd_aggregate_task_status (dict_t *rsp_dict, glusterd_volinfo_t *volinfo)
ret = _add_task_to_dict (rsp_dict, volinfo, volinfo->rebal.op,
tasks);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Failed to add task details to dict");
goto out;
}
@@ -2849,7 +2939,8 @@ glusterd_aggregate_task_status (dict_t *rsp_dict, glusterd_volinfo_t *volinfo)
ret = dict_set_int32 (rsp_dict, "tasks", tasks);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Error setting tasks count in dict");
goto out;
}
@@ -2901,7 +2992,8 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr,
if ((cmd & GF_CLI_STATUS_ALL)) {
ret = glusterd_get_all_volnames (rsp_dict);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLNAMES_GET_FAIL,
"failed to get all volume "
"names for status");
}
@@ -2920,7 +3012,8 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr,
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Volume with name: %s "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "Volume with name: %s "
"does not exist", volname);
goto out;
}
@@ -3114,19 +3207,22 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr,
ret = dict_set_int32 (rsp_dict, "brick-index-max", brick_index);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Error setting brick-index-max to dict");
goto out;
}
ret = dict_set_int32 (rsp_dict, "other-count", other_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Error setting other-count to dict");
goto out;
}
ret = dict_set_int32 (rsp_dict, "count", node_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Error setting node count to dict");
goto out;
}
@@ -3144,7 +3240,7 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr,
ret = 0;
out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -3154,7 +3250,7 @@ glusterd_op_ac_none (glusterd_op_sm_event_t *event, void *ctx)
{
int ret = 0;
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3210,7 +3306,8 @@ glusterd_op_ac_send_lock (glusterd_op_sm_event_t *event, void *ctx)
ret = proc->fn (NULL, this, peerinfo);
if (ret) {
rcu_read_unlock ();
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_LOCK_REQ_SEND_FAIL,
"Failed to send lock request "
"for operation 'Volume %s' to "
"peer %s",
@@ -3233,7 +3330,8 @@ glusterd_op_ac_send_lock (glusterd_op_sm_event_t *event, void *ctx)
peerinfo);
if (ret) {
rcu_read_unlock ();
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"failed to set peerinfo");
dict_unref (dict);
goto out;
@@ -3242,7 +3340,8 @@ glusterd_op_ac_send_lock (glusterd_op_sm_event_t *event, void *ctx)
ret = proc->fn (NULL, this, dict);
if (ret) {
rcu_read_unlock ();
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_MGMTV3_LOCK_REQ_SEND_FAIL,
"Failed to send mgmt_v3 lock "
"request for operation "
"'Volume %s' to peer %s",
@@ -3267,7 +3366,7 @@ out:
if (ret)
ret = glusterd_op_sm_locking_failed (&event->txn_id);
- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3370,7 +3469,7 @@ glusterd_op_ac_send_unlock (glusterd_op_sm_event_t *event, void *ctx)
if (!opinfo.pending_count)
ret = glusterd_op_sm_inject_all_acc (&event->txn_id);
- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3386,7 +3485,7 @@ glusterd_op_ac_ack_drain (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACK,
&event->txn_id, NULL);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3426,13 +3525,15 @@ glusterd_op_ac_lock (glusterd_op_sm_event_t *event, void *ctx)
} else {
ret = dict_get_str (lock_ctx->dict, "volname", &volname);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to acquire volname");
else {
ret = glusterd_mgmt_v3_lock (volname, lock_ctx->uuid,
&op_errno, "vol");
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MGMTV3_LOCK_GET_FAIL,
"Unable to acquire lock for %s",
volname);
goto out;
@@ -3454,7 +3555,7 @@ out:
dict_unref (lock_ctx->dict);
}
- gf_log (THIS->name, GF_LOG_DEBUG, "Lock Returned %d", ret);
+ gf_msg_debug (THIS->name, 0, "Lock Returned %d", ret);
return ret;
}
@@ -3486,13 +3587,15 @@ glusterd_op_ac_unlock (glusterd_op_sm_event_t *event, void *ctx)
} else {
ret = dict_get_str (lock_ctx->dict, "volname", &volname);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to acquire volname");
else {
ret = glusterd_mgmt_v3_unlock (volname, lock_ctx->uuid,
"vol");
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MGMTV3_UNLOCK_FAIL,
"Unable to release lock for %s",
volname);
goto out;
@@ -3515,7 +3618,7 @@ out:
dict_unref (lock_ctx->dict);
}
- gf_log (this->name, GF_LOG_DEBUG, "Unlock Returned %d", ret);
+ gf_msg_debug (this->name, 0, "Unlock Returned %d", ret);
if (priv->pending_quorum_action)
glusterd_do_quorum_action ();
@@ -3535,7 +3638,7 @@ glusterd_op_ac_local_unlock (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_unlock (*originator);
- gf_log (THIS->name, GF_LOG_DEBUG, "Unlock Returned %d", ret);
+ gf_msg_debug (THIS->name, 0, "Unlock Returned %d", ret);
return ret;
}
@@ -3556,7 +3659,7 @@ glusterd_op_ac_rcvd_lock_acc (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACC,
&event->txn_id, NULL);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
out:
return ret;
@@ -3658,7 +3761,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx)
op = glusterd_op_get_op ();
ctx = (void*)glusterd_op_get_ctx ();
if (!ctx) {
- gf_log (this->name, GF_LOG_ERROR, "Null Context for "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_OPTIONS_GIVEN, "Null Context for "
"op %d", op);
ret = -1;
goto out;
@@ -3668,7 +3772,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx)
#define GD_SYNC_OPCODE_KEY "sync-mgmt-operation"
ret = dict_get_int32 (op_ctx, GD_SYNC_OPCODE_KEY, (int32_t*)&op);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get volume"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get volume"
" operation");
goto out;
}
@@ -3684,7 +3789,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx)
ret = dict_set_int32 (dict, "port",
glusterfs_port);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Failed to set port in "
"dictionary");
goto out;
@@ -3714,7 +3820,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx)
{
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_CRITICAL,
+ gf_msg (this->name, GF_LOG_CRITICAL, 0,
+ GD_MSG_DICT_GET_FAILED,
"volname is not present in "
"operation ctx");
goto out;
@@ -3737,7 +3844,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx)
dict_t *dict = ctx;
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_CRITICAL,
+ gf_msg (this->name, GF_LOG_CRITICAL, 0,
+ GD_MSG_DICT_GET_FAILED,
"volname is not present in "
"operation ctx");
goto out;
@@ -3762,7 +3870,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx)
ret = dict_get_uint32 (dict, "cmd",
&status_cmd);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Status command not present "
"in op ctx");
goto out;
@@ -3875,14 +3984,18 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx)
rsp_dict = dict_new();
if (!rsp_dict) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to create rsp_dict");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_DICT_CREATE_FAIL,
+ "Failed to create rsp_dict");
ret = -1;
goto out;
}
ret = glusterd_op_build_payload (&dict, &op_errstr, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, LOGSTR_BUILD_PAYLOAD,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL,
+ LOGSTR_BUILD_PAYLOAD,
gd_op_list[op]);
if (op_errstr == NULL)
gf_asprintf (&op_errstr, OPERRSTR_BUILD_PAYLOAD);
@@ -3901,7 +4014,8 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_op_stage_validate (op, dict, &op_errstr, rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, LOGSTR_STAGE_FAIL,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VALIDATE_FAILED, LOGSTR_STAGE_FAIL,
gd_op_list[op], "localhost",
(op_errstr) ? ":" : " ", (op_errstr) ? op_errstr : " ");
if (op_errstr == NULL)
@@ -3934,14 +4048,16 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx)
ret = dict_set_static_ptr (dict, "peerinfo", peerinfo);
if (ret) {
rcu_read_unlock ();
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "failed to "
"set peerinfo");
goto out;
}
ret = proc->fn (NULL, this, dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_STAGE_REQ_SEND_FAIL, "Failed to "
"send stage request for operation "
"'Volume %s' to peer %s",
gd_op_list[op], peerinfo->hostname);
@@ -3965,14 +4081,14 @@ out:
opinfo.op_ret = ret;
}
- gf_log (this->name, GF_LOG_DEBUG, "Sent stage op request for "
+ gf_msg_debug (this->name, 0, "Sent stage op request for "
"'Volume %s' to %d peers", gd_op_list[op],
opinfo.pending_count);
if (!opinfo.pending_count)
ret = glusterd_op_sm_inject_all_acc (&event->txn_id);
- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
@@ -4006,7 +4122,7 @@ glusterd_op_volume_dict_uuid_to_hostname (dict_t *dict, const char *key_fmt,
if (ret)
continue;
- gf_log (this->name, GF_LOG_DEBUG, "Got uuid %s",
+ gf_msg_debug (this->name, 0, "Got uuid %s",
uuid_str);
ret = gf_uuid_parse (uuid_str, uuid);
@@ -4018,11 +4134,12 @@ glusterd_op_volume_dict_uuid_to_hostname (dict_t *dict, const char *key_fmt,
hostname = glusterd_uuid_to_hostname (uuid);
if (hostname) {
- gf_log (this->name, GF_LOG_DEBUG, "%s -> %s",
+ gf_msg_debug (this->name, 0, "%s -> %s",
uuid_str, hostname);
ret = dict_set_dynstr (dict, key, hostname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Error setting hostname %s to dict",
hostname);
GF_FREE (hostname);
@@ -4032,7 +4149,7 @@ glusterd_op_volume_dict_uuid_to_hostname (dict_t *dict, const char *key_fmt,
}
out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4066,7 +4183,8 @@ reassign_defrag_status (dict_t *dict, char *key, gf_defrag_status_t *status)
ret = dict_set_int32(dict, key, *status);
if (ret)
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_SET_FAILED,
"failed to reset defrag %s in dict", key);
return ret;
@@ -4088,13 +4206,15 @@ glusterd_op_check_peer_defrag_status (dict_t *dict, int count)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (THIS->name, GF_LOG_WARNING, "Unable to get volume name");
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
goto out;
}
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (THIS->name, GF_LOG_WARNING, FMTSTR_CHECK_VOL_EXISTS,
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS,
volname);
goto out;
}
@@ -4111,7 +4231,8 @@ glusterd_op_check_peer_defrag_status (dict_t *dict, int count)
snprintf (key, 256, "status-%d", i);
ret = dict_get_int32 (dict, key, (int32_t *)&status);
if (ret) {
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_GET_FAILED,
"failed to get defrag %s", key);
goto out;
}
@@ -4224,7 +4345,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
op_ctx = glusterd_op_get_ctx();
if (!op_ctx) {
- gf_log (this->name, GF_LOG_CRITICAL,
+ gf_msg (this->name, GF_LOG_CRITICAL, 0,
+ GD_MSG_OPCTX_NULL,
"Operation context is not present.");
goto out;
}
@@ -4233,13 +4355,13 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
case GD_OP_STATUS_VOLUME:
ret = dict_get_uint32 (op_ctx, "cmd", &cmd);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to get status cmd");
goto out;
}
if (!glusterd_is_volume_status_modify_op_ctx (cmd)) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"op_ctx modification not required for status "
"operation being performed");
goto out;
@@ -4248,14 +4370,14 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
ret = dict_get_int32 (op_ctx, "brick-index-max",
&brick_index_max);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to get brick-index-max");
goto out;
}
ret = dict_get_int32 (op_ctx, "other-count", &other_count);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to get other-count");
goto out;
}
@@ -4297,7 +4419,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
"brick%d.peerid", i);
uuid = gf_strdup (uuid_str);
if (!uuid) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"unable to create dup of"
" uuid_str");
continue;
@@ -4315,7 +4437,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
"brick%d.path",
0, count);
if (ret)
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_CONVERSION_FAILED,
"Failed uuid to hostname conversion");
break;
@@ -4327,7 +4450,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
ret = dict_get_int32 (op_ctx, "count", &count);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to get brick count");
goto out;
}
@@ -4336,7 +4459,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
"%d-brick",
1, (count + 1));
if (ret)
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_CONVERSION_FAILED,
"Failed uuid to hostname conversion");
break;
@@ -4347,7 +4471,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
case GD_OP_DEFRAG_BRICK_VOLUME:
ret = dict_get_int32 (op_ctx, "count", &count);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to get count");
goto out;
}
@@ -4370,7 +4494,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
"node-name-%d", i);
uuid = gf_strdup (uuid_str);
if (!uuid) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"unable to create dup of"
" uuid_str");
continue;
@@ -4388,18 +4512,20 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
"node-name-%d",
1, (count + 1));
if (ret)
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_CONVERSION_FAILED,
"Failed uuid to hostname conversion");
ret = glusterd_op_check_peer_defrag_status (op_ctx, count);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DEFRAG_STATUS_UPDATE_FAIL,
"Failed to reset defrag status for fix-layout");
break;
default:
ret = 0;
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"op_ctx modification not required");
break;
@@ -4407,7 +4533,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx)
out:
if (ret)
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_OPCTX_UPDATE_FAIL,
"op_ctx modification failed");
return;
}
@@ -4487,7 +4614,9 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_op_build_payload (&dict, &op_errstr, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, LOGSTR_BUILD_PAYLOAD,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL,
+ LOGSTR_BUILD_PAYLOAD,
gd_op_list[op]);
if (op_errstr == NULL)
gf_asprintf (&op_errstr, OPERRSTR_BUILD_PAYLOAD);
@@ -4497,7 +4626,8 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_op_commit_perform (op, dict, &op_errstr, NULL); //rsp_dict invalid for source
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, LOGSTR_COMMIT_FAIL,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_COMMIT_OP_FAIL, LOGSTR_COMMIT_FAIL,
gd_op_list[op], "localhost", (op_errstr) ? ":" : " ",
(op_errstr) ? op_errstr : " ");
if (op_errstr == NULL)
@@ -4527,13 +4657,16 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx)
ret = dict_set_static_ptr (dict, "peerinfo", peerinfo);
if (ret) {
rcu_read_unlock ();
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"failed to set peerinfo");
goto out;
}
ret = proc->fn (NULL, this, dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_COMMIT_REQ_SEND_FAIL,
+ "Failed to "
"send commit request for operation "
"'Volume %s' to peer %s",
gd_op_list[op], peerinfo->hostname);
@@ -4545,7 +4678,7 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx)
rcu_read_unlock ();
opinfo.pending_count = pending_count;
- gf_log (this->name, GF_LOG_DEBUG, "Sent commit op req for 'Volume %s' "
+ gf_msg_debug (this->name, 0, "Sent commit op req for 'Volume %s' "
"to %d peers", gd_op_list[op], opinfo.pending_count);
out:
if (dict)
@@ -4567,7 +4700,7 @@ out:
}
err:
- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
@@ -4590,7 +4723,7 @@ glusterd_op_ac_rcvd_stage_op_acc (glusterd_op_sm_event_t *event, void *ctx)
&event->txn_id, NULL);
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -4612,7 +4745,7 @@ glusterd_op_ac_stage_op_failed (glusterd_op_sm_event_t *event, void *ctx)
&event->txn_id, NULL);
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -4634,7 +4767,7 @@ glusterd_op_ac_commit_op_failed (glusterd_op_sm_event_t *event, void *ctx)
&event->txn_id, NULL);
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -4656,7 +4789,8 @@ glusterd_op_ac_brick_op_failed (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_remove_pending_entry (&opinfo.pending_bricks, ev_ctx->pending_node->node);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "unknown response received ");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_UNKNOWN_RESPONSE, "unknown response received ");
ret = -1;
free_errstr = _gf_true;
goto out;
@@ -4683,7 +4817,7 @@ out:
if (free_errstr && ev_ctx->op_errstr)
GF_FREE (ev_ctx->op_errstr);
GF_FREE (ctx);
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4710,7 +4844,8 @@ glusterd_op_ac_rcvd_commit_op_acc (glusterd_op_sm_event_t *event, void *ctx)
if (op == GD_OP_REPLACE_BRICK) {
ret = glusterd_op_sm_inject_all_acc (&event->txn_id);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Couldn't start "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_RBOP_START_FAIL, "Couldn't start "
"replace-brick operation.");
goto out;
}
@@ -4754,7 +4889,7 @@ glusterd_op_ac_rcvd_unlock_acc (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACC,
&event->txn_id, NULL);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
out:
return ret;
@@ -4824,14 +4959,16 @@ glusterd_op_txn_complete (uuid_t *txn_id)
ret = glusterd_unlock (MY_UUID);
/* unlock cant/shouldnt fail here!! */
if (ret)
- gf_log (this->name, GF_LOG_CRITICAL,
+ gf_msg (this->name, GF_LOG_CRITICAL, 0,
+ GD_MSG_GLUSTERD_UNLOCK_FAIL,
"Unable to clear local lock, ret: %d", ret);
else
- gf_log (this->name, GF_LOG_DEBUG, "Cleared local lock");
+ gf_msg_debug (this->name, 0, "Cleared local lock");
} else {
ret = dict_get_str (ctx, "volname", &volname);
if (ret)
- gf_log ("", GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_DICT_GET_FAILED,
"No Volume name present. "
"Locks have not been held.");
@@ -4839,7 +4976,8 @@ glusterd_op_txn_complete (uuid_t *txn_id)
ret = glusterd_mgmt_v3_unlock (volname, MY_UUID,
"vol");
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MGMTV3_UNLOCK_FAIL,
"Unable to release lock for %s",
volname);
}
@@ -4849,7 +4987,9 @@ glusterd_op_txn_complete (uuid_t *txn_id)
op_errno, req, ctx, op_errstr);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Responding to cli failed, "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_CLI_RESP,
+ "Responding to cli failed, "
"ret: %d", ret);
//Ignore this error, else state machine blocks
ret = 0;
@@ -4865,10 +5005,11 @@ glusterd_op_txn_complete (uuid_t *txn_id)
/* Clearing the transaction opinfo */
ret = glusterd_clear_txn_opinfo (txn_id);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_TRANS_OPINFO_CLEAR_FAIL,
"Unable to clear transaction's opinfo");
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4881,7 +5022,7 @@ glusterd_op_ac_unlocked_all (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_op_txn_complete (&event->txn_id);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -4908,7 +5049,8 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx)
rsp_dict = dict_new ();
if (!rsp_dict) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_DICT_CREATE_FAIL,
"Failed to get new dictionary");
return -1;
}
@@ -4917,7 +5059,8 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx)
rsp_dict);
if (status) {
- gf_log (this->name, GF_LOG_ERROR, "Stage failed on operation"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VALIDATE_FAILED, "Stage failed on operation"
" 'Volume %s', Status : %d", gd_op_list[req_ctx->op],
status);
}
@@ -4934,7 +5077,8 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx)
ret = dict_set_bin (rsp_dict, "transaction_id",
txn_id, sizeof(*txn_id));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Failed to set transaction id.");
goto out;
}
@@ -4946,7 +5090,7 @@ out:
if (op_errstr && (strcmp (op_errstr, "")))
GF_FREE (op_errstr);
- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
if (rsp_dict)
dict_unref (rsp_dict);
@@ -5030,7 +5174,8 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx)
}
if (status)
- gf_log (this->name, GF_LOG_ERROR, "Commit of operation "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_COMMIT_OP_FAIL, "Commit of operation "
"'Volume %s' failed: %d", gd_op_list[req_ctx->op],
status);
@@ -5046,7 +5191,8 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx)
ret = dict_set_bin (rsp_dict, "transaction_id",
txn_id, sizeof(*txn_id));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Failed to set transaction id.");
goto out;
}
@@ -5061,7 +5207,7 @@ out:
if (rsp_dict)
dict_unref (rsp_dict);
- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -5088,7 +5234,7 @@ glusterd_op_ac_send_commit_failed (glusterd_op_sm_event_t *event, void *ctx)
opinfo.op_errstr = NULL;
}
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning with %d", ret);
return ret;
}
@@ -5231,11 +5377,12 @@ glusterd_op_stage_validate (glusterd_op_t op, dict_t *dict, char **op_errstr,
break;
default:
- gf_log (this->name, GF_LOG_ERROR, "Unknown op %s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "Unknown op %s",
gd_op_list[op]);
}
- gf_log (this->name, GF_LOG_DEBUG, "OP = %d. Returning %d", op, ret);
+ gf_msg_debug (this->name, 0, "OP = %d. Returning %d", op, ret);
return ret;
}
@@ -5353,7 +5500,8 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr,
break;
default:
- gf_log (this->name, GF_LOG_ERROR, "Unknown op %s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "Unknown op %s",
gd_op_list[op]);
break;
}
@@ -5361,7 +5509,7 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr,
if (ret == 0)
glusterd_op_commit_hook (op, dict, GD_COMMIT_HOOK_POST);
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -5383,7 +5531,8 @@ glusterd_bricks_select_stop_volume (dict_t *dict, char **op_errstr,
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS,
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS,
volname);
gf_asprintf (op_errstr, FMTSTR_CHECK_VOL_EXISTS, volname);
goto out;
@@ -5430,26 +5579,29 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr,
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
goto out;
}
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to allocate memory");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "Unable to allocate memory");
goto out;
}
ret = dict_get_int32 (dict, "count", &count);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get count");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get count");
goto out;
}
ret = dict_get_int32 (dict, "command", &command);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get command");
+ gf_log ("glusterd", GF_LOG_ERROR, "Unable to get command");
goto out;
}
@@ -5458,7 +5610,8 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr,
ret = dict_get_int32 (dict, "force", &force);
if (ret) {
- gf_log (THIS->name, GF_LOG_INFO, "force flag is not set");
+ gf_msg (THIS->name, GF_LOG_INFO, 0,
+ GD_MSG_DICT_GET_FAILED, "force flag is not set");
ret = 0;
goto out;
}
@@ -5468,7 +5621,8 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr,
ret = dict_get_str (dict, key, &brick);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to get brick");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get brick");
goto out;
}
@@ -5524,7 +5678,8 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr,
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "volume name get failed");
goto out;
}
@@ -5534,13 +5689,15 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr,
volname);
*op_errstr = gf_strdup (msg);
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "%s", msg);
goto out;
}
ret = dict_get_int32 (dict, "op", &stats_op);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "volume profile op get failed");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "volume profile op get failed");
goto out;
}
@@ -5554,7 +5711,9 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr,
if (ret) {
if (!priv->nfs_svc.online) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "NFS server"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NFS_SERVER_NOT_RUNNING,
+ "NFS server"
" is not running");
goto out;
}
@@ -5597,7 +5756,9 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr,
if (ret) {
if (!priv->nfs_svc.online) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "NFS server"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NFS_SERVER_NOT_RUNNING,
+ "NFS server"
" is not running");
goto out;
}
@@ -5662,7 +5823,8 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr,
default:
GF_ASSERT (0);
- gf_log ("glusterd", GF_LOG_ERROR, "Invalid profile op: %d",
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "Invalid profile op: %d",
stats_op);
ret = -1;
goto out;
@@ -5671,7 +5833,7 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr,
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -5894,7 +6056,8 @@ glusterd_bricks_select_snap (dict_t *dict, char **op_errstr,
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get"
" volname");
goto out;
}
@@ -5924,7 +6087,7 @@ glusterd_bricks_select_snap (dict_t *dict, char **op_errstr,
ret = 0;
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning ret %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning ret %d", ret);
return ret;
}
@@ -5948,7 +6111,9 @@ fill_shd_status_for_local_bricks (dict_t *dict, glusterd_volinfo_t *volinfo,
cmd_replica_index = get_replica_index_for_per_replica_cmd
(volinfo, req_dict);
if (cmd_replica_index == -1) {
- gf_log (THIS->name, GF_LOG_ERROR, "Could not find the "
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_REPLICA_INDEX_GET_FAIL,
+ "Could not find the "
"replica index for per replica type command");
ret = -1;
goto out;
@@ -5976,14 +6141,16 @@ fill_shd_status_for_local_bricks (dict_t *dict, glusterd_volinfo_t *volinfo,
uuid_utoa(MY_UUID));
ret = dict_set_dynstr (dict, key, gf_strdup(value));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to"
"set the dictionary for shd status msg");
goto out;
}
snprintf (key, sizeof (key), "%d-shd-status",index);
ret = dict_set_str (dict, key, "off");
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to"
" set dictionary for shd status msg");
goto out;
}
@@ -6018,7 +6185,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr,
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "volume name get failed");
goto out;
}
@@ -6028,13 +6196,15 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr,
volname);
*op_errstr = gf_strdup (msg);
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "%s", msg);
goto out;
}
ret = dict_get_int32 (dict, "heal-op", (int32_t*)&heal_op);
if (ret || (heal_op == GF_SHD_OP_INVALID)) {
- gf_log ("glusterd", GF_LOG_ERROR, "heal op invalid");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "heal op invalid");
goto out;
}
@@ -6043,7 +6213,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr,
case GF_SHD_OP_STATISTICS_HEAL_COUNT:
if (!priv->shd_svc.online) {
if (!rsp_dict) {
- gf_log (this->name, GF_LOG_ERROR, "Received "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_OPCTX_NULL, "Received "
"empty ctx.");
goto out;
}
@@ -6053,7 +6224,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr,
ALL_HEAL_XL,
dict);
if (ret)
- gf_log (this->name, GF_LOG_ERROR, "Unable to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SHD_STATUS_SET_FAIL, "Unable to "
"fill the shd status for the local "
"bricks");
goto out;
@@ -6063,7 +6235,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr,
case GF_SHD_OP_STATISTICS_HEAL_COUNT_PER_REPLICA:
if (!priv->shd_svc.online) {
if (!rsp_dict) {
- gf_log (this->name, GF_LOG_ERROR, "Received "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_OPCTX_NULL, "Received "
"empty ctx.");
goto out;
}
@@ -6072,7 +6245,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr,
PER_HEAL_XL,
dict);
if (ret)
- gf_log (this->name, GF_LOG_ERROR, "Unable to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SHD_STATUS_SET_FAIL, "Unable to "
"fill the shd status for the local"
" bricks.");
goto out;
@@ -6106,7 +6280,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr,
if (!hxlator_count)
goto out;
if (hxlator_count == -1) {
- gf_log (this->name, GF_LOG_ERROR, "Could not determine the"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_XLATOR_COUNT_GET_FAIL, "Could not determine the"
"translator count");
ret = -1;
goto out;
@@ -6129,7 +6304,7 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr,
}
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning ret %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning ret %d", ret);
return ret;
}
@@ -6150,7 +6325,8 @@ glusterd_bricks_select_rebalance_volume (dict_t *dict, char **op_errstr,
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "volume name get failed");
goto out;
}
@@ -6160,7 +6336,8 @@ glusterd_bricks_select_rebalance_volume (dict_t *dict, char **op_errstr,
volname);
*op_errstr = gf_strdup (msg);
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "%s", msg);
goto out;
}
pending_node = GF_CALLOC (1, sizeof (*pending_node),
@@ -6204,7 +6381,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr,
ret = dict_get_int32 (dict, "cmd", &cmd);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get status type");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get status type");
goto out;
}
@@ -6229,7 +6407,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr,
}
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get volname");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get volname");
goto out;
}
ret = glusterd_volinfo_find (volname, &volinfo);
@@ -6240,7 +6419,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr,
if ( (cmd & GF_CLI_STATUS_BRICK) != 0) {
ret = dict_get_str (dict, "brick", &brickname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get brick");
goto out;
}
@@ -6269,7 +6449,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr,
} else if ((cmd & GF_CLI_STATUS_NFS) != 0) {
if (!priv->nfs_svc.online) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NFS_SERVER_NOT_RUNNING,
"NFS server is not running");
goto out;
}
@@ -6288,7 +6469,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr,
} else if ((cmd & GF_CLI_STATUS_SHD) != 0) {
if (!priv->shd_svc.online) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SELF_HEALD_DISABLED,
"Self-heal daemon is not running");
goto out;
}
@@ -6306,7 +6488,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr,
ret = 0;
} else if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) {
if (!priv->quotad_svc.online) {
- gf_log (this->name, GF_LOG_ERROR, "Quotad is not "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_QUOTAD_NOT_RUNNING, "Quotad is not "
"running");
ret = -1;
goto out;
@@ -6363,7 +6546,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr,
ret = 0;
} else if ((cmd & GF_CLI_STATUS_SNAPD) != 0) {
if (!volinfo->snapd.svc.online) {
- gf_log (this->name, GF_LOG_ERROR, "snapd is not "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPD_NOT_RUNNING, "snapd is not "
"running");
ret = -1;
goto out;
@@ -6371,7 +6555,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr,
pending_node = GF_CALLOC (1, sizeof (*pending_node),
gf_gld_mt_pending_node_t);
if (!pending_node) {
- gf_log (this->name, GF_LOG_ERROR, "failed to allocate "
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "failed to allocate "
"memory for pending node");
ret = -1;
goto out;
@@ -6395,7 +6580,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr,
gf_gld_mt_pending_node_t);
if (!pending_node) {
ret = -1;
- gf_log (THIS->name ,GF_LOG_ERROR,
+ gf_msg (THIS->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY,
"Unable to allocate memory");
goto out;
}
@@ -6427,13 +6613,15 @@ glusterd_bricks_select_barrier (dict_t *dict, struct cds_list_head *selected)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to get volname");
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get volname");
goto out;
}
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to find volume %s",
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "Failed to find volume %s",
volname);
goto out;
}
@@ -6456,7 +6644,7 @@ glusterd_bricks_select_barrier (dict_t *dict, struct cds_list_head *selected)
}
out:
- gf_log(THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -6485,7 +6673,9 @@ glusterd_op_ac_send_brick_op (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_op_build_payload (&req_ctx->dict, &op_errstr,
NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, LOGSTR_BUILD_PAYLOAD,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL,
+ LOGSTR_BUILD_PAYLOAD,
gd_op_list[op]);
if (op_errstr == NULL)
gf_asprintf (&op_errstr,
@@ -6509,7 +6699,7 @@ glusterd_op_ac_send_brick_op (glusterd_op_sm_event_t *event, void *ctx)
}
out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -6545,7 +6735,8 @@ glusterd_op_ac_rcvd_brick_op_acc (glusterd_op_sm_event_t *event, void *ctx)
ret = glusterd_remove_pending_entry (&opinfo.pending_bricks,
pending_entry);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "unknown response received ");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_UNKNOWN_RESPONSE, "unknown response received ");
ret = -1;
goto out;
}
@@ -6566,7 +6757,7 @@ out:
if (ev_ctx->rsp_dict)
dict_unref (ev_ctx->rsp_dict);
GF_FREE (ev_ctx);
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -6623,7 +6814,7 @@ glusterd_op_bricks_select (glusterd_op_t op, dict_t *dict, char **op_errstr,
break;
}
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -6958,7 +7149,7 @@ glusterd_op_sm_inject_event (glusterd_op_sm_event_type_t event_type,
if (txn_id)
gf_uuid_copy (event->txn_id, *txn_id);
- gf_log (THIS->name, GF_LOG_DEBUG, "Enqueue event: '%s'",
+ gf_msg_debug (THIS->name, 0, "Enqueue event: '%s'",
glusterd_op_sm_event_name_get (event->event));
cds_list_add_tail (&event->list, &gd_op_sm_queue);
@@ -7026,7 +7217,8 @@ glusterd_op_sm ()
ret = synclock_trylock (&gd_op_sm_lock);
if (ret) {
lock_err = errno;
- gf_log (this->name, GF_LOG_ERROR, "lock failed due to %s",
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_LOCK_FAIL, "lock failed due to %s",
strerror (lock_err));
goto lock_failed;
}
@@ -7038,17 +7230,18 @@ glusterd_op_sm ()
cds_list_del_init (&event->list);
event_type = event->event;
- gf_log (this->name, GF_LOG_DEBUG, "Dequeued event of "
+ gf_msg_debug (this->name, 0, "Dequeued event of "
"type: '%s'",
glusterd_op_sm_event_name_get(event_type));
- gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s",
+ gf_msg_debug (this->name, 0, "transaction ID = %s",
uuid_utoa (event->txn_id));
ret = glusterd_get_txn_opinfo (&event->txn_id,
&txn_op_info);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_TRANS_OPINFO_GET_FAIL,
"Unable to get transaction's opinfo");
glusterd_destroy_op_event_ctx (event);
GF_FREE (event);
@@ -7066,7 +7259,8 @@ glusterd_op_sm ()
ret = handler (event, event->ctx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_HANDLER_RETURNED,
"handler returned: %d", ret);
glusterd_destroy_op_event_ctx (event);
GF_FREE (event);
@@ -7077,7 +7271,8 @@ glusterd_op_sm ()
event_type);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_EVENT_STATE_TRANSITION_FAIL,
"Unable to transition"
"state from '%s' to '%s'",
glusterd_op_sm_state_name_get(opinfo.state.state),
@@ -7092,14 +7287,16 @@ glusterd_op_sm ()
/* Clearing the transaction opinfo */
ret = glusterd_clear_txn_opinfo(&event->txn_id);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_TRANS_OPINFO_CLEAR_FAIL,
"Unable to clear "
"transaction's opinfo");
} else {
ret = glusterd_set_txn_opinfo (&event->txn_id,
&opinfo);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_TRANS_OPINFO_SET_FAIL,
"Unable to set "
"transaction's opinfo");
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index 6f41b7b..1a90aae 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -170,7 +170,9 @@ glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid)
*/
ret = dict_set_static_ptr (friends, "peerinfo", peerinfo);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "failed to set peerinfo");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "failed to set peerinfo");
goto unlock;
}
@@ -182,7 +184,7 @@ glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid)
unlock:
rcu_read_unlock ();
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
out:
if (friends)
@@ -197,7 +199,7 @@ glusterd_ac_none (glusterd_friend_sm_event_t *event, void *ctx)
{
int ret = 0;
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -207,7 +209,8 @@ glusterd_ac_error (glusterd_friend_sm_event_t *event, void *ctx)
{
int ret = 0;
- gf_log ("", GF_LOG_ERROR, "Received event %d ", event->event);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_AC_ERROR, "Received event %d ", event->event);
return ret;
}
@@ -227,7 +230,8 @@ glusterd_ac_reverse_probe_begin (glusterd_friend_sm_event_t *event, void *ctx)
peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!peerinfo) {
- gf_log (THIS->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
ret = -1;
goto out;
@@ -237,7 +241,9 @@ glusterd_ac_reverse_probe_begin (glusterd_friend_sm_event_t *event, void *ctx)
(GD_FRIEND_EVENT_PROBE, &new_event);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to get new new_event");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_EVENT_NEW_GET_FAIL,
+ "Unable to get new new_event");
ret = -1;
goto out;
}
@@ -260,8 +266,10 @@ glusterd_ac_reverse_probe_begin (glusterd_friend_sm_event_t *event, void *ctx)
ret = glusterd_friend_sm_inject_event (new_event);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to inject new_event %d, "
- "ret = %d", new_event->event, ret);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_EVENT_INJECT_FAIL,
+ "Unable to inject new_event %d, "
+ "ret = %d", new_event->event, ret);
}
out:
@@ -275,7 +283,7 @@ out:
GF_FREE (new_ev_ctx->hostname);
GF_FREE (new_ev_ctx);
}
- gf_log ("", GF_LOG_DEBUG, "returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "returning with %d", ret);
return ret;
}
@@ -300,7 +308,9 @@ glusterd_ac_friend_add (glusterd_friend_sm_event_t *event, void *ctx)
peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!peerinfo) {
- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND,
+ "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
goto out;
}
@@ -320,7 +330,7 @@ glusterd_ac_friend_add (glusterd_friend_sm_event_t *event, void *ctx)
out:
rcu_read_unlock ();
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -382,7 +392,9 @@ glusterd_ac_friend_probe (glusterd_friend_sm_event_t *event, void *ctx)
*/
ret = dict_set_static_ptr (dict, "peerinfo", peerinfo);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "failed to set peerinfo");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "failed to set peerinfo");
goto out;
}
@@ -397,7 +409,7 @@ out:
if (dict)
dict_unref (dict);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -427,7 +439,8 @@ glusterd_ac_send_friend_remove_req (glusterd_friend_sm_event_t *event,
peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!peerinfo) {
- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
goto out;
}
@@ -443,8 +456,9 @@ glusterd_ac_send_friend_remove_req (glusterd_friend_sm_event_t *event,
gf_uuid_copy (new_event->peerid, peerinfo->uuid);
ret = glusterd_friend_sm_inject_event (new_event);
} else {
- gf_log ("glusterd", GF_LOG_ERROR,
- "Unable to get event");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_EVENT_NEW_GET_FAIL,
+ "Unable to get event");
}
if (ctx) {
@@ -473,7 +487,7 @@ glusterd_ac_send_friend_remove_req (glusterd_friend_sm_event_t *event,
out:
rcu_read_unlock ();
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -516,7 +530,8 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
cur_peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!cur_peerinfo) {
- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
ret = -1;
goto out;
@@ -559,7 +574,9 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
ret = dict_set_static_ptr (friends, "peerinfo", peerinfo);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "failed to set peerinfo");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "failed to set peerinfo");
goto out;
}
@@ -569,7 +586,7 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
}
}
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
out:
rcu_read_unlock ();
@@ -606,7 +623,8 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv)
"Deleting stale volume %s", volinfo->volname);
ret = glusterd_delete_volume (volinfo);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_STALE_VOL_REMOVE_FAIL,
"Error deleting stale volume");
goto out;
}
@@ -614,7 +632,7 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv)
}
ret = 0;
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -662,7 +680,8 @@ glusterd_ac_handle_friend_remove_req (glusterd_friend_sm_event_t *event,
ret = glusterd_peer_detach_cleanup (priv);
if (ret) {
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ GD_MSG_PEER_DETACH_CLEANUP_FAIL,
"Peer detach cleanup was not successful");
ret = 0;
}
@@ -671,7 +690,7 @@ out:
GF_FREE (new_event->peername);
GF_FREE (new_event);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning with %d", ret);
return ret;
}
@@ -687,7 +706,9 @@ glusterd_ac_friend_remove (glusterd_friend_sm_event_t *event, void *ctx)
peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!peerinfo) {
- gf_log (THIS->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND,
+ "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
rcu_read_unlock ();
goto out;
@@ -704,7 +725,9 @@ glusterd_ac_friend_remove (glusterd_friend_sm_event_t *event, void *ctx)
ret = glusterd_peerinfo_cleanup (peerinfo);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Cleanup returned: %d", ret);
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_DETACH_CLEANUP_FAIL,
+ "Cleanup returned: %d", ret);
}
out:
return 0;
@@ -747,7 +770,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx)
rcu_read_lock ();
peerinfo = glusterd_peerinfo_find (event->peerid, event->peername);
if (!peerinfo) {
- gf_log (this->name, GF_LOG_ERROR, "Could not find peer %s(%s)",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND, "Could not find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
ret = -1;
rcu_read_unlock ();
@@ -792,7 +816,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx)
(conf->op_version >= GD_OP_VERSION_RHS_3_0)) {
ret = glusterd_import_friend_missed_snap_list (ev_ctx->vols);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MISSED_SNAP_LIST_STORE_FAIL,
"Failed to import peer's "
"missed_snaps_list.");
event_type = GD_FRIEND_EVENT_LOCAL_RJT;
@@ -810,7 +835,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx)
event->peername,
event->peerid);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_COMPARE_CONFLICT,
"Conflict in comparing peer's snapshots");
event_type = GD_FRIEND_EVENT_LOCAL_RJT;
op_errno = GF_PROBE_SNAP_CONFLICT;
@@ -821,7 +847,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx)
ret = glusterd_friend_sm_new_event (event_type, &new_event);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Out of Memory");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out of Memory");
}
new_event->peername = gf_strdup (event->peername);
@@ -861,7 +888,7 @@ out:
GF_FREE (new_event->peername);
GF_FREE (new_event);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -1112,7 +1139,7 @@ int
glusterd_friend_sm_inject_event (glusterd_friend_sm_event_t *event)
{
GF_ASSERT (event);
- gf_log ("glusterd", GF_LOG_DEBUG, "Enqueue event: '%s'",
+ gf_msg_debug ("glusterd", 0, "Enqueue event: '%s'",
glusterd_friend_sm_event_name_get (event->event));
cds_list_add_tail (&event->list, &gd_friend_sm_queue);
@@ -1195,7 +1222,8 @@ glusterd_friend_sm ()
peerinfo = glusterd_peerinfo_find (event->peerid,
event->peername);
if (!peerinfo) {
- gf_log ("glusterd", GF_LOG_CRITICAL, "Received"
+ gf_msg ("glusterd", GF_LOG_CRITICAL, 0,
+ GD_MSG_PEER_NOT_FOUND, "Received"
" event %s with empty peer info",
glusterd_friend_sm_event_name_get (event_type));
@@ -1203,7 +1231,7 @@ glusterd_friend_sm ()
rcu_read_unlock ();
continue;
}
- gf_log ("", GF_LOG_DEBUG, "Dequeued event of type: '%s'",
+ gf_msg_debug ("glusterd", 0, "Dequeued event of type: '%s'",
glusterd_friend_sm_event_name_get (event_type));
@@ -1232,7 +1260,9 @@ glusterd_friend_sm ()
}
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "handler returned: "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_HANDLER_RETURNED,
+ "handler returned: "
"%d", ret);
glusterd_destroy_friend_event_context (event);
GF_FREE (event);
@@ -1251,7 +1281,9 @@ glusterd_friend_sm ()
event_type);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to transition"
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_EVENT_STATE_TRANSITION_FAIL,
+ "Unable to transition"
" state from '%s' to '%s' for event '%s'",
glusterd_friend_sm_state_name_get(old_state),
glusterd_friend_sm_state_name_get(state[event_type].next_state),
@@ -1275,7 +1307,8 @@ glusterd_friend_sm ()
* something has gone terribly wrong.
*/
ret = -1;
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_PEER_NOT_FOUND,
"Cannot find peer %s(%s)",
event->peername, uuid_utoa (event->peerid));
goto out;
--
1.7.1