summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNandaja Varma <nandaja.varma@gmail.com>2015-03-04 17:07:53 +0530
committerVijay Bellur <vbellur@redhat.com>2015-05-05 06:04:57 -0700
commit1a89389834b646acaecf4791eeec9d29b6be6f1f (patch)
treeb5f42545c60c53685d38ae751221bb58b02dc4ec
parentedfe56dfd8ceb4ef0c160484de04af30e8f5b7df (diff)
Snapshot: New logging framework implementation of snapshot messages.
Backport of: http://review.gluster.org/9796 Change-Id: I3e8b5f6ae59d16752beb8053c2afddfb5c00be14 BUG: 1194640 Signed-off-by: Nandaja Varma <nandaja.varma@gmail.com> Reviewed-on: http://review.gluster.org/9796 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/10405 Reviewed-by: Sakshi Bansal
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c559
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c1670
2 files changed, 1455 insertions, 774 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
index 1da8a5b4490..5bd4d4109e0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
@@ -31,6 +31,7 @@
#include "glusterd-snapd-svc-helper.h"
#include "glusterd-snapshot-utils.h"
#include "glusterd-server-quorum.h"
+#include "glusterd-messages.h"
/*
* glusterd_snap_geo_rep_restore:
@@ -62,7 +63,7 @@ glusterd_snap_geo_rep_restore (glusterd_volinfo_t *snap_volinfo,
geo_rep_indexing_on = glusterd_volinfo_get_boolean (new_volinfo,
VKEY_MARKER_XTIME);
if (geo_rep_indexing_on == -1) {
- gf_log (this->name, GF_LOG_DEBUG, "Failed"
+ gf_msg_debug (this->name, 0, "Failed"
" to check whether geo-rep-indexing enabled or not");
ret = 0;
goto out;
@@ -77,7 +78,8 @@ glusterd_snap_geo_rep_restore (glusterd_volinfo_t *snap_volinfo,
PATH_MAX - strlen(snap_tstamp_file) - 1);
ret = gf_set_timestamp (snap_tstamp_file, vol_tstamp_file);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_TSTAMP_SET_FAIL,
"Unable to set atime and mtime of %s as of %s",
vol_tstamp_file, snap_tstamp_file);
goto out;
@@ -126,7 +128,8 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict,
brick_count++;
ret = glusterd_brickinfo_new (&new_brickinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to create "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_NEW_INFO_FAIL, "Failed to create "
"new brickinfo");
goto out;
}
@@ -134,7 +137,8 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict,
/* Duplicate brickinfo */
ret = glusterd_brickinfo_dup (brickinfo, new_brickinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to dup "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_SET_INFO_FAIL, "Failed to dup "
"brickinfo");
goto out;
}
@@ -188,7 +192,8 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict,
sizeof (new_volinfo->volume_id),
XATTR_REPLACE);
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SETXATTR_FAIL, "Failed to "
"set extended attribute %s on %s. "
"Reason: %s, snap: %s",
GF_XATTR_VOL_ID_KEY,
@@ -210,7 +215,8 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict,
brick_count,
GF_SNAP_OPTION_TYPE_RESTORE);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MISSEDSNAP_INFO_SET_FAIL,
"Failed to add missed snapshot info "
"for %s:%s in the rsp_dict",
brickinfo->hostname,
@@ -228,7 +234,8 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict,
/* Regenerate all volfiles */
ret = glusterd_create_volfiles_and_notify_services (new_volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"Failed to regenerate volfiles");
goto out;
}
@@ -236,7 +243,8 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict,
/* Restore geo-rep marker.tstamp's timestamp */
ret = glusterd_snap_geo_rep_restore (snap_volinfo, new_volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_TSTAMP_SET_FAIL,
"Geo-rep: marker.tstamp's timestamp restoration failed");
goto out;
}
@@ -265,7 +273,8 @@ glusterd_snap_volinfo_find_by_volume_id (uuid_t volume_id,
GF_ASSERT (volinfo);
if (gf_uuid_is_null(volume_id)) {
- gf_log (this->name, GF_LOG_WARNING, "Volume UUID is NULL");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_UUID_NULL, "Volume UUID is NULL");
goto out;
}
@@ -279,9 +288,10 @@ glusterd_snap_volinfo_find_by_volume_id (uuid_t volume_id,
}
}
- gf_log (this->name, GF_LOG_WARNING, "Snap volume not found");
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_SNAP_NOT_FOUND,
+ "Snap volume not found");
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -308,10 +318,11 @@ glusterd_snap_volinfo_find (char *snap_volname, glusterd_snap_t *snap,
}
}
- gf_log (this->name, GF_LOG_WARNING, "Snap volume %s not found",
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND, "Snap volume %s not found",
snap_volname);
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -339,11 +350,11 @@ glusterd_snap_volinfo_find_from_parent_volname (char *origin_volname,
}
}
- gf_log (this->name, GF_LOG_DEBUG, "Snap volume not found(snap: %s, "
+ gf_msg_debug (this->name, 0, "Snap volume not found(snap: %s, "
"origin-volume: %s", snap->snapname, origin_volname);
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -378,7 +389,8 @@ gd_add_brick_snap_details_to_dict (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.snap_status", prefix);
ret = dict_set_int32 (dict, key, brickinfo->snap_status);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_STATUS_FAIL,
"Failed to set snap_status for %s:%s",
brickinfo->hostname, brickinfo->path);
goto out;
@@ -388,7 +400,8 @@ gd_add_brick_snap_details_to_dict (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.device_path", prefix);
ret = dict_set_str (dict, key, brickinfo->device_path);
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 snap_device for %s:%s",
brickinfo->hostname, brickinfo->path);
goto out;
@@ -397,7 +410,8 @@ gd_add_brick_snap_details_to_dict (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.fs_type", prefix);
ret = dict_set_str (dict, key, brickinfo->fstype);
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 fstype for %s:%s",
brickinfo->hostname, brickinfo->path);
goto out;
@@ -406,7 +420,8 @@ gd_add_brick_snap_details_to_dict (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.mnt_opts", prefix);
ret = dict_set_str (dict, key, brickinfo->mnt_opts);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRK_MOUNTOPTS_FAIL,
"Failed to set mnt_opts for %s:%s",
brickinfo->hostname, brickinfo->path);
goto out;
@@ -416,7 +431,8 @@ gd_add_brick_snap_details_to_dict (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.mount_dir", prefix);
ret = dict_set_str (dict, key, brickinfo->mount_dir);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Failed to set mount_dir for %s:%s",
brickinfo->hostname, brickinfo->path);
@@ -457,7 +473,8 @@ gd_add_vol_snap_details_to_dict (dict_t *dict, char *prefix,
(dict, key,
uuid_utoa (volinfo->restored_from_snap));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set %s for volume"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to set %s for volume"
"%s", key, volinfo->volname);
goto out;
}
@@ -468,7 +485,8 @@ gd_add_vol_snap_details_to_dict (dict_t *dict, char *prefix,
ret = dict_set_dynstr_with_alloc (dict, key,
volinfo->parent_volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set %s "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to set %s "
"for volume %s", key, volinfo->volname);
goto out;
}
@@ -478,7 +496,8 @@ gd_add_vol_snap_details_to_dict (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.is_snap_volume", prefix);
ret = dict_set_uint32 (dict, key, volinfo->is_snap_volume);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set %s for volume"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to set %s for volume"
"%s", key, volinfo->volname);
goto out;
}
@@ -487,7 +506,8 @@ gd_add_vol_snap_details_to_dict (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.snap-max-hard-limit", prefix);
ret = dict_set_uint64 (dict, key, volinfo->snap_max_hard_limit);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set %s for volume"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to set %s for volume"
"%s", key, volinfo->volname);
}
@@ -534,7 +554,8 @@ glusterd_add_missed_snaps_to_export_dict (dict_t *peer_data)
ret = dict_set_dynstr_with_alloc (peer_data, name_buf,
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 %s",
name_buf);
goto out;
@@ -546,13 +567,14 @@ glusterd_add_missed_snaps_to_export_dict (dict_t *peer_data)
ret = dict_set_int32 (peer_data, "missed_snap_count",
missed_snap_count);
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 missed_snap_count");
goto out;
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -581,7 +603,8 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
ret = glusterd_add_volume_to_dict (volinfo, peer_data,
volcount, prefix);
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 snap:%s volume:%s "
"to peer_data dict for handshake",
snap->snapname, volinfo->volname);
@@ -595,7 +618,8 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
volcount,
prefix);
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 quota conf for "
"snap:%s volume:%s to peer_data "
"dict for handshake", snap->snapname,
@@ -616,7 +640,8 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
snprintf (buf, sizeof(buf), "%s.host_bricks", prefix);
ret = dict_set_int8 (peer_data, buf, (int8_t) host_bricks);
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 host_bricks for snap %s",
snap->snapname);
goto out;
@@ -625,7 +650,8 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
snprintf (buf, sizeof(buf), "%s.volcount", prefix);
ret = dict_set_int32 (peer_data, buf, volcount);
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 volcount for snap %s",
snap->snapname);
goto out;
@@ -634,7 +660,8 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
snprintf (buf, sizeof(buf), "%s.snapname", prefix);
ret = dict_set_dynstr_with_alloc (peer_data, buf, snap->snapname);
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 snapname for snap %s",
snap->snapname);
goto out;
@@ -644,7 +671,8 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
ret = dict_set_dynstr_with_alloc (peer_data, buf,
uuid_utoa (snap->snap_id));
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 snap_id for snap %s",
snap->snapname);
goto out;
@@ -655,7 +683,8 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
ret = dict_set_dynstr_with_alloc (peer_data, buf,
snap->description);
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 description for snap %s",
snap->snapname);
goto out;
@@ -665,7 +694,8 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
snprintf (buf, sizeof(buf), "%s.time_stamp", prefix);
ret = dict_set_int64 (peer_data, buf, (int64_t)snap->time_stamp);
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 time_stamp for snap %s",
snap->snapname);
goto out;
@@ -674,7 +704,8 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
snprintf (buf, sizeof(buf), "%s.snap_restored", prefix);
ret = dict_set_int8 (peer_data, buf, snap->snap_restored);
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 snap_restored for snap %s",
snap->snapname);
goto out;
@@ -683,13 +714,14 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
snprintf (buf, sizeof(buf), "%s.snap_status", prefix);
ret = dict_set_int32 (peer_data, buf, snap->snap_status);
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 snap_status for snap %s",
snap->snapname);
goto out;
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -712,7 +744,8 @@ glusterd_add_snapshots_to_export_dict (dict_t *peer_data)
snap_count++;
ret = glusterd_add_snap_to_dict (snap, peer_data, snap_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 add snap(%s) to the "
" peer_data dict for handshake",
snap->snapname);
@@ -722,12 +755,13 @@ glusterd_add_snapshots_to_export_dict (dict_t *peer_data)
ret = dict_set_int32 (peer_data, "snap_count", snap_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap_count");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snap_count");
goto out;
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -765,7 +799,8 @@ gd_import_new_brick_snap_details (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.snap_status", prefix);
ret = dict_get_int32 (dict, key, &brickinfo->snap_status);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s missing in payload", key);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "%s missing in payload", key);
goto out;
}
@@ -773,7 +808,8 @@ gd_import_new_brick_snap_details (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.device_path", prefix);
ret = dict_get_str (dict, key, &snap_device);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s missing in payload", key);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "%s missing in payload", key);
goto out;
}
strcpy (brickinfo->device_path, snap_device);
@@ -781,7 +817,8 @@ gd_import_new_brick_snap_details (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.fs_type", prefix);
ret = dict_get_str (dict, key, &fs_type);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s missing in payload", key);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "%s missing in payload", key);
goto out;
}
strcpy (brickinfo->fstype, fs_type);
@@ -789,7 +826,8 @@ gd_import_new_brick_snap_details (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.mnt_opts", prefix);
ret = dict_get_str (dict, key, &mnt_opts);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s missing in payload", key);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "%s missing in payload", key);
goto out;
}
strcpy (brickinfo->mnt_opts, mnt_opts);
@@ -798,7 +836,9 @@ gd_import_new_brick_snap_details (dict_t *dict, char *prefix,
snprintf (key, sizeof (key), "%s.mount_dir", prefix);
ret = dict_get_str (dict, key, &mount_dir);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s missing in payload", key);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
+ "%s missing in payload", key);
goto out;
}
strcpy (brickinfo->mount_dir, mount_dir);
@@ -842,7 +882,8 @@ gd_import_volume_snap_details (dict_t *dict, glusterd_volinfo_t *volinfo,
snprintf (key, sizeof (key), "%s.is_snap_volume", prefix);
ret = dict_get_uint32 (dict, key, &volinfo->is_snap_volume);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s missing in payload "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "%s missing in payload "
"for %s", key, volname);
goto out;
}
@@ -851,7 +892,8 @@ gd_import_volume_snap_details (dict_t *dict, glusterd_volinfo_t *volinfo,
snprintf (key, sizeof (key), "%s.restored_from_snap", prefix);
ret = dict_get_str (dict, key, &restored_snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s missing in payload "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "%s missing in payload "
"for %s", key, volname);
goto out;
}
@@ -863,7 +905,8 @@ gd_import_volume_snap_details (dict_t *dict, glusterd_volinfo_t *volinfo,
ret = dict_get_uint64 (dict, key,
&volinfo->snap_max_hard_limit);
if (ret)
- gf_log (this->name, GF_LOG_ERROR, "%s missing in payload "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "%s missing in payload "
"for %s", key, volname);
out:
return ret;
@@ -891,7 +934,8 @@ glusterd_perform_missed_op (glusterd_snap_t *snap, int32_t op)
dict = dict_new();
if (!dict) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to create dict");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_CREATE_FAIL, "Unable to create dict");
ret = -1;
goto out;
}
@@ -900,7 +944,8 @@ glusterd_perform_missed_op (glusterd_snap_t *snap, int32_t op)
case GF_SNAP_OPTION_TYPE_DELETE:
ret = glusterd_snap_remove (dict, snap, _gf_true, _gf_false);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_REMOVE_FAIL,
"Failed to remove snap");
goto out;
}
@@ -916,7 +961,8 @@ glusterd_perform_missed_op (glusterd_snap_t *snap, int32_t op)
ret = glusterd_volinfo_find (parent_volname, &volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_GET_FAIL,
"Could not get volinfo of %s",
parent_volname);
goto out;
@@ -935,7 +981,8 @@ glusterd_perform_missed_op (glusterd_snap_t *snap, int32_t op)
ret = gd_restore_snap_volume (dict, dict, volinfo,
snap_volinfo, 0);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_RESTORE_FAIL,
"Failed to restore snap for %s",
snap->snapname);
volinfo->version++;
@@ -949,7 +996,8 @@ glusterd_perform_missed_op (glusterd_snap_t *snap, int32_t op)
ret = glusterd_lvm_snapshot_remove (dict,
volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_REMOVE_FAIL,
"Failed to remove LVM backend");
goto out;
}
@@ -965,7 +1013,8 @@ glusterd_perform_missed_op (glusterd_snap_t *snap, int32_t op)
parent_volname,
snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CLEANUP_FAIL,
"Failed to perform snapshot restore "
"cleanup for %s volume",
parent_volname);
@@ -981,7 +1030,8 @@ glusterd_perform_missed_op (glusterd_snap_t *snap, int32_t op)
/* The entry must be a create, delete, or
* restore entry
*/
- gf_log (this->name, GF_LOG_ERROR, "Invalid missed snap entry");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Invalid missed snap entry");
ret = -1;
goto out;
}
@@ -993,7 +1043,7 @@ out:
parent_volname = NULL;
}
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1030,7 +1080,7 @@ glusterd_perform_missed_snap_ops ()
/* If the snap is not found, then a delete or a
* restore can't be pending on that snap_uuid.
*/
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Not a pending delete or restore op");
continue;
}
@@ -1056,7 +1106,8 @@ glusterd_perform_missed_snap_ops ()
(snap,
snap_opinfo->op);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED,
"Failed to perform missed snap op");
goto out;
}
@@ -1069,7 +1120,7 @@ glusterd_perform_missed_snap_ops ()
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1094,7 +1145,8 @@ glusterd_import_friend_missed_snap_list (dict_t *peer_data)
ret = dict_get_int32 (peer_data, "missed_snap_count",
&missed_snap_count);
if (ret) {
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_MISSED_SNAP_GET_FAIL,
"No missed snaps");
ret = 0;
goto out;
@@ -1103,14 +1155,16 @@ glusterd_import_friend_missed_snap_list (dict_t *peer_data)
ret = glusterd_add_missed_snaps_to_list (peer_data,
missed_snap_count);
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 add missed snaps to list");
goto out;
}
ret = glusterd_perform_missed_snap_ops ();
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED,
"Failed to perform snap operations");
/* Not going to out at this point coz some *
* missed ops might have been performed. We *
@@ -1120,13 +1174,14 @@ glusterd_import_friend_missed_snap_list (dict_t *peer_data)
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;
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1162,7 +1217,7 @@ glusterd_is_peer_snap_conflicting (char *peer_snap_name, char *peer_snap_id,
/* Current node contains the same snap having
* the same snapname and snap_id
*/
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Snapshot %s from peer %s present in "
"localhost", peer_snap_name, hostname);
*conflict = _gf_false;
@@ -1170,7 +1225,7 @@ glusterd_is_peer_snap_conflicting (char *peer_snap_name, char *peer_snap_id,
/* Current node contains the same snap having
* the same snapname but different snap_id
*/
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Snapshot %s from peer %s conflicts with "
"snapshot in localhost", peer_snap_name,
hostname);
@@ -1178,7 +1233,8 @@ glusterd_is_peer_snap_conflicting (char *peer_snap_name, char *peer_snap_id,
}
} else {
/* Peer contains snapshots missing on the current node */
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_MISSED_SNAP_PRESENT,
"Snapshot %s from peer %s missing on localhost",
peer_snap_name, hostname);
*conflict = _gf_false;
@@ -1209,7 +1265,7 @@ glusterd_are_snap_bricks_local (glusterd_snap_t *snap)
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", is_local);
+ gf_msg_trace (this->name, 0, "Returning %d", is_local);
return is_local;
}
@@ -1261,7 +1317,7 @@ glusterd_peer_has_missed_snap_delete (uuid_t peerid, char *peer_snap_id)
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", missed_delete);
+ gf_msg_trace (this->name, 0, "Returning %d", missed_delete);
return missed_delete;
}
@@ -1281,7 +1337,8 @@ glusterd_gen_snap_volfiles (glusterd_volinfo_t *snap_vol, char *peer_snap_name)
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_SET_FAIL, "Failed to store snapshot "
"volinfo (%s) for snap %s", snap_vol->volname,
peer_snap_name);
goto out;
@@ -1289,7 +1346,8 @@ glusterd_gen_snap_volfiles (glusterd_volinfo_t *snap_vol, char *peer_snap_name)
ret = generate_brick_volfiles (snap_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"generating the brick volfiles for the "
"snap %s failed", peer_snap_name);
goto out;
@@ -1297,7 +1355,8 @@ glusterd_gen_snap_volfiles (glusterd_volinfo_t *snap_vol, char *peer_snap_name)
ret = generate_client_volfiles (snap_vol, GF_CLIENT_TRUSTED);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"generating the trusted client volfiles for "
"the snap %s failed", peer_snap_name);
goto out;
@@ -1305,7 +1364,8 @@ glusterd_gen_snap_volfiles (glusterd_volinfo_t *snap_vol, char *peer_snap_name)
ret = generate_client_volfiles (snap_vol, GF_CLIENT_OTHER);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"generating the client volfiles for the "
"snap %s failed", peer_snap_name);
goto out;
@@ -1314,7 +1374,8 @@ glusterd_gen_snap_volfiles (glusterd_volinfo_t *snap_vol, char *peer_snap_name)
ret = glusterd_volinfo_find (snap_vol->parent_volname,
&parent_volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Parent volinfo "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_GET_FAIL, "Parent volinfo "
"not found for %s volume of snap %s",
snap_vol->volname, peer_snap_name);
goto out;
@@ -1326,12 +1387,13 @@ glusterd_gen_snap_volfiles (glusterd_volinfo_t *snap_vol, char *peer_snap_name)
ret = glusterd_store_volinfo (snap_vol, GLUSTERD_VOLINFO_VER_AC_NONE);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_SET_FAIL,
"Failed to store snap volinfo");
goto out;
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1363,14 +1425,16 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
snap = glusterd_new_snap_object ();
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR, "Could not create "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Could not create "
"the snap object for snap %s", peer_snap_name);
goto out;
}
dict = dict_new ();
if (!dict) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_CREATE_FAIL,
"Failed to create dict");
ret = -1;
goto out;
@@ -1385,7 +1449,8 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
snprintf (buf, sizeof(buf), "%s.time_stamp", prefix);
ret = dict_get_int64 (peer_data, buf, &snap->time_stamp);
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 time_stamp for snap %s",
peer_snap_name);
goto out;
@@ -1394,7 +1459,8 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
snprintf (buf, sizeof(buf), "%s.snap_restored", prefix);
ret = dict_get_int8 (peer_data, buf, (int8_t *) &snap->snap_restored);
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 snap_restored for snap %s",
peer_snap_name);
goto out;
@@ -1403,7 +1469,8 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
snprintf (buf, sizeof(buf), "%s.snap_status", prefix);
ret = dict_get_int32 (peer_data, buf, (int32_t *) &snap->snap_status);
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 snap_status for snap %s",
peer_snap_name);
goto out;
@@ -1412,7 +1479,7 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
/* If the snap is scheduled to be decommissioned, then
* don't accept the snap */
if (snap->snap_status == GD_SNAP_STATUS_DECOMMISSION) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"The snap(%s) is scheduled to be decommissioned "
"Not accepting the snap.", peer_snap_name);
glusterd_snap_remove (dict, snap,
@@ -1424,7 +1491,8 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
snprintf (buf, sizeof(buf), "%s.volcount", prefix);
ret = dict_get_int32 (peer_data, buf, &volcount);
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 volcount for snap %s",
peer_snap_name);
goto out;
@@ -1432,7 +1500,9 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
ret = glusterd_store_create_snap_dir (snap);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to create snap dir");
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPDIR_CREATE_FAIL,
+ "Failed to create snap dir");
goto out;
}
@@ -1444,7 +1514,8 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
ret = glusterd_import_volinfo (peer_data, i,
&snap_vol, prefix);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_SET_FAIL,
"Failed to import snap volinfo for "
"snap %s", peer_snap_name);
goto out;
@@ -1454,7 +1525,8 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
ret = glusterd_gen_snap_volfiles (snap_vol, peer_snap_name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"Failed to generate snap vol files "
"for snap %s", peer_snap_name);
goto out;
@@ -1463,7 +1535,8 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
ret = glusterd_import_quota_conf (peer_data, i,
snap_vol, prefix);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_QUOTA_CONFIG_IMPORT_FAIL,
"Failed to import quota conf "
"for snap %s", peer_snap_name);
goto out;
@@ -1474,7 +1547,8 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
ret = glusterd_store_snap (snap);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Could not store snap"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Could not store snap"
"object %s", peer_snap_name);
goto out;
}
@@ -1487,7 +1561,7 @@ out:
if (dict)
dict_unref (dict);
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1551,8 +1625,10 @@ glusterd_compare_and_update_snap (dict_t *peer_data, int32_t snap_count,
snprintf (buf, sizeof(buf), "%s.snapname", prefix);
ret = dict_get_str (peer_data, buf, &peer_snap_name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Unable to fetch snapname from peer: %s", peername);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
+ "Unable to fetch snapname from peer: %s",
+ peername);
goto out;
}
@@ -1560,8 +1636,10 @@ glusterd_compare_and_update_snap (dict_t *peer_data, int32_t snap_count,
snprintf (buf, sizeof(buf), "%s.snap_id", prefix);
ret = dict_get_str (peer_data, buf, &peer_snap_id);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Unable to fetch snap_id from peer: %s", peername);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
+ "Unable to fetch snap_id from peer: %s",
+ peername);
goto out;
}
@@ -1572,7 +1650,9 @@ glusterd_compare_and_update_snap (dict_t *peer_data, int32_t snap_count,
peer_snap_id);
if (missed_delete == _gf_true) {
/* Peer has missed delete on the missing/conflicting snap_id */
- gf_log (this->name, GF_LOG_INFO, "Peer %s has missed a delete "
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_MISSED_SNAP_DELETE,
+ "Peer %s has missed a delete "
"on snap %s", peername, peer_snap_name);
ret = 0;
goto out;
@@ -1609,7 +1689,8 @@ glusterd_compare_and_update_snap (dict_t *peer_data, int32_t snap_count,
snprintf (buf, sizeof(buf), "%s.host_bricks", prefix);
ret = dict_get_int8 (peer_data, buf, (int8_t *) &is_hosted);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch host_bricks from peer: %s "
"for %s", peername, peer_snap_name);
goto out;
@@ -1622,9 +1703,10 @@ glusterd_compare_and_update_snap (dict_t *peer_data, int32_t snap_count,
* then it's a peer reject
*/
if (is_hosted == is_local) {
- gf_log (this->name, GF_LOG_ERROR,
- "Conflict in snapshot %s with peer %s", peer_snap_name,
- peername);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CONFLICT,
+ "Conflict in snapshot %s with peer %s",
+ peer_snap_name, peername);
ret = -1;
goto out;
}
@@ -1633,7 +1715,7 @@ glusterd_compare_and_update_snap (dict_t *peer_data, int32_t snap_count,
/* If there was a conflict, and the peer is not hosting
* any brick, then don't accept peer data
*/
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Peer doesn't hosts bricks for conflicting "
"snap(%s). Not accepting peer data.",
peer_snap_name);
@@ -1646,13 +1728,14 @@ glusterd_compare_and_update_snap (dict_t *peer_data, int32_t snap_count,
* data and accept peer data
*/
- gf_log (this->name, GF_LOG_DEBUG, "Peer hosts bricks for conflicting "
+ gf_msg_debug (this->name, 0, "Peer hosts bricks for conflicting "
"snap(%s). Removing local data. Accepting peer data.",
peer_snap_name);
dict = dict_new();
if (!dict) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_CREATE_FAIL,
"Unable to create dict");
ret = -1;
goto out;
@@ -1660,7 +1743,8 @@ glusterd_compare_and_update_snap (dict_t *peer_data, int32_t snap_count,
ret = glusterd_snap_remove (dict, snap, _gf_true, _gf_false);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_REMOVE_FAIL,
"Failed to remove snap %s", snap->snapname);
goto out;
}
@@ -1671,9 +1755,10 @@ accept_peer_data:
ret = glusterd_import_friend_snap (peer_data, snap_count,
peer_snap_name, peer_snap_id);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to import snap %s from peer %s", peer_snap_name,
- peername);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_IMPORT_FAIL,
+ "Failed to import snap %s from peer %s",
+ peer_snap_name, peername);
goto out;
}
@@ -1681,7 +1766,7 @@ out:
if (dict)
dict_unref (dict);
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1704,7 +1789,8 @@ glusterd_compare_friend_snapshots (dict_t *peer_data, char *peername,
ret = dict_get_int32 (peer_data, "snap_count", &snap_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to fetch snap_count");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to fetch snap_count");
goto out;
}
@@ -1713,7 +1799,8 @@ glusterd_compare_friend_snapshots (dict_t *peer_data, char *peername,
ret = glusterd_compare_and_update_snap (peer_data, i, peername,
peerid);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED,
"Failed to compare snapshots with peer %s",
peername);
goto out;
@@ -1721,7 +1808,7 @@ glusterd_compare_friend_snapshots (dict_t *peer_data, char *peername,
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1781,7 +1868,7 @@ glusterd_add_snapd_to_dict (glusterd_volinfo_t *volinfo,
out:
if (ret)
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1800,14 +1887,16 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
uint64_t voldisplaycount = 0;
if (!dst || !src) {
- gf_log ("", GF_LOG_ERROR, "Source or Destination "
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_EMPTY, "Source or Destination "
"dict is empty.");
goto out;
}
ret = dict_get_int32 (dst, "config-command", &config_command);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"failed to get config-command type");
goto out;
}
@@ -1822,7 +1911,8 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
hard_limit);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Unable to set snap_max_hard_limit");
goto out;
}
@@ -1836,7 +1926,8 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
&soft_limit);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get snap_max_soft_limit");
goto out;
}
@@ -1845,7 +1936,8 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
soft_limit);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Unable to set snap_max_soft_limit");
goto out;
}
@@ -1853,7 +1945,8 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_get_uint64 (src, "voldisplaycount",
&voldisplaycount);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get voldisplaycount");
goto out;
}
@@ -1861,7 +1954,8 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_set_uint64 (dst, "voldisplaycount",
voldisplaycount);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Unable to set voldisplaycount");
goto out;
}
@@ -1871,13 +1965,15 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
"volume%"PRIu64"-volname", i);
ret = dict_get_str (src, buf, &volname);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get %s", buf);
goto out;
}
ret = dict_set_str (dst, buf, volname);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Unable to set %s", buf);
goto out;
}
@@ -1886,13 +1982,15 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
"volume%"PRIu64"-snap-max-hard-limit", i);
ret = dict_get_uint64 (src, buf, &value);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get %s", buf);
goto out;
}
ret = dict_set_uint64 (dst, buf, value);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Unable to set %s", buf);
goto out;
}
@@ -1901,13 +1999,15 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
"volume%"PRIu64"-active-hard-limit", i);
ret = dict_get_uint64 (src, buf, &value);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get %s", buf);
goto out;
}
ret = dict_set_uint64 (dst, buf, value);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Unable to set %s", buf);
goto out;
}
@@ -1916,13 +2016,15 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
"volume%"PRIu64"-snap-max-soft-limit", i);
ret = dict_get_uint64 (src, buf, &value);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get %s", buf);
goto out;
}
ret = dict_set_uint64 (dst, buf, value);
if (ret) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Unable to set %s", buf);
goto out;
}
@@ -1935,7 +2037,7 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("", 0, "Returning %d", ret);
return ret;
}
@@ -1959,20 +2061,22 @@ glusterd_merge_brick_status (dict_t *dst, dict_t *src)
GF_ASSERT (this);
if (!dst || !src) {
- gf_log (this->name, GF_LOG_ERROR, "Source or Destination "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_EMPTY, "Source or Destination "
"dict is empty.");
goto out;
}
ret = dict_get_int32 (dst, "type", &snap_command);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "unable to get the type of "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "unable to get the type of "
"the snapshot command");
goto out;
}
if (snap_command == GF_SNAP_OPTION_TYPE_DELETE) {
- gf_log (this->name, GF_LOG_DEBUG, "snapshot delete command."
+ gf_msg_debug (this->name, 0, "snapshot delete command."
" Need not merge the status of the bricks");
ret = 0;
goto out;
@@ -1980,7 +2084,8 @@ glusterd_merge_brick_status (dict_t *dst, dict_t *src)
ret = dict_get_int64 (src, "volcount", &volume_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to "
"get the volume count");
goto out;
}
@@ -1990,7 +2095,7 @@ glusterd_merge_brick_status (dict_t *dst, dict_t *src)
"snap-vol%"PRId64"_brickcount", index+1);
ret = dict_get_int64 (src, snapbrckcnt, &brick_count);
if (ret) {
- gf_log (this->name, GF_LOG_TRACE,
+ gf_msg_trace (this->name, 0,
"No bricks for this volume in this dict (%s)",
snapbrckcnt);
continue;
@@ -2004,7 +2109,8 @@ glusterd_merge_brick_status (dict_t *dst, dict_t *src)
ret = dict_get_int64 (src, snapbrckord, &brick_order);
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 order (%s)",
snapbrckord);
goto out;
@@ -2015,14 +2121,16 @@ glusterd_merge_brick_status (dict_t *dst, dict_t *src)
index+1, brick_order);
ret = dict_get_int32 (src, key, &brick_online);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to "
"get the brick status (%s)", key);
goto out;
}
ret = dict_set_int32 (dst, key, brick_online);
if (ret) {
- 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 the brick status (%s)", key);
goto out;
}
@@ -2055,27 +2163,31 @@ glusterd_snap_create_use_rsp_dict (dict_t *dst, dict_t *src)
GF_ASSERT (this);
if (!dst || !src) {
- gf_log (this->name, GF_LOG_ERROR, "Source or Destination "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_EMPTY, "Source or Destination "
"dict is empty.");
goto out;
}
ret = glusterd_merge_brick_status (dst, src);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to merge brick "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_SET_INFO_FAIL, "failed to merge brick "
"status");
goto out;
}
ret = dict_get_str (src, "snapuuid", &buf);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to get snap UUID");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to get snap UUID");
goto out;
}
ret = dict_set_dynstr_with_alloc (dst, "snapuuid", buf);
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 snap uuid in dict");
goto out;
}
@@ -2086,7 +2198,8 @@ glusterd_snap_create_use_rsp_dict (dict_t *dst, dict_t *src)
if (!ret) {
ret = dict_set_int8 (dst, "soft-limit-reach", soft_limit_flag);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set "
"soft_limit_flag");
goto out;
}
@@ -2095,7 +2208,7 @@ glusterd_snap_create_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_get_int32 (src, "missed_snap_count",
&src_missed_snap_count);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, "No missed snaps");
+ gf_msg_debug (this->name, 0, "No missed snaps");
ret = 0;
goto out;
}
@@ -2111,7 +2224,8 @@ glusterd_snap_create_use_rsp_dict (dict_t *dst, dict_t *src)
snprintf (name_buf, sizeof(name_buf), "missed_snaps_%d", i);
ret = dict_get_str (src, name_buf, &buf);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch %s", name_buf);
goto out;
}
@@ -2127,7 +2241,8 @@ glusterd_snap_create_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_set_dynstr (dst, name_buf, tmp_str);
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 %s", name_buf);
goto out;
}
@@ -2138,7 +2253,8 @@ glusterd_snap_create_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_set_int32 (dst, "missed_snap_count", dst_missed_snap_count);
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 dst_missed_snap_count");
goto out;
}
@@ -2147,7 +2263,7 @@ out:
if (ret && tmp_str)
GF_FREE(tmp_str);
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2158,14 +2274,16 @@ glusterd_snap_use_rsp_dict (dict_t *dst, dict_t *src)
int32_t snap_command = 0;
if (!dst || !src) {
- gf_log ("", GF_LOG_ERROR, "Source or Destination "
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_EMPTY, "Source or Destination "
"dict is empty.");
goto out;
}
ret = dict_get_int32 (dst, "type", &snap_command);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "unable to get the type of "
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "unable to get the type of "
"the snapshot command");
goto out;
}
@@ -2176,14 +2294,18 @@ glusterd_snap_use_rsp_dict (dict_t *dst, dict_t *src)
case GF_SNAP_OPTION_TYPE_CLONE:
ret = glusterd_snap_create_use_rsp_dict (dst, src);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to use rsp dict");
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_RSP_DICT_USE_FAIL,
+ "Unable to use rsp dict");
goto out;
}
break;
case GF_SNAP_OPTION_TYPE_CONFIG:
ret = glusterd_snap_config_use_rsp_dict (dst, src);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to use rsp dict");
+ gf_msg ("", GF_LOG_ERROR, 0,
+ GD_MSG_RSP_DICT_USE_FAIL,
+ "Unable to use rsp dict");
goto out;
}
break;
@@ -2196,7 +2318,7 @@ glusterd_snap_use_rsp_dict (dict_t *dst, dict_t *src)
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("", 0, "Returning %d", ret);
return ret;
}
@@ -2262,7 +2384,7 @@ glusterd_missed_snapinfo_new (glusterd_missed_snap_info **missed_snapinfo)
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2292,7 +2414,7 @@ glusterd_missed_snap_op_new (glusterd_snap_op_t **snap_op)
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2373,16 +2495,17 @@ glusterd_mount_lvm_snapshot (glusterd_brickinfo_t *brickinfo,
runner_log (&runner, this->name, GF_LOG_DEBUG, msg);
ret = runner_run (&runner);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "mounting the snapshot "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_MOUNT_FAIL, "mounting the snapshot "
"logical device %s failed (error: %s)",
brickinfo->device_path, strerror (errno));
goto out;
} else
- gf_log (this->name, GF_LOG_DEBUG, "mounting the snapshot "
+ gf_msg_debug (this->name, 0, "mounting the snapshot "
"logical device %s successful", brickinfo->device_path);
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -2401,7 +2524,8 @@ glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict,
GF_ASSERT (this);
if (!volinfo || !dict) {
- gf_log (this->name, GF_LOG_WARNING, "input parameters NULL");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_INVALID_ENTRY, "input parameters NULL");
goto out;
}
@@ -2413,7 +2537,8 @@ glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict,
if (down_count) {
snprintf (err_str, sizeof (err_str), "One or more bricks may "
"be down.");
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_DISCONNECTED, "%s", err_str);
*op_errstr = gf_strdup (err_str);
goto out;
}
@@ -2443,7 +2568,8 @@ glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict,
if (!quorum_met) {
snprintf (err_str, sizeof (err_str), "quorum is not met");
- gf_log (this->name, GF_LOG_WARNING, "%s", err_str);
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SERVER_QUORUM_NOT_MET, "%s", err_str);
*op_errstr = gf_strdup (err_str);
}
@@ -2476,7 +2602,8 @@ glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index,
GF_ASSERT (priv);
if (!volinfo || !dict) {
- gf_log (this->name, GF_LOG_WARNING, "input parameters NULL");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_INVALID_ENTRY, "input parameters NULL");
goto out;
}
@@ -2496,7 +2623,8 @@ glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index,
ret = 1;
snprintf (err_str, sizeof (err_str), "quorum "
"is not met");
- gf_log (this->name, GF_LOG_ERROR, "%s",
+ gf_msg (this->name, GF_LOG_ERROR,
+ 0, GD_MSG_SERVER_QUORUM_NOT_MET, "%s",
err_str);
*op_errstr = gf_strdup (err_str);
goto out;
@@ -2548,7 +2676,7 @@ glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index,
}
if (quorum_met) {
- gf_log (this->name, GF_LOG_DEBUG, "volume %s is in quorum",
+ gf_msg_debug (this->name, 0, "volume %s is in quorum",
volinfo->volname);
ret = 0;
}
@@ -2582,21 +2710,24 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,
GF_ASSERT (this);
if (!dict) {
- gf_log (this->name, GF_LOG_ERROR, "dict is NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_EMPTY, "dict is NULL");
goto out;
}
if (snap_volume) {
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to "
"get snapname");
goto out;
}
snap = glusterd_find_snap_by_name (snapname);
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_NOT_FOUND, "failed to "
"get the snapshot %s", snapname);
ret = -1;
goto out;
@@ -2614,16 +2745,18 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,
if (!does_gd_meet_server_quorum (this)) {
snprintf (err_str, sizeof (err_str),
"glusterds are not in quorum");
- gf_log (this->name, GF_LOG_WARNING, "%s", err_str);
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SERVER_QUORUM_NOT_MET, "%s", err_str);
*op_errstr = gf_strdup (err_str);
ret = -1;
goto out;
} else
- gf_log (this->name, GF_LOG_DEBUG, "glusterds are in quorum");
+ gf_msg_debug (this->name, 0, "glusterds are in quorum");
ret = dict_get_int64 (dict, "volcount", &volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to get "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to get "
"volcount");
goto out;
}
@@ -2633,7 +2766,8 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,
snap_volume?"snap-volname":"volname", i);
ret = dict_get_str (dict, key, &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to "
"get volname");
goto out;
}
@@ -2642,7 +2776,8 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,
ret = glusterd_snap_volinfo_find (volname, snap,
&volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_NOT_FOUND,
"failed to get snap volume %s "
"for snap %s", volname,
snapname);
@@ -2651,7 +2786,8 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,
} else {
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,
"failed to find the volume %s",
volname);
goto out;
@@ -2717,7 +2853,8 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,
(tmp >= quorum_count)) {
quorum_count = tmp;
} else {
- gf_log(this->name, GF_LOG_INFO,
+ gf_msg(this->name, GF_LOG_INFO, 0,
+ GD_MSG_QUORUM_COUNT_IGNORED,
"Ignoring small quorum-count "
"(%d) on dispersed volume", tmp);
quorum_type = NULL;
@@ -2736,7 +2873,8 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,
quorum_type,
op_errstr);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "volume %s "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_VOL_NOT_FOUND, "volume %s "
"is not in quorum", volinfo->volname);
goto out;
}
@@ -2758,14 +2896,16 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume,
GF_ASSERT (this);
if (!dict) {
- gf_log (this->name, GF_LOG_ERROR, "dict is NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_EMPTY, "dict is NULL");
goto out;
}
ret = dict_get_int32 (dict, "type", &snap_command);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "unable to get the type of "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "unable to get the type of "
"the snapshot command");
goto out;
}
@@ -2775,7 +2915,8 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume,
ret = glusterd_snap_quorum_check_for_create (dict, snap_volume,
op_errstr);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Quorum check"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_QUORUM_CHECK_FAIL, "Quorum check"
"failed during snapshot create command");
goto out;
}
@@ -2786,13 +2927,14 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume,
ret = -1;
snprintf (err_str, sizeof (err_str),
"glusterds are not in quorum");
- gf_log (this->name, GF_LOG_WARNING, "%s",
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SERVER_QUORUM_NOT_MET, "%s",
err_str);
*op_errstr = gf_strdup (err_str);
goto out;
}
- gf_log (this->name, GF_LOG_DEBUG, "glusterds are in "
+ gf_msg_debug (this->name, 0, "glusterds are in "
"quorum");
break;
case GF_SNAP_OPTION_TYPE_DELETE:
@@ -2801,13 +2943,14 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume,
ret = -1;
snprintf (err_str, sizeof (err_str),
"glusterds are not in quorum");
- gf_log (this->name, GF_LOG_WARNING, "%s",
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SERVER_QUORUM_NOT_MET, "%s",
err_str);
*op_errstr = gf_strdup (err_str);
goto out;
}
- gf_log (this->name, GF_LOG_DEBUG, "glusterds are in "
+ gf_msg_debug (this->name, 0, "glusterds are in "
"quorum");
break;
default:
@@ -2838,10 +2981,11 @@ glusterd_umount (const char *path)
runner_log (&runner, this->name, GF_LOG_DEBUG, msg);
ret = runner_run (&runner);
if (ret)
- gf_log (this->name, GF_LOG_ERROR, "umounting %s failed (%s)",
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_GLUSTERD_UMOUNT_FAIL, "umounting %s failed (%s)",
path, strerror (errno));
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -2866,7 +3010,8 @@ glusterd_copy_file (const char *source, const char *destination)
/* Here is stat is made to get the file permission of source file*/
ret = lstat (source, &stbuf);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s not found", source);
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "%s not found", source);
goto out;
}
@@ -2875,7 +3020,8 @@ glusterd_copy_file (const char *source, const char *destination)
src_fd = open (source, O_RDONLY);
if (src_fd < 0) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "Unable to open file %s",
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "Unable to open file %s",
source);
goto out;
}
@@ -2883,7 +3029,8 @@ glusterd_copy_file (const char *source, const char *destination)
dest_fd = open (destination, O_CREAT | O_RDWR, dest_mode);
if (dest_fd < 0) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FILE_OP_FAILED,
"Unble to open a file %s", destination);
goto out;
}
@@ -2891,7 +3038,8 @@ glusterd_copy_file (const char *source, const char *destination)
do {
ret = read (src_fd, buffer, sizeof (buffer));
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR, "Error reading file "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "Error reading file "
"%s", source);
goto out;
}
@@ -2901,7 +3049,8 @@ glusterd_copy_file (const char *source, const char *destination)
ret = write (dest_fd, buffer, read_len);
if (ret != read_len) {
- gf_log (this->name, GF_LOG_ERROR, "Error writing in "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FILE_OP_FAILED, "Error writing in "
"file %s", destination);
goto out;
}
@@ -2933,7 +3082,8 @@ glusterd_copy_folder (const char *source, const char *destination)
dir_ptr = opendir (source);
if (!dir_ptr) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to open %s", source);
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED, "Unable to open %s", source);
goto out;
}
@@ -2953,7 +3103,8 @@ glusterd_copy_folder (const char *source, const char *destination)
ret = glusterd_copy_file (src_path, dest_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not copy "
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Could not copy "
"%s to %s", src_path, dest_path);
goto out;
}
@@ -2988,7 +3139,8 @@ glusterd_get_geo_rep_session (char *slave_key, char *origin_volname,
ret = dict_get_str (gsync_slaves_dict, slave_key, &buffer);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to "
"get value for key %s", slave_key);
goto out;
}
@@ -3089,7 +3241,7 @@ glusterd_copy_quota_files (glusterd_volinfo_t *src_vol,
ret = lstat (src_path, &stbuf);
if (ret) {
ret = 0;
- gf_log (this->name, GF_LOG_DEBUG, "%s not found", src_path);
+ gf_msg_debug (this->name, 0, "%s not found", src_path);
goto out;
}
@@ -3100,7 +3252,8 @@ glusterd_copy_quota_files (glusterd_volinfo_t *src_vol,
ret = glusterd_copy_file (src_path, dest_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to copy %s in %s",
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Failed to copy %s in %s",
src_path, dest_path);
goto out;
}
@@ -3142,7 +3295,8 @@ glusterd_restore_geo_rep_files (glusterd_volinfo_t *snap_vol)
ret = glusterd_volinfo_find (origin_volname, &origin_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "Unable to fetch "
"volinfo for volname %s", origin_volname);
goto out;
}
@@ -3166,7 +3320,8 @@ glusterd_restore_geo_rep_files (glusterd_volinfo_t *snap_vol)
snap_vol->gsync_slaves,
session, slave);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GEOREP_GET_FAILED,
"Failed to get geo-rep session");
goto out;
}
@@ -3186,7 +3341,8 @@ glusterd_restore_geo_rep_files (glusterd_volinfo_t *snap_vol)
ret = glusterd_copy_folder (src_path, dest_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not copy "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DIR_OP_FAILED, "Could not copy "
"%s to %s", src_path, dest_path);
goto out;
}
@@ -3207,12 +3363,13 @@ glusterd_is_snapd_enabled (glusterd_volinfo_t *volinfo)
ret = dict_get_str_boolean (volinfo->dict, "features.uss", -2);
if (ret == -2) {
- gf_log (this->name, GF_LOG_DEBUG, "Key features.uss not "
+ gf_msg_debug (this->name, 0, "Key features.uss not "
"present in the dict for volume %s", volinfo->volname);
ret = 0;
} else if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get 'features.uss'"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get 'features.uss'"
" from dict for volume %s", volinfo->volname);
}
@@ -3263,7 +3420,8 @@ glusterd_is_snap_soft_limit_reached (glusterd_volinfo_t *volinfo, dict_t *dict)
limit = (opt_max_soft * effective_max_limit)/100;
if (volinfo->snap_count >= limit && auto_delete != _gf_true) {
- gf_log (this->name, GF_LOG_WARNING, "Soft-limit "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SOFT_LIMIT_REACHED, "Soft-limit "
"(value = %"PRIu64") of volume %s is reached. "
"Snapshot creation is not possible once effective "
"hard-limit (value = %"PRIu64") is reached.",
@@ -3272,7 +3430,8 @@ glusterd_is_snap_soft_limit_reached (glusterd_volinfo_t *volinfo, dict_t *dict)
ret = dict_set_int8 (dict, "soft-limit-reach",
_gf_true);
if (ret) {
- 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 soft limit exceed flag in "
"response dictionary");
}
@@ -3306,7 +3465,7 @@ gd_get_snap_conf_values_if_present (dict_t *dict, uint64_t *sys_hard_limit,
*/
if (dict_get_uint64 (dict, GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
sys_hard_limit)) {
- gf_log (this->name, GF_LOG_DEBUG, "%s is not present in"
+ gf_msg_debug (this->name, 0, "%s is not present in"
"dictionary",
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
}
@@ -3317,7 +3476,7 @@ gd_get_snap_conf_values_if_present (dict_t *dict, uint64_t *sys_hard_limit,
*/
if (dict_get_uint64 (dict, GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
sys_soft_limit)) {
- gf_log (this->name, GF_LOG_DEBUG, "%s is not present in"
+ gf_msg_debug (this->name, 0, "%s is not present in"
"dictionary",
GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT);
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index b344559dd0d..dbb9e934839 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -19,6 +19,7 @@
#include <sys/statvfs.h>
#include <sys/mount.h>
#include <signal.h>
+#include "glusterd-messages.h"
#if defined(GF_LINUX_HOST_OS)
#include <mntent.h>
@@ -100,11 +101,15 @@ glusterd_build_snap_device_path (char *device, char *snapname,
this = THIS;
GF_ASSERT (this);
if (!device) {
- gf_log (this->name, GF_LOG_ERROR, "device is NULL");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY,
+ "device is NULL");
goto out;
}
if (!snapname) {
- gf_log (this->name, GF_LOG_ERROR, "snapname is NULL");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY,
+ "snapname is NULL");
goto out;
}
@@ -116,7 +121,8 @@ glusterd_build_snap_device_path (char *device, char *snapname,
runner_log (&runner, this->name, GF_LOG_DEBUG, msg);
ret = runner_start (&runner);
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get volume group "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_VG_GET_FAIL, "Failed to get volume group "
"for device %s", device);
runner_end (&runner);
goto out;
@@ -124,7 +130,8 @@ glusterd_build_snap_device_path (char *device, char *snapname,
ptr = fgets(volgroup, sizeof(volgroup),
runner_chio (&runner, STDOUT_FILENO));
if (!ptr || !strlen(volgroup)) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get volume group "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_VG_GET_FAIL, "Failed to get volume group "
"for snap %s", snapname);
runner_end (&runner);
ret = -1;
@@ -136,8 +143,10 @@ glusterd_build_snap_device_path (char *device, char *snapname,
snapname, brickcount);
snap_device = gf_strdup (snap);
if (!snap_device) {
- gf_log (this->name, GF_LOG_WARNING, "Cannot copy the "
- "snapshot device name for snapname: %s", snapname);
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ GD_MSG_NO_MEMORY,
+ "Cannot copy the snapshot device name for snapname: %s",
+ snapname);
}
out:
@@ -188,7 +197,8 @@ glusterd_find_missed_snap (dict_t *rsp_dict, glusterd_volinfo_t *vol,
brick_count + 1,
op);
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 add missed snapshot "
"info for %s:%s in the "
"rsp_dict", brickinfo->hostname,
@@ -204,7 +214,7 @@ glusterd_find_missed_snap (dict_t *rsp_dict, glusterd_volinfo_t *vol,
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -427,7 +437,8 @@ snap_max_limits_display_commit (dict_t *rsp_dict, char *volname,
out:
if (ret) {
strncpy (op_errstr, err_str, len);
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "%s", err_str);
}
return ret;
}
@@ -492,7 +503,8 @@ glusterd_copy_geo_rep_session_files (char *session,
ret = mkdir_p (snap_session_dir, 0777, _gf_true);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED,
"Creating directory %s failed", snap_session_dir);
goto out;
}
@@ -501,15 +513,17 @@ glusterd_copy_geo_rep_session_files (char *session,
reg_exp = GF_CALLOC (1, sizeof (regex_t), gf_common_mt_regex_t);
if (!reg_exp) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "Failed to allocate "
- "memory for regular expression");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY,
+ "Failed to allocate memory for regular expression");
goto out;
}
ret = regcomp (reg_exp, "(.*status$)|(.*conf$)\0", REG_EXTENDED);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
- "compile the regular expression");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_REG_COMPILE_FAILED,
+ "Failed to compile the regular expression");
goto out;
}
@@ -518,7 +532,8 @@ glusterd_copy_geo_rep_session_files (char *session,
alphasort);
if (file_count <= 0) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "Session files not present "
+ gf_msg (this->name, GF_LOG_ERROR, ENOENT,
+ GD_MSG_FILE_OP_FAILED, "Session files not present "
"in %s", georep_session_dir);
goto out;
}
@@ -544,8 +559,9 @@ glusterd_copy_geo_rep_session_files (char *session,
ret = glusterd_copy_file (src_path, dest_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not "
- "copy file %s of session %s",
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY,
+ "Could not copy file %s of session %s",
files[i]->d_name, session);
goto out;
}
@@ -594,8 +610,10 @@ glusterd_snapshot_backup_vol (glusterd_volinfo_t *volinfo)
/* Create trash folder if it is not there */
ret = mkdir (trashdir, 0777);
if (ret && errno != EEXIST) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to create trash "
- "directory, reason : %s", strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED,
+ "Failed to create trash directory, reason : %s",
+ strerror (errno));
ret = -1;
goto out;
}
@@ -603,7 +621,9 @@ glusterd_snapshot_backup_vol (glusterd_volinfo_t *volinfo)
/* Move the origin volume volder to the backup location */
ret = rename (pathname, delete_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to rename snap "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED,
+ "Failed to rename snap "
"directory %s to %s", pathname, delete_path);
goto out;
}
@@ -612,7 +632,9 @@ glusterd_snapshot_backup_vol (glusterd_volinfo_t *volinfo)
* happen. */
ret = mkdir (pathname, 0777);
if (ret && errno != EEXIST) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to create origin "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED,
+ "Failed to create origin "
"volume directory (%s), reason : %s",
pathname, strerror (errno));
ret = -1;
@@ -627,27 +649,28 @@ out:
/* Revert the changes in case of failure */
ret = rmdir (pathname);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to rmdir: %s,err: %s",
pathname, strerror (errno));
}
ret = rename (delete_path, pathname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED,
"Failed to rename directory %s to %s",
delete_path, pathname);
}
ret = rmdir (trashdir);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to rmdir: %s, Reason: %s",
trashdir, strerror (errno));
}
}
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", op_ret);
+ gf_msg_trace (this->name, 0, "Returning %d", op_ret);
return op_ret;
}
@@ -686,7 +709,8 @@ glusterd_copy_geo_rep_files (glusterd_volinfo_t *origin_vol,
ret = mkdir (snapgeo_dir, 0777);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED,
"Creating directory %s failed", snapgeo_dir);
goto out;
}
@@ -700,14 +724,16 @@ glusterd_copy_geo_rep_files (glusterd_volinfo_t *origin_vol,
origin_vol->gsync_slaves,
session, slave);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GEOREP_GET_FAILED,
"Failed to get geo-rep session");
goto out;
}
ret = glusterd_copy_geo_rep_session_files (session, snap_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to copy files"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FILE_OP_FAILED, "Failed to copy files"
" related to session %s", session);
goto out;
}
@@ -749,8 +775,9 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "snap name");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
+ "Failed to get snap name");
goto out;
}
@@ -761,7 +788,9 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (ret < 0) {
goto out;
}
- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_NOT_FOUND,
+ "%s", *op_errstr);
ret = -1;
goto out;
}
@@ -773,7 +802,8 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_volinfo_find (snap_volinfo->parent_volname,
&parent_volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND,
"Could not get volinfo of %s",
snap_volinfo->parent_volname);
goto out;
@@ -782,7 +812,9 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_set_dynstr_with_alloc (rsp_dict, "snapuuid",
uuid_utoa (snap->snap_id));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "Failed to set snap "
"uuid in response dictionary for %s snapshot",
snap->snapname);
goto out;
@@ -792,7 +824,9 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_set_dynstr_with_alloc (rsp_dict, "volname",
snap_volinfo->parent_volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "Failed to set snap "
"uuid in response dictionary for %s snapshot",
snap->snapname);
goto out;
@@ -801,7 +835,9 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_set_dynstr_with_alloc (rsp_dict, "volid",
uuid_utoa (parent_volinfo->volume_id));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "Failed to set snap "
"uuid in response dictionary for %s snapshot",
snap->snapname);
goto out;
@@ -810,7 +846,9 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
/* Take backup of the volinfo folder */
ret = glusterd_snapshot_backup_vol (parent_volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to backup "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_OP_FAILED,
+ "Failed to backup "
"volume backend files for %s volume",
parent_volinfo->volname);
goto out;
@@ -824,7 +862,8 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
&priv->peers,
GF_SNAP_OPTION_TYPE_RESTORE);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MISSED_SNAP_GET_FAIL,
"Failed to find missed snap restores");
goto out;
}
@@ -837,7 +876,8 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
* that the called function will do that in case of
* failure.
*/
- gf_log (this->name, GF_LOG_ERROR, "Failed to restore "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_RESTORE_FAIL, "Failed to restore "
"snap for %s", snapname);
goto out;
}
@@ -849,7 +889,8 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_lvm_snapshot_remove (rsp_dict,
parent_volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_LVM_REMOVE_FAILED,
"Failed to remove LVM backend");
goto out;
}
@@ -907,7 +948,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get "
"snap name");
goto out;
}
@@ -919,7 +961,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
if (ret < 0) {
goto out;
}
- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr);
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND, "%s", *op_errstr);
ret = -1;
goto out;
}
@@ -932,14 +975,16 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
if (ret < 0) {
goto out;
}
- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED, "%s", *op_errstr);
ret = -1;
goto out;
}
ret = dict_set_str (rsp_dict, "snapname", snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set "
"snap name(%s)", snapname);
goto out;
}
@@ -947,7 +992,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_get_int32 (dict, "volcount", &volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get volume count");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get volume count");
goto out;
}
@@ -957,7 +1003,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
snprintf (key, sizeof (key), "volname%d", i);
ret = dict_get_str (dict, key, &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to "
"get volume name");
goto out;
}
@@ -969,7 +1016,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
if (ret < 0) {
goto out;
}
- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr);
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND, "%s", *op_errstr);
ret = -1;
goto out;
}
@@ -981,7 +1029,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
if (ret < 0) {
goto out;
}
- gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED, "%s", *op_errstr);
ret = -1;
goto out;
}
@@ -1002,7 +1051,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
volcount, brick_count);
ret = dict_set_str (rsp_dict, key, brickinfo->path);
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 %s", key);
goto out;
}
@@ -1013,7 +1063,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_set_int32 (rsp_dict, key,
brickinfo->snap_status);
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 %s", key);
goto out;
}
@@ -1024,7 +1075,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_set_str (rsp_dict, key,
brickinfo->device_path);
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 %s", key);
goto out;
}
@@ -1035,7 +1087,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_set_str (rsp_dict, key,
brickinfo->fstype);
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 %s", key);
goto out;
}
@@ -1046,7 +1099,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_set_str (rsp_dict, key,
brickinfo->mnt_opts);
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 %s", key);
goto out;
}
@@ -1055,7 +1109,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
snprintf (key, sizeof (key), "snap%d.brick_count", volcount);
ret = dict_set_int32 (rsp_dict, key, brick_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 %s", key);
goto out;
}
@@ -1063,7 +1118,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_set_int32 (rsp_dict, "volcount", volcount);
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 %s", key);
goto out;
}
@@ -1117,7 +1173,7 @@ snap_max_hard_limits_validate (dict_t *dict, char *volname,
&opt_hard_max);
if (ret) {
ret = 0;
- gf_log (this->name, GF_LOG_DEBUG, "%s is not present in "
+ gf_msg_debug (this->name, 0, "%s is not present in "
"opts dictionary",
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
}
@@ -1143,7 +1199,8 @@ snap_max_hard_limits_validate (dict_t *dict, char *volname,
out:
if (ret) {
*op_errstr = gf_strdup (err_str);
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED, "%s", err_str);
}
return ret;
}
@@ -1210,7 +1267,8 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr)
ret = snap_max_hard_limits_validate (dict, volname,
hard_limit, op_errstr);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_HARD_LIMIT_SET_FAIL,
"snap-max-hard-limit validation failed.");
goto out;
}
@@ -1297,7 +1355,8 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr)
out:
if (ret && err_str[0] != '\0') {
- gf_log (this->name, loglevel, "%s", err_str);
+ gf_msg (this->name, loglevel, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED, "%s", err_str);
*op_errstr = gf_strdup (err_str);
}
@@ -1347,7 +1406,8 @@ glusterd_handle_snapshot_config (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_set_int32 (dict, "hold_vol_locks",
_gf_false);
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 hold_vol_locks value "
"as _gf_false");
goto out;
@@ -1361,7 +1421,8 @@ glusterd_handle_snapshot_config (rpcsvc_request_t *req, glusterd_op_t op,
ret = snap_max_limits_display_commit (dict, volname,
err_str, len);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_HARD_LIMIT_SET_FAIL,
"snap-max-limit "
"display commit failed.");
goto out;
@@ -1373,14 +1434,16 @@ glusterd_handle_snapshot_config (rpcsvc_request_t *req, glusterd_op_t op,
ret = glusterd_op_send_cli_response (op, 0, 0, req, dict,
err_str);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to send cli "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_CLI_RESP, "Failed to send cli "
"response");
goto out;
}
break;
default:
- gf_log (this->name, GF_LOG_ERROR, "Unknown config type");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_COMMAND_NOT_FOUND, "Unknown config type");
ret = -1;
break;
}
@@ -1412,7 +1475,8 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_get_int64 (src, "volcount", &volume_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to "
"get the volume count");
goto out;
}
@@ -1423,7 +1487,7 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
"vol%"PRId64"_brickcount", i+1);
ret = dict_get_int64 (src, snapbrckcnt, &brick_count);
if (ret) {
- gf_log (this->name, GF_LOG_TRACE,
+ gf_msg_trace (this->name, 0,
"No bricks for this volume in this dict");
continue;
}
@@ -1435,7 +1499,8 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_get_ptr (src, key,
(void **)&snap_brick_dir);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch %s", key);
continue;
}
@@ -1445,7 +1510,8 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
"vol%"PRId64".brick%"PRId64".order", i+1, j);
ret = dict_get_int64 (src, snapbrckord, &brick_order);
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 order");
goto out;
}
@@ -1456,7 +1522,8 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_set_dynstr_with_alloc (dst, key,
snap_brick_dir);
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 %s", key);
goto out;
}
@@ -1465,7 +1532,8 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
"vol%"PRId64".fstype%"PRId64, i+1, j);
ret = dict_get_str (src, key, &value);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch %s", key);
continue;
}
@@ -1475,7 +1543,8 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
brick_order);
ret = dict_set_dynstr_with_alloc (dst, key, value);
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 %s", key);
goto out;
}
@@ -1484,7 +1553,8 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
"vol%"PRId64".mnt_opts%"PRId64, i+1, j);
ret = dict_get_str (src, key, &value);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch %s", key);
continue;
}
@@ -1494,7 +1564,8 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
brick_order);
ret = dict_set_dynstr_with_alloc (dst, key, value);
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 %s", key);
goto out;
}
@@ -1505,7 +1576,8 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_get_ptr (src, key,
(void **)&snap_device);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch snap_device");
goto out;
}
@@ -1516,7 +1588,8 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_set_dynstr_with_alloc (dst, key,
snap_device);
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 %s", key);
goto out;
}
@@ -1525,14 +1598,16 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
"vol%"PRId64".brick%"PRId64".status", i+1, brick_order);
ret = dict_get_int32 (src, key, &brick_online);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to "
"get the brick status");
goto out;
}
ret = dict_set_int32 (dst, key, brick_online);
if (ret) {
- 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 the brick status");
goto out;
}
@@ -1542,7 +1617,7 @@ glusterd_snap_create_clone_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1564,14 +1639,15 @@ glusterd_snap_restore_use_rsp_dict (dict_t *dst, dict_t *src)
GF_ASSERT (this);
if (!dst || !src) {
- gf_log (this->name, GF_LOG_ERROR, "Source or Destination "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Source or Destination "
"dict is empty.");
goto out;
}
ret = dict_get_int32 (src, "volcount", &vol_count);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, "No volumes");
+ gf_msg_debug (this->name, 0, "No volumes");
ret = 0;
goto out;
}
@@ -1580,7 +1656,8 @@ glusterd_snap_restore_use_rsp_dict (dict_t *dst, dict_t *src)
snprintf (key, sizeof (key), "snap%d.brick_count", i);
ret = dict_get_int32 (src, key, &brickcount);
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 %s", key);
goto out;
}
@@ -1592,14 +1669,14 @@ glusterd_snap_restore_use_rsp_dict (dict_t *dst, dict_t *src)
if (ret) {
/* The brickinfo will be present in
* another rsp_dict */
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"%s not present", key);
ret = 0;
continue;
}
ret = dict_set_dynstr_with_alloc (dst, key, strvalue);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to set %s", key);
goto out;
}
@@ -1608,13 +1685,15 @@ glusterd_snap_restore_use_rsp_dict (dict_t *dst, dict_t *src)
"snap%d.brick%d.snap_status", i, j);
ret = dict_get_int32 (src, key, &value);
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 %s", key);
goto out;
}
ret = dict_set_int32 (dst, key, value);
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 %s", key);
goto out;
}
@@ -1623,13 +1702,14 @@ glusterd_snap_restore_use_rsp_dict (dict_t *dst, dict_t *src)
"snap%d.brick%d.device_path", i, j);
ret = dict_get_str (src, key, &strvalue);
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 %s", key);
goto out;
}
ret = dict_set_dynstr_with_alloc (dst, key, strvalue);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to set %s", key);
goto out;
}
@@ -1638,13 +1718,14 @@ glusterd_snap_restore_use_rsp_dict (dict_t *dst, dict_t *src)
"snap%d.brick%d.fs_type", i, j);
ret = dict_get_str (src, key, &strvalue);
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 %s", key);
goto out;
}
ret = dict_set_dynstr_with_alloc (dst, key, strvalue);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to set %s", key);
goto out;
}
@@ -1653,13 +1734,14 @@ glusterd_snap_restore_use_rsp_dict (dict_t *dst, dict_t *src)
"snap%d.brick%d.mnt_opts", i, j);
ret = dict_get_str (src, key, &strvalue);
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 %s", key);
goto out;
}
ret = dict_set_dynstr_with_alloc (dst, key, strvalue);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to set %s", key);
goto out;
}
@@ -1667,7 +1749,7 @@ glusterd_snap_restore_use_rsp_dict (dict_t *dst, dict_t *src)
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1682,14 +1764,16 @@ glusterd_snap_pre_validate_use_rsp_dict (dict_t *dst, dict_t *src)
GF_ASSERT (this);
if (!dst || !src) {
- gf_log (this->name, GF_LOG_ERROR, "Source or Destination "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "Source or Destination "
"dict is empty.");
goto out;
}
ret = dict_get_int32 (dst, "type", &snap_command);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "unable to get the type of "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "unable to get the type of "
"the snapshot command");
goto out;
}
@@ -1700,7 +1784,8 @@ glusterd_snap_pre_validate_use_rsp_dict (dict_t *dst, dict_t *src)
ret = glusterd_snap_create_clone_pre_val_use_rsp_dict (dst,
src);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to use "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to use "
"rsp dict");
goto out;
}
@@ -1708,7 +1793,8 @@ glusterd_snap_pre_validate_use_rsp_dict (dict_t *dst, dict_t *src)
case GF_SNAP_OPTION_TYPE_RESTORE:
ret = glusterd_snap_restore_use_rsp_dict (dst, src);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to use "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_RSP_DICT_USE_FAIL, "Unable to use "
"rsp dict");
goto out;
}
@@ -1719,7 +1805,7 @@ glusterd_snap_pre_validate_use_rsp_dict (dict_t *dst, dict_t *src)
ret = 0;
out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1745,7 +1831,8 @@ glusterd_add_brick_status_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo,
GF_ASSERT (conf);
if (!key_prefix) {
- gf_log (this->name, GF_LOG_ERROR, "key prefix is NULL");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "key prefix is NULL");
goto out;
}
@@ -1755,7 +1842,8 @@ glusterd_add_brick_status_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo,
ret = dict_set_int32 (dict, key_prefix, brick_online);
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 %s", key_prefix);
goto out;
}
@@ -1802,7 +1890,8 @@ glusterd_is_thinp_brick (char *device)
ret = runner_start (&runner);
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get thin pool "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_TPOOL_GET_FAIL, "Failed to get thin pool "
"name for device %s", device);
runner_end (&runner);
goto out;
@@ -1811,7 +1900,8 @@ glusterd_is_thinp_brick (char *device)
ptr = fgets(pool_name, sizeof(pool_name),
runner_chio (&runner, STDOUT_FILENO));
if (!ptr || !strlen(pool_name)) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get pool name "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_TPOOL_GET_FAIL, "Failed to get pool name "
"for device %s", device);
runner_end (&runner);
ret = -1;
@@ -1854,7 +1944,8 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags,
GF_ASSERT (conf);
if (!snapname || !volinfo) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to validate "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Failed to validate "
"snapname or volume information");
ret = -1;
goto out;
@@ -1869,7 +1960,8 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags,
if (!glusterd_is_brick_started (brickinfo)) {
if (!clone && (flags & GF_CLI_FLAG_OP_FORCE)) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_BRICK_DISCONNECTED,
"brick %s:%s is not started",
brickinfo->hostname,
brickinfo->path);
@@ -1941,7 +2033,8 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags,
i, brick_count);
ret = dict_set_dynstr (rsp_dict, key, device);
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 %s", key);
GF_FREE (device);
goto out;
@@ -1951,7 +2044,8 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags,
ret = glusterd_update_mntopts (brickinfo->path,
brickinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRK_MOUNTOPTS_FAIL, "Failed to "
"update mount options for %s brick",
brickinfo->path);
}
@@ -1961,7 +2055,8 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags,
ret = dict_set_dynstr_with_alloc (rsp_dict, key,
brickinfo->fstype);
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 %s", key);
goto out;
}
@@ -1971,7 +2066,8 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags,
ret = dict_set_dynstr_with_alloc (rsp_dict, key,
brickinfo->mnt_opts);
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 %s", key);
goto out;
}
@@ -1981,7 +2077,8 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags,
ret = dict_set_dynstr_with_alloc (rsp_dict, key,
brickinfo->mount_dir);
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 %s", key);
goto out;
}
@@ -1990,7 +2087,8 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags,
"vol%"PRId64".brick%"PRId64".order", i, brick_count);
ret = dict_set_int64 (rsp_dict, key, brick_order);
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 %s", key);
goto out;
}
@@ -2003,7 +2101,9 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags,
brickinfo,
key);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "failed to "
"add brick status to dict");
goto out;
}
@@ -2013,7 +2113,8 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags,
snprintf (key, sizeof(key) - 1, "vol%"PRId64"_brickcount", volcount);
ret = dict_set_int64 (rsp_dict, key, brick_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set %s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set %s",
key);
goto out;
}
@@ -2081,7 +2182,8 @@ glusterd_snapshot_clone_prevalidate (dict_t *dict, char **op_errstr,
snap_vol = list_entry (snap->volumes.next,
glusterd_volinfo_t, vol_list);
if (!snap_vol) {
- gf_log ("glusterd", GF_LOG_ERROR, "Failed to get snap "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_GET_FAIL, "Failed to get snap "
"volinfo %s", snap->snapname);
goto out;
}
@@ -2089,7 +2191,8 @@ glusterd_snapshot_clone_prevalidate (dict_t *dict, char **op_errstr,
snprintf (key, sizeof(key) - 1, "vol1_volid");
ret = dict_get_bin (dict, key, (void **)&snap_volid);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch snap_volid");
goto out;
}
@@ -2104,7 +2207,9 @@ glusterd_snapshot_clone_prevalidate (dict_t *dict, char **op_errstr,
}
ret = dict_set_int64 (rsp_dict, "volcount", volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set volcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "Failed to set volcount");
goto out;
}
@@ -2116,7 +2221,7 @@ out:
*op_errstr = gf_strdup (err_str);
}
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2168,7 +2273,8 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_get_int32 (dict, "flags", &flags);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get flags");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get flags");
goto out;
}
@@ -2236,7 +2342,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
&opt_hard_max);
if (ret) {
ret = 0;
- gf_log (this->name, GF_LOG_DEBUG, "%s is not present "
+ gf_msg_debug (this->name, 0, "%s is not present "
"in opts dictionary",
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
}
@@ -2261,7 +2367,8 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
snprintf (key, sizeof(key) - 1, "vol%"PRId64"_volid", i);
ret = dict_get_bin (dict, key, (void **)&snap_volid);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch snap_volid");
goto out;
}
@@ -2275,7 +2382,8 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
flags, snapname, err_str, snap_volname, i,
volinfo, &loglevel, 0);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_PRE_VALIDATION_FAIL,
"Failed to pre validate");
goto out;
}
@@ -2284,18 +2392,20 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_set_int64 (rsp_dict, "volcount", volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set volcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set volcount");
goto out;
}
ret = 0;
out:
if (ret && err_str[0] != '\0') {
- gf_log (this->name, loglevel, "%s", err_str);
+ gf_msg (this->name, loglevel, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED, "%s", err_str);
*op_errstr = gf_strdup (err_str);
}
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2308,7 +2418,8 @@ glusterd_new_snap_object()
if (snap) {
if (LOCK_INIT (&snap->lock)) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed initiating"
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_LOCK_INIT_FAILED, "Failed initiating"
" snap lock");
GF_FREE (snap);
return NULL;
@@ -2350,7 +2461,7 @@ glusterd_list_add_snapvol (glusterd_volinfo_t *origin_vol,
}
UNLOCK (&origin_vol->lock);
- gf_log (THIS->name, GF_LOG_DEBUG, "Snapshot %s added to the list",
+ gf_msg_debug (THIS->name, 0, "Snapshot %s added to the list",
snap->snapname);
ret = 0;
out:
@@ -2369,7 +2480,7 @@ glusterd_find_snap_by_name (char *snapname)
cds_list_for_each_entry (snap, &priv->snapshots, snap_list) {
if (!strcmp (snap->snapname, snapname)) {
- gf_log (THIS->name, GF_LOG_DEBUG, "Found "
+ gf_msg_debug (THIS->name, 0, "Found "
"snap %s (%s)", snap->snapname,
uuid_utoa (snap->snap_id));
goto out;
@@ -2394,7 +2505,7 @@ glusterd_find_snap_by_id (uuid_t snap_id)
cds_list_for_each_entry (snap, &priv->snapshots, snap_list) {
if (!gf_uuid_compare (snap->snap_id, snap_id)) {
- gf_log (THIS->name, GF_LOG_DEBUG, "Found "
+ gf_msg_debug (THIS->name, 0, "Found "
"snap %s (%s)", snap->snapname,
uuid_utoa (snap->snap_id));
goto out;
@@ -2428,7 +2539,8 @@ glusterd_do_lvm_snapshot_remove (glusterd_volinfo_t *snap_vol,
GF_ASSERT (priv);
if (!brickinfo) {
- gf_log (this->name, GF_LOG_ERROR, "brickinfo NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "brickinfo NULL");
goto out;
}
GF_ASSERT (snap_vol);
@@ -2439,7 +2551,8 @@ glusterd_do_lvm_snapshot_remove (glusterd_volinfo_t *snap_vol,
if (gf_is_service_running (pidfile, &pid)) {
ret = kill (pid, SIGKILL);
if (ret && errno != ESRCH) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to kill pid "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_PID_KILL_FAIL, "Unable to kill pid "
"%d reason : %s", pid, strerror(errno));
goto out;
}
@@ -2448,7 +2561,8 @@ glusterd_do_lvm_snapshot_remove (glusterd_volinfo_t *snap_vol,
/* Check if the brick is mounted and then try unmounting the brick */
ret = glusterd_get_brick_root (brickinfo->path, &mnt_pt);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Getting the root "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_BRICK_PATH_UNMOUNTED, "Getting the root "
"of the brick for volume %s (snap %s) failed. "
"Removing lv (%s).", snap_vol->volname,
snap_vol->snapshot->snapname, snap_device);
@@ -2459,7 +2573,8 @@ glusterd_do_lvm_snapshot_remove (glusterd_volinfo_t *snap_vol,
}
if ((unmount == _gf_true) && (strcmp (mnt_pt, mount_pt))) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_BRICK_PATH_UNMOUNTED,
"Lvm is not mounted for brick %s:%s. "
"Removing lv (%s).", brickinfo->hostname,
brickinfo->path, snap_device);
@@ -2478,14 +2593,15 @@ glusterd_do_lvm_snapshot_remove (glusterd_volinfo_t *snap_vol,
if (!ret)
break;
- gf_log (this->name, GF_LOG_DEBUG, "umount failed for "
+ gf_msg_debug (this->name, 0, "umount failed for "
"path %s (brick: %s): %s. Retry(%d)", mount_pt,
brickinfo->path, strerror (errno), retry_count);
sleep (1);
}
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "umount failed for "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_UNOUNT_FAILED, "umount failed for "
"path %s (brick: %s): %s.", mount_pt,
brickinfo->path, strerror (errno));
goto out;
@@ -2500,7 +2616,8 @@ glusterd_do_lvm_snapshot_remove (glusterd_volinfo_t *snap_vol,
ret = runner_run (&runner);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "removing snapshot of the "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "removing snapshot of the "
"brick (%s:%s) of device %s failed",
brickinfo->hostname, brickinfo->path, snap_device);
goto out;
@@ -2532,7 +2649,7 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)
if ((snap_vol->is_snap_volume == _gf_false) &&
(gf_uuid_is_null (snap_vol->restored_from_snap))) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Not a snap volume, or a restored snap volume.");
ret = 0;
goto out;
@@ -2542,7 +2659,7 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)
cds_list_for_each_entry (brickinfo, &snap_vol->bricks, brick_list) {
brick_count++;
if (gf_uuid_compare (brickinfo->uuid, MY_UUID)) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"%s:%s belongs to a different node",
brickinfo->hostname, brickinfo->path);
continue;
@@ -2553,7 +2670,8 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)
brick_count + 1,
&brick_mount_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_GET_INFO_FAIL,
"Failed to find brick_mount_path for %s",
brickinfo->path);
ret = 0;
@@ -2562,7 +2680,7 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)
ret = lstat (brick_mount_path, &stbuf);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Brick %s:%s already deleted.",
brickinfo->hostname, brickinfo->path);
ret = 0;
@@ -2570,7 +2688,8 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)
}
if (brickinfo->snap_status == -1) {
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_SNAPSHOT_PENDING,
"snapshot was pending. lvm not present "
"for brick %s:%s of the snap %s.",
brickinfo->hostname, brickinfo->path,
@@ -2586,7 +2705,8 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)
brick_count + 1,
GF_SNAP_OPTION_TYPE_DELETE);
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 add missed snapshot "
"info for %s:%s in the "
"rsp_dict", brickinfo->hostname,
@@ -2600,7 +2720,7 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)
/* Check if the brick has a LV associated with it */
if (strlen(brickinfo->device_path) == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Brick (%s:%s) does not have a LV "
"associated with it. Removing the brick path",
brickinfo->hostname, brickinfo->path);
@@ -2610,7 +2730,7 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)
/* Verify if the device path exists or not */
ret = stat (brickinfo->device_path, &stbuf);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"LV (%s) for brick (%s:%s) not present. "
"Removing the brick path",
brickinfo->device_path,
@@ -2625,7 +2745,8 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)
brick_mount_path,
brickinfo->device_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to "
"remove the snapshot %s (%s)",
brickinfo->path, brickinfo->device_path);
err = -1; /* We need to record this failure */
@@ -2642,7 +2763,8 @@ remove_brick_path:
*/
tmp = strstr (brick_mount_path, "brick");
if (!tmp) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY,
"Invalid brick %s", brickinfo->path);
GF_FREE (brick_mount_path);
brick_mount_path = NULL;
@@ -2667,7 +2789,8 @@ remove_brick_path:
/* Will occur when multiple glusterds
* are running in the same node
*/
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ GD_MSG_DIR_OP_FAILED,
"Failed to rmdir: %s, err: %s. "
"More than one glusterd running "
"on this node.",
@@ -2675,7 +2798,8 @@ remove_brick_path:
ret = 0;
goto out;
} else
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED,
"Failed to rmdir: %s, err: %s",
brick_dir, strerror (errno));
goto out;
@@ -2688,7 +2812,7 @@ out:
ret = err;
}
GF_FREE (brick_mount_path);
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2711,7 +2835,8 @@ glusterd_snap_volume_remove (dict_t *rsp_dict,
GF_ASSERT (snap_vol);
if (!snap_vol) {
- gf_log(this->name, GF_LOG_WARNING, "snap_vol in NULL");
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ GD_MSG_INVALID_ENTRY, "snap_vol in NULL");
ret = -1;
goto out;
}
@@ -2722,7 +2847,8 @@ glusterd_snap_volume_remove (dict_t *rsp_dict,
ret = glusterd_brick_stop (snap_vol, brickinfo, _gf_false);
if (ret) {
- gf_log(this->name, GF_LOG_WARNING, "Failed to stop "
+ gf_msg(this->name, GF_LOG_WARNING, 0,
+ GD_MSG_BRICK_STOP_FAIL, "Failed to stop "
"brick for volume %s", snap_vol->volname);
save_ret = ret;
@@ -2737,7 +2863,8 @@ glusterd_snap_volume_remove (dict_t *rsp_dict,
if (remove_lvm) {
ret = glusterd_lvm_snapshot_remove (rsp_dict, snap_vol);
if (ret) {
- gf_log(this->name, GF_LOG_WARNING, "Failed to remove "
+ gf_msg(this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to remove "
"lvm snapshot volume %s", snap_vol->volname);
save_ret = ret;
if (!force)
@@ -2747,7 +2874,8 @@ glusterd_snap_volume_remove (dict_t *rsp_dict,
ret = glusterd_store_delete_volume (snap_vol);
if (ret) {
- gf_log(this->name, GF_LOG_WARNING, "Failed to remove volume %s "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_VOL_DELETE_FAIL, "Failed to remove volume %s "
"from store", snap_vol->volname);
save_ret = ret;
if (!force)
@@ -2758,7 +2886,8 @@ glusterd_snap_volume_remove (dict_t *rsp_dict,
ret = glusterd_volinfo_find (snap_vol->parent_volname,
&origin_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND, "Failed to get "
"parent volinfo %s for volume %s",
snap_vol->parent_volname, snap_vol->volname);
save_ret = ret;
@@ -2773,7 +2902,7 @@ glusterd_snap_volume_remove (dict_t *rsp_dict,
if (save_ret)
ret = save_ret;
out:
- gf_log (this->name, GF_LOG_TRACE, "returning %d", ret);
+ gf_msg_trace (this->name, 0, "returning %d", ret);
return ret;
}
@@ -2781,14 +2910,16 @@ int32_t
glusterd_snapobject_delete (glusterd_snap_t *snap)
{
if (snap == NULL) {
- gf_log(THIS->name, GF_LOG_WARNING, "snap is NULL");
+ gf_msg(THIS->name, GF_LOG_WARNING, EINVAL,
+ GD_MSG_INVALID_ENTRY, "snap is NULL");
return -1;
}
cds_list_del_init (&snap->snap_list);
cds_list_del_init (&snap->volumes);
if (LOCK_DESTROY(&snap->lock))
- gf_log (THIS->name, GF_LOG_WARNING, "Failed destroying lock"
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ GD_MSG_LOCK_DESTROY_FAILED, "Failed destroying lock"
"of snap %s", snap->snapname);
GF_FREE (snap->description);
@@ -2815,7 +2946,8 @@ glusterd_snap_remove (dict_t *rsp_dict,
GF_ASSERT (snap);
if (!snap) {
- gf_log(this->name, GF_LOG_WARNING, "snap is NULL");
+ gf_msg(this->name, GF_LOG_WARNING, EINVAL,
+ GD_MSG_INVALID_ENTRY, "snap is NULL");
ret = -1;
goto out;
}
@@ -2826,7 +2958,8 @@ glusterd_snap_remove (dict_t *rsp_dict,
if (ret && !force) {
/* Don't clean up the snap on error when
force flag is disabled */
- gf_log(this->name, GF_LOG_WARNING, "Failed to remove "
+ gf_msg(this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to remove "
"volinfo %s for snap %s", snap_vol->volname,
snap->snapname);
save_ret = ret;
@@ -2836,7 +2969,8 @@ glusterd_snap_remove (dict_t *rsp_dict,
ret = glusterd_store_delete_snap (snap);
if (ret) {
- gf_log(this->name, GF_LOG_WARNING, "Failed to remove snap %s "
+ gf_msg(this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to remove snap %s "
"from store", snap->snapname);
save_ret = ret;
if (!force)
@@ -2845,13 +2979,14 @@ glusterd_snap_remove (dict_t *rsp_dict,
ret = glusterd_snapobject_delete (snap);
if (ret)
- gf_log (this->name, GF_LOG_WARNING, "Failed to delete "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to delete "
"snap object %s", snap->snapname);
if (save_ret)
ret = save_ret;
out:
- gf_log (THIS->name, GF_LOG_TRACE, "returning %d", ret);
+ gf_msg_trace (THIS->name, 0, "returning %d", ret);
return ret;
}
@@ -2885,7 +3020,8 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
snprintf (key, sizeof (key), "%s.volname", keyprefix);
ret = dict_set_dynstr (dict, key, value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set "
"volume name in dictionary: %s", key);
goto out;
}
@@ -2900,7 +3036,8 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
snprintf (key, sizeof (key), "%s.vol-id", keyprefix);
ret = dict_set_dynstr (dict, key, value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_MEMORY, "Failed to set "
"volume id in dictionary: %s", key);
goto out;
}
@@ -2919,12 +3056,14 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
ret = dict_set_str (dict, key, "None");
break;
default:
- gf_log (this->name, GF_LOG_ERROR, "Invalid volume status");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Invalid volume status");
ret = -1;
goto out;
}
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set volume status"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set volume status"
" in dictionary: %s", key);
goto out;
}
@@ -2932,7 +3071,8 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
ret = glusterd_volinfo_find (snap_vol->parent_volname, &origin_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to get the parent "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND, "failed to get the parent "
"volinfo for the volume %s", snap_vol->volname);
goto out;
}
@@ -2946,19 +3086,19 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
&opt_hard_max);
if (ret) {
ret = 0;
- gf_log (this->name, GF_LOG_DEBUG, "%s is not present in "
+ gf_msg_debug (this->name, 0, "%s is not present in "
"opts dictionary",
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
}
if (opt_hard_max < origin_vol->snap_max_hard_limit) {
snap_limit = opt_hard_max;
- gf_log(this->name, GF_LOG_DEBUG, "system snap-max-hard-limit is"
+ gf_msg_debug (this->name, 0, "system snap-max-hard-limit is"
" lesser than volume snap-max-hard-limit, "
"snap-max-hard-limit value is set to %d", snap_limit);
} else {
snap_limit = origin_vol->snap_max_hard_limit;
- gf_log(this->name, GF_LOG_DEBUG, "volume snap-max-hard-limit is"
+ gf_msg_debug (this->name, 0, "volume snap-max-hard-limit is"
" lesser than system snap-max-hard-limit, "
"snap-max-hard-limit value is set to %d", snap_limit);
}
@@ -2970,7 +3110,8 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
else
ret = dict_set_int32 (dict, key, 0);
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 available snaps");
goto out;
}
@@ -2978,7 +3119,8 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
snprintf (key, sizeof (key), "%s.snapcount", keyprefix);
ret = dict_set_int32 (dict, key, origin_vol->snap_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not save snapcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Could not save snapcount");
goto out;
}
@@ -2993,7 +3135,8 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
snprintf (key, sizeof (key), "%s.origin-volname", keyprefix);
ret = dict_set_dynstr (dict, key, value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set parent "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set parent "
"volume name in dictionary: %s", key);
goto out;
}
@@ -3034,7 +3177,8 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap,
snprintf (key, sizeof (key), "%s.snapname", keyprefix);
ret = dict_set_dynstr (dict, key, value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set "
"snap name in dictionary");
goto out;
}
@@ -3049,8 +3193,9 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap,
snprintf (key, sizeof (key), "%s.snap-id", keyprefix);
ret = dict_set_dynstr (dict, key, value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
- "snap id in dictionary");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set "
+ "snap id in dictionary");
goto out;
}
value = NULL;
@@ -3067,8 +3212,9 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap,
snprintf (key, sizeof (key), "%s.snap-time", keyprefix);
ret = dict_set_dynstr (dict, key, value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
- "snap time stamp in dictionary");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set "
+ "snap time stamp in dictionary");
goto out;
}
value = NULL;
@@ -3084,7 +3230,8 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap,
snprintf (key, sizeof (key), "%s.snap-desc", keyprefix);
ret = dict_set_dynstr (dict, key, value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set "
"snap description in dictionary");
goto out;
}
@@ -3109,12 +3256,14 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap,
ret = dict_set_str (dict, key, "None");
break;
default:
- gf_log (this->name, GF_LOG_ERROR, "Invalid snap status");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Invalid snap status");
ret = -1;
goto out;
}
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap status "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snap status "
"in dictionary");
goto out;
}
@@ -3125,7 +3274,8 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap,
ret = glusterd_snapshot_get_snapvol_detail (dict,
volinfo, key, 0);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_DICT_GET_FAILED, "Failed to "
"get volume detail %s for snap %s",
snap_vol->volname, snap->snapname);
goto out;
@@ -3140,7 +3290,8 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap,
ret = glusterd_snapshot_get_snapvol_detail (dict,
snap_vol, key, 1);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to "
"get volume detail %s for snap %s",
snap_vol->volname, snap->snapname);
goto out;
@@ -3151,7 +3302,8 @@ done:
snprintf (key, sizeof (key), "%s.vol-count", keyprefix);
ret = dict_set_int32 (dict, key, volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set %s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set %s",
key);
goto out;
}
@@ -3188,7 +3340,8 @@ glusterd_snapshot_get_all_snap_info (dict_t *dict)
snprintf (key, sizeof (key), "snap%d", snapcount);
ret = glusterd_snapshot_get_snap_detail (dict, snap, key, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get "
"snapdetail for snap %s", snap->snapname);
goto out;
}
@@ -3196,7 +3349,8 @@ glusterd_snapshot_get_all_snap_info (dict_t *dict)
ret = dict_set_int32 (dict, "snapcount", snapcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snapcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snapcount");
goto out;
}
@@ -3231,7 +3385,8 @@ glusterd_snapshot_get_info_by_volume (dict_t *dict, char *volname,
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
snprintf (err_str, len, "Volume (%s) does not exist", volname);
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND, "%s", err_str);
goto out;
}
@@ -3244,19 +3399,19 @@ glusterd_snapshot_get_info_by_volume (dict_t *dict, char *volname,
&opt_hard_max);
if (ret) {
ret = 0;
- gf_log (this->name, GF_LOG_DEBUG, "%s is not present in "
+ gf_msg_debug (this->name, 0, "%s is not present in "
"opts dictionary",
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
}
if (opt_hard_max < volinfo->snap_max_hard_limit) {
snap_limit = opt_hard_max;
- gf_log(this->name, GF_LOG_DEBUG, "system snap-max-hard-limit is"
+ gf_msg_debug (this->name, 0, "system snap-max-hard-limit is"
" lesser than volume snap-max-hard-limit, "
"snap-max-hard-limit value is set to %d", snap_limit);
} else {
snap_limit = volinfo->snap_max_hard_limit;
- gf_log(this->name, GF_LOG_DEBUG, "volume snap-max-hard-limit is"
+ gf_msg_debug (this->name, 0, "volume snap-max-hard-limit is"
" lesser than system snap-max-hard-limit, "
"snap-max-hard-limit value is set to %d", snap_limit);
}
@@ -3267,7 +3422,8 @@ glusterd_snapshot_get_info_by_volume (dict_t *dict, char *volname,
else
ret = dict_set_int32 (dict, "snaps-available", 0);
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 available snaps");
goto out;
}
@@ -3279,7 +3435,8 @@ glusterd_snapshot_get_info_by_volume (dict_t *dict, char *volname,
ret = dict_set_dynstr (dict, "origin-volname", value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set parent "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set parent "
"volume name in dictionary: %s", key);
goto out;
}
@@ -3293,7 +3450,8 @@ glusterd_snapshot_get_info_by_volume (dict_t *dict, char *volname,
snap_vol->snapshot,
key, snap_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get "
"snapdetail for snap %s",
snap_vol->snapshot->snapname);
goto out;
@@ -3301,7 +3459,8 @@ glusterd_snapshot_get_info_by_volume (dict_t *dict, char *volname,
}
ret = dict_set_int32 (dict, "snapcount", snapcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snapcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snapcount");
goto out;
}
@@ -3344,7 +3503,8 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_get_int32 (dict, "cmd", &cmd);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get type "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get type "
"of snapshot info");
goto out;
}
@@ -3354,7 +3514,8 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op,
{
ret = glusterd_snapshot_get_all_snap_info (dict);
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 info of all snaps");
goto out;
}
@@ -3365,14 +3526,16 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op,
{
ret = dict_get_str (dict, "snapname", &snapname);
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 snap name");
goto out;
}
ret = dict_set_int32 (dict, "snapcount", 1);
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 snapcount");
goto out;
}
@@ -3382,7 +3545,8 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op,
snprintf (err_str, len,
"Snapshot (%s) does not exist",
snapname);
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND,
"%s", err_str);
ret = -1;
goto out;
@@ -3390,7 +3554,8 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op,
ret = glusterd_snapshot_get_snap_detail (dict, snap,
"snap1", NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_NOT_FOUND,
"Failed to get snap detail of snap "
"%s", snap->snapname);
goto out;
@@ -3402,14 +3567,16 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op,
{
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND,
"Failed to get volname");
goto out;
}
ret = glusterd_snapshot_get_info_by_volume (dict,
volname, err_str, len);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND,
"Failed to get volume info of volume "
"%s", volname);
goto out;
@@ -3421,7 +3588,8 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_set_int8 (dict, "snap-driven", snap_driven);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap-driven");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snap-driven");
goto out;
}
@@ -3430,8 +3598,9 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op,
of the response */
ret = glusterd_op_send_cli_response (op, 0, 0, req, dict, err_str);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to send cli "
- "response");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_CLI_RESP, "Failed to send cli "
+ "response");
goto out;
}
@@ -3464,7 +3633,8 @@ glusterd_snapshot_get_all_snapnames (dict_t *dict)
snapcount++;
snapname = gf_strdup (snap->snapname);
if (!snapname) {
- gf_log (this->name, GF_LOG_ERROR, "strdup failed");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "strdup failed");
ret = -1;
goto out;
}
@@ -3472,7 +3642,8 @@ glusterd_snapshot_get_all_snapnames (dict_t *dict)
ret = dict_set_dynstr (dict, key, snapname);
if (ret) {
GF_FREE (snapname);
- gf_log (this->name, GF_LOG_ERROR, "Failed to set %s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set %s",
key);
goto out;
}
@@ -3480,7 +3651,8 @@ glusterd_snapshot_get_all_snapnames (dict_t *dict)
ret = dict_set_int32 (dict, "snapcount", snapcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snapcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snapcount");
goto out;
}
@@ -3515,7 +3687,8 @@ glusterd_snapshot_get_vol_snapnames (dict_t *dict, glusterd_volinfo_t *volinfo)
ret = dict_set_dynstr_with_alloc (dict, key,
snap_vol->snapshot->snapname);
if (ret) {
- 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 %s", key);
GF_FREE (snapname);
goto out;
@@ -3524,7 +3697,8 @@ glusterd_snapshot_get_vol_snapnames (dict_t *dict, glusterd_volinfo_t *volinfo)
ret = dict_set_int32 (dict, "snapcount", snapcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snapcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snapcount");
goto out;
}
@@ -3554,7 +3728,8 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op,
if (NULL == volname) {
ret = glusterd_snapshot_get_all_snapnames (dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_LIST_GET_FAIL,
"Failed to get snapshot list");
goto out;
}
@@ -3563,14 +3738,16 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op,
if (ret) {
snprintf (err_str, len,
"Volume (%s) does not exist", volname);
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND,
"%s", err_str);
goto out;
}
ret = glusterd_snapshot_get_vol_snapnames (dict, volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_LIST_GET_FAIL,
"Failed to get snapshot list for volume %s",
volname);
goto out;
@@ -3581,7 +3758,8 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op,
In case of failure the caller of this function will take of response.*/
ret = glusterd_op_send_cli_response (op, 0, 0, req, dict, err_str);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to send cli "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_CLI_RESP, "Failed to send cli "
"response");
goto out;
}
@@ -3632,12 +3810,14 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_get_int64 (dict, "volcount", &volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to "
"get the volume count");
goto out;
}
if (volcount <= 0) {
- gf_log (this->name, GF_LOG_ERROR, "Invalid volume count %"PRId64
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Invalid volume count %"PRId64
" supplied", volcount);
ret = -1;
goto out;
@@ -3645,20 +3825,22 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to get the snapname");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to get the snapname");
goto out;
}
timestamp = dict_get_str_boolean (dict, "no-timestamp", _gf_false);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, "no-timestamp flag "
+ gf_msg_debug (this->name, 0, "no-timestamp flag "
"is not set");
goto out;
}
ret = dict_set_int64 (dict, "snap-time", (int64_t)time(&snap_time));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set snap-time");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to set snap-time");
goto out;
}
@@ -3670,7 +3852,8 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_set_dynstr_with_alloc (dict, "snapname",
new_snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to update "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to update "
"snap-name");
goto out;
}
@@ -3680,14 +3863,16 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
if (strlen(snapname) >= GLUSTERD_MAX_SNAP_NAME) {
snprintf (err_str, len, "snapname cannot exceed 255 "
"characters");
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "%s", err_str);
ret = -1;
goto out;
}
uuid_ptr = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
if (!uuid_ptr) {
- gf_log (this->name, GF_LOG_ERROR, "Out Of Memory");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out Of Memory");
ret = -1;
goto out;
}
@@ -3695,7 +3880,8 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
gf_uuid_generate (*uuid_ptr);
ret = dict_set_bin (dict, "snap-id", uuid_ptr, sizeof(uuid_t));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set snap-id");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to set snap-id");
GF_FREE (uuid_ptr);
goto out;
}
@@ -3705,7 +3891,8 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
snprintf (key, sizeof (key), "volname%d", i);
ret = dict_get_str (dict, key, &volname);
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 volume name");
goto out;
}
@@ -3716,7 +3903,8 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
snprintf (key, sizeof(key), "volume%d_username", i);
ret = dict_set_dynstr (dict, key, username);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snap "
"username for volume %s", volname);
GF_FREE (username);
goto out;
@@ -3727,7 +3915,8 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
snprintf (key, sizeof(key), "volume%d_password", i);
ret = dict_set_dynstr (dict, key, password);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snap "
"password for volume %s", volname);
GF_FREE (password);
goto out;
@@ -3735,7 +3924,8 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
uuid_ptr = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
if (!uuid_ptr) {
- gf_log (this->name, GF_LOG_ERROR, "Out Of Memory");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out Of Memory");
ret = -1;
goto out;
}
@@ -3744,7 +3934,8 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
gf_uuid_generate (*uuid_ptr);
ret = dict_set_bin (dict, key, uuid_ptr, sizeof(uuid_t));
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 snap_volid");
GF_FREE (uuid_ptr);
goto out;
@@ -3753,7 +3944,8 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
snprintf (key, sizeof (key), "snap-volname%d", i);
ret = dict_set_dynstr_with_alloc (dict, key, snap_volname);
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 snap volname");
GF_FREE (uuid_ptr);
goto out;
@@ -3762,7 +3954,9 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
ret = glusterd_mgmt_v3_initiate_snap_phases (req, op, dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to initiate snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_INIT_FAIL,
+ "Failed to initiate snap "
"phases");
}
@@ -3802,7 +3996,8 @@ glusterd_handle_snapshot_status (rpcsvc_request_t *req, glusterd_op_t op,
ret = glusterd_mgmt_v3_initiate_snap_phases (req, op, dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to initiate "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_INIT_FAIL, "Failed to initiate "
"snap phases");
goto out;
}
@@ -3850,7 +4045,8 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_get_str (dict, "clonename", &clonename);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to "
"get the clone name");
goto out;
}
@@ -3859,7 +4055,8 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
snprintf (key, sizeof(key), "volname1");
ret = dict_set_dynstr (dict, key, volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set clone "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set clone "
"name for volume locking");
GF_FREE (volname);
goto out;
@@ -3867,13 +4064,15 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to get the snapname");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to get the snapname");
goto out;
}
uuid_ptr = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
if (!uuid_ptr) {
- gf_log (this->name, GF_LOG_ERROR, "Out Of Memory");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out Of Memory");
ret = -1;
goto out;
}
@@ -3881,7 +4080,8 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
gf_uuid_generate (*uuid_ptr);
ret = dict_set_bin (dict, "clone-id", uuid_ptr, sizeof(uuid_t));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set clone-id");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to set clone-id");
GF_FREE (uuid_ptr);
goto out;
}
@@ -3889,7 +4089,8 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_get_str (dict, "snapname", &snapname);
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 snapname name");
goto out;
}
@@ -3899,7 +4100,9 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
snprintf (key, sizeof(key), "volume1_username");
ret = dict_set_dynstr (dict, key, username);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set clone "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "Failed to set clone "
"username for volume %s", clonename);
GF_FREE (username);
goto out;
@@ -3910,7 +4113,9 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
snprintf (key, sizeof(key), "volume1_password");
ret = dict_set_dynstr (dict, key, password);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set clone "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "Failed to set clone "
"password for volume %s", clonename);
GF_FREE (password);
goto out;
@@ -3918,7 +4123,8 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
uuid_ptr = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
if (!uuid_ptr) {
- gf_log (this->name, GF_LOG_ERROR, "Out Of Memory");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out Of Memory");
ret = -1;
goto out;
}
@@ -3927,7 +4133,8 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
gf_uuid_generate (*uuid_ptr);
ret = dict_set_bin (dict, key, uuid_ptr, sizeof(uuid_t));
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 clone_volid");
GF_FREE (uuid_ptr);
goto out;
@@ -3935,7 +4142,8 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
snprintf (key, sizeof (key), "clone-volname%d", i);
ret = dict_set_dynstr_with_alloc (dict, key, snap_volname);
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 snap volname");
GF_FREE (uuid_ptr);
goto out;
@@ -3943,8 +4151,9 @@ glusterd_handle_snapshot_clone (rpcsvc_request_t *req, glusterd_op_t op,
ret = glusterd_mgmt_v3_initiate_snap_phases (req, op, dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to initiate snap "
- "phases");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_INIT_FAIL, "Failed to initiate "
+ "snap phases");
}
out:
@@ -3989,7 +4198,8 @@ glusterd_handle_snapshot_restore (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to "
"get snapname");
goto out;
}
@@ -3998,7 +4208,8 @@ glusterd_handle_snapshot_restore (rpcsvc_request_t *req, glusterd_op_t op,
if (!snap) {
snprintf (err_str, len, "Snapshot (%s) does not exist",
snapname);
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND, "%s", err_str);
ret = -1;
goto out;
}
@@ -4013,7 +4224,8 @@ glusterd_handle_snapshot_restore (rpcsvc_request_t *req, glusterd_op_t op,
}
ret = dict_set_dynstr (dict, key, buf);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not set "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Could not set "
"parent volume name %s in the dict",
snap_volinfo->parent_volname);
GF_FREE (buf);
@@ -4024,15 +4236,17 @@ glusterd_handle_snapshot_restore (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_set_int32 (dict, "volcount", i);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Could not save volume count");
goto out;
}
ret = glusterd_mgmt_v3_initiate_snap_phases (req, op, dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to initiate snap "
- "phases");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_INIT_FAIL,
+ "Failed to initiate snap phases");
goto out;
}
@@ -4063,7 +4277,8 @@ glusterd_create_snap_object (dict_t *dict, dict_t *rsp_dict)
/* Fetch snapname, description, id and time from dict */
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch snapname");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to fetch snapname");
goto out;
}
@@ -4072,18 +4287,21 @@ glusterd_create_snap_object (dict_t *dict, dict_t *rsp_dict)
ret = dict_get_bin (dict, "snap-id", (void **)&snap_id);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch snap_id");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to fetch snap_id");
goto out;
}
ret = dict_get_int64 (dict, "snap-time", &time_stamp);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch snap-time");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to fetch snap-time");
goto out;
}
if (time_stamp <= 0) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "Invalid time-stamp: %"PRId64,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Invalid time-stamp: %"PRId64,
time_stamp);
goto out;
}
@@ -4091,7 +4309,8 @@ glusterd_create_snap_object (dict_t *dict, dict_t *rsp_dict)
cds_list_for_each_entry (snap, &priv->snapshots, snap_list) {
if (!strcmp (snap->snapname, snapname) ||
!gf_uuid_compare (snap->snap_id, *snap_id)) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL,
"Found duplicate snap %s (%s)",
snap->snapname, uuid_utoa (snap->snap_id));
ret = -1;
@@ -4105,7 +4324,8 @@ glusterd_create_snap_object (dict_t *dict, dict_t *rsp_dict)
snap = glusterd_new_snap_object ();
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR, "Could not create "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Could not create "
"the snap object for snap %s", snapname);
goto out;
}
@@ -4122,7 +4342,8 @@ glusterd_create_snap_object (dict_t *dict, dict_t *rsp_dict)
if (description) {
snap->description = gf_strdup (description);
if (snap->description == NULL) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL,
"Saving the Snapshot Description Failed");
ret = -1;
goto out;
@@ -4131,7 +4352,8 @@ glusterd_create_snap_object (dict_t *dict, dict_t *rsp_dict)
ret = glusterd_store_snap (snap);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Could not store snap"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Could not store snap"
"object %s", snap->snapname);
goto out;
}
@@ -4139,7 +4361,7 @@ glusterd_create_snap_object (dict_t *dict, dict_t *rsp_dict)
glusterd_list_add_order (&snap->snap_list, &priv->snapshots,
glusterd_compare_snap_time);
- gf_log (this->name, GF_LOG_TRACE, "Snapshot %s added to the list",
+ gf_msg_trace (this->name, 0, "Snapshot %s added to the list",
snap->snapname);
ret = 0;
@@ -4200,7 +4422,8 @@ glusterd_add_missed_snaps_to_dict (dict_t *rsp_dict,
ret = dict_set_dynstr_with_alloc (rsp_dict, name_buf,
missed_snap_entry);
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 missed_snap_entry (%s) "
"in the rsp_dict.", missed_snap_entry);
goto out;
@@ -4211,7 +4434,8 @@ glusterd_add_missed_snaps_to_dict (dict_t *rsp_dict,
ret = dict_set_int32 (rsp_dict, "missed_snap_count",
missed_snap_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 missed_snap_count for %s "
"in the rsp_dict.", missed_snap_entry);
goto out;
@@ -4221,7 +4445,7 @@ out:
if (snap_uuid)
GF_FREE (snap_uuid);
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4250,7 +4474,8 @@ glusterd_take_lvm_snapshot (glusterd_brickinfo_t *brickinfo,
origin_device = glusterd_get_brick_mount_device (origin_brick_path);
if (!origin_device) {
- gf_log (this->name, GF_LOG_ERROR, "getting device name for "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_GET_INFO_FAIL, "getting device name for "
"the brick %s failed", origin_brick_path);
goto out;
}
@@ -4263,7 +4488,8 @@ glusterd_take_lvm_snapshot (glusterd_brickinfo_t *brickinfo,
runner_redir (&runner, STDOUT_FILENO, RUN_PIPE);
ret = runner_start (&runner);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_LVCREATE_FAIL,
"Failed to run lvcreate help");
runner_end (&runner);
goto out;
@@ -4296,7 +4522,8 @@ glusterd_take_lvm_snapshot (glusterd_brickinfo_t *brickinfo,
runner_log (&runner, this->name, GF_LOG_DEBUG, msg);
ret = runner_run (&runner);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "taking snapshot of the "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "taking snapshot of the "
"brick (%s) of device %s failed",
origin_brick_path, origin_device);
}
@@ -4328,7 +4555,9 @@ glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo,
ret = mkdir_p (snap_brick_mount_path, 0777, _gf_true);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "creating the brick directory"
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED,
+ "creating the brick directory"
" %s for the snapshot %s(device: %s) failed",
snap_brick_mount_path, snap_volinfo->volname,
brickinfo->device_path);
@@ -4343,14 +4572,17 @@ glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo,
*/
ret = glusterd_mount_lvm_snapshot (brickinfo, snap_brick_mount_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_LVM_MOUNT_FAILED,
"Failed to mount lvm snapshot.");
goto out;
}
ret = stat (brickinfo->path, &statbuf);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "stat of the brick %s"
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ GD_MSG_FILE_OP_FAILED,
+ "stat of the brick %s"
"(brick mount: %s) failed (%s)", brickinfo->path,
snap_brick_mount_path, strerror (errno));
goto out;
@@ -4360,7 +4592,8 @@ glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo,
snap_volinfo->volume_id, 16,
XATTR_REPLACE);
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_SETXATTR_FAIL, "Failed to set "
"extended attribute %s on %s. Reason: "
"%s, snap: %s", GF_XATTR_VOL_ID_KEY,
brickinfo->path, strerror (errno),
@@ -4370,14 +4603,15 @@ glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo,
out:
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "unmounting the snap brick"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_UMOUNTING_SNAP_BRICK, "unmounting the snap brick"
" mount %s", snap_brick_mount_path);
/*umount2 system call doesn't cleanup mtab entry after un-mount.
So use external umount command*/
glusterd_umount (snap_brick_mount_path);
}
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4409,13 +4643,15 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict,
volcount, brick_count);
ret = dict_set_dynstr_with_alloc (dict, key, original_brickinfo->path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set %s", key);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set %s", key);
goto out;
}
ret = glusterd_brickinfo_new (&snap_brickinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_NEW_INFO_FAIL,
"initializing the brick for the snap "
"volume failed (snapname: %s)",
snap_vol->snapshot->snapname);
@@ -4454,7 +4690,8 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict,
* pending snapshot and storing the original brickinfo
* will help in mapping while recreating the missed snapshot
*/
- gf_log (this->name, GF_LOG_WARNING, "Unable to fetch "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_NOT_FOUND, "Unable to fetch "
"snap mount path(%s). Adding to missed_snap_list", key);
snap_brickinfo->snap_status = -1;
@@ -4471,7 +4708,8 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict,
(!gf_uuid_compare (original_brickinfo->uuid, MY_UUID)) &&
(!glusterd_is_brick_started (original_brickinfo))) {
/* In case if the brick goes down after prevalidate. */
- gf_log (this->name, GF_LOG_WARNING, "brick %s:%s is not"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_BRICK_DISCONNECTED, "brick %s:%s is not"
" started (snap: %s)",
original_brickinfo->hostname,
original_brickinfo->path,
@@ -4488,7 +4726,9 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict,
brick_count + 1,
GF_SNAP_OPTION_TYPE_CREATE);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to add missed"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MISSEDSNAP_INFO_SET_FAIL,
+ "Failed to add missed"
" snapshot info for %s:%s in the rsp_dict",
original_brickinfo->hostname,
original_brickinfo->path);
@@ -4511,14 +4751,16 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict,
/* If the device name is empty, so will be the brick path
* Hence the missed snap has already been added above
*/
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_NOT_FOUND, "Unable to fetch "
"snap device (%s). Leaving empty", key);
} else
strcpy (snap_brickinfo->device_path, snap_device);
ret = gf_canonicalize_path (snap_brick_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_CANONICALIZE_FAIL,
"Failed to canonicalize path");
goto out;
}
@@ -4541,7 +4783,7 @@ out:
if (ret && snap_brickinfo)
GF_FREE (snap_brickinfo);
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4600,7 +4842,8 @@ glusterd_update_fs_label (glusterd_brickinfo_t *brickinfo)
runner_add_args (&runner, "tune2fs", "-L", label,
brickinfo->device_path, NULL);
} else {
- gf_log (this->name, GF_LOG_WARNING, "Changing file-system "
+ gf_msg (this->name, GF_LOG_WARNING, EOPNOTSUPP,
+ GD_MSG_OP_UNSUPPORTED, "Changing file-system "
"label of %s file-system is not supported as of now",
brickinfo->fstype);
runner_end (&runner);
@@ -4611,7 +4854,8 @@ glusterd_update_fs_label (glusterd_brickinfo_t *brickinfo)
runner_log (&runner, this->name, GF_LOG_DEBUG, msg);
ret = runner_run (&runner);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to change "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FS_LABEL_UPDATE_FAIL, "Failed to change "
"filesystem label of %s brick to %s",
brickinfo->path, label);
goto out;
@@ -4639,7 +4883,8 @@ glusterd_take_brick_snapshot (dict_t *dict, glusterd_volinfo_t *snap_vol,
GF_ASSERT (brickinfo);
if (strlen(brickinfo->device_path) == 0) {
- gf_log (this->name, GF_LOG_ERROR, "Device path is empty "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Device path is empty "
"brick %s:%s", brickinfo->hostname, brickinfo->path);
ret = -1;
goto out;
@@ -4649,14 +4894,16 @@ glusterd_take_brick_snapshot (dict_t *dict, glusterd_volinfo_t *snap_vol,
brick_count);
ret = dict_get_str (dict, key, &origin_brick_path);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Unable to fetch "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to fetch "
"brick path (%s)", key);
goto out;
}
ret = glusterd_take_lvm_snapshot (brickinfo, origin_brick_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to take snapshot of "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Failed to take snapshot of "
"brick %s:%s", brickinfo->hostname, origin_brick_path);
goto out;
}
@@ -4668,7 +4915,8 @@ glusterd_take_brick_snapshot (dict_t *dict, glusterd_volinfo_t *snap_vol,
*/
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_FS_LABEL_UPDATE_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
@@ -4679,7 +4927,8 @@ glusterd_take_brick_snapshot (dict_t *dict, glusterd_volinfo_t *snap_vol,
/* create the complete brick here */
ret = glusterd_snap_brick_create (snap_vol, brickinfo, brick_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "not able to"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_CREATION_FAIL, "not able to"
" create the brick for the snap %s"
", volume %s", snap_vol->snapshot->snapname,
snap_vol->volname);
@@ -4687,7 +4936,7 @@ glusterd_take_brick_snapshot (dict_t *dict, glusterd_volinfo_t *snap_vol,
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4723,14 +4972,16 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
snprintf (key, sizeof(key), "volume%"PRId64"_username", volcount);
ret = dict_get_str (dict, key, &username);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get %s for "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get %s for "
"snap %s", key, snap->snapname);
goto out;
}
snprintf (key, sizeof(key), "volume%"PRId64"_password", volcount);
ret = dict_get_str (dict, key, &password);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get %s for "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get %s for "
"snap %s", key, snap->snapname);
goto out;
}
@@ -4738,7 +4989,8 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
snprintf (key, sizeof(key) - 1, "vol%"PRId64"_volid", volcount);
ret = dict_get_bin (dict, key, (void **)&snap_volid);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch snap_volid");
goto out;
}
@@ -4749,7 +5001,8 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
*/
ret = glusterd_volinfo_dup (origin_vol, &snap_vol, _gf_false);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to duplicate volinfo "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_OP_FAILED, "Failed to duplicate volinfo "
"for the snapshot %s", snap->snapname);
goto out;
}
@@ -4764,7 +5017,8 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
snap_vol->is_snap_volume = _gf_false;
ret = dict_get_str (dict, "clonename", &clonename);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get %s "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get %s "
"for snap %s", key, snap->snapname);
goto out;
}
@@ -4775,7 +5029,8 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
strcpy (snap_vol->parent_volname, origin_vol->volname);
ret = glusterd_list_add_snapvol (origin_vol, snap_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "could not add the "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_LIST_SET_FAIL, "could not add the "
"snap volume %s to the list",
snap_vol->volname);
goto out;
@@ -4788,7 +5043,8 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
ret = glusterd_copy_geo_rep_files (origin_vol, snap_vol,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to copy "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_OP_FAILED, "Failed to copy "
"geo-rep config and status files for volume %s",
origin_vol->volname);
goto out;
@@ -4805,7 +5061,8 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
volcount, brick_count,
clone);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_ADD_FAIL,
"Failed to add the snap brick for "
"%s:%s to the snap volume",
brickinfo->hostname, brickinfo->path);
@@ -4829,7 +5086,8 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
ret = glusterd_store_volinfo (snap_vol,
GLUSTERD_VOLINFO_VER_AC_INCREMENT);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to store snapshot "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_SET_FAIL, "Failed to store snapshot "
"volinfo (%s) for snap %s", snap_vol->volname,
snap->snapname);
goto out;
@@ -4837,14 +5095,16 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
ret = glusterd_copy_quota_files (origin_vol, snap_vol, &conf_present);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to copy quota "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_VOL_CONFIG_FAIL, "Failed to copy quota "
"config and cksum for volume %s", origin_vol->volname);
goto out;
}
ret = generate_brick_volfiles (snap_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "generating the brick "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL, "generating the brick "
"volfiles for the snap %s (volume: %s) failed",
snap->snapname, origin_vol->volname);
goto out;
@@ -4852,7 +5112,8 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
ret = generate_client_volfiles (snap_vol, GF_CLIENT_TRUSTED);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "generating the trusted "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL, "generating the trusted "
"client volfiles for the snap %s (volume: %s) failed",
snap->snapname, origin_vol->volname);
goto out;
@@ -4860,7 +5121,8 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,
ret = generate_client_volfiles (snap_vol, GF_CLIENT_OTHER);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "generating the client "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL, "generating the client "
"volfiles for the snap %s (volume: %s) failed",
snap->snapname, origin_vol->volname);
goto out;
@@ -4898,13 +5160,15 @@ glusterd_snapshot_activate_deactivate_prevalidate (dict_t *dict,
this = THIS;
if (!dict || !op_errstr) {
- gf_log (this->name, GF_LOG_ERROR, "input parameters NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "input parameters NULL");
goto out;
}
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Getting the snap name "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Getting the snap name "
"failed");
goto out;
}
@@ -4921,7 +5185,8 @@ glusterd_snapshot_activate_deactivate_prevalidate (dict_t *dict,
if (is_op_activate) {
ret = dict_get_int32 (dict, "flags", &flags);
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 flags");
goto out;
}
@@ -4933,7 +5198,8 @@ glusterd_snapshot_activate_deactivate_prevalidate (dict_t *dict,
snap_volinfo = cds_list_entry (snap->volumes.next, glusterd_volinfo_t,
vol_list);
if (!snap_volinfo) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOLINFO_GET_FAIL,
"Unable to fetch snap_volinfo");
ret = -1;
goto out;
@@ -4970,7 +5236,8 @@ glusterd_snapshot_activate_deactivate_prevalidate (dict_t *dict,
out:
if (ret && err_str[0] != '\0') {
- gf_log (this->name, loglevel, "%s", err_str);
+ gf_msg (this->name, loglevel, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED, "%s", err_str);
*op_errstr = gf_strdup (err_str);
}
@@ -4995,7 +5262,8 @@ glusterd_handle_snapshot_delete_vol (dict_t *dict, char *err_str, int len)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get "
"volume name");
goto out;
}
@@ -5003,14 +5271,16 @@ glusterd_handle_snapshot_delete_vol (dict_t *dict, char *err_str, int len)
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
snprintf (err_str, len, "Volume (%s) does not exist", volname);
- gf_log (this->name, GF_LOG_ERROR, "Failed to get volinfo of "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND, "Failed to get volinfo of "
"volume %s", volname);
goto out;
}
ret = glusterd_snapshot_get_vol_snapnames (dict, volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_LIST_GET_FAIL,
"Failed to get snapshot list for volume %s", volname);
goto out;
}
@@ -5051,7 +5321,8 @@ glusterd_handle_snapshot_delete_all (dict_t *dict)
ret = dict_set_dynstr_with_alloc (dict, key, snap->snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not save "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Could not save "
"snap name");
goto out;
}
@@ -5059,7 +5330,9 @@ glusterd_handle_snapshot_delete_all (dict_t *dict)
ret = dict_set_int32 (dict, "snapcount", i);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not save snapcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "Could not save snapcount");
goto out;
}
@@ -5094,7 +5367,8 @@ glusterd_handle_snapshot_delete_type_snap (rpcsvc_request_t *req,
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get snapname");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to get snapname");
goto out;
}
@@ -5102,8 +5376,8 @@ glusterd_handle_snapshot_delete_type_snap (rpcsvc_request_t *req,
if (!snap) {
snprintf (err_str, len, "Snapshot (%s) does not exist",
snapname);
- gf_log (this->name, GF_LOG_ERROR,
- "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND, "%s", err_str);
ret = -1;
goto out;
}
@@ -5114,14 +5388,16 @@ glusterd_handle_snapshot_delete_type_snap (rpcsvc_request_t *req,
volname = gf_strdup (snap_vol->parent_volname);
if (!volname) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "strdup failed");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "strdup failed");
goto out;
}
snprintf (key, sizeof (key), "volname%"PRId64, volcount);
ret = dict_set_dynstr (dict, key, volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set "
"volume name in dictionary");
GF_FREE (volname);
goto out;
@@ -5130,13 +5406,16 @@ glusterd_handle_snapshot_delete_type_snap (rpcsvc_request_t *req,
}
ret = dict_set_int64 (dict, "volcount", volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set volcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "Failed to set volcount");
goto out;
}
ret = glusterd_mgmt_v3_initiate_snap_phases (req, op, dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to initiate snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_INIT_FAIL, "Failed to initiate snap "
"phases");
goto out;
}
@@ -5177,7 +5456,8 @@ glusterd_handle_snapshot_delete (rpcsvc_request_t *req, glusterd_op_t op,
ret = dict_get_int32 (dict, "delete-cmd", &delete_cmd);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get delete-cmd");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_COMMAND_NOT_FOUND, "Failed to get delete-cmd");
goto out;
}
@@ -5186,7 +5466,8 @@ glusterd_handle_snapshot_delete (rpcsvc_request_t *req, glusterd_op_t op,
ret = glusterd_handle_snapshot_delete_type_snap (req, op, dict,
err_str, len);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to handle "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to handle "
"snapshot delete for type SNAP");
goto out;
}
@@ -5195,7 +5476,8 @@ glusterd_handle_snapshot_delete (rpcsvc_request_t *req, glusterd_op_t op,
case GF_SNAP_DELETE_TYPE_ALL:
ret = glusterd_handle_snapshot_delete_all (dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to handle "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to handle "
"snapshot delete for type ALL");
goto out;
}
@@ -5204,14 +5486,16 @@ glusterd_handle_snapshot_delete (rpcsvc_request_t *req, glusterd_op_t op,
case GF_SNAP_DELETE_TYPE_VOL:
ret = glusterd_handle_snapshot_delete_vol (dict, err_str, len);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to handle "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to handle "
"snapshot delete for type VOL");
goto out;
}
break;
default:
- gf_log (this->name, GF_LOG_ERROR, "Wrong snapshot delete type");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Wrong snapshot delete type");
break;
}
@@ -5220,7 +5504,8 @@ glusterd_handle_snapshot_delete (rpcsvc_request_t *req, glusterd_op_t op,
ret = glusterd_op_send_cli_response (op, 0, 0, req, dict,
err_str);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to send cli "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_NO_CLI_RESP, "Failed to send cli "
"response");
goto out;
}
@@ -5242,20 +5527,23 @@ glusterd_snapshot_remove_prevalidate (dict_t *dict, char **op_errstr,
this = THIS;
if (!dict || !op_errstr) {
- gf_log (this->name, GF_LOG_ERROR, "input parameters NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "input parameters NULL");
goto out;
}
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Getting the snap name "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Getting the snap name "
"failed");
goto out;
}
snap = glusterd_find_snap_by_name (snapname);
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND,
"Snapshot (%s) does not exist", snapname);
ret = -1;
goto out;
@@ -5264,7 +5552,8 @@ glusterd_snapshot_remove_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_set_dynstr_with_alloc (dict, "snapuuid",
uuid_utoa (snap->snap_id));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snap "
"uuid in response dictionary for %s snapshot",
snap->snapname);
goto out;
@@ -5294,13 +5583,15 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr,
GF_ASSERT (conf);
GF_ASSERT (op_errstr);
if (!dict) {
- gf_log (this->name, GF_LOG_ERROR, "Input dict is NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "Input dict is NULL");
goto out;
}
ret = dict_get_int32 (dict, "status-cmd", &cmd);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Could not fetch status cmd");
goto out;
}
@@ -5314,7 +5605,8 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr,
{
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Could not fetch snapname");
goto out;
}
@@ -5326,7 +5618,8 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr,
goto out;
}
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND,
"Snapshot (%s) does not exist",
snapname);
goto out;
@@ -5337,7 +5630,8 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr,
{
ret = dict_get_str (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,
"Could not fetch volname");
goto out;
}
@@ -5350,7 +5644,8 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr,
goto out;
}
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "Volume "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND, "Volume "
"%s not present", volname);
goto out;
}
@@ -5359,7 +5654,8 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr,
}
default:
{
- gf_log (this->name, GF_LOG_ERROR, "Invalid command");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_COMMAND_NOT_FOUND, "Invalid command");
break;
}
}
@@ -5387,26 +5683,30 @@ glusterd_snapshot_activate_commit (dict_t *dict, char **op_errstr,
GF_ASSERT (op_errstr);
if (!dict || !op_errstr) {
- gf_log (this->name, GF_LOG_ERROR, "input parameters NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "input parameters NULL");
goto out;
}
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Getting the snap name "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Getting the snap name "
"failed");
goto out;
}
ret = dict_get_int32 (dict, "flags", &flags);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get flags");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get flags");
goto out;
}
snap = glusterd_find_snap_by_name (snapname);
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND,
"Snapshot (%s) does not exist", snapname);
ret = -1;
goto out;
@@ -5418,7 +5718,8 @@ glusterd_snapshot_activate_commit (dict_t *dict, char **op_errstr,
snap_volinfo = cds_list_entry (snap->volumes.next, glusterd_volinfo_t,
vol_list);
if (!snap_volinfo) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_GET_FAIL,
"Unable to fetch snap_volinfo");
ret = -1;
goto out;
@@ -5427,7 +5728,8 @@ glusterd_snapshot_activate_commit (dict_t *dict, char **op_errstr,
ret = glusterd_start_volume (snap_volinfo, flags, _gf_true);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_ACTIVATE_FAIL,
"Failed to activate snap volume %s of the snap %s",
snap_volinfo->volname, snap->snapname);
goto out;
@@ -5436,7 +5738,8 @@ glusterd_snapshot_activate_commit (dict_t *dict, char **op_errstr,
ret = dict_set_dynstr_with_alloc (rsp_dict, "snapuuid",
uuid_utoa (snap->snap_id));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snap "
"uuid in response dictionary for %s snapshot",
snap->snapname);
goto out;
@@ -5464,20 +5767,23 @@ glusterd_snapshot_deactivate_commit (dict_t *dict, char **op_errstr,
GF_ASSERT (op_errstr);
if (!dict || !op_errstr) {
- gf_log (this->name, GF_LOG_ERROR, "input parameters NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "input parameters NULL");
goto out;
}
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Getting the snap name "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Getting the snap name "
"failed");
goto out;
}
snap = glusterd_find_snap_by_name (snapname);
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND,
"Snapshot (%s) does not exist", snapname);
ret = -1;
goto out;
@@ -5489,7 +5795,8 @@ glusterd_snapshot_deactivate_commit (dict_t *dict, char **op_errstr,
snap_volinfo = cds_list_entry (snap->volumes.next, glusterd_volinfo_t,
vol_list);
if (!snap_volinfo) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_GET_FAIL,
"Unable to fetch snap_volinfo");
ret = -1;
goto out;
@@ -5497,7 +5804,8 @@ glusterd_snapshot_deactivate_commit (dict_t *dict, char **op_errstr,
ret = glusterd_stop_volume (snap_volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to deactivate"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_DEACTIVATE_FAIL, "Failed to deactivate"
"snap %s", snapname);
goto out;
}
@@ -5505,7 +5813,8 @@ glusterd_snapshot_deactivate_commit (dict_t *dict, char **op_errstr,
ret = dict_set_dynstr_with_alloc (rsp_dict, "snapuuid",
uuid_utoa (snap->snap_id));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snap "
"uuid in response dictionary for %s snapshot",
snap->snapname);
goto out;
@@ -5538,20 +5847,23 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr,
GF_ASSERT (priv);
if (!dict || !op_errstr) {
- gf_log (this->name, GF_LOG_ERROR, "input parameters NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "input parameters NULL");
goto out;
}
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Getting the snap name "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Getting the snap name "
"failed");
goto out;
}
snap = glusterd_find_snap_by_name (snapname);
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND,
"Snapshot (%s) does not exist", snapname);
ret = -1;
goto out;
@@ -5560,7 +5872,8 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr,
ret = dict_set_dynstr_with_alloc (rsp_dict, "snapuuid",
uuid_utoa (snap->snap_id));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap uuid in "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snap uuid in "
"response dictionary for %s snapshot",
snap->snapname);
goto out;
@@ -5572,11 +5885,13 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr,
snap->snap_status = GD_SNAP_STATUS_DECOMMISSION;
ret = glusterd_store_snap (snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_OBJECT_STORE_FAIL, "Failed to "
"store snap object %s", snap->snapname);
goto out;
} else
- gf_log (this->name, GF_LOG_INFO, "Successfully marked "
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_SNAPSHOT_OP_SUCCESS, "Successfully marked "
"snap %s for decommission.", snap->snapname);
if (is_origin_glusterd (dict) == _gf_true) {
@@ -5587,7 +5902,8 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr,
glusterd_volinfo_t,
vol_list);
if (!snap_volinfo) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_GET_FAIL,
"Unable to fetch snap_volinfo");
ret = -1;
goto out;
@@ -5599,7 +5915,8 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr,
&priv->peers,
GF_SNAP_OPTION_TYPE_DELETE);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MISSED_SNAP_GET_FAIL,
"Failed to find missed snap deletes");
goto out;
}
@@ -5607,21 +5924,24 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr,
ret = glusterd_snap_remove (rsp_dict, snap, _gf_true, _gf_false);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to remove snap %s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to remove snap %s",
snapname);
goto out;
}
dup_snapname = gf_strdup (snapname);
if (!dup_snapname) {
- gf_log (this->name, GF_LOG_ERROR, "Strdup failed");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Strdup failed");
ret = -1;
goto out;
}
ret = dict_set_dynstr (rsp_dict, "snapname", dup_snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set the snapname");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set the snapname");
GF_FREE (dup_snapname);
goto out;
}
@@ -5647,13 +5967,15 @@ glusterd_do_snap_cleanup (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
GF_ASSERT (conf);
if (!dict || !op_errstr) {
- gf_log (this->name, GF_LOG_ERROR, "input parameters NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY, "input parameters NULL");
goto out;
}
ret = dict_get_str (dict, "snapname", &name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "getting the snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "getting the snap "
"name failed (volume: %s)", volinfo->volname);
goto out;
}
@@ -5665,7 +5987,8 @@ glusterd_do_snap_cleanup (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
*/
snap = glusterd_find_snap_by_name (name);
if (!snap) {
- gf_log (this->name, GF_LOG_INFO, "Snapshot (%s) does not exist",
+ gf_msg (this->name, GF_LOG_INFO, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND, "Snapshot (%s) does not exist",
name);
ret = 0;
goto out;
@@ -5675,7 +5998,7 @@ glusterd_do_snap_cleanup (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (ret) {
/* Ignore failure as this is a cleanup of half cooked
snapshot */
- gf_log (this->name, GF_LOG_DEBUG, "removing the snap %s failed",
+ gf_msg_debug (this->name, 0, "removing the snap %s failed",
name);
ret = 0;
}
@@ -5708,27 +6031,29 @@ glusterd_snapshot_update_snaps_post_validate (dict_t *dict, char **op_errstr,
ret = dict_get_int32 (dict, "missed_snap_count",
&missed_snap_count);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, "No missed snaps");
+ gf_msg_debug (this->name, 0, "No missed snaps");
ret = 0;
goto out;
}
ret = glusterd_add_missed_snaps_to_list (dict, missed_snap_count);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MISSEDSNAP_INFO_SET_FAIL,
"Failed to add missed snaps to list");
goto out;
}
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_MISSEDSNAP_INFO_SET_FAIL,
"Failed to update missed_snaps_list");
goto out;
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -5751,16 +6076,19 @@ glusterd_take_brick_snapshot_task (void *opaque)
snap_args->brickorder);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to "
- "take backend snapshot for brick "
- "%s:%s volume(%s)", snap_args->brickinfo->hostname,
- snap_args->brickinfo->path, snap_args->snap_vol->volname);
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Failed to "
+ "take backend snapshot for brick "
+ "%s:%s volume(%s)", snap_args->brickinfo->hostname,
+ snap_args->brickinfo->path,
+ snap_args->snap_vol->volname);
}
snprintf (key, sizeof (key), "snap-vol%d.brick%d.status",
snap_args->volcount, snap_args->brickorder);
if (dict_set_int32 (snap_args->rsp_dict, key, (ret)?0:1)) {
- gf_log (THIS->name, GF_LOG_ERROR, "failed to "
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "failed to "
"add %s to dict", key);
ret = -1;
goto out;
@@ -5822,7 +6150,8 @@ glusterd_schedule_brick_snapshot (dict_t *dict, dict_t *rsp_dict,
brickcount);
ret = dict_set_int32 (rsp_dict, key, brickorder);
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 %s", key);
goto out;
}
@@ -5836,8 +6165,9 @@ glusterd_schedule_brick_snapshot (dict_t *dict, dict_t *rsp_dict,
volcount, brickorder);
ret = dict_set_int32 (rsp_dict, key, 0);
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 %s to "
"dict", key);
goto out;
@@ -5870,7 +6200,8 @@ glusterd_schedule_brick_snapshot (dict_t *dict, dict_t *rsp_dict,
glusterd_take_brick_snapshot_cbk,
NULL, snap_args);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Failed to "
"spawn task for snapshot create");
GF_FREE (snap_args);
goto out;
@@ -5883,7 +6214,8 @@ glusterd_schedule_brick_snapshot (dict_t *dict, dict_t *rsp_dict,
snprintf (key, sizeof (key), "snap-vol%d_brickcount", volcount);
ret = dict_set_int64 (rsp_dict, key, brickcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "failed to "
"add %s to dict", key);
goto out;
}
@@ -5892,7 +6224,8 @@ glusterd_schedule_brick_snapshot (dict_t *dict, dict_t *rsp_dict,
taskcount = 0;
if (args.op_ret)
- gf_log (this->name, GF_LOG_ERROR, "Failed to create snapshot");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Failed to create snapshot");
ret = args.op_ret;
out:
@@ -5922,19 +6255,22 @@ glusterd_create_snap_object_for_clone (dict_t *dict, dict_t *rsp_dict)
/* Fetch snapname, description, id and time from dict */
ret = dict_get_str (dict, "clonename", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch clonename");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to fetch clonename");
goto out;
}
ret = dict_get_bin (dict, "clone-id", (void **)&snap_id);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch clone_id");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to fetch clone_id");
goto out;
}
snap = glusterd_new_snap_object ();
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR, "Could not create "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_OBJ_NEW_FAIL, "Could not create "
"the snap object for snap %s", snapname);
goto out;
}
@@ -5987,19 +6323,22 @@ glusterd_snapshot_clone_commit (dict_t *dict, char **op_errstr,
ret = dict_get_str (dict, "clonename", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch clonename");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to fetch clonename");
goto out;
}
tmp_name = gf_strdup (snapname);
if (!tmp_name) {
- gf_log (this->name, GF_LOG_ERROR, "Out of memory");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out of memory");
ret = -1;
goto out;
}
ret = dict_set_dynstr (rsp_dict, "clonename", tmp_name);
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 clonename in rsp_dict");
GF_FREE (tmp_name);
goto out;
@@ -6009,8 +6348,9 @@ glusterd_snapshot_clone_commit (dict_t *dict, char **op_errstr,
ret = dict_get_str (dict, "snapname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "failed to get snap name");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
+ "failed to get snap name");
goto out;
}
snap_parent = glusterd_find_snap_by_name (volname);
@@ -6020,13 +6360,15 @@ glusterd_snapshot_clone_commit (dict_t *dict, char **op_errstr,
origin_vol = cds_list_entry (snap_parent->volumes.next,
glusterd_volinfo_t, vol_list);
if (!origin_vol) {
- gf_log ("glusterd", GF_LOG_ERROR, "Failed to get snap "
- "volinfo %s", snap_parent->snapname);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_GET_FAIL, "Failed to get snap "
+ "volinfo %s", snap_parent->snapname);
goto out;
}
snap = glusterd_create_snap_object_for_clone (dict, rsp_dict);
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR, "creating the"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_OBJ_NEW_FAIL, "creating the"
"snap object %s failed", snapname);
ret = -1;
goto out;
@@ -6035,21 +6377,24 @@ glusterd_snapshot_clone_commit (dict_t *dict, char **op_errstr,
snap_vol = glusterd_do_snap_vol (origin_vol, snap, dict,
rsp_dict, 1, 1);
if (!snap_vol) {
- ret = -1;
- gf_log (this->name, GF_LOG_WARNING, "taking the "
- "snapshot of the volume %s failed", volname);
- goto out;
+ ret = -1;
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "taking the "
+ "snapshot of the volume %s failed", volname);
+ goto out;
}
volcount = 1;
ret = dict_set_int64 (rsp_dict, "volcount", volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set volcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set volcount");
goto out;
}
ret = glusterd_schedule_brick_snapshot (dict, rsp_dict, snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to take backend "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_BACKEND_MAKE_FAIL, "Failed to take backend "
"snapshot %s", snap->snapname);
goto out;
}
@@ -6058,7 +6403,8 @@ glusterd_snapshot_clone_commit (dict_t *dict, char **op_errstr,
ret = dict_set_dynstr_with_alloc (rsp_dict, "snapuuid",
uuid_utoa (snap->snap_id));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snap "
"uuid in response dictionary for %s snapshot",
snap->snapname);
goto out;
@@ -6079,7 +6425,7 @@ out:
snap = NULL;
}
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -6113,26 +6459,30 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
ret = dict_get_int64 (dict, "volcount", &volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to "
"get the volume count");
goto out;
}
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch snapname");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to fetch snapname");
goto out;
}
tmp_name = gf_strdup (snapname);
if (!tmp_name) {
- gf_log (this->name, GF_LOG_ERROR, "Out of memory");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out of memory");
ret = -1;
goto out;
}
ret = dict_set_dynstr (rsp_dict, "snapname", tmp_name);
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 snapname in rsp_dict");
GF_FREE (tmp_name);
goto out;
@@ -6141,7 +6491,8 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
snap = glusterd_create_snap_object (dict, rsp_dict);
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR, "creating the"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "creating the"
"snap object %s failed", snapname);
ret = -1;
goto out;
@@ -6151,14 +6502,16 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
snprintf (key, sizeof (key), "volname%"PRId64, i);
ret = dict_get_str (dict, key, &volname);
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 volume name");
goto out;
}
ret = glusterd_volinfo_find (volname, &origin_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND,
"failed to get the volinfo for "
"the volume %s", volname);
goto out;
@@ -6168,7 +6521,8 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
ret = glusterd_is_snap_soft_limit_reached (origin_vol,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED, "Failed to "
"check soft limit exceeded or not, "
"for volume %s ", origin_vol->volname);
goto out;
@@ -6179,20 +6533,23 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
rsp_dict, i, 0);
if (!snap_vol) {
ret = -1;
- gf_log (this->name, GF_LOG_WARNING, "taking the "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "taking the "
"snapshot of the volume %s failed", volname);
goto out;
}
}
ret = dict_set_int64 (rsp_dict, "volcount", volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set volcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set volcount");
goto out;
}
ret = glusterd_schedule_brick_snapshot (dict, rsp_dict, snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to take backend "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Failed to take backend "
"snapshot %s", snap->snapname);
goto out;
}
@@ -6200,7 +6557,8 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
ret = dict_set_dynstr_with_alloc (rsp_dict, "snapuuid",
uuid_utoa (snap->snap_id));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snap "
"uuid in response dictionary for %s snapshot",
snap->snapname);
goto out;
@@ -6215,7 +6573,8 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
ret = glusterd_store_volinfo (snap_vol,
GLUSTERD_VOLINFO_VER_AC_INCREMENT);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_SET_FAIL,
"Failed to store snap volinfo %s",
snap_vol->volname);
goto out;
@@ -6231,7 +6590,8 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
ret = glusterd_brick_start (snap_vol, brickinfo,
_gf_false);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "starting "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_BRICK_DISCONNECTED, "starting "
"the brick %s:%s for the snap %s "
"(volume: %s) failed",
brickinfo->hostname, brickinfo->path,
@@ -6245,7 +6605,8 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
ret = glusterd_store_volinfo (snap_vol,
GLUSTERD_VOLINFO_VER_AC_INCREMENT);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_SET_FAIL, "Failed to store "
"snap volinfo %s", snap_vol->volname);
goto out;
}
@@ -6261,7 +6622,7 @@ out:
snap = NULL;
}
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -6293,7 +6654,8 @@ snap_max_hard_limit_set_commit (dict_t *dict, uint64_t value,
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to store "
"%s in the options",
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
goto out;
@@ -6312,7 +6674,8 @@ snap_max_hard_limit_set_commit (dict_t *dict, uint64_t value,
ret = glusterd_store_options (this, conf->opts);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_FAIL, "Failed to store "
"options");
goto out;
}
@@ -6340,7 +6703,8 @@ snap_max_hard_limit_set_commit (dict_t *dict, uint64_t value,
out:
if (ret) {
*op_errstr = gf_strdup (err_str);
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPSHOT_OP_FAILED, "%s", err_str);
}
return ret;
}
@@ -6374,7 +6738,8 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
ret = dict_get_int32 (dict, "config-command", &config_command);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_COMMAND_NOT_FOUND,
"failed to get config-command type");
goto out;
}
@@ -6397,7 +6762,8 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
ret = snap_max_hard_limit_set_commit (dict, hard_limit, volname,
op_errstr);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_HARD_LIMIT_SET_FAIL,
"snap-max-hard-limit set commit failed.");
goto out;
}
@@ -6410,7 +6776,8 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
soft_limit);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Failed to save %s in the dictionary",
GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT);
goto out;
@@ -6430,7 +6797,8 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
auto_delete);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Could not "
"save auto-delete value in conf->opts");
goto out;
}
@@ -6442,13 +6810,15 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
GLUSTERD_STORE_KEY_SNAP_ACTIVATE,
snap_activate);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not save "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Could not save "
"snap-activate-on-create value in conf->opts");
goto out;
}
} else {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "Invalid option");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Invalid option");
goto out;
}
@@ -6457,7 +6827,8 @@ done:
ret = glusterd_get_next_global_opt_version_str (conf->opts,
&next_version);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLOBAL_OP_VERSION_GET_FAIL,
"Failed to get next global opt-version");
goto out;
}
@@ -6465,21 +6836,23 @@ done:
ret = dict_set_str (conf->opts, GLUSTERD_GLOBAL_OPT_VERSION,
next_version);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLOBAL_OP_VERSION_SET_FAIL,
"Failed to set next global opt-version");
goto out;
}
ret = glusterd_store_options (this, conf->opts);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_FAIL,
"Failed to store options");
goto out;
}
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -6510,7 +6883,8 @@ glusterd_get_brick_lvm_details (dict_t *rsp_dict,
device = glusterd_get_brick_mount_device (brickinfo->path);
if (!device) {
- gf_log (this->name, GF_LOG_ERROR, "Getting device name for "
+ 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,
brickinfo->path);
goto out;
@@ -6536,7 +6910,8 @@ glusterd_get_brick_lvm_details (dict_t *rsp_dict,
runner_log (&runner, "", GF_LOG_DEBUG, msg);
ret = runner_start (&runner);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_LVS_FAIL,
"Could not perform lvs action");
goto end;
}
@@ -6552,7 +6927,8 @@ glusterd_get_brick_lvm_details (dict_t *rsp_dict,
token++;
if (!token) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY,
"Invalid vg entry");
goto end;
}
@@ -6569,7 +6945,8 @@ glusterd_get_brick_lvm_details (dict_t *rsp_dict,
ret = dict_set_dynstr (rsp_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,
"Could not save vgname ");
goto end;
}
@@ -6590,7 +6967,8 @@ glusterd_get_brick_lvm_details (dict_t *rsp_dict,
ret = dict_set_dynstr (rsp_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,
"Could not save data percent ");
goto end;
}
@@ -6610,7 +6988,8 @@ glusterd_get_brick_lvm_details (dict_t *rsp_dict,
ret = dict_set_dynstr (rsp_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,
"Could not save meta data percent ");
goto end;
}
@@ -6678,7 +7057,8 @@ glusterd_get_single_brick_status (char **op_errstr, dict_t *rsp_dict,
ret = dict_set_dynstr (rsp_dict, key, value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Unable to store "
"brick_path %s", brickinfo->path);
goto out;
}
@@ -6695,7 +7075,8 @@ glusterd_get_single_brick_status (char **op_errstr, dict_t *rsp_dict,
keyprefix, index);
ret = dict_set_dynstr (rsp_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,
"Could not save vgname ");
goto out;
}
@@ -6719,7 +7100,8 @@ glusterd_get_single_brick_status (char **op_errstr, dict_t *rsp_dict,
}
ret = dict_set_str (rsp_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,
"Could not save brick status");
goto out;
}
@@ -6732,7 +7114,8 @@ glusterd_get_single_brick_status (char **op_errstr, dict_t *rsp_dict,
}
ret = dict_set_str (rsp_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,
"Could not save brick status");
goto out;
}
@@ -6750,7 +7133,8 @@ glusterd_get_single_brick_status (char **op_errstr, dict_t *rsp_dict,
ret = dict_set_int32 (rsp_dict, key, pid);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Could not save pid %d", pid);
goto out;
}
@@ -6766,7 +7150,8 @@ glusterd_get_single_brick_status (char **op_errstr, dict_t *rsp_dict,
snap_volinfo->volname,
device, key);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_GET_INFO_FAIL, "Failed to get "
"brick LVM details");
goto out;
}
@@ -6820,7 +7205,8 @@ glusterd_get_single_snap_status (char **op_errstr, dict_t *rsp_dict,
snap_volinfo, brickinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Getting "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_STATUS_FAIL, "Getting "
"single snap status failed");
goto out;
}
@@ -6834,7 +7220,8 @@ glusterd_get_single_snap_status (char **op_errstr, dict_t *rsp_dict,
ret = dict_set_int32 (rsp_dict, brickkey, brickcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Could not save brick count");
goto out;
}
@@ -6848,7 +7235,8 @@ glusterd_get_single_snap_status (char **op_errstr, dict_t *rsp_dict,
ret = dict_set_int32 (rsp_dict, key, volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Could not save volcount");
goto out;
}
@@ -6889,7 +7277,8 @@ glusterd_get_each_snap_object_status (char **op_errstr, dict_t *rsp_dict,
}
ret = dict_set_dynstr (rsp_dict, key, temp);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not save "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Could not save "
"snap name");
goto out;
}
@@ -6909,7 +7298,8 @@ glusterd_get_each_snap_object_status (char **op_errstr, dict_t *rsp_dict,
ret = dict_set_dynstr (rsp_dict, key, temp);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not save "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Could not save "
"snap UUID");
goto out;
}
@@ -6919,7 +7309,8 @@ glusterd_get_each_snap_object_status (char **op_errstr, dict_t *rsp_dict,
ret = glusterd_get_single_snap_status (op_errstr, rsp_dict, keyprefix,
snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_STATUS_FAIL,
"Could not get single snap status");
goto out;
}
@@ -6931,7 +7322,8 @@ glusterd_get_each_snap_object_status (char **op_errstr, dict_t *rsp_dict,
ret = dict_set_int32 (rsp_dict, key, 1);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not save volcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Could not save volcount");
goto out;
}
out:
@@ -6965,7 +7357,8 @@ glusterd_get_snap_status_of_volume (char **op_errstr, dict_t *rsp_dict,
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get volinfo of "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND, "Failed to get volinfo of "
"volume %s", volname);
goto out;
}
@@ -6981,7 +7374,8 @@ glusterd_get_snap_status_of_volume (char **op_errstr, dict_t *rsp_dict,
ret = dict_set_dynstr_with_alloc (rsp_dict, key,
snap_volinfo->snapshot->snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not save "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Could not save "
"snap name");
goto out;
}
@@ -6991,7 +7385,8 @@ glusterd_get_snap_status_of_volume (char **op_errstr, dict_t *rsp_dict,
ret = dict_set_int32 (rsp_dict, "status.snapcount", i);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to save snapcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to save snapcount");
ret = -1;
goto out;
}
@@ -7030,7 +7425,8 @@ glusterd_get_all_snapshot_status (dict_t *dict, char **op_errstr,
ret = dict_set_dynstr_with_alloc (rsp_dict, key,
snap->snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not save "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Could not save "
"snap name");
goto out;
}
@@ -7040,7 +7436,8 @@ glusterd_get_all_snapshot_status (dict_t *dict, char **op_errstr,
ret = dict_set_int32 (rsp_dict, "status.snapcount", i);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not save snapcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Could not save snapcount");
goto out;
}
@@ -7074,14 +7471,16 @@ glusterd_snapshot_status_commit (dict_t *dict, char **op_errstr,
GF_ASSERT (conf);
ret = dict_get_int32 (dict, "status-cmd", &cmd);
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 status cmd type");
goto out;
}
ret = dict_set_int32 (rsp_dict, "status-cmd", cmd);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Could not save status cmd in rsp dictionary");
goto out;
}
@@ -7091,7 +7490,8 @@ glusterd_snapshot_status_commit (dict_t *dict, char **op_errstr,
ret = glusterd_get_all_snapshot_status (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_STATUS_FAIL, "Unable to "
"get snapshot status");
goto out;
}
@@ -7102,7 +7502,8 @@ glusterd_snapshot_status_commit (dict_t *dict, char **op_errstr,
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to "
"get snap name");
goto out;
}
@@ -7115,21 +7516,24 @@ glusterd_snapshot_status_commit (dict_t *dict, char **op_errstr,
goto out;
}
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "Unable to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_GET_FAIL, "Unable to "
"get snap volinfo");
goto out;
}
ret = glusterd_get_each_snap_object_status (op_errstr,
rsp_dict, snap, "status.snap0");
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_STATUS_FAIL, "Unable to "
"get status of snap %s", get_buffer);
goto out;
}
ret = dict_set_int32 (rsp_dict, "status.snapcount", 1);
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 snapcount to 1");
goto out;
}
@@ -7139,7 +7543,8 @@ glusterd_snapshot_status_commit (dict_t *dict, char **op_errstr,
{
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to"
" get volume name");
goto out;
}
@@ -7147,7 +7552,8 @@ glusterd_snapshot_status_commit (dict_t *dict, char **op_errstr,
ret = glusterd_get_snap_status_of_volume (op_errstr,
rsp_dict, volname, "status.vol0");
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Function :"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_STATUS_FAIL, "Function :"
" glusterd_get_snap_status_of_volume "
"failed");
goto out;
@@ -7189,7 +7595,8 @@ glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict)
ret = dict_get_int64 (dict, "volcount", &volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to get the volcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to get the volcount");
goto out;
}
@@ -7197,14 +7604,16 @@ glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict)
snprintf (key, sizeof (key), "volname%d", i);
ret = dict_get_str (dict, key, &volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to get the "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "failed to get the "
"volname");
goto out;
}
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "volinfo for %s "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND, "volinfo for %s "
"not found", volname);
goto out;
}
@@ -7240,7 +7649,8 @@ glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict)
snap->snap_status = GD_SNAP_STATUS_DECOMMISSION;
ret = glusterd_store_snap (snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "could "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_OBJECT_STORE_FAIL, "could "
"not store snap object %s",
snap->snapname);
goto unlock;
@@ -7249,7 +7659,8 @@ glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict)
ret = glusterd_snap_remove (rsp_dict, snap,
_gf_true, _gf_true);
if (ret)
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_REMOVE_FAIL,
"failed to remove snap %s",
snap->snapname);
}
@@ -7288,7 +7699,8 @@ glusterd_snapshot_clone_postvalidate (dict_t *dict, int32_t op_ret,
ret = glusterd_do_snap_cleanup (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "cleanup "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CLEANUP_FAIL, "cleanup "
"operation failed");
goto out;
}
@@ -7304,14 +7716,16 @@ glusterd_snapshot_clone_postvalidate (dict_t *dict, int32_t op_ret,
ret = dict_get_str (dict, "clonename", &clonename);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to fetch "
"clonename");
goto out;
}
ret = glusterd_volinfo_find (clonename, &snap_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "unable to find clone "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "unable to find clone "
"%s volinfo", clonename);
goto out;
}
@@ -7320,14 +7734,16 @@ glusterd_snapshot_clone_postvalidate (dict_t *dict, int32_t op_ret,
op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Failed to "
"create snapshot");
goto out;
}
snap = snap_vol->snapshot;
ret = glusterd_snapobject_delete (snap);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to delete "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to delete "
"snap object %s", snap->snapname);
goto out;
}
@@ -7367,7 +7783,8 @@ glusterd_snapshot_create_postvalidate (dict_t *dict, int32_t op_ret,
ret = glusterd_do_snap_cleanup (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "cleanup "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CLEANUP_FAIL, "cleanup "
"operation failed");
goto out;
}
@@ -7383,14 +7800,16 @@ glusterd_snapshot_create_postvalidate (dict_t *dict, int32_t op_ret,
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to fetch "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to fetch "
"snapname");
goto out;
}
snap = glusterd_find_snap_by_name (snapname);
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR, "unable to find snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_NOT_FOUND, "unable to find snap "
"%s", snapname);
goto out;
}
@@ -7398,7 +7817,8 @@ glusterd_snapshot_create_postvalidate (dict_t *dict, int32_t op_ret,
snap->snap_status = GD_SNAP_STATUS_IN_USE;
ret = glusterd_store_snap (snap);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Could not store snap"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_OBJECT_STORE_FAIL, "Could not store snap"
"object %s", snap->snapname);
goto out;
}
@@ -7407,7 +7827,8 @@ glusterd_snapshot_create_postvalidate (dict_t *dict, int32_t op_ret,
op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Failed to "
"create snapshot");
goto out;
}
@@ -7451,7 +7872,8 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_get_int32 (dict, "type", &snap_command);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "unable to get the type of "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_COMMAND_NOT_FOUND, "unable to get the type of "
"the snapshot command");
goto out;
}
@@ -7462,7 +7884,8 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_snapshot_create_commit (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Failed to "
"create snapshot");
goto out;
}
@@ -7472,7 +7895,8 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_snapshot_clone_commit (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CLONE_FAILED, "Failed to "
"clone snapshot");
goto out;
}
@@ -7482,7 +7906,8 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_snapshot_config_commit (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CONFIG_FAIL,
"snapshot config failed");
goto out;
}
@@ -7492,7 +7917,8 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_snapshot_remove_commit (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to "
"delete snapshot");
if (*op_errstr) {
/* If error string is already set
@@ -7502,7 +7928,8 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_get_str (dict, "snapname", &snap_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 snapname");
snap_name = "NA";
}
@@ -7520,7 +7947,8 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_snapshot_restore (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_RESTORE_FAIL, "Failed to "
"restore snapshot");
goto out;
}
@@ -7530,7 +7958,8 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_snapshot_activate_commit (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_ACTIVATE_FAIL, "Failed to "
"activate snapshot");
goto out;
}
@@ -7541,7 +7970,8 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_snapshot_deactivate_commit (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_DEACTIVATE_FAIL, "Failed to "
"deactivate snapshot");
goto out;
}
@@ -7552,7 +7982,8 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = glusterd_snapshot_status_commit (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_STATUS_FAIL, "Failed to "
"show snapshot status");
goto out;
}
@@ -7560,7 +7991,8 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
default:
- gf_log (this->name, GF_LOG_WARNING, "invalid snap command");
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ GD_MSG_INVALID_ENTRY, "invalid snap command");
goto out;
break;
}
@@ -7591,7 +8023,8 @@ glusterd_snapshot_brickop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_get_int32 (dict, "type", &snap_command);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "unable to get the type of "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_COMMAND_NOT_FOUND, "unable to get the type of "
"the snapshot command");
goto out;
}
@@ -7604,7 +8037,8 @@ glusterd_snapshot_brickop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
*/
ret = dict_get_str (dict, "operation-type", &op_type);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to fetch "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to fetch "
"operation type");
goto out;
}
@@ -7615,7 +8049,8 @@ glusterd_snapshot_brickop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
*/
ret = glusterd_set_barrier_value (dict, "enable");
if (ret) {
- 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 barrier value as enable in dict");
goto out;
}
@@ -7625,14 +8060,16 @@ glusterd_snapshot_brickop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
*/
ret = glusterd_set_barrier_value (dict, "disable");
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Failed to "
"set barrier value as disable in "
"dict");
goto out;
}
} else {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "Invalid op_type");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Invalid op_type");
goto out;
}
@@ -7643,7 +8080,8 @@ glusterd_snapshot_brickop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
snprintf (key, 1024, "volname%"PRId64, count);
ret = dict_get_str (dict, key, &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 get volname");
goto out;
}
@@ -7688,7 +8126,8 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_get_int32 (dict, "type", &snap_command);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "unable to get the type of "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_COMMAND_NOT_FOUND, "unable to get the type of "
"the snapshot command");
goto out;
}
@@ -7698,7 +8137,8 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr,
ret = glusterd_snapshot_create_prevalidate (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot create "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Snapshot create "
"pre-validation failed");
goto out;
}
@@ -7708,7 +8148,9 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr,
ret = glusterd_snapshot_clone_prevalidate (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot clone "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CLONE_PREVAL_FAILED,
+ "Snapshot clone "
"pre-validation failed");
goto out;
}
@@ -7718,7 +8160,8 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr,
case (GF_SNAP_OPTION_TYPE_CONFIG):
ret = glusterd_snapshot_config_prevalidate (dict, op_errstr);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot config "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CONFIG_FAIL, "Snapshot config "
"pre-validation failed");
goto out;
}
@@ -7728,7 +8171,8 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr,
ret = glusterd_snapshot_restore_prevalidate (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot restore "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_RESTORE_FAIL, "Snapshot restore "
"validation failed");
goto out;
}
@@ -7738,7 +8182,8 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr,
ret = glusterd_snapshot_activate_deactivate_prevalidate (dict,
op_errstr, rsp_dict, _gf_true);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot activate "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_ACTIVATE_FAIL, "Snapshot activate "
"validation failed");
goto out;
}
@@ -7747,7 +8192,8 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr,
ret = glusterd_snapshot_activate_deactivate_prevalidate (dict,
op_errstr, rsp_dict, _gf_false);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_DEACTIVATE_FAIL,
"Snapshot deactivate validation failed");
goto out;
}
@@ -7756,7 +8202,8 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr,
ret = glusterd_snapshot_remove_prevalidate (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot remove "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Snapshot remove "
"validation failed");
goto out;
}
@@ -7766,14 +8213,16 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr,
ret = glusterd_snapshot_status_prevalidate (dict, op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot status "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_STATUS_FAIL, "Snapshot status "
"validation failed");
goto out;
}
break;
default:
- gf_log (this->name, GF_LOG_WARNING, "invalid snap command");
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ GD_MSG_COMMAND_NOT_FOUND, "invalid snap command");
goto out;
}
@@ -7817,7 +8266,8 @@ glusterd_snapshot_restore_cleanup (dict_t *rsp_dict,
/* Now delete the snap entry. */
ret = glusterd_snap_remove (rsp_dict, snap, _gf_false, _gf_true);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to delete "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_REMOVE_FAIL, "Failed to delete "
"snap %s", snap->snapname);
goto out;
}
@@ -7825,7 +8275,8 @@ glusterd_snapshot_restore_cleanup (dict_t *rsp_dict,
/* Delete the backup copy of volume folder */
ret = recursive_rmdir (delete_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to remove "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED, "Failed to remove "
"backup dir (%s)", delete_path);
goto out;
}
@@ -7871,7 +8322,8 @@ glusterd_snapshot_revert_partial_restored_vol (glusterd_volinfo_t *volinfo)
* volume's backend folder.*/
ret = recursive_rmdir (pathname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to remove "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED, "Failed to remove "
"%s directory", pathname);
goto out;
}
@@ -7880,7 +8332,8 @@ glusterd_snapshot_revert_partial_restored_vol (glusterd_volinfo_t *volinfo)
* location.*/
ret = rename (trash_path, pathname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to rename folder "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED, "Failed to rename folder "
"from %s to %s", trash_path, pathname);
goto out;
}
@@ -7888,7 +8341,8 @@ glusterd_snapshot_revert_partial_restored_vol (glusterd_volinfo_t *volinfo)
/* Retrieve the volume from the store */
reverted_vol = glusterd_store_retrieve_volume (volinfo->volname, NULL);
if (NULL == reverted_vol) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to load restored "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_OP_FAILED, "Failed to load restored "
"%s volume", volinfo->volname);
goto out;
}
@@ -7940,14 +8394,17 @@ glusterd_snapshot_revert_restore_from_snap (glusterd_snap_t *snap)
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not get volinfo of "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND, "Could not get volinfo of "
"%s", snap_volinfo->parent_volname);
goto out;
}
ret = glusterd_snapshot_revert_partial_restored_vol (volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to revert snapshot "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_RESTORE_REVERT_FAIL,
+ "Failed to revert snapshot "
"restore operation for %s volume", volname);
goto out;
}
@@ -7986,14 +8443,16 @@ glusterd_snapshot_restore_postop (dict_t *dict, int32_t op_ret,
ret = dict_get_str (dict, "snapname", &name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "getting the snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "getting the snap "
"name failed (volume: %s)", name);
goto out;
}
snap = glusterd_find_snap_by_name (name);
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_NOT_FOUND,
"Snapshot (%s) does not exist", name);
ret = -1;
goto out;
@@ -8002,28 +8461,32 @@ glusterd_snapshot_restore_postop (dict_t *dict, int32_t op_ret,
/* TODO: fix this when multiple volume support will come */
ret = dict_get_str (dict, "volname1", &volname);
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 volume name");
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,
"Volume (%s) does not exist ", volname);
goto out;
}
ret = dict_get_str (dict, "snapname", &name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "getting the snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "getting the snap "
"name failed (volume: %s)", volinfo->volname);
goto out;
}
snap = glusterd_find_snap_by_name (name);
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR, "snap %s is not found", name);
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_SNAP_NOT_FOUND, "snap %s is not found", name);
ret = -1;
goto out;
}
@@ -8034,7 +8497,8 @@ glusterd_snapshot_restore_postop (dict_t *dict, int32_t op_ret,
volname,
snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to perform "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CLEANUP_FAIL, "Failed to perform "
"snapshot restore cleanup for %s volume",
volname);
goto out;
@@ -8049,7 +8513,9 @@ glusterd_snapshot_restore_postop (dict_t *dict, int32_t op_ret,
ret = glusterd_snapshot_revert_partial_restored_vol (volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to revert "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_RESTORE_REVERT_FAIL,
+ "Failed to revert "
"restore operation for %s volume", volname);
goto out;
}
@@ -8058,7 +8524,8 @@ glusterd_snapshot_restore_postop (dict_t *dict, int32_t op_ret,
/* We need to save this in disk */
ret = glusterd_store_snap (snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_OBJECT_STORE_FAIL,
"Could not store snap object for %s snap",
snap->snapname);
goto out;
@@ -8086,7 +8553,8 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr,
ret = dict_get_int32 (dict, "type", &snap_command);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "unable to get the type of "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_COMMAND_NOT_FOUND, "unable to get the type of "
"the snapshot command");
goto out;
}
@@ -8097,7 +8565,8 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr,
op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot create "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CREATION_FAIL, "Snapshot create "
"post-validation failed");
goto out;
}
@@ -8108,7 +8577,9 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr,
op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot create "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CLONE_POSTVAL_FAILED,
+ "Snapshot create "
"post-validation failed");
goto out;
}
@@ -8116,7 +8587,7 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr,
break;
case GF_SNAP_OPTION_TYPE_DELETE:
if (op_ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"op_ret = %d. Not performing delete "
"post_validate", op_ret);
ret = 0;
@@ -8126,7 +8597,8 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr,
op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MISSED_SNAP_LIST_STORE_FAIL, "Failed to "
"update missed snaps list");
goto out;
}
@@ -8137,7 +8609,8 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr,
op_errstr,
rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_RESTORE_FAIL, "Failed to "
"update missed snaps list");
goto out;
}
@@ -8145,7 +8618,8 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr,
ret = glusterd_snapshot_restore_postop (dict, op_ret,
op_errstr, rsp_dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_RESTORE_FAIL, "Failed to "
"perform snapshot restore post-op");
goto out;
}
@@ -8164,7 +8638,8 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr,
ret = 0;
break;
default:
- gf_log (this->name, GF_LOG_WARNING, "invalid snap command");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_COMMAND_NOT_FOUND, "invalid snap command");
goto out;
}
@@ -8188,21 +8663,24 @@ glusterd_is_lvm_cmd_available (char *lvm_cmd)
ret = stat (lvm_cmd, &buf);
if (ret != 0) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_msg (THIS->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED,
"stat fails on %s, exiting. (errno = %d (%s))",
lvm_cmd, errno, strerror(errno));
return _gf_false;
}
if ((!ret) && (!S_ISREG(buf.st_mode))) {
- gf_log (THIS->name, GF_LOG_CRITICAL,
+ gf_msg (THIS->name, GF_LOG_CRITICAL, EINVAL,
+ GD_MSG_COMMAND_NOT_FOUND,
"Provided command %s is not a regular file,"
"exiting", lvm_cmd);
return _gf_false;
}
if ((!ret) && (!(buf.st_mode & S_IXUSR))) {
- gf_log (THIS->name, GF_LOG_CRITICAL,
+ gf_msg (THIS->name, GF_LOG_CRITICAL, 0,
+ GD_MSG_NO_EXEC_PERMS,
"Provided command %s has no exec permissions,"
"exiting", lvm_cmd);
return _gf_false;
@@ -8247,7 +8725,8 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
cli_req.dict.dict_len,
&dict);
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR, "failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to "
"unserialize req-buffer to dictionary");
snprintf (err_str, sizeof (err_str), "Unable to decode "
"the command");
@@ -8271,7 +8750,8 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
} else {
- gf_log (this->name, GF_LOG_ERROR, "request dict length is %d",
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "request dict length is %d",
cli_req.dict.dict_len);
goto out;
}
@@ -8280,7 +8760,9 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
snprintf (err_str, sizeof (err_str), "Cluster operating version"
" is lesser than the supported version "
"for a snapshot");
- gf_log (this->name, GF_LOG_ERROR, "%s (%d < %d)", err_str,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_UNSUPPORTED_VERSION,
+ "%s (%d < %d)", err_str,
conf->op_version, GD_OP_VERSION_3_6_0);
ret = -1;
goto out;
@@ -8289,14 +8771,16 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
ret = dict_get_int32 (dict, "type", &type);
if (ret < 0) {
snprintf (err_str, sizeof (err_str), "Command type not found");
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_COMMAND_NOT_FOUND, "%s", err_str);
goto out;
}
if (!glusterd_is_lvm_cmd_available (LVM_CREATE)) {
snprintf (err_str, sizeof (err_str), "LVM commands not found,"
" snapshot functionality is disabled");
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_COMMAND_NOT_FOUND, "%s", err_str);
ret = -1;
goto out;
}
@@ -8306,8 +8790,9 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
ret = glusterd_handle_snapshot_create (req, cli_op, dict,
err_str, sizeof (err_str));
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot create "
- "failed: %s", err_str);
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CREATION_FAIL,
+ "Snapshot create failed: %s", err_str);
}
break;
@@ -8315,8 +8800,9 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
ret = glusterd_handle_snapshot_clone (req, cli_op, dict,
err_str, sizeof (err_str));
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot clone "
- "failed: %s", err_str);
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CLONE_FAILED, "Snapshot clone "
+ "failed: %s", err_str);
}
break;
@@ -8324,8 +8810,9 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
ret = glusterd_handle_snapshot_restore (req, cli_op, dict,
err_str, sizeof (err_str));
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot restore "
- "failed: %s", err_str);
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_RESTORE_FAIL,
+ "Snapshot restore failed: %s", err_str);
}
break;
@@ -8333,24 +8820,27 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
ret = glusterd_handle_snapshot_info (req, cli_op, dict,
err_str, sizeof (err_str));
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot info "
- "failed");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_INFO_FAIL,
+ "Snapshot info failed");
}
break;
case GF_SNAP_OPTION_TYPE_LIST:
ret = glusterd_handle_snapshot_list (req, cli_op, dict,
err_str, sizeof (err_str));
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot list "
- "failed");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_LIST_GET_FAIL,
+ "Snapshot list failed");
}
break;
case GF_SNAP_OPTION_TYPE_CONFIG:
ret = glusterd_handle_snapshot_config (req, cli_op, dict,
err_str, sizeof (err_str));
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "snapshot config "
- "failed");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_CONFIG_FAIL,
+ "snapshot config failed");
}
break;
case GF_SNAP_OPTION_TYPE_DELETE:
@@ -8358,15 +8848,17 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
err_str,
sizeof (err_str));
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot delete "
- "failed: %s", err_str);
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_REMOVE_FAIL,
+ "Snapshot delete failed: %s", err_str);
}
break;
case GF_SNAP_OPTION_TYPE_ACTIVATE:
ret = glusterd_mgmt_v3_initiate_snap_phases (req, cli_op,
dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_ACTIVATE_FAIL,
"Snapshot activate failed: %s", err_str);
}
break;
@@ -8374,7 +8866,8 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
ret = glusterd_mgmt_v3_initiate_snap_phases (req, cli_op,
dict);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_DEACTIVATE_FAIL,
"Snapshot deactivate failed: %s", err_str);
}
break;
@@ -8383,12 +8876,14 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
err_str,
sizeof (err_str));
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Snapshot status "
- "failed: %s", err_str);
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_STATUS_FAIL,
+ "Snapshot status failed: %s", err_str);
}
break;
default:
- gf_log (this->name, GF_LOG_ERROR, "Unknown snapshot request "
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_COMMAND_NOT_FOUND, "Unkown snapshot request "
"type (%d)", type);
ret = -1; /* Failure */
}
@@ -8479,7 +8974,8 @@ glusterd_update_missed_snap_entry (glusterd_missed_snap_info *missed_snapinfo,
if ((snap_opinfo->status == GD_MISSED_SNAP_PENDING) &&
(missed_snap_op->status == GD_MISSED_SNAP_DONE)) {
snap_opinfo->status = GD_MISSED_SNAP_DONE;
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_MISSED_SNAP_STATUS_DONE,
"Updating missed snap status "
"for %s:%s=%s:%d:%s:%d as DONE",
missed_snapinfo->node_uuid,
@@ -8504,7 +9000,8 @@ glusterd_update_missed_snap_entry (glusterd_missed_snap_info *missed_snapinfo,
/* Optimizing create and delete entries for the same
* brick and same node
*/
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_MISSED_SNAP_STATUS_DONE,
"Updating missed snap status "
"for %s:%s=%s:%d:%s:%d as DONE",
missed_snapinfo->node_uuid,
@@ -8521,7 +9018,8 @@ glusterd_update_missed_snap_entry (glusterd_missed_snap_info *missed_snapinfo,
}
if (match == _gf_true) {
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_DUP_ENTRY,
"Duplicate entry. Not updating");
glusterd_free_snap_op (missed_snap_op);
} else {
@@ -8531,7 +9029,7 @@ glusterd_update_missed_snap_entry (glusterd_missed_snap_info *missed_snapinfo,
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -8565,7 +9063,8 @@ glusterd_add_new_entry_to_list (char *missed_info, char *snap_vol_id,
* snap id and the op */
ret = glusterd_missed_snap_op_new (&missed_snap_op);
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 new missed snap object.");
ret = -1;
goto out;
@@ -8603,7 +9102,8 @@ glusterd_add_new_entry_to_list (char *missed_info, char *snap_vol_id,
/* First snap op missed for the brick */
ret = glusterd_missed_snapinfo_new (&missed_snapinfo);
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 snapinfo");
goto out;
}
@@ -8641,7 +9141,8 @@ glusterd_add_new_entry_to_list (char *missed_info, char *snap_vol_id,
ret = glusterd_update_missed_snap_entry (missed_snapinfo,
missed_snap_op);
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 update existing missed snap entry.");
goto out;
}
@@ -8656,7 +9157,7 @@ out:
glusterd_free_missed_snapinfo (missed_snapinfo);
}
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -8695,12 +9196,13 @@ glusterd_add_missed_snaps_to_list (dict_t *dict, int32_t missed_snap_count)
i);
ret = dict_get_str (dict, name_buf, &buf);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch %s", name_buf);
goto out;
}
- gf_log (this->name, GF_LOG_DEBUG, "missed_snap_entry = %s",
+ gf_msg_debug (this->name, 0, "missed_snap_entry = %s",
buf);
/* Need to make a duplicate string coz the same dictionary *
@@ -8725,7 +9227,8 @@ glusterd_add_missed_snaps_to_list (dict_t *dict, int32_t missed_snap_count)
if (!nodeid || !snap_uuid || !brick_path ||
!snap_vol_id || brick_num < 1 || snap_op < 1 ||
snap_status < 1) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_MISSED_SNAP_ENTRY,
"Invalid missed_snap_entry");
ret = -1;
goto out;
@@ -8741,7 +9244,8 @@ glusterd_add_missed_snaps_to_list (dict_t *dict, int32_t missed_snap_count)
snap_op,
snap_status);
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 store missed snaps_list");
goto out;
}
@@ -8755,7 +9259,7 @@ out:
if (tmp)
GF_FREE (tmp);
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -8808,7 +9312,9 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
*/
ret = glusterd_store_snap (snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Could not store snap "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FILE_OP_FAILED,
+ "Could not store snap "
"object for %s snap of %s volume", snap_vol->volname,
snap_vol->parent_volname);
goto out;
@@ -8819,7 +9325,9 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
*/
ret = glusterd_stop_volume (snap_vol);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to stop "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_STOP_FAILED,
+ "Failed to stop "
"snap volume");
goto out;
}
@@ -8827,7 +9335,8 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
/* Create a new volinfo for the restored volume */
ret = glusterd_volinfo_dup (snap_vol, &new_volinfo, _gf_true);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to create volinfo");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_OP_FAILED, "Failed to create volinfo");
goto out;
}
@@ -8845,7 +9354,8 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
/* Initialize the snapd service */
ret = glusterd_snapdsvc_init (new_volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to initialize snapd "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize snapd "
"service for volume %s", orig_vol->volname);
goto out;
}
@@ -8854,7 +9364,8 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
ret = glusterd_snap_volinfo_restore (dict, rsp_dict, new_volinfo,
snap_vol, volcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to restore snap");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_RESTORE_FAIL, "Failed to restore snap");
goto out;
}
@@ -8868,14 +9379,17 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
*/
ret = glusterd_restore_geo_rep_files (snap_vol);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to restore "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_RESTORE_FAIL,
+ "Failed to restore "
"geo-rep files for snap %s",
snap_vol->snapshot->snapname);
}
ret = glusterd_copy_quota_files (snap_vol, orig_vol, &conf_present);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to restore "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_RESTORE_FAIL, "Failed to restore "
"quota files for snap %s",
snap_vol->snapshot->snapname);
goto out;
@@ -8887,14 +9401,16 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
*/
ret = glusterd_compute_cksum (new_volinfo, _gf_true);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to compute "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_CKSUM_COMPUTE_FAIL, "Failed to compute "
"checksum for quota conf file");
goto out;
}
ret = glusterd_store_save_quota_version_and_cksum (new_volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_QUOTA_CKSUM_VER_STORE_FAIL, "Failed to "
"store quota version and cksum");
goto out;
}
@@ -8909,7 +9425,8 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
ret = glusterd_store_volinfo (new_volinfo,
GLUSTERD_VOLINFO_VER_AC_INCREMENT);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to store volinfo");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_OP_FAILED, "Failed to store volinfo");
goto out;
}
@@ -8962,7 +9479,8 @@ glusterd_snapshot_get_volnames_uuids (dict_t *dict,
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_VOL_NOT_FOUND,
"Failed to get volinfo of volume %s",
volname);
op_errno = EINVAL;
@@ -8982,7 +9500,8 @@ glusterd_snapshot_get_volnames_uuids (dict_t *dict,
ret = dict_set_dynstr_with_alloc (dict, key,
snap_vol->snapshot->snapname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set "
"snap name in dictionary");
goto out;
}
@@ -8992,7 +9511,8 @@ glusterd_snapshot_get_volnames_uuids (dict_t *dict,
ret = dict_set_dynstr_with_alloc (dict, key,
uuid_utoa(snap_vol->snapshot->snap_id));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set "
"snap id in dictionary");
goto out;
}
@@ -9001,7 +9521,8 @@ glusterd_snapshot_get_volnames_uuids (dict_t *dict,
snprintf (key, sizeof (key), "snap-volname.%d", snapcount);
ret = dict_set_dynstr_with_alloc (dict, key, snap_vol->volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set "
"snap id in dictionary");
goto out;
}
@@ -9009,7 +9530,8 @@ glusterd_snapshot_get_volnames_uuids (dict_t *dict,
ret = dict_set_int32 (dict, "snap-count", snapcount);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set snapcount");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set snapcount");
op_errno = -ret;
goto out;
}