summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-store.c
diff options
context:
space:
mode:
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 ee279d30d17..690023bdb3c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -38,6 +38,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"
@@ -170,19 +171,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;
}
@@ -332,7 +336,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;
}
@@ -343,7 +348,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;
}
@@ -405,7 +411,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;
}
@@ -425,11 +431,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;
}
@@ -453,7 +461,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;
}
@@ -471,7 +479,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;
@@ -479,7 +488,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;
}
@@ -489,7 +500,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;
}
@@ -519,7 +530,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;
}
@@ -536,21 +547,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;
}
@@ -589,8 +604,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 {
@@ -602,7 +617,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;
}
@@ -644,8 +659,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);
}
@@ -655,7 +670,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;
}
@@ -685,13 +700,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;
@@ -732,18 +749,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;
}
@@ -779,7 +798,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;
}
@@ -787,7 +807,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;
}
@@ -797,19 +818,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;
}
@@ -988,7 +1013,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;
}
@@ -1018,7 +1044,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;
}
@@ -1037,7 +1063,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;
@@ -1063,7 +1090,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;
}
@@ -1106,7 +1133,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;
}
@@ -1284,7 +1311,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;
}
@@ -1342,7 +1369,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;
}
@@ -1370,7 +1397,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;
}
@@ -1398,7 +1425,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;
}
@@ -1475,8 +1502,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;
}
@@ -1504,8 +1532,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;
}
@@ -1519,26 +1548,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;
}
@@ -1546,7 +1583,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;
}
@@ -1594,7 +1631,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;
}
@@ -1629,15 +1666,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;
@@ -1645,8 +1684,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:
@@ -1656,7 +1695,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;
}
@@ -1693,15 +1732,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;
@@ -1709,8 +1750,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;
}
@@ -1720,8 +1761,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;
}
@@ -1731,11 +1772,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:
@@ -1745,19 +1786,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:
@@ -1767,7 +1808,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;
}
@@ -1793,7 +1834,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;
}
@@ -1805,8 +1847,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;
}
@@ -1819,7 +1862,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;
}
@@ -1828,7 +1872,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;
}
@@ -1848,7 +1893,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;
@@ -1873,7 +1919,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;
}
@@ -1884,14 +1930,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;
}
@@ -1930,7 +1977,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;
}
@@ -1942,14 +1989,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;
}
@@ -1976,7 +2024,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;
@@ -2022,9 +2071,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,
@@ -2032,7 +2083,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;
}
@@ -2044,7 +2095,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;
}
@@ -2052,7 +2103,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;
}
@@ -2106,20 +2157,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;
}
@@ -2139,7 +2193,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;
}
@@ -2166,13 +2222,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);
@@ -2207,9 +2265,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) {
@@ -2285,7 +2343,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);
}
@@ -2299,7 +2358,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;
}
@@ -2322,7 +2383,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;
}
@@ -2389,15 +2450,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;
@@ -2431,7 +2494,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;
}
@@ -2463,26 +2526,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);
@@ -2520,7 +2586,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,
@@ -2537,11 +2604,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,
@@ -2560,7 +2628,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))) {
@@ -2610,7 +2679,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;
@@ -2626,11 +2696,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;
}
@@ -2701,7 +2773,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;
}
@@ -2746,7 +2820,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;
}
@@ -2788,7 +2863,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;
}
@@ -2802,7 +2878,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;
}
@@ -2928,7 +3004,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;
}
@@ -2941,7 +3018,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;
@@ -2950,7 +3028,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);
@@ -2965,7 +3044,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;
}
@@ -2998,7 +3077,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;
@@ -3022,7 +3102,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;
}
@@ -3070,24 +3150,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;
}
@@ -3117,7 +3199,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;
@@ -3131,17 +3214,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;
}
}
@@ -3150,7 +3233,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");
}
@@ -3165,7 +3249,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;
}
@@ -3184,7 +3268,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;
}
@@ -3194,7 +3279,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;
}
@@ -3223,33 +3308,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))) {
@@ -3278,7 +3367,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");
}
@@ -3301,22 +3392,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;
}
@@ -3328,7 +3423,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;
}
@@ -3362,11 +3457,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;
}
@@ -3379,16 +3476,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;
}
@@ -3402,7 +3499,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;
@@ -3415,7 +3513,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;
}
@@ -3424,7 +3523,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;
}
@@ -3451,7 +3550,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;
}
@@ -3462,7 +3563,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;
@@ -3474,7 +3576,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;
}
@@ -3482,7 +3584,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;
}
@@ -3521,7 +3623,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;
}
@@ -3530,7 +3633,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;
}
@@ -3552,14 +3655,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;
@@ -3567,14 +3673,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;
}
@@ -3582,13 +3690,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;
}
@@ -3597,6 +3706,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,};
@@ -3607,7 +3717,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);
@@ -3643,7 +3754,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;
}
@@ -3668,7 +3779,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;
}
@@ -3797,7 +3908,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;
}
@@ -3823,7 +3934,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;
}
@@ -3844,7 +3955,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;
}
@@ -3878,7 +3989,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;
}
@@ -3924,7 +4037,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);
}
@@ -3981,7 +4095,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;
}
@@ -4011,7 +4125,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;
@@ -4024,7 +4139,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;
@@ -4033,7 +4149,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;
}
@@ -4065,7 +4181,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;
@@ -4076,7 +4193,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;
@@ -4085,7 +4204,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;
@@ -4096,7 +4216,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;
}
@@ -4120,7 +4240,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;
}
@@ -4131,7 +4252,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);
@@ -4140,7 +4262,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;
}
@@ -4178,20 +4300,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;
}
@@ -4219,22 +4343,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;
@@ -4278,7 +4404,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;
}
@@ -4286,7 +4413,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;
}