summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-handshake.c
diff options
context:
space:
mode:
authorNandaja Varma <nandaja.varma@gmail.com>2015-03-12 16:55:20 +0530
committerAtin Mukherjee <amukherj@redhat.com>2015-06-14 23:55:59 -0700
commit40795d95697068a0beb52364b97818dc80e49440 (patch)
treed276ec63dfa8ab197110550ef8f3f77c7a61a5d4 /xlators/mgmt/glusterd/src/glusterd-handshake.c
parent2ae034374ce449c54b1b4ae8350401371db1d8d3 (diff)
handshake,locks,mountbroker,syncop/glusterd:New logging framework
Change-Id: If491a6945b7a0afa10165ff9f9874a244aece36f BUG: 1194640 Signed-off-by: Nandaja Varma <nandaja.varma@gmail.com> Reviewed-on: http://review.gluster.org/9864 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-handshake.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c265
1 files changed, 174 insertions, 91 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index 0cb92abca16..52df83f426c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -21,6 +21,7 @@
#include "glusterd-svc-mgmt.h"
#include "glusterd-snapd-svc-helper.h"
#include "glusterd-quotad-svc.h"
+#include "glusterd-messages.h"
#include "glusterfs3.h"
#include "protocol-common.h"
@@ -70,20 +71,25 @@ get_snap_volname_and_volinfo (const char *volpath, char **volname,
strtok_r (str_token, "/", &save_ptr);
snapname = strtok_r(NULL, "/", &save_ptr);
if (!snapname) {
- gf_log(this->name, GF_LOG_ERROR, "Invalid path: %s", volpath);
+ gf_msg(this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY,
+ "Invalid path: %s", volpath);
goto out;
}
volname_token = strtok_r(NULL, "/", &save_ptr);
if (!volname_token) {
- gf_log(this->name, GF_LOG_ERROR, "Invalid path: %s", volpath);
+ gf_msg (this->name, GF_LOG_ERROR,
+ EINVAL, GD_MSG_INVALID_ENTRY,
+ "Invalid path: %s", volpath);
goto out;
}
snap = glusterd_find_snap_by_name (snapname);
if (!snap) {
- gf_log(this->name, GF_LOG_ERROR, "Failed to "
- "fetch snap %s", snapname);
+ gf_msg(this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND, "Failed to "
+ "fetch snap %s", snapname);
goto out;
}
@@ -105,14 +111,16 @@ get_snap_volname_and_volinfo (const char *volpath, char **volname,
/* Split the volume name */
vol = strtok_r (volname_token, ".", &save_ptr);
if (!vol) {
- gf_log(this->name, GF_LOG_ERROR, "Invalid "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Invalid "
"volname (%s)", volname_token);
goto out;
}
ret = glusterd_snap_volinfo_find (vol, snap, volinfo);
if (ret) {
- gf_log(this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg(this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_INFO_FAIL, "Failed to "
"fetch snap volume from volname (%s)",
vol);
goto out;
@@ -123,9 +131,10 @@ get_snap_volname_and_volinfo (const char *volpath, char **volname,
ret = glusterd_snap_volinfo_find_from_parent_volname (
volname_token, snap, volinfo);
if (ret) {
- gf_log(this->name, GF_LOG_ERROR, "Failed to "
- "fetch snap volume from parent "
- "volname (%s)", volname_token);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_INFO_FAIL, "Failed to "
+ "fetch snap volume from parent "
+ "volname (%s)", volname_token);
goto out;
}
@@ -182,7 +191,8 @@ build_volfile_path (char *volume_id, char *path,
ret = glusterd_volinfo_find (volid_ptr, &volinfo);
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_GET_FAIL,
"Couldn't find volinfo");
goto out;
}
@@ -219,7 +229,8 @@ build_volfile_path (char *volume_id, char *path,
ret = get_snap_volname_and_volinfo (volid_ptr, &volname,
&volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get snap"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_INFO_FAIL, "Failed to get snap"
" volinfo from path (%s)", volume_id);
ret = -1;
goto out;
@@ -247,7 +258,8 @@ build_volfile_path (char *volume_id, char *path,
ret = glusterd_volinfo_find (volid_ptr, &volinfo);
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_GET_FAIL,
"Couldn't find volinfo");
goto out;
}
@@ -366,7 +378,8 @@ glusterd_get_args_from_dict (gf_getspec_req *args, peer_info_t *peerinfo,
ret = dict_unserialize (args->xdata.xdata_val,
args->xdata.xdata_len, &dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_UNSERIALIZE_FAIL,
"Failed to unserialize request dictionary");
goto out;
}
@@ -374,7 +387,8 @@ glusterd_get_args_from_dict (gf_getspec_req *args, peer_info_t *peerinfo,
ret = dict_get_int32 (dict, "min-op-version",
&client_min_op_version);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Failed to get client-min-op-version");
goto out;
}
@@ -382,7 +396,8 @@ glusterd_get_args_from_dict (gf_getspec_req *args, peer_info_t *peerinfo,
ret = dict_get_int32 (dict, "max-op-version",
&client_max_op_version);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Failed to get client-max-op-version");
goto out;
}
@@ -390,13 +405,13 @@ glusterd_get_args_from_dict (gf_getspec_req *args, peer_info_t *peerinfo,
ret = dict_get_str (dict, "brick_name",
brick_name);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"No brick name present");
ret = 0;
goto out;
}
- gf_log (this->name, GF_LOG_DEBUG, "brick_name = %s", *brick_name);
+ gf_msg_debug (this->name, 0, "brick_name = %s", *brick_name);
out:
peerinfo->max_op_version = client_max_op_version;
peerinfo->min_op_version = client_min_op_version;
@@ -434,7 +449,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
/* Find the snap-object */
snap = glusterd_find_snap_by_id (snap_uuid);
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_NOT_FOUND,
"Unable to find the snap with snap_uuid %s",
missed_snapinfo->snap_uuid);
ret = -1;
@@ -451,7 +467,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
}
if (!snap_vol) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND,
"Unable to find the snap_vol(%s) "
"for snap(%s)", snap_opinfo->snap_vol_id,
snap->snapname);
@@ -467,7 +484,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
}
if (brickinfo->snap_status != -1) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_STATUS_NOT_PENDING,
"The snap status of the missed "
"brick(%s) is not pending", brickinfo->path);
goto out;
@@ -476,7 +494,9 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
/* Fetch the device path */
device = glusterd_get_brick_mount_device (snap_opinfo->brick_path);
if (!device) {
- gf_log (this->name, GF_LOG_ERROR, "Getting device name for the"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_GET_INFO_FAIL,
+ "Getting device name for the"
"brick %s:%s failed", brickinfo->hostname,
snap_opinfo->brick_path);
ret = -1;
@@ -486,7 +506,9 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
device = glusterd_build_snap_device_path (device, snap_vol->volname,
snap_opinfo->brick_num - 1);
if (!device) {
- gf_log (this->name, GF_LOG_ERROR, "cannot copy the snapshot "
+ gf_msg (this->name, GF_LOG_ERROR, ENXIO,
+ GD_MSG_SNAP_DEVICE_NAME_GET_FAIL,
+ "cannot copy the snapshot "
"device name (volname: %s, snapname: %s)",
snap_vol->volname, snap->snapname);
ret = -1;
@@ -499,7 +521,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
* snap volinfo. */
ret = glusterd_update_mntopts (snap_opinfo->brick_path, brickinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to update "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRK_MOUNTOPTS_FAIL, "Failed to update "
"mount options for %s brick", brickinfo->path);
/* We should not fail snapshot operation if we fail to get
* the file-system type */
@@ -507,7 +530,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
ret = glusterd_take_lvm_snapshot (brickinfo, snap_opinfo->brick_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED,
"Failed to take snapshot of %s",
snap_opinfo->brick_path);
goto out;
@@ -520,7 +544,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
*/
ret = glusterd_update_fs_label (brickinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to update "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_SET_INFO_FAIL, "Failed to update "
"file-system label for %s brick", brickinfo->path);
/* Failing to update label should not cause snapshot failure.
* Currently label is updated only for XFS and ext2/ext3/ext4
@@ -532,7 +557,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
ret = glusterd_snap_brick_create (snap_vol, brickinfo,
snap_opinfo->brick_num - 1);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_CREATION_FAIL, "Failed to "
" create and mount the brick(%s) for the snap %s",
snap_opinfo->brick_path,
snap_vol->snapshot->snapname);
@@ -543,7 +569,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
ret = glusterd_store_volinfo (snap_vol,
GLUSTERD_VOLINFO_VER_AC_NONE);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to store snapshot "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_STORE_FAIL, "Failed to store snapshot "
"volinfo (%s) for snap %s", snap_vol->volname,
snap->snapname);
goto out;
@@ -551,7 +578,8 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
ret = glusterd_brick_start (snap_vol, brickinfo, _gf_false);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "starting the "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_BRICK_DISCONNECTED, "starting the "
"brick %s:%s for the snap %s failed",
brickinfo->hostname, brickinfo->path,
snap->snapname);
@@ -610,8 +638,9 @@ glusterd_take_missing_brick_snapshots (char *brick_name)
(missed_snapinfo,
snap_opinfo);
if (ret) {
- gf_log (this->name,
- GF_LOG_ERROR,
+ gf_msg (this->name,
+ GF_LOG_ERROR, 0,
+ GD_MSG_MISSED_SNAP_CREATE_FAIL,
"Failed to create "
"missed snap for %s",
brick_name);
@@ -642,7 +671,8 @@ glusterd_take_missing_brick_snapshots (char *brick_name)
if (update_list == _gf_true) {
ret = glusterd_store_update_missed_snaps ();
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 update missed_snaps_list");
goto out;
}
@@ -678,7 +708,8 @@ _client_supports_volume (peer_info_t *peerinfo, int32_t *op_errno)
(peerinfo->max_op_version < volinfo->client_op_version))) {
ret = _gf_false;
*op_errno = ENOTSUP;
- gf_log ("glusterd", GF_LOG_INFO,
+ gf_msg ("glusterd", GF_LOG_INFO, ENOTSUP,
+ GD_MSG_UNSUPPORTED_VERSION,
"Client %s (%d -> %d) doesn't support required "
"op-version (%d). Rejecting volfile request.",
peerinfo->identifier, peerinfo->min_op_version,
@@ -733,7 +764,8 @@ __server_getspec (rpcsvc_request_t *req)
ret = glusterd_get_args_from_dict (&args, peerinfo, &brick_name);
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 args from dict");
goto fail;
}
@@ -773,7 +805,8 @@ __server_getspec (rpcsvc_request_t *req)
/* to allocate the proper buffer to hold the file data */
ret = stat (filename, &stbuf);
if (ret < 0){
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED,
"Unable to stat %s (%s)",
filename, strerror (errno));
goto fail;
@@ -781,7 +814,8 @@ __server_getspec (rpcsvc_request_t *req)
spec_fd = open (filename, O_RDONLY);
if (spec_fd < 0) {
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED,
"Unable to open %s (%s)",
filename, strerror (errno));
goto fail;
@@ -803,11 +837,12 @@ __server_getspec (rpcsvc_request_t *req)
}
if (brick_name) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Look for missing snap creates for %s", brick_name);
op_ret = glusterd_take_missing_brick_snapshots (brick_name);
if (op_ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MISSED_SNAP_CREATE_FAIL,
"Failed to take missing brick snapshots");
ret = -1;
goto fail;
@@ -867,14 +902,17 @@ __server_event_notify (rpcsvc_request_t *req)
ret = dict_unserialize (args.dict.dict_val,
args.dict.dict_len, &dict);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Failed to unserialize req");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_UNSERIALIZE_FAIL,
+ "Failed to unserialize req");
goto fail;
}
}
switch (args.op) {
case GF_EN_DEFRAG_STATUS:
- gf_log ("", GF_LOG_INFO,
+ gf_msg ("glusterd", GF_LOG_INFO, 0,
+ GD_MSG_DEFRAG_STATUS_UPDATED,
"received defrag status updated");
if (dict) {
glusterd_defrag_event_notify_handle (dict);
@@ -882,7 +920,8 @@ __server_event_notify (rpcsvc_request_t *req)
}
break;
default:
- gf_log ("", GF_LOG_ERROR, "Unknown op received in event "
+ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL,
+ GD_MSG_OP_UNSUPPORTED, "Unknown op received in event "
"notify");
ret = -1;
break;
@@ -920,7 +959,8 @@ gd_validate_cluster_op_version (xlator_t *this, int cluster_op_version,
conf = this->private;
if (cluster_op_version > GD_OP_VERSION_MAX) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_OP_VERSION_MISMATCH,
"operating version %d is more than the maximum "
"supported (%d) on the machine (as per peer request "
"from %s)", cluster_op_version, GD_OP_VERSION_MAX,
@@ -934,7 +974,8 @@ gd_validate_cluster_op_version (xlator_t *this, int cluster_op_version,
*/
if ((cluster_op_version < conf->op_version) &&
!cds_list_empty (&conf->volumes)) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_OP_VERS_ADJUST_FAIL,
"cannot reduce operating version to %d from current "
"version %d as volumes exist (as per peer request from "
"%s)", cluster_op_version, conf->op_version, peerid);
@@ -995,7 +1036,8 @@ gd_validate_mgmt_hndsk_req (rpcsvc_request_t *req, dict_t *dict)
rcu_read_unlock ();
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Rejecting management "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_HANDSHAKE_REQ_REJECTED, "Rejecting management "
"handshake request from unknown peer %s",
req->trans->peerinfo.identifier);
return _gf_false;
@@ -1043,7 +1085,8 @@ __glusterd_mgmt_hndsk_versions (rpcsvc_request_t *req)
ret = dict_set_int32 (dict, GD_OP_VERSION_KEY, conf->op_version);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_SET_FAILED,
"failed to set operating version");
rsp.op_ret = ret;
goto out;
@@ -1051,7 +1094,8 @@ __glusterd_mgmt_hndsk_versions (rpcsvc_request_t *req)
ret = dict_set_int32 (dict, GD_MIN_OP_VERSION_KEY, GD_OP_VERSION_MIN);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_SET_FAILED,
"failed to set %s", GD_MIN_OP_VERSION_KEY);
rsp.op_ret = ret;
goto out;
@@ -1059,7 +1103,8 @@ __glusterd_mgmt_hndsk_versions (rpcsvc_request_t *req)
ret = dict_set_int32 (dict, GD_MAX_OP_VERSION_KEY, GD_OP_VERSION_MAX);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_SET_FAILED,
"failed to set %s", GD_MAX_OP_VERSION_KEY);
rsp.op_ret = ret;
goto out;
@@ -1127,7 +1172,8 @@ __glusterd_mgmt_hndsk_versions_ack (rpcsvc_request_t *req)
ret = dict_get_int32 (clnt_dict, GD_OP_VERSION_KEY, &peer_op_version);
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 the op-version key peer=%s",
req->trans->peerinfo.identifier);
goto out;
@@ -1142,12 +1188,15 @@ __glusterd_mgmt_hndsk_versions_ack (rpcsvc_request_t *req)
/* As this is ACK from the Cluster for the versions supported,
can set the op-version of 'this' glusterd to the one
received. */
- gf_log (this->name, GF_LOG_INFO, "using the op-version %d",
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_VERS_INFO, "using the op-version %d",
peer_op_version);
conf->op_version = peer_op_version;
ret = glusterd_store_global_info (this);
if (ret)
- gf_log (this->name, GF_LOG_ERROR, "Failed to store op-version");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLOBAL_OP_VERSION_SET_FAIL,
+ "Failed to store op-version");
out:
rsp.op_ret = ret;
@@ -1195,13 +1244,15 @@ __server_get_volume_info (rpcsvc_request_t *req)
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_log ("glusterd", GF_LOG_INFO, "Received get volume info req");
+ gf_msg ("glusterd", GF_LOG_INFO, 0,
+ GD_MSG_VOL_INFO_REQ_RECVD, "Received get volume info req");
if (vol_info_req.dict.dict_len) {
/* Unserialize the dictionary */
dict = dict_new ();
if (!dict) {
- gf_log ("", GF_LOG_WARNING, "Out of Memory");
+ gf_msg ("glusterd", GF_LOG_WARNING, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out of Memory");
op_errno = ENOMEM;
ret = -1;
goto out;
@@ -1211,7 +1262,8 @@ __server_get_volume_info (rpcsvc_request_t *req)
vol_info_req.dict.dict_len,
&dict);
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_UNSERIALIZE_FAIL,
"failed to "
"unserialize req-buffer to dictionary");
op_errno = -ret;
@@ -1224,7 +1276,8 @@ __server_get_volume_info (rpcsvc_request_t *req)
ret = dict_get_int32 (dict, "flags", &flags);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "failed to get flags");
+ gf_msg (THIS->name, GF_LOG_ERROR, -ret,
+ GD_MSG_DICT_GET_FAILED, "failed to get flags");
op_errno = -ret;
ret = -1;
goto out;
@@ -1232,7 +1285,8 @@ __server_get_volume_info (rpcsvc_request_t *req)
if (!flags) {
/* Nothing to query about. Just return success */
- gf_log (THIS->name, GF_LOG_ERROR, "No flags set");
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_FLAG_SET, "No flags set");
ret = 0;
goto out;
}
@@ -1261,7 +1315,8 @@ __server_get_volume_info (rpcsvc_request_t *req)
dict_rsp = dict_new ();
if (!dict_rsp) {
- gf_log ("", GF_LOG_WARNING, "Out of Memory");
+ gf_msg ("glusterd", GF_LOG_WARNING, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out of Memory");
op_errno = ENOMEM;
ret = -1;
goto out;
@@ -1332,7 +1387,8 @@ __server_get_snap_info (rpcsvc_request_t *req)
(xdrproc_t)xdr_gf_getsnap_name_uuid_req);
if (ret < 0) {
req->rpc_err = GARBAGE_ARGS;
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_REQ_DECODE_FAIL,
"Failed to decode management handshake response");
goto out;
}
@@ -1349,7 +1405,8 @@ __server_get_snap_info (rpcsvc_request_t *req)
snap_info_req.dict.dict_len,
&dict);
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL,
+ GD_MSG_DICT_UNSERIALIZE_FAIL,
"Failed to unserialize dictionary");
op_errno = EINVAL;
ret = -1;
@@ -1362,7 +1419,8 @@ __server_get_snap_info (rpcsvc_request_t *req)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
op_errno = EINVAL;
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL,
+ GD_MSG_DICT_GET_FAILED,
"Failed to retrieve volname");
ret = -1;
goto out;
@@ -1379,7 +1437,8 @@ __server_get_snap_info (rpcsvc_request_t *req)
&snap_info_rsp);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND,
"Error getting snapshot volume names and uuids : %s",
volname);
op_errno = EINVAL;
@@ -1508,7 +1567,8 @@ glusterd_event_connected_inject (glusterd_peerctx_t *peerctx)
(GD_FRIEND_EVENT_CONNECTED, &event);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get new event");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_EVENT_NEW_GET_FAIL, "Unable to get new event");
goto out;
}
@@ -1516,7 +1576,8 @@ glusterd_event_connected_inject (glusterd_peerctx_t *peerctx)
if (!ctx) {
ret = -1;
- gf_log ("", GF_LOG_ERROR, "Memory not available");
+ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Memory not available");
goto out;
}
@@ -1525,7 +1586,8 @@ glusterd_event_connected_inject (glusterd_peerctx_t *peerctx)
peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
ret = -1;
- 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)",
peerctx->peername, uuid_utoa (peerctx->peerid));
goto unlock;
}
@@ -1541,13 +1603,14 @@ glusterd_event_connected_inject (glusterd_peerctx_t *peerctx)
ret = glusterd_friend_sm_inject_event (event);
if (ret)
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to inject "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_EVENT_INJECT_FAIL, "Unable to inject "
"EVENT_CONNECTED ret = %d", ret);
unlock:
rcu_read_unlock ();
out:
- gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "returning %d", ret);
return ret;
}
@@ -1593,7 +1656,7 @@ gd_validate_peer_op_version (xlator_t *this, glusterd_peerinfo_t *peerinfo,
ret = 0;
out:
- gf_log (this->name , GF_LOG_DEBUG, "Peer %s %s", peerinfo->hostname,
+ gf_msg_debug (this->name , 0, "Peer %s %s", peerinfo->hostname,
((ret < 0) ? "rejected" : "accepted"));
return ret;
}
@@ -1618,7 +1681,7 @@ __glusterd_mgmt_hndsk_version_ack_cbk (struct rpc_req *req, struct iovec *iov,
rcu_read_lock ();
peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
- gf_log (this->name, GF_LOG_DEBUG, "Could not find peer %s(%s)",
+ gf_msg_debug (this->name, 0, "Could not find peer %s(%s)",
peerctx->peername, uuid_utoa (peerctx->peerid));
ret = -1;
goto out;
@@ -1627,7 +1690,8 @@ __glusterd_mgmt_hndsk_version_ack_cbk (struct rpc_req *req, struct iovec *iov,
if (-1 == req->rpc_status) {
snprintf (msg, sizeof (msg),
"Error through RPC layer, retry again later");
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_RPC_LAYER_ERROR, "%s", msg);
peerctx->errstr = gf_strdup (msg);
goto out;
}
@@ -1635,7 +1699,8 @@ __glusterd_mgmt_hndsk_version_ack_cbk (struct rpc_req *req, struct iovec *iov,
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_mgmt_hndsk_rsp);
if (ret < 0) {
snprintf (msg, sizeof (msg), "Failed to decode XDR");
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_REQ_DECODE_FAIL, "%s", msg);
peerctx->errstr = gf_strdup (msg);
goto out;
}
@@ -1645,7 +1710,8 @@ __glusterd_mgmt_hndsk_version_ack_cbk (struct rpc_req *req, struct iovec *iov,
ret = -1;
snprintf (msg, sizeof (msg),
"Failed to get handshake ack from remote server");
- gf_log (frame->this->name, GF_LOG_ERROR, "%s", msg);
+ gf_msg (frame->this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_HANDSHAKE_ACK, "%s", msg);
peerctx->errstr = gf_strdup (msg);
goto out;
}
@@ -1665,7 +1731,8 @@ __glusterd_mgmt_hndsk_version_ack_cbk (struct rpc_req *req, struct iovec *iov,
} else if (GD_MODE_SWITCH_ON == peerctx->args.mode) {
peerctx->args.mode = GD_MODE_ON;
} else {
- gf_log (this->name, GF_LOG_WARNING, "unknown mode %d",
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_UNKNOWN_MODE, "unknown mode %d",
peerctx->args.mode);
}
@@ -1723,7 +1790,7 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov,
peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
ret = -1;
- gf_log (this->name, GF_LOG_DEBUG, "Could not find peer %s(%s)",
+ gf_msg_debug (this->name, 0, "Could not find peer %s(%s)",
peerctx->peername, uuid_utoa (peerctx->peerid));
goto out;
}
@@ -1732,7 +1799,8 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov,
ret = -1;
snprintf (msg, sizeof (msg),
"Error through RPC layer, retry again later");
- gf_log (this->name, GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_RPC_LAYER_ERROR, "%s", msg);
peerctx->errstr = gf_strdup (msg);
goto out;
}
@@ -1741,7 +1809,8 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov,
if (ret < 0) {
snprintf (msg, sizeof (msg), "Failed to decode management "
"handshake response");
- gf_log (this->name, GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_REQ_DECODE_FAIL, "%s", msg);
peerctx->errstr = gf_strdup (msg);
goto out;
}
@@ -1752,7 +1821,8 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov,
op_errno = rsp.op_errno;
if (-1 == rsp.op_ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, op_errno,
+ GD_MSG_VERS_GET_FAIL,
"failed to get the 'versions' from peer (%s)",
req->conn->trans->peerinfo.identifier);
goto out;
@@ -1762,7 +1832,8 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov,
ret = gd_validate_peer_op_version (this, peerinfo, dict,
&peerctx->errstr);
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_OP_VERSION_MISMATCH,
"failed to validate the operating version of peer (%s)",
peerinfo->hostname);
goto out;
@@ -1774,7 +1845,8 @@ __glusterd_mgmt_hndsk_version_cbk (struct rpc_req *req, struct iovec *iov,
ret = dict_set_int32 (rsp_dict, GD_OP_VERSION_KEY, conf->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 operating version in dict");
goto out;
}
@@ -1844,7 +1916,8 @@ glusterd_mgmt_handshake (xlator_t *this, glusterd_peerctx_t *peerctx)
ret = dict_set_dynstr (req_dict, GD_PEER_ID_KEY,
gf_strdup (uuid_utoa (MY_UUID)));
if (ret) {
- gf_log(this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DICT_SET_FAILED,
"failed to set peer ID in dict");
goto out;
}
@@ -1856,7 +1929,7 @@ glusterd_mgmt_handshake (xlator_t *this, glusterd_peerctx_t *peerctx)
peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
- gf_log (THIS->name, GF_LOG_DEBUG, "Could not find peer %s(%s)",
+ gf_msg_debug (THIS->name, 0, "Could not find peer %s(%s)",
peerctx->peername, uuid_utoa (peerctx->peerid));
goto unlock;
}
@@ -1903,7 +1976,7 @@ glusterd_set_clnt_mgmt_program (glusterd_peerinfo_t *peerinfo,
}
if (ret) {
- gf_log ("", GF_LOG_DEBUG,
+ gf_msg_debug ("glusterd", 0,
"%s (%"PRId64":%"PRId64") not supported",
trav->progname, trav->prognum,
trav->progver);
@@ -1913,21 +1986,24 @@ glusterd_set_clnt_mgmt_program (glusterd_peerinfo_t *peerinfo,
}
if (peerinfo->mgmt) {
- gf_log ("", GF_LOG_INFO,
+ gf_msg ("glusterd", GF_LOG_INFO, 0,
+ GD_MSG_VERS_INFO,
"Using Program %s, Num (%d), Version (%d)",
peerinfo->mgmt->progname, peerinfo->mgmt->prognum,
peerinfo->mgmt->progver);
}
if (peerinfo->peer) {
- gf_log ("", GF_LOG_INFO,
+ gf_msg ("glusterd", GF_LOG_INFO, 0,
+ GD_MSG_VERS_INFO,
"Using Program %s, Num (%d), Version (%d)",
peerinfo->peer->progname, peerinfo->peer->prognum,
peerinfo->peer->progver);
}
if (peerinfo->mgmt_v3) {
- gf_log ("", GF_LOG_INFO,
+ gf_msg ("glusterd", GF_LOG_INFO, 0,
+ GD_MSG_VERS_INFO,
"Using Program %s, Num (%d), Version (%d)",
peerinfo->mgmt_v3->progname,
peerinfo->mgmt_v3->prognum,
@@ -1985,7 +2061,7 @@ __glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov,
peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
- gf_log (this->name, GF_LOG_DEBUG, "Couldn't find peer %s(%s)",
+ gf_msg_debug (this->name, 0, "Couldn't find peer %s(%s)",
peerctx->peername, uuid_utoa (peerctx->peerid));
goto out;
}
@@ -1993,7 +2069,8 @@ __glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov,
if (-1 == req->rpc_status) {
snprintf (msg, sizeof (msg),
"Error through RPC layer, retry again later");
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_RPC_LAYER_ERROR, "%s", msg);
peerctx->errstr = gf_strdup (msg);
goto out;
}
@@ -2001,20 +2078,22 @@ __glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov,
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_dump_rsp);
if (ret < 0) {
snprintf (msg, sizeof (msg), "Failed to decode XDR");
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_REQ_DECODE_FAIL, "%s", msg);
peerctx->errstr = gf_strdup (msg);
goto out;
}
if (-1 == rsp.op_ret) {
snprintf (msg, sizeof (msg),
"Failed to get the 'versions' from remote server");
- gf_log (frame->this->name, GF_LOG_ERROR, "%s", msg);
+ gf_msg (frame->this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VERS_GET_FAIL, "%s", msg);
peerctx->errstr = gf_strdup (msg);
goto out;
}
if (_mgmt_hndsk_prog_present (rsp.prog)) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Proceeding to op-version handshake with peer %s",
peerinfo->hostname);
ret = glusterd_mgmt_handshake (this, peerctx);
@@ -2025,14 +2104,17 @@ __glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov,
"Peer %s does not support required op-version",
peerinfo->hostname);
peerctx->errstr = gf_strdup (msg);
- gf_log (this->name, GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VERSION_UNSUPPORTED, "%s", msg);
goto out;
}
/* Make sure we assign the proper program to peer */
ret = glusterd_set_clnt_mgmt_program (peerinfo, rsp.prog);
if (ret) {
- gf_log ("", GF_LOG_WARNING, "failed to set the mgmt program");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_MGMT_PGM_SET_FAIL,
+ "failed to set the mgmt program");
goto out;
}
@@ -2044,7 +2126,8 @@ __glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov,
} else if (GD_MODE_SWITCH_ON == peerctx->args.mode) {
peerctx->args.mode = GD_MODE_ON;
} else {
- gf_log ("", GF_LOG_WARNING, "unknown mode %d",
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_UNKNOWN_MODE, "unknown mode %d",
peerctx->args.mode);
}
@@ -2106,7 +2189,7 @@ glusterd_peer_dump_version (xlator_t *this, struct rpc_clnt *rpc,
peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
if (!peerinfo) {
- gf_log (this->name, GF_LOG_DEBUG, "Couldn't find peer %s(%s)",
+ gf_msg_debug (this->name, 0, "Couldn't find peer %s(%s)",
peerctx->peername, uuid_utoa (peerctx->peerid));
goto unlock;
}