summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-store.c
diff options
context:
space:
mode:
authorNandaja Varma <nandaja.varma@gmail.com>2015-03-13 16:55:17 +0530
committerAtin Mukherjee <amukherj@redhat.com>2015-06-15 22:28:58 -0700
commit25f28a9c23b1adf665a982c2f5157bf13361521b (patch)
tree7318a5ec7d805169d46ab58c3c4947190751a0cc /xlators/mgmt/glusterd/src/glusterd-store.c
parent60b6e5d2c3442ea0f7f85374d6613cd0dd76604c (diff)
rebalance,store,glusterd/glusterd: porting to new logging framework
Change-Id: I231b79e3414e60fe67cde577dd585cce83c8bfad BUG: 1194640 Signed-off-by: Nandaja Varma <nandaja.varma@gmail.com> Reviewed-on: http://review.gluster.org/9877 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Sachin Pandit <spandit@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c552
1 files changed, 340 insertions, 212 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 45f955fad90..c4c6f740571 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -33,6 +33,7 @@
#include "store.h"
#include "glusterd-store.h"
#include "glusterd-snapshot-utils.h"
+#include "glusterd-messages.h"
#include "rpc-clnt.h"
#include "common-utils.h"
@@ -165,19 +166,22 @@ glusterd_store_is_valid_brickpath (char *volname, char *brick)
ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to create brick "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_BRICK_CREATION_FAIL, "Failed to create brick "
"info for brick %s", brick);
ret = 0;
goto out;
}
ret = glusterd_volinfo_new (&volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to create volinfo");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL, "Failed to create volinfo");
ret = 0;
goto out;
}
if (volname_len >= sizeof (volinfo->volname)) {
- gf_log (this->name, GF_LOG_WARNING, "volume name too long");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_NAME_TOO_LONG, "volume name too long");
ret = 0;
goto out;
}
@@ -327,7 +331,8 @@ gd_store_brick_snap_details_write (int fd, glusterd_brickinfo_t *brickinfo)
ret = gf_store_save_value (fd,
GLUSTERD_STORE_KEY_BRICK_FSTYPE, value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to save "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_FS_LABEL_UPDATE_FAIL, "Failed to save "
"brick fs type of brick %s", brickinfo->path);
goto out;
}
@@ -338,7 +343,8 @@ gd_store_brick_snap_details_write (int fd, glusterd_brickinfo_t *brickinfo)
ret = gf_store_save_value (fd,
GLUSTERD_STORE_KEY_BRICK_MNTOPTS, value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to save "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRK_MOUNTOPTS_FAIL, "Failed to save "
"brick mnt opts of brick %s", brickinfo->path);
goto out;
}
@@ -400,7 +406,7 @@ glusterd_store_brickinfo_write (int fd, glusterd_brickinfo_t *brickinfo)
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_BRICK_VGNAME,
brickinfo->vg);
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -420,11 +426,13 @@ glusterd_store_snapd_write (int fd, glusterd_volinfo_t *volinfo)
snprintf (value, sizeof(value), "%d", volinfo->snapd.port);
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAPD_PORT, value);
if (ret)
- gf_log (this->name, GF_LOG_ERROR, "failed to store the snapd "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPD_PORT_STORE_FAIL,
+ "failed to store the snapd "
"port of volume %s", volinfo->volname);
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -448,7 +456,7 @@ glusterd_store_perform_brick_store (glusterd_brickinfo_t *brickinfo)
out:
if (ret && (fd > 0))
gf_store_unlink_tmppath (brickinfo->shandle);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -466,7 +474,8 @@ glusterd_store_perform_snapd_store (glusterd_volinfo_t *volinfo)
fd = gf_store_mkstemp (volinfo->snapd.handle);
if (fd <= 0) {
- gf_log (this->name, GF_LOG_ERROR, "failed to create the "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "failed to create the "
"temporary file for the snapd store handle of volume "
"%s", volinfo->volname);
goto out;
@@ -474,7 +483,9 @@ glusterd_store_perform_snapd_store (glusterd_volinfo_t *volinfo)
ret = glusterd_store_snapd_write (fd, volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to write snapd port "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPD_PORT_STORE_FAIL,
+ "failed to write snapd port "
"info to store handle (volume: %s", volinfo->volname);
goto out;
}
@@ -484,7 +495,7 @@ glusterd_store_perform_snapd_store (glusterd_volinfo_t *volinfo)
out:
if (ret && (fd > 0))
gf_store_unlink_tmppath (volinfo->snapd.handle);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -514,7 +525,7 @@ glusterd_store_brickinfo (glusterd_volinfo_t *volinfo,
ret = glusterd_store_perform_brick_store (brickinfo);
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning with %d", ret);
return ret;
}
@@ -531,21 +542,25 @@ glusterd_store_snapd_info (glusterd_volinfo_t *volinfo)
ret = glusterd_store_create_snapd_shandle_on_absence (volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to create store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_HANDLE_CREATE_FAIL,
+ "failed to create store "
"handle for snapd (volume: %s)", volinfo->volname);
goto out;
}
ret = glusterd_store_perform_snapd_store (volinfo);
if (ret)
- gf_log (this->name, GF_LOG_ERROR, "failed to store snapd info "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPD_INFO_STORE_FAIL,
+ "failed to store snapd info "
"of the volume %s", volinfo->volname);
out:
if (ret)
gf_store_unlink_tmppath (volinfo->snapd.handle);
- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -584,8 +599,8 @@ glusterd_store_delete_brick (glusterd_brickinfo_t *brickinfo, char *delete_path)
ret = unlink (brickpath);
if ((ret < 0) && (errno != ENOENT)) {
- gf_log (this->name, GF_LOG_DEBUG, "Unlink failed on %s, "
- "reason: %s", brickpath, strerror(errno));
+ gf_msg_debug (this->name, 0, "Unlink failed on %s",
+ brickpath);
ret = -1;
goto out;
} else {
@@ -597,7 +612,7 @@ out:
gf_store_handle_destroy (brickinfo->shandle);
brickinfo->shandle = NULL;
}
- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -639,8 +654,8 @@ glusterd_store_remove_bricks (glusterd_volinfo_t *volinfo, char *delete_path)
brickdir, entry->d_name);
ret = unlink (path);
if (ret && errno != ENOENT) {
- gf_log (this->name, GF_LOG_DEBUG, "Unable to unlink %s, "
- "reason: %s", path, strerror(errno));
+ gf_msg_debug (this->name, 0, "Unable to unlink %s",
+ path);
}
GF_FOR_EACH_ENTRY_IN_DIR (entry, dir);
}
@@ -650,7 +665,7 @@ glusterd_store_remove_bricks (glusterd_volinfo_t *volinfo, char *delete_path)
ret = rmdir (brickdir);
out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -680,13 +695,15 @@ _storeslaves (dict_t *this, char *key, data_t *value, void *data)
if (!value || !value->data)
return -1;
- gf_log (xl->name, GF_LOG_DEBUG, "Storing in volinfo:key= %s, val=%s",
+ gf_msg_debug (xl->name, 0, "Storing in volinfo:key= %s, val=%s",
key, value->data);
ret = gf_store_save_value (shandle->fd, key, (char*)value->data);
if (ret) {
- gf_log (xl->name, GF_LOG_ERROR, "Unable to write into store"
- " handle for path: %s", shandle->path);
+ gf_msg (xl->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_HANDLE_WRITE_FAIL,
+ "Unable to write into store"
+ " handle for path: %s", shandle->path);
return -1;
}
return 0;
@@ -727,18 +744,20 @@ int _storeopts (dict_t *this, char *key, data_t *value, void *data)
}
if (1 == exists) {
- gf_log (xl->name, GF_LOG_DEBUG, "Storing in volinfo:key= %s, "
+ gf_msg_debug (xl->name, 0, "Storing in volinfo:key= %s, "
"val=%s", key, value->data);
} else {
- gf_log (xl->name, GF_LOG_DEBUG, "Discarding:key= %s, val=%s",
+ gf_msg_debug (xl->name, 0, "Discarding:key= %s, val=%s",
key, value->data);
return 0;
}
ret = gf_store_save_value (shandle->fd, key, (char*)value->data);
if (ret) {
- gf_log (xl->name, GF_LOG_ERROR, "Unable to write into store"
+ gf_msg (xl->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_HANDLE_WRITE_FAIL,
+ "Unable to write into store"
" handle for path: %s", shandle->path);
return -1;
}
@@ -774,7 +793,8 @@ glusterd_volume_write_snap_details (int fd, glusterd_volinfo_t *volinfo)
snprintf (buf, sizeof (buf), "%s", volinfo->parent_volname);
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_PARENT_VOLNAME, buf);
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 "
GLUSTERD_STORE_KEY_PARENT_VOLNAME);
goto out;
}
@@ -782,7 +802,8 @@ glusterd_volume_write_snap_details (int fd, glusterd_volinfo_t *volinfo)
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_RESTORED_SNAP,
uuid_utoa (volinfo->restored_from_snap));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_HANDLE_WRITE_FAIL,
"Unable to write restored_from_snap");
goto out;
}
@@ -792,19 +813,23 @@ glusterd_volume_write_snap_details (int fd, glusterd_volinfo_t *volinfo)
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
buf);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_HARD_LIMIT_SET_FAIL,
"Unable to write snap-max-hard-limit");
goto out;
}
ret = glusterd_store_snapd_info (volinfo);
if (ret)
- gf_log (this->name, GF_LOG_ERROR, "snapd info store failed "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPD_INFO_STORE_FAIL, "snapd info store failed "
"volume: %s", volinfo->volname);
out:
if (ret)
- gf_log (this->name, GF_LOG_ERROR, "Failed to write snap details"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPINFO_WRITE_FAIL,
+ "Failed to write snap details"
" for volume %s", volinfo->volname);
return ret;
}
@@ -983,7 +1008,8 @@ glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo)
out:
if (ret)
- gf_log (this->name, GF_LOG_ERROR, "Unable to write volume "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_VALS_WRITE_FAIL, "Unable to write volume "
"values for %s", volinfo->volname);
return ret;
}
@@ -1013,7 +1039,7 @@ glusterd_store_create_volume_dir (glusterd_volinfo_t *volinfo)
sizeof (voldirpath));
ret = gf_store_mkdir (voldirpath);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning with %d", ret);
return ret;
}
@@ -1032,7 +1058,8 @@ glusterd_store_create_snap_dir (glusterd_snap_t *snap)
ret = mkdir_p (snapdirpath, 0755, _gf_true);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to create snaps dir "
+ gf_msg (THIS->name, GF_LOG_ERROR, errno,
+ GD_MSG_CREATE_DIR_FAILED, "Failed to create snaps dir "
"%s", snapdirpath);
}
return ret;
@@ -1058,7 +1085,7 @@ glusterd_store_volinfo_write (int fd, glusterd_volinfo_t *volinfo)
dict_foreach (volinfo->gsync_slaves, _storeslaves, shandle);
shandle->fd = 0;
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -1101,7 +1128,7 @@ glusterd_store_snapinfo_write (glusterd_snap_t *snap)
ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_TIMESTAMP, buf);
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -1279,7 +1306,7 @@ glusterd_store_brickinfos (glusterd_volinfo_t *volinfo, int vol_fd)
brick_count++;
}
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -1337,7 +1364,7 @@ glusterd_store_node_state_write (int fd, glusterd_volinfo_t *volinfo)
&fd);
}
out:
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -1365,7 +1392,7 @@ glusterd_store_perform_node_state_store (glusterd_volinfo_t *volinfo)
out:
if (ret && (fd > 0))
gf_store_unlink_tmppath (volinfo->node_state_shandle);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -1393,7 +1420,7 @@ glusterd_store_perform_volume_store (glusterd_volinfo_t *volinfo)
out:
if (ret && (fd > 0))
gf_store_unlink_tmppath (volinfo->shandle);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -1470,8 +1497,9 @@ glusterd_store_volinfo_atomic_update (glusterd_volinfo_t *volinfo)
out:
if (ret)
- gf_log (THIS->name, GF_LOG_ERROR, "Couldn't rename "
- "temporary file(s): Reason %s", strerror (errno));
+ gf_msg (THIS->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "Couldn't rename "
+ "temporary file(s)");
return ret;
}
@@ -1499,8 +1527,9 @@ glusterd_store_snap_atomic_update (glusterd_snap_t *snap)
ret = gf_store_rename_tmppath (snap->shandle);
if (ret)
- gf_log (THIS->name, GF_LOG_ERROR, "Couldn't rename "
- "temporary file(s): Reason %s", strerror (errno));
+ gf_msg (THIS->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "Couldn't rename "
+ "temporary file(s)");
return ret;
}
@@ -1514,26 +1543,34 @@ glusterd_store_snap (glusterd_snap_t *snap)
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;
}
ret = glusterd_store_create_snap_shandle_on_absence (snap);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to create snap info "
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPINFO_CREATE_FAIL,
+ "Failed to create snap info "
"file");
goto out;
}
ret = glusterd_store_snapinfo_write (snap);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to write snap info");
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPINFO_WRITE_FAIL,
+ "Failed to write snap info");
goto out;
}
ret = glusterd_store_snap_atomic_update (snap);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR,"Failed to do automic update");
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_AUTOMIC_UPDATE_FAIL,
+ "Failed to do automic update");
goto out;
}
@@ -1541,7 +1578,7 @@ out:
if (ret && snap->shandle)
gf_store_unlink_tmppath (snap->shandle);
- gf_log (THIS->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -1589,7 +1626,7 @@ out:
if (ret)
glusterd_store_volume_cleanup_tmp (volinfo);
- gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
return ret;
}
@@ -1624,15 +1661,17 @@ glusterd_store_delete_volume (glusterd_volinfo_t *volinfo)
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_CREATE_DIR_FAILED, "Failed to create trash "
+ "directory");
ret = -1;
goto out;
}
ret = rename (pathname, delete_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to rename volume "
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED, "Failed to rename volume "
"directory for volume %s", volinfo->volname);
rename_fail = _gf_true;
goto out;
@@ -1640,8 +1679,8 @@ glusterd_store_delete_volume (glusterd_volinfo_t *volinfo)
ret = recursive_rmdir (trashdir);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s, Reason:"
- " %s", trashdir, strerror (errno));
+ gf_msg_debug (this->name, 0, "Failed to rmdir: %s",
+ trashdir);
}
out:
@@ -1651,7 +1690,7 @@ out:
}
ret = (rename_fail == _gf_true) ? -1: 0;
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1688,15 +1727,17 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
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_CREATE_DIR_FAILED, "Failed to create trash "
+ "directory");
ret = -1;
goto out;
}
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_DIR_OP_FAILED, "Failed to rename snap "
"directory %s to %s", pathname, delete_path);
rename_fail = _gf_true;
goto out;
@@ -1704,8 +1745,8 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
dir = opendir (delete_path);
if (!dir) {
- gf_log (this->name, GF_LOG_DEBUG, "Failed to open directory %s."
- " Reason : %s", delete_path, strerror (errno));
+ gf_msg_debug (this->name, 0, "Failed to open directory %s.",
+ delete_path);
ret = 0;
goto out;
}
@@ -1715,8 +1756,8 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
snprintf (path, PATH_MAX, "%s/%s", delete_path, entry->d_name);
ret = stat (path, &st);
if (ret == -1) {
- gf_log (this->name, GF_LOG_DEBUG, "Failed to stat "
- "entry %s : %s", path, strerror (errno));
+ gf_msg_debug (this->name, 0, "Failed to stat "
+ "entry %s", path);
goto stat_failed;
}
@@ -1726,11 +1767,11 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
ret = unlink (path);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, " Failed to remove "
- "%s. Reason : %s", path, strerror (errno));
+ gf_msg_debug (this->name, 0, " Failed to remove "
+ "%s", path);
}
- gf_log (this->name, GF_LOG_DEBUG, "%s %s",
+ gf_msg_debug (this->name, 0, "%s %s",
ret ? "Failed to remove":"Removed",
entry->d_name);
stat_failed:
@@ -1740,19 +1781,19 @@ stat_failed:
ret = closedir (dir);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, "Failed to close dir %s. "
- "Reason : %s",delete_path, strerror (errno));
+ gf_msg_debug (this->name, 0, "Failed to close dir %s.",
+ delete_path);
}
ret = rmdir (delete_path);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s,err: %s",
- delete_path, strerror (errno));
+ gf_msg_debug (this->name, 0, "Failed to rmdir: %s",
+ delete_path);
}
ret = rmdir (trashdir);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s, Reason:"
- " %s", trashdir, strerror (errno));
+ gf_msg_debug (this->name, 0, "Failed to rmdir: %s",
+ trashdir);
}
out:
@@ -1762,7 +1803,7 @@ out:
}
ret = (rename_fail == _gf_true) ? -1: 0;
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -1788,7 +1829,8 @@ glusterd_store_global_info (xlator_t *this)
GLUSTERD_INFO_FILE);
ret = gf_store_handle_new (path, &handle);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_HANDLE_GET_FAIL,
"Unable to get store handle");
goto out;
}
@@ -1800,8 +1842,9 @@ glusterd_store_global_info (xlator_t *this)
/* These options need to be available for all users */
ret = chmod (handle->path, 0644);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "chmod error for %s: %s",
- GLUSTERD_INFO_FILE, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "chmod error for %s",
+ GLUSTERD_INFO_FILE);
goto out;
}
@@ -1814,7 +1857,8 @@ glusterd_store_global_info (xlator_t *this)
ret = gf_store_save_value (handle->fd, GLUSTERD_STORE_UUID_KEY,
uuid_str);
if (ret) {
- gf_log (this->name, GF_LOG_CRITICAL,
+ gf_msg (this->name, GF_LOG_CRITICAL, 0,
+ GD_MSG_UUID_SET_FAIL,
"Storing uuid failed ret = %d", ret);
goto out;
}
@@ -1823,7 +1867,8 @@ glusterd_store_global_info (xlator_t *this)
ret = gf_store_save_value (handle->fd, GD_OP_VERSION_KEY,
op_version_str);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_OP_VERS_STORE_FAIL,
"Storing op-version failed ret = %d", ret);
goto out;
}
@@ -1843,7 +1888,8 @@ out:
GF_FREE (uuid_str);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GLUSTERD_GLOBAL_INFO_STORE_FAIL,
"Failed to store glusterd global-info");
return ret;
@@ -1868,7 +1914,7 @@ glusterd_retrieve_op_version (xlator_t *this, int *op_version)
ret = gf_store_handle_retrieve (path, &handle);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "Unable to get store "
+ gf_msg_debug (this->name, 0, "Unable to get store "
"handle!");
goto out;
}
@@ -1879,14 +1925,15 @@ glusterd_retrieve_op_version (xlator_t *this, int *op_version)
ret = gf_store_retrieve_value (priv->handle, GD_OP_VERSION_KEY,
&op_version_str);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"No previous op_version present");
goto out;
}
tmp_version = strtol (op_version_str, &tmp, 10);
if ((tmp_version <= 0) || (tmp && strlen (tmp) > 1)) {
- gf_log (this->name, GF_LOG_WARNING, "invalid version number");
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ GD_MSG_UNSUPPORTED_VERSION, "invalid version number");
goto out;
}
@@ -1925,7 +1972,7 @@ glusterd_retrieve_sys_snap_max_limit (xlator_t *this, uint64_t *limit,
ret = gf_store_handle_retrieve (path, &handle);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "Unable to get store "
+ gf_msg_debug (this->name, 0, "Unable to get store "
"handle!");
goto out;
}
@@ -1937,14 +1984,15 @@ glusterd_retrieve_sys_snap_max_limit (xlator_t *this, uint64_t *limit,
key,
&limit_str);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"No previous %s present", key);
goto out;
}
tmp_limit = strtoul (limit_str, &tmp, 10);
if ((tmp_limit <= 0) || (tmp && strlen (tmp) > 1)) {
- gf_log (this->name, GF_LOG_WARNING, "invalid version number");
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ GD_MSG_UNSUPPORTED_VERSION, "invalid version number");
goto out;
}
@@ -1971,7 +2019,8 @@ glusterd_restore_op_version (xlator_t *this)
if (!ret) {
if ((op_version < GD_OP_VERSION_MIN) ||
(op_version > GD_OP_VERSION_MAX)) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_UNSUPPORTED_VERSION,
"wrong op-version (%d) retrieved", op_version);
ret = -1;
goto out;
@@ -2017,9 +2066,11 @@ glusterd_retrieve_uuid ()
int32_t ret = -1;
gf_store_handle_t *handle = NULL;
glusterd_conf_t *priv = NULL;
+ xlator_t *this = NULL;
char path[PATH_MAX] = {0,};
- priv = THIS->private;
+ this = THIS;
+ priv = this->private;
if (!priv->handle) {
snprintf (path, PATH_MAX, "%s/%s", priv->workdir,
@@ -2027,7 +2078,7 @@ glusterd_retrieve_uuid ()
ret = gf_store_handle_retrieve (path, &handle);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "Unable to get store"
+ gf_msg_debug (this->name, 0, "Unable to get store"
"handle!");
goto out;
}
@@ -2039,7 +2090,7 @@ glusterd_retrieve_uuid ()
&uuid_str);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "No previous uuid is present");
+ gf_msg_debug (this->name, 0, "No previous uuid is present");
goto out;
}
@@ -2047,7 +2098,7 @@ glusterd_retrieve_uuid ()
out:
GF_FREE (uuid_str);
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -2101,20 +2152,23 @@ glusterd_store_retrieve_snapd (glusterd_volinfo_t *volinfo)
ret = gf_store_handle_retrieve (path, &volinfo->snapd.handle);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "volinfo handle is NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_HANDLE_NULL, "volinfo handle is NULL");
goto out;
}
ret = gf_store_iter_new (volinfo->snapd.handle, &iter);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get new store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get new store "
"iter");
goto out;
}
ret = gf_store_iter_get_next (iter, &key, &value, &op_errno);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get next store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get next store "
"iter");
goto out;
}
@@ -2134,7 +2188,9 @@ glusterd_store_retrieve_snapd (glusterd_volinfo_t *volinfo)
ret = gf_store_iter_destroy (iter);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to destroy store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_ITER_DESTROY_FAIL,
+ "Failed to destroy store "
"iter");
goto out;
}
@@ -2161,13 +2217,15 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
gf_store_iter_t *tmpiter = NULL;
char *tmpvalue = NULL;
struct pmap_registry *pmap = NULL;
+ xlator_t *this = NULL;
int brickid = 0;
gf_store_op_errno_t op_errno = GD_STORE_SUCCESS;
GF_ASSERT (volinfo);
GF_ASSERT (volinfo->volname);
- priv = THIS->private;
+ this = THIS;
+ priv = this->private;
GLUSTERD_GET_BRICK_DIR (brickdir, volinfo, priv);
@@ -2202,9 +2260,9 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
ret = gf_store_iter_get_next (iter, &key, &value, &op_errno);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to iterate "
- "the store for brick: %s, reason: %s", path,
- gf_store_strerror (op_errno));
+ gf_msg ("glusterd", GF_LOG_ERROR, op_errno,
+ GD_MSG_STORE_ITER_GET_FAIL, "Unable to iterate "
+ "the store for brick: %s", path);
goto out;
}
while (!ret) {
@@ -2280,7 +2338,8 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
strncpy (brickinfo->brick_id, value,
sizeof (brickinfo->brick_id));
} else {
- gf_log ("", GF_LOG_ERROR, "Unknown key: %s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_UNKNOWN_KEY, "Unknown key: %s",
key);
}
@@ -2294,7 +2353,9 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
}
if (op_errno != GD_STORE_EOF) {
- gf_log ("", GF_LOG_ERROR, "Error parsing brickinfo: "
+ gf_msg (this->name, GF_LOG_ERROR, op_errno,
+ GD_MSG_PARSE_BRICKINFO_FAIL,
+ "Error parsing brickinfo: "
"op_errno=%d", op_errno);
goto out;
}
@@ -2317,7 +2378,7 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
if (ret)
goto out;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -2384,15 +2445,17 @@ glusterd_store_retrieve_node_state (glusterd_volinfo_t *volinfo)
dup_value = gf_strdup (value);
if (!dup_value) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY,
"Failed to strdup value string");
goto out;
}
ret = dict_set_str (tmp_dict, key, dup_value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Error setting data in rebal "
- "dict.");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "Error setting data in rebal "
+ "dict.");
goto out;
}
dup_value = NULL;
@@ -2426,7 +2489,7 @@ out:
if (tmp_dict)
dict_unref (tmp_dict);
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -2458,26 +2521,29 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
ret = gf_store_handle_retrieve (path, &volinfo->shandle);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "volinfo handle is NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_HANDLE_NULL, "volinfo handle is NULL");
goto out;
}
ret = gf_store_iter_new (volinfo->shandle, &iter);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get new store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get new store "
"iter");
goto out;
}
ret = gf_store_iter_get_next (iter, &key, &value, &op_errno);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get next store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get next store "
"iter");
goto out;
}
while (!ret) {
- gf_log ("", GF_LOG_DEBUG, "key = %s value = %s", key, value);
+ gf_msg_debug (this->name, 0, "key = %s value = %s", key, value);
if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_TYPE,
strlen (GLUSTERD_STORE_KEY_VOL_TYPE))) {
volinfo->type = atoi (value);
@@ -2515,7 +2581,8 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
strlen (GLUSTERD_STORE_KEY_VOL_ID))) {
ret = gf_uuid_parse (value, volinfo->volume_id);
if (ret)
- gf_log ("", GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_UUID_PARSE_FAIL,
"failed to parse uuid");
} else if (!strncmp (key, GLUSTERD_STORE_KEY_USERNAME,
@@ -2532,11 +2599,12 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
ret = dict_set_dynstr (volinfo->gsync_slaves, key,
gf_strdup (value));
if (ret) {
- gf_log ("",GF_LOG_ERROR, "Error in "
- "dict_set_str");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Error in "
+ "dict_set_str");
goto out;
}
- gf_log ("", GF_LOG_DEBUG, "Parsed as "GEOREP" "
+ gf_msg_debug (this->name, 0, "Parsed as "GEOREP" "
" slave:key=%s,value:%s", key, value);
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_OP_VERSION,
@@ -2555,7 +2623,8 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
strlen (GLUSTERD_STORE_KEY_VOL_RESTORED_SNAP))) {
ret = gf_uuid_parse (value, volinfo->restored_from_snap);
if (ret)
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_UUID_PARSE_FAIL,
"failed to parse restored snap's uuid");
} else if (!strncmp (key, GLUSTERD_STORE_KEY_PARENT_VOLNAME,
strlen (GLUSTERD_STORE_KEY_PARENT_VOLNAME))) {
@@ -2605,7 +2674,8 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
/*Ignore GLUSTERD_STORE_KEY_VOL_BRICK since
glusterd_store_retrieve_bricks gets it later*/
if (!strstr (key, GLUSTERD_STORE_KEY_VOL_BRICK))
- gf_log ("", GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_UNKNOWN_KEY,
"Unknown key: %s", key);
break;
@@ -2621,11 +2691,13 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
ret = dict_set_str(volinfo->dict, key,
gf_strdup (value));
if (ret) {
- gf_log ("",GF_LOG_ERROR, "Error in "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "Error in "
"dict_set_str");
goto out;
}
- gf_log ("", GF_LOG_DEBUG, "Parsed as Volume-"
+ gf_msg_debug (this->name, 0, "Parsed as Volume-"
"set:key=%s,value:%s", key, value);
break;
}
@@ -2696,7 +2768,9 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
ret = gf_store_iter_destroy (iter);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to destroy store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_ITER_DESTROY_FAIL,
+ "Failed to destroy store "
"iter");
goto out;
}
@@ -2741,7 +2815,8 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
ret = glusterd_store_update_volinfo (volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to update volinfo "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLINFO_UPDATE_FAIL, "Failed to update volinfo "
"for %s volume", volname);
goto out;
}
@@ -2783,7 +2858,8 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
ret = glusterd_volinfo_find (volinfo->parent_volname,
&origin_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", volname);
goto out;
}
@@ -2797,7 +2873,7 @@ out:
volinfo = NULL;
}
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return volinfo;
}
@@ -2923,7 +2999,8 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap)
dir = opendir (path);
if (!dir) {
- gf_log ("", GF_LOG_ERROR, "Unable to open dir %s", path);
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED, "Unable to open dir %s", path);
goto out;
}
@@ -2936,7 +3013,8 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap)
volinfo = glusterd_store_retrieve_volume (entry->d_name, snap);
if (!volinfo) {
- gf_log ("", GF_LOG_ERROR, "Unable to restore "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOL_RESTORE_FAIL, "Unable to restore "
"volume: %s", entry->d_name);
ret = -1;
goto out;
@@ -2945,7 +3023,8 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap)
ret = glusterd_store_retrieve_node_state (volinfo);
if (ret) {
/* Backward compatibility */
- gf_log ("", GF_LOG_INFO, "Creating a new node_state "
+ gf_log (this->name, GF_LOG_INFO,
+ "Creating a new node_state "
"for volume: %s.", entry->d_name);
glusterd_store_create_nodestate_sh_on_absence (volinfo);
ret = glusterd_store_perform_node_state_store (volinfo);
@@ -2960,7 +3039,7 @@ next:
out:
if (dir)
closedir (dir);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -2993,7 +3072,8 @@ glusterd_find_brick_mount_path (char *brick_path, char **brick_mount_path)
/* Snapshot bricks must have brick num as part
* of the brickpath
*/
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY,
"Invalid brick path(%s)", brick_path);
ret = -1;
goto out;
@@ -3017,7 +3097,7 @@ out:
GF_FREE (*brick_mount_path);
*brick_mount_path = NULL;
}
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3065,24 +3145,26 @@ glusterd_mount_brick_paths (char *brick_mount_path,
NULL);
ret = runner_run (&runner);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to activate %s. Error: %s",
- brickinfo->device_path, strerror(errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_SNAP_ACTIVATE_FAIL,
+ "Failed to activate %s.",
+ brickinfo->device_path);
goto out;
} else
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Activating %s successful", brickinfo->device_path);
/* Mount the snapshot */
ret = glusterd_mount_lvm_snapshot (brickinfo, brick_mount_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_MOUNT_FAIL,
"Failed to mount lvm snapshot.");
goto out;
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3112,7 +3194,8 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this,
ret = glusterd_find_brick_mount_path (brickinfo->path,
&brick_mount_path);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRK_MNTPATH_GET_FAIL,
"Failed to find brick_mount_path for %s",
brickinfo->path);
goto out;
@@ -3126,17 +3209,17 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this,
ret = mkdir_p (brick_mount_path, 0777,
_gf_true);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to create %s. "
- "Error: %s", brick_mount_path,
- strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_CREATE_DIR_FAILED,
+ "Failed to create %s. ",
+ brick_mount_path);
goto out;
}
} else {
- gf_log (this->name, GF_LOG_ERROR,
- "Brick Path(%s) not valid. "
- "Error: %s", brickinfo->path,
- strerror(errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED,
+ "Brick Path(%s) not valid. ",
+ brickinfo->path);
goto out;
}
}
@@ -3145,7 +3228,8 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this,
* If not, mount the device_path at the brick_mount_path */
ret = glusterd_mount_brick_paths (brick_mount_path, brickinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRK_MNTPATH_MOUNT_FAIL,
"Failed to mount brick_mount_path");
}
@@ -3160,7 +3244,7 @@ out:
if (ret && brick_mount_path)
GF_FREE (brick_mount_path);
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3179,7 +3263,8 @@ glusterd_resolve_snap_bricks (xlator_t *this, glusterd_snap_t *snap)
brick_list) {
ret = glusterd_resolve_brick (brickinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_RESOLVE_BRICK_FAIL,
"resolve brick failed in restore");
goto out;
}
@@ -3189,7 +3274,7 @@ glusterd_resolve_snap_bricks (xlator_t *this, glusterd_snap_t *snap)
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3218,33 +3303,37 @@ glusterd_store_update_snap (glusterd_snap_t *snap)
ret = gf_store_handle_retrieve (path, &snap->shandle);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "snap handle is NULL");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_HANDLE_NULL, "snap handle is NULL");
goto out;
}
ret = gf_store_iter_new (snap->shandle, &iter);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get new store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get new store "
"iter");
goto out;
}
ret = gf_store_iter_get_next (iter, &key, &value, &op_errno);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get next store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_ITER_GET_FAIL, "Failed to get next store "
"iter");
goto out;
}
while (!ret) {
- gf_log (this->name, GF_LOG_DEBUG, "key = %s value = %s",
+ gf_msg_debug (this->name, 0, "key = %s value = %s",
key, value);
if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_ID,
strlen (GLUSTERD_STORE_KEY_SNAP_ID))) {
ret = gf_uuid_parse (value, snap->snap_id);
if (ret)
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_UUID_PARSE_FAIL,
"Failed to parse uuid");
} else if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_RESTORED,
strlen (GLUSTERD_STORE_KEY_SNAP_RESTORED))) {
@@ -3273,7 +3362,9 @@ glusterd_store_update_snap (glusterd_snap_t *snap)
ret = gf_store_iter_destroy (iter);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to destroy store "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_ITER_DESTROY_FAIL,
+ "Failed to destroy store "
"iter");
}
@@ -3296,22 +3387,26 @@ glusterd_store_retrieve_snap (char *snapname)
snap = glusterd_new_snap_object ();
if (!snap) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to create "
- " snap object");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_OBJECT_STORE_FAIL, "Failed to create "
+ " snap object");
goto out;
}
strncpy (snap->snapname, snapname, strlen(snapname));
ret = glusterd_store_update_snap (snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to update snapshot "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPSHOT_UPDATE_FAIL,
+ "Failed to update snapshot "
"for %s snap", snapname);
goto out;
}
ret = glusterd_store_retrieve_volumes (this, snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to retrieve "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_VOL_RETRIEVE_FAIL, "Failed to retrieve "
"snap volumes for snap %s", snapname);
goto out;
}
@@ -3323,7 +3418,7 @@ glusterd_store_retrieve_snap (char *snapname)
glusterd_compare_snap_time);
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3357,11 +3452,13 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t *this)
if (!fp) {
/* If errno is ENOENT then there are no missed snaps yet */
if (errno != ENOENT) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to open %s. "
- "Error: %s", path, strerror(errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED,
+ "Failed to open %s. ",
+ path);
} else {
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_MISSED_SNAP_LIST_EMPTY,
"No missed snaps list.");
ret = 0;
}
@@ -3374,16 +3471,16 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t *this)
&store_errno);
if (ret) {
if (store_errno == GD_STORE_EOF) {
- gf_log (this->name,
- GF_LOG_DEBUG,
+ gf_msg_debug (this->name,
+ 0,
"EOF for missed_snap_list");
ret = 0;
break;
}
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, store_errno,
+ GD_MSG_MISSED_SNAP_GET_FAIL,
"Failed to fetch data from "
- "missed_snaps_list. Error: %s",
- gf_store_strerror (store_errno));
+ "missed_snaps_list.");
goto out;
}
@@ -3397,7 +3494,8 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t *this)
if (!missed_node_info || !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, EINVAL,
+ GD_MSG_INVALID_MISSED_SNAP_ENTRY,
"Invalid missed_snap_entry");
ret = -1;
goto out;
@@ -3410,7 +3508,8 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t *this)
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;
}
@@ -3419,7 +3518,7 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t *this)
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3446,7 +3545,9 @@ glusterd_store_retrieve_snaps (xlator_t *this)
backward compatibility */
if (errno != ENOENT) {
ret = -1;
- gf_log ("", GF_LOG_ERROR, "Unable to open dir %s", path);
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED, "Unable to open dir %s",
+ path);
}
goto out;
}
@@ -3457,7 +3558,8 @@ glusterd_store_retrieve_snaps (xlator_t *this)
if (strcmp (entry->d_name, GLUSTERD_MISSED_SNAPS_LIST_FILE)) {
ret = glusterd_store_retrieve_snap (entry->d_name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_RESTORE_FAIL,
"Unable to restore snapshot: %s",
entry->d_name);
goto out;
@@ -3469,7 +3571,7 @@ glusterd_store_retrieve_snaps (xlator_t *this)
/* Retrieve missed_snaps_list */
ret = glusterd_store_retrieve_missed_snaps_list (this);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Failed to retrieve missed_snaps_list");
goto out;
}
@@ -3477,7 +3579,7 @@ glusterd_store_retrieve_snaps (xlator_t *this)
out:
if (dir)
closedir (dir);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3516,7 +3618,8 @@ glusterd_store_write_missed_snapinfo (int32_t fd)
snap_opinfo->op, snap_opinfo->status);
ret = gf_store_save_value (fd, key, value);
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 write missed snapinfo");
goto out;
}
@@ -3525,7 +3628,7 @@ glusterd_store_write_missed_snapinfo (int32_t fd)
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -3547,14 +3650,17 @@ glusterd_store_update_missed_snaps ()
ret = glusterd_store_create_missed_snaps_list_shandle_on_absence ();
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to obtain "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MISSED_SNAP_LIST_STORE_HANDLE_GET_FAIL,
+ "Unable to obtain "
"missed_snaps_list store handle.");
goto out;
}
fd = gf_store_mkstemp (priv->missed_snaps_list_shandle);
if (fd <= 0) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED,
"Failed to create tmp file");
ret = -1;
goto out;
@@ -3562,14 +3668,16 @@ glusterd_store_update_missed_snaps ()
ret = glusterd_store_write_missed_snapinfo (fd);
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 write missed snaps to disk");
goto out;
}
ret = gf_store_rename_tmppath (priv->missed_snaps_list_shandle);
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 the tmp file");
goto out;
}
@@ -3577,13 +3685,14 @@ out:
if (ret && (fd > 0)) {
ret = gf_store_unlink_tmppath (priv->missed_snaps_list_shandle);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_TMP_FILE_UNLINK_FAIL,
"Failed to unlink the tmp file");
}
ret = -1;
}
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -3592,6 +3701,7 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo)
{
int32_t ret = -1;
glusterd_conf_t *priv = NULL;
+ xlator_t *this = NULL;
char peerdir[PATH_MAX] = {0,};
char filepath[PATH_MAX] = {0,};
char hostname_path[PATH_MAX] = {0,};
@@ -3602,7 +3712,8 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo)
goto out;
}
- priv = THIS->private;
+ this = THIS;
+ priv = this->private;
snprintf (peerdir, PATH_MAX, "%s/peers", priv->workdir);
@@ -3638,7 +3749,7 @@ out:
gf_store_handle_destroy (peerinfo->shandle);
peerinfo->shandle = NULL;
}
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -3663,7 +3774,7 @@ glusterd_store_create_peer_dir ()
glusterd_store_peerinfo_dirpath_set (path, sizeof (path));
ret = gf_store_mkdir (path);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -3792,7 +3903,7 @@ glusterd_store_peer_write (int fd, glusterd_peerinfo_t *peerinfo)
}
out:
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -3818,7 +3929,7 @@ glusterd_store_perform_peer_store (glusterd_peerinfo_t *peerinfo)
out:
if (ret && (fd > 0))
gf_store_unlink_tmppath (peerinfo->shandle);
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -3839,7 +3950,7 @@ glusterd_store_peerinfo (glusterd_peerinfo_t *peerinfo)
ret = glusterd_store_perform_peer_store (peerinfo);
out:
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -3873,7 +3984,9 @@ glusterd_store_retrieve_peers (xlator_t *this)
dir = opendir (path);
if (!dir) {
- gf_log ("", GF_LOG_ERROR, "Unable to open dir %s", path);
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED,
+ "Unable to open dir %s", path);
ret = -1;
goto out;
}
@@ -3919,7 +4032,8 @@ glusterd_store_retrieve_peers (xlator_t *this)
strlen (GLUSTERD_STORE_KEY_PEER_HOSTNAME))) {
ret = gd_add_address_to_peer (peerinfo, value);
} else {
- gf_log ("", GF_LOG_ERROR, "Unknown key: %s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_UNKNOWN_KEY, "Unknown key: %s",
key);
}
@@ -3976,7 +4090,7 @@ out:
if (dir)
closedir (dir);
- gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+ gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -4006,7 +4120,8 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t *this)
ret = glusterd_recreate_vol_brick_mounts (this, volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRK_MNT_RECREATE_FAIL,
"Failed to recreate brick mounts "
"for %s", volinfo->volname);
goto out;
@@ -4019,7 +4134,8 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t *this)
ret = glusterd_recreate_vol_brick_mounts (this,
volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_BRK_MNT_RECREATE_FAIL,
"Failed to recreate brick mounts "
"for %s", snap->snapname);
goto out;
@@ -4028,7 +4144,7 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t *this)
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -4060,7 +4176,8 @@ glusterd_snap_cleanup (xlator_t *this)
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;
@@ -4071,7 +4188,9 @@ glusterd_snap_cleanup (xlator_t *this)
if (snap->snap_status == GD_SNAP_STATUS_RESTORED) {
ret = glusterd_snapshot_revert_restore_from_snap (snap);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_SNAP_RESTORE_REVERT_FAIL,
+ "Failed to "
"revert partially restored snapshot "
"(%s)", snap->snapname);
goto out;
@@ -4080,7 +4199,8 @@ glusterd_snap_cleanup (xlator_t *this)
ret = glusterd_snap_remove (dict, snap,
_gf_true, _gf_true);
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 the snapshot %s",
snap->snapname);
goto out;
@@ -4091,7 +4211,7 @@ out:
if (dict)
dict_unref (dict);
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -4115,7 +4235,8 @@ glusterd_resolve_all_bricks (xlator_t *this)
brick_list) {
ret = glusterd_resolve_brick (brickinfo);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_RESOLVE_BRICK_FAIL,
"resolve brick failed in restore");
goto out;
}
@@ -4126,7 +4247,8 @@ glusterd_resolve_all_bricks (xlator_t *this)
cds_list_for_each_entry (snap, &priv->snapshots, snap_list) {
ret = glusterd_resolve_snap_bricks (this, snap);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_RESOLVE_BRICK_FAIL,
"resolving the snap bricks"
" failed for snap: %s",
snap->snapname);
@@ -4135,7 +4257,7 @@ glusterd_resolve_all_bricks (xlator_t *this)
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+ gf_msg_trace (this->name, 0, "Returning with %d", ret);
return ret;
}
@@ -4173,20 +4295,22 @@ glusterd_restore ()
ret = glusterd_snap_cleanup (this);
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 "
"a cleanup of the snapshots");
goto out;
}
ret = glusterd_recreate_all_snap_brick_mounts (this);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to recreate "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_BRK_MNT_RECREATE_FAIL, "Failed to recreate "
"all snap brick mounts");
goto out;
}
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4214,22 +4338,24 @@ glusterd_store_retrieve_quota_version (glusterd_volinfo_t *volinfo)
ret = gf_store_handle_new (cksum_path, &handle);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to get store handle "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_STORE_HANDLE_GET_FAIL,
+ "Unable to get store handle "
"for %s", cksum_path);
goto out;
}
ret = gf_store_retrieve_value (handle, "version", &version_str);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, "Version absent");
+ gf_msg_debug (this->name, 0, "Version absent");
ret = 0;
goto out;
}
version = strtoul (version_str, &tmp, 10);
if ((errno == ERANGE) || (errno == EINVAL)) {
- gf_log (this->name, GF_LOG_DEBUG, "Invalid version number");
- goto out;
+ gf_msg_debug (this->name, 0, "Invalid version number");
+ goto out;
}
volinfo->quota_conf_version = version;
ret = 0;
@@ -4273,7 +4399,8 @@ glusterd_store_save_quota_version_and_cksum (glusterd_volinfo_t *volinfo)
snprintf (buf, sizeof (buf)-1, "%u", volinfo->quota_conf_cksum);
ret = gf_store_save_value (fd, "cksum", buf);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to store cksum");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_CKSUM_STORE_FAIL, "Failed to store cksum");
goto out;
}
@@ -4281,7 +4408,8 @@ glusterd_store_save_quota_version_and_cksum (glusterd_volinfo_t *volinfo)
snprintf (buf, sizeof (buf)-1, "%u", volinfo->quota_conf_version);
ret = gf_store_save_value (fd, "version", buf);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to store version");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VERS_STORE_FAIL, "Failed to store version");
goto out;
}