From 25f28a9c23b1adf665a982c2f5157bf13361521b Mon Sep 17 00:00:00 2001 From: Nandaja Varma Date: Fri, 13 Mar 2015 16:55:17 +0530 Subject: rebalance,store,glusterd/glusterd: porting to new logging framework Change-Id: I231b79e3414e60fe67cde577dd585cce83c8bfad BUG: 1194640 Signed-off-by: Nandaja Varma Reviewed-on: http://review.gluster.org/9877 Tested-by: Gluster Build System Reviewed-by: Sachin Pandit Tested-by: NetBSD Build System Reviewed-by: Atin Mukherjee --- xlators/mgmt/glusterd/src/glusterd-rebalance.c | 102 +++-- xlators/mgmt/glusterd/src/glusterd-store.c | 552 +++++++++++++++---------- xlators/mgmt/glusterd/src/glusterd.c | 208 ++++++---- 3 files changed, 538 insertions(+), 324 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index 9f4b42171c5..0ec1d69a0c1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -50,7 +50,7 @@ glusterd_defrag_start_validate (glusterd_volinfo_t *volinfo, char *op_errstr, /* Check only if operation is not remove-brick */ if ((GD_OP_REMOVE_BRICK != op) && !gd_is_remove_brick_committed (volinfo)) { - gf_log (this->name, GF_LOG_DEBUG, "A remove-brick task on " + gf_msg_debug (this->name, 0, "A remove-brick task on " "volume %s is not yet committed", volinfo->volname); snprintf (op_errstr, len, "A remove-brick task on volume %s is" " not yet committed. Either commit or stop the " @@ -59,7 +59,7 @@ glusterd_defrag_start_validate (glusterd_volinfo_t *volinfo, char *op_errstr, } if (glusterd_is_defrag_on (volinfo)) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "rebalance on volume %s already started", volinfo->volname); snprintf (op_errstr, len, "Rebalance on %s is already started", @@ -69,7 +69,7 @@ glusterd_defrag_start_validate (glusterd_volinfo_t *volinfo, char *op_errstr, ret = 0; out: - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -118,7 +118,7 @@ __glusterd_defrag_notify (struct rpc_clnt *rpc, void *mydata, } UNLOCK (&defrag->lock); - gf_log ("", GF_LOG_DEBUG, "%s got RPC_CLNT_CONNECT", + gf_msg_debug (this->name, 0, "%s got RPC_CLNT_CONNECT", rpc->conn.name); break; } @@ -160,7 +160,7 @@ __glusterd_defrag_notify (struct rpc_clnt *rpc, void *mydata, glusterd_volinfo_unref (volinfo); break; default: - gf_log ("", GF_LOG_TRACE, + gf_msg_trace (this->name, 0, "got some other RPC event %d", event); ret = 0; break; @@ -229,7 +229,8 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, GLUSTERD_GET_DEFRAG_DIR (defrag_path, volinfo, priv); ret = mkdir_p (defrag_path, 0777, _gf_true); if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, "Failed to create " + gf_msg (THIS->name, GF_LOG_ERROR, errno, + GD_MSG_CREATE_DIR_FAILED, "Failed to create " "directory %s", defrag_path); goto out; } @@ -290,7 +291,7 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, ret = runner_run_nowait (&runner); if (ret) { - gf_log ("glusterd", GF_LOG_DEBUG, "rebalance command failed"); + gf_msg_debug ("glusterd", 0, "rebalance command failed"); goto out; } @@ -304,7 +305,7 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, defrag->cbk_fn = cbk; out: - gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug ("glusterd", 0, "Returning %d", ret); return ret; } @@ -346,7 +347,8 @@ glusterd_rebalance_rpc_create (glusterd_volinfo_t *volinfo, * with the older path */ if (ret && (errno == ENOENT)) { - gf_log (this->name, GF_LOG_WARNING, "Rebalance sockfile " + gf_msg (this->name, GF_LOG_WARNING, errno, + GD_MSG_FILE_OP_FAILED, "Rebalance sockfile " "%s does not exist. Trying old path.", sockfile); GLUSTERD_GET_DEFRAG_SOCK_FILE_OLD (sockfile, volinfo, @@ -394,14 +396,16 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname, int ret = -1; if (glusterd_volinfo_find(volname, volinfo)) { - gf_log ("glusterd", GF_LOG_ERROR, "Received rebalance on invalid" + gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, + GD_MSG_VOL_NOT_FOUND, "Received rebalance on invalid" " volname %s", volname); snprintf (op_errstr, len, "Volume %s does not exist", volname); goto out; } if ((*volinfo)->brick_count <= (*volinfo)->dist_leaf_count) { - gf_log ("glusterd", GF_LOG_ERROR, "Volume %s is not a " + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_DISTRIBUTE, "Volume %s is not a " "distribute type or contains only 1 brick", volname); snprintf (op_errstr, len, "Volume %s is not a distribute " "volume or contains only 1 brick.\n" @@ -410,7 +414,8 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname, } if ((*volinfo)->status != GLUSTERD_STATUS_STARTED) { - gf_log ("glusterd", GF_LOG_ERROR, "Received rebalance on stopped" + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOL_STOPPED, "Received rebalance on stopped" " volname %s", volname); snprintf (op_errstr, len, "Volume %s needs to " "be started to perform rebalance", volname); @@ -429,7 +434,7 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname, ret = 0; out: - gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug ("glusterd", 0, "Returning %d", ret); return ret; } @@ -467,7 +472,8 @@ __glusterd_handle_defrag_volume (rpcsvc_request_t *req) cli_req.dict.dict_len, &dict); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "failed to " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_UNSERIALIZE_FAIL, "failed to " "unserialize req-buffer to dictionary"); snprintf (msg, sizeof (msg), "Unable to decode the " "command"); @@ -478,14 +484,16 @@ __glusterd_handle_defrag_volume (rpcsvc_request_t *req) ret = dict_get_str (dict, "volname", &volname); if (ret) { snprintf (msg, sizeof (msg), "Failed to get volume name"); - gf_log (this->name, GF_LOG_ERROR, "%s", msg); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "%s", msg); goto out; } ret = dict_get_int32 (dict, "rebalance-command", (int32_t*)&cmd); if (ret) { snprintf (msg, sizeof (msg), "Failed to get command"); - gf_log (this->name, GF_LOG_ERROR, "%s", msg); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "%s", msg); goto out; } @@ -575,20 +583,20 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, "volname not found"); + gf_msg_debug (this->name, 0, "volname not found"); goto out; } ret = dict_get_int32 (dict, "rebalance-command", &cmd); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, "cmd not found"); + gf_msg_debug (this->name, 0, "cmd not found"); goto out; } ret = glusterd_rebalance_cmd_validate (cmd, volname, &volinfo, msg, sizeof (msg)); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, "failed to validate"); + gf_msg_debug (this->name, 0, "failed to validate"); goto out; } switch (cmd) { @@ -626,7 +634,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) op_ctx = glusterd_op_get_ctx (); if (!op_ctx) { ret = -1; - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_OPCTX_GET_FAIL, "Failed to get op_ctx"); goto out; } @@ -634,7 +643,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) ret = glusterd_generate_and_set_task_id (op_ctx, GF_REBALANCE_TID_KEY); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_TASKID_GEN_FAIL, "Failed to generate task-id"); goto out; } @@ -644,7 +654,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) if (ret) { snprintf (msg, sizeof (msg), "Missing rebalance-id"); - gf_log (this->name, GF_LOG_WARNING, "%s", msg); + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_REBALANCE_ID_MISSING, "%s", msg); ret = 0; } } @@ -652,7 +663,7 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) sizeof (msg), GD_OP_REBALANCE); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "start validate failed"); goto out; } @@ -663,10 +674,11 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) case GF_DEFRAG_CMD_STOP_DETACH_TIER: ret = dict_get_str (dict, "cmd-str", &cmd_str); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to get " - "command string"); - ret = -1; - goto out; + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Failed to get " + "command string"); + ret = -1; + goto out; } if ((strstr(cmd_str, "rebalance") != NULL) && (volinfo->rebal.op != GD_OP_REBALANCE)) { @@ -737,13 +749,13 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, "volname not given"); + gf_msg_debug (this->name, 0, "volname not given"); goto out; } ret = dict_get_int32 (dict, "rebalance-command", &cmd); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, "command not given"); + gf_msg_debug (this->name, 0, "command not given"); goto out; } @@ -751,7 +763,7 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) ret = glusterd_rebalance_cmd_validate (cmd, volname, &volinfo, msg, sizeof (msg)); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, "cmd validate failed"); + gf_msg_debug (this->name, 0, "cmd validate failed"); goto out; } @@ -764,7 +776,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) if (!gf_uuid_is_null (volinfo->rebal.rebalance_id)) { ctx = glusterd_op_get_ctx (); if (!ctx) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_OPCTX_GET_FAIL, "Failed to get op_ctx"); ret = -1; goto out; @@ -779,7 +792,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) (volinfo->rebal.rebalance_id, ctx, GF_REBALANCE_TID_KEY); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_TASKID_GEN_FAIL, "Failed to set task-id"); goto out; } @@ -799,7 +813,7 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) ret = dict_get_str (dict, GF_REBALANCE_TID_KEY, &task_id_str); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, "Missing rebalance " + gf_msg_debug (this->name, 0, "Missing rebalance " "id"); ret = 0; } else { @@ -849,7 +863,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) ret = glusterd_create_volfiles_and_notify_services (volinfo); if (ret) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_VOLFILE_CREATE_FAIL, "failed to create volfiles"); goto out; } @@ -857,7 +872,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) ret = glusterd_store_volinfo (volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT); if (ret) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_VOLINFO_SET_FAIL, "failed to store volinfo"); goto out; } @@ -895,7 +911,8 @@ glusterd_defrag_event_notify_handle (dict_t *dict) ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to get volname"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Failed to get volname"); return ret; } @@ -908,8 +925,9 @@ glusterd_defrag_event_notify_handle (dict_t *dict) } volname = volname_ptr + 1; } else { - gf_log (this->name, GF_LOG_ERROR, - "volname received (%s) is not prefixed with rebalance.", + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_NO_REBALANCE_PFX_IN_VOLNAME, + "volname recieved (%s) is not prefixed with rebalance.", volname); ret = -1; goto out; @@ -917,7 +935,9 @@ glusterd_defrag_event_notify_handle (dict_t *dict) ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to get volinfo for %s" + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOLINFO_GET_FAIL, + "Failed to get volinfo for %s" , volname); return ret; } @@ -925,7 +945,9 @@ glusterd_defrag_event_notify_handle (dict_t *dict) ret = glusterd_defrag_volume_status_update (volinfo, dict); if (ret) - gf_log (this->name, GF_LOG_ERROR, "Failed to update status"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DEFRAG_STATUS_UPDATE_FAIL, + "Failed to update status"); out: return ret; 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; } diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index c71b79882fb..9b86f9bdb94 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -41,6 +41,7 @@ #include "glusterd-scrub-svc.h" #include "glusterd-quotad-svc.h" #include "glusterd-snapd-svc.h" +#include "glusterd-messages.h" #include "common-utils.h" #include "glusterd-geo-rep.h" #include "run.h" @@ -155,7 +156,8 @@ glusterd_uuid_init () ret = glusterd_uuid_generate_save (); if (ret) { - gf_log ("glusterd", GF_LOG_ERROR, + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_UUID_GEN_STORE_FAIL, "Unable to generate and save new UUID"); return ret; } @@ -183,7 +185,8 @@ glusterd_uuid_generate_save () ret = glusterd_store_global_info (this); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_UUID_STORE_FAIL, "Unable to store the generated uuid %s", uuid_utoa (priv->uuid)); @@ -215,7 +218,8 @@ glusterd_options_init (xlator_t *this) ret = glusterd_store_options (this, priv->opts); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to store version"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VERS_STORE_FAIL, "Unable to store version"); return ret; } out: @@ -294,7 +298,8 @@ mem_acct_init (xlator_t *this) ret = xlator_mem_acct_init (this, gf_gld_mt_end + 1); if (ret != 0) { - gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + GD_MSG_NO_MEMORY, "Memory accounting init" " failed"); return ret; } @@ -311,7 +316,8 @@ glusterd_rpcsvc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, glusterd_conf_t *priv = NULL; if (!xl || !data) { - gf_log ("glusterd", GF_LOG_WARNING, + gf_msg ("glusterd", GF_LOG_WARNING, 0, + GD_MSG_NO_INIT, "Calling rpc_notify without initializing"); goto out; } @@ -356,7 +362,7 @@ glusterd_program_register (xlator_t *this, rpcsvc_t *svc, ret = rpcsvc_program_register (svc, prog); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "cannot register program (name: %s, prognum:%d, " "progver:%d)", prog->progname, prog->prognum, prog->progver); @@ -385,7 +391,7 @@ glusterd_rpcsvc_options_build (dict_t *options) goto out; } - gf_log ("", GF_LOG_DEBUG, "listen-backlog value: %d", backlog); + gf_msg_debug ("", 0, "listen-backlog value: %d", backlog); out: return ret; @@ -406,12 +412,14 @@ glusterd_check_gsync_present (int *valid_state) ret = runner_start (&runner); if (ret == -1) { if (errno == ENOENT) { - gf_log ("glusterd", GF_LOG_INFO, GEOREP + gf_msg ("glusterd", GF_LOG_INFO, errno, + GD_MSG_MODULE_NOT_INSTALLED, GEOREP " module not installed in the system"); *valid_state = 0; } else { - gf_log ("glusterd", GF_LOG_ERROR, GEOREP + gf_msg ("glusterd", GF_LOG_ERROR, errno, + GD_MSG_MODULE_NOT_WORKING, GEOREP " module not working as desired"); *valid_state = -1; } @@ -422,14 +430,16 @@ glusterd_check_gsync_present (int *valid_state) if (ptr) { if (!strstr (buff, "gsyncd")) { ret = -1; - gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not " + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_MODULE_NOT_WORKING, GEOREP" module not " "working as desired"); *valid_state = -1; goto out; } } else { ret = -1; - gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not " + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_MODULE_NOT_WORKING, GEOREP" module not " "working as desired"); *valid_state = -1; goto out; @@ -440,7 +450,7 @@ glusterd_check_gsync_present (int *valid_state) runner_end (&runner); - gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug ("glusterd", 0, "Returning %d", ret); return ret; } @@ -464,7 +474,8 @@ group_write_allow (char *path, gid_t gid) out: if (ret == -1) - gf_log ("", GF_LOG_CRITICAL, + gf_msg ("", GF_LOG_CRITICAL, errno, + GD_MSG_WRITE_ACCESS_GRANT_FAIL, "failed to set up write access to %s for group %d (%s)", path, gid, strerror (errno)); return ret; @@ -482,7 +493,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) if (strlen (conf->workdir)+2 > PATH_MAX-strlen(GEOREP)) { ret = -1; - gf_log ("glusterd", GF_LOG_CRITICAL, + gf_msg ("glusterd", GF_LOG_CRITICAL, 0, + GD_MSG_DIRPATH_TOO_LONG, "directory path %s/"GEOREP" is longer than PATH_MAX", conf->workdir); goto out; @@ -491,7 +503,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) snprintf (georepdir, PATH_MAX, "%s/"GEOREP, conf->workdir); ret = mkdir_p (georepdir, 0777, _gf_true); if (-1 == ret) { - gf_log ("glusterd", GF_LOG_CRITICAL, + gf_msg ("glusterd", GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create "GEOREP" directory %s", georepdir); goto out; @@ -499,14 +512,16 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) if (strlen (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP) >= PATH_MAX) { ret = -1; - gf_log ("glusterd", GF_LOG_CRITICAL, + gf_msg ("glusterd", GF_LOG_CRITICAL, 0, + GD_MSG_DIRPATH_TOO_LONG, "directory path "DEFAULT_LOG_FILE_DIRECTORY"/" GEOREP" is longer than PATH_MAX"); goto out; } ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP, 0777, _gf_true); if (-1 == ret) { - gf_log ("glusterd", GF_LOG_CRITICAL, + gf_msg ("glusterd", GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create "GEOREP" log directory"); goto out; } @@ -514,7 +529,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) /* Slave log file directory */ if (strlen(DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves") >= PATH_MAX) { ret = -1; - gf_log ("glusterd", GF_LOG_CRITICAL, + gf_msg ("glusterd", GF_LOG_CRITICAL, 0, + GD_MSG_DIRPATH_TOO_LONG, "directory path "DEFAULT_LOG_FILE_DIRECTORY"/" GEOREP"-slaves"" is longer than PATH_MAX"); goto out; @@ -522,7 +538,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves", 0777, _gf_true); if (-1 == ret) { - gf_log ("glusterd", GF_LOG_CRITICAL, + gf_msg ("glusterd", GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create "GEOREP" slave log directory"); goto out; } @@ -530,7 +547,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) /* MountBroker log file directory */ if (strlen(DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves/mbr") >= PATH_MAX) { ret = -1; - gf_log ("glusterd", GF_LOG_CRITICAL, + gf_msg ("glusterd", GF_LOG_CRITICAL, 0, + GD_MSG_DIRPATH_TOO_LONG, "directory path "DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP "-slaves/mbr"" is longer than PATH_MAX"); goto out; @@ -538,7 +556,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves/mbr", 0777, _gf_true); if (-1 == ret) { - gf_log ("glusterd", GF_LOG_CRITICAL, + gf_msg ("glusterd", GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create "GEOREP" mountbroker slave log directory"); goto out; } @@ -549,7 +568,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) else { gr = getgrnam (greplg_s); if (!gr) { - gf_log ("glusterd", GF_LOG_CRITICAL, + gf_msg ("glusterd", GF_LOG_CRITICAL, 0, + GD_MSG_LOGGROUP_INVALID, "group "GEOREP"-log-group %s does not exist", greplg_s); ret = -1; goto out; @@ -566,7 +586,7 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) } out: - gf_log("", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug ("", 0, "Returning %d", ret); return ret; } @@ -818,7 +838,8 @@ check_prepare_mountbroker_root (char *mountbroker_root) ret = fstat (dfd, &st); } if (ret == -1 || !S_ISDIR (st.st_mode)) { - gf_log ("", GF_LOG_ERROR, + gf_msg ("", GF_LOG_ERROR, errno, + GD_MSG_DIR_OP_FAILED, "cannot access mountbroker-root directory %s", mountbroker_root); ret = -1; @@ -826,14 +847,16 @@ check_prepare_mountbroker_root (char *mountbroker_root) } if (st.st_uid != 0 || (st.st_mode & (S_IWGRP|S_IWOTH))) { - gf_log ("", GF_LOG_ERROR, + gf_msg ("", GF_LOG_ERROR, 0, + GD_MSG_DIR_PERM_LIBERAL, "permissions on mountbroker-root directory %s are " "too liberal", mountbroker_root); ret = -1; goto out; } if (!(st.st_mode & (S_IXGRP|S_IXOTH))) { - gf_log ("", GF_LOG_WARNING, + gf_msg ("", GF_LOG_WARNING, 0, + GD_MSG_DIR_PERM_STRICT, "permissions on mountbroker-root directory %s are " "probably too strict", mountbroker_root); } @@ -847,7 +870,8 @@ check_prepare_mountbroker_root (char *mountbroker_root) ret = fstat (dfd2, &st2); } if (ret == -1) { - gf_log ("", GF_LOG_ERROR, + gf_msg ("", GF_LOG_ERROR, errno, + GD_MSG_DIR_OP_FAILED, "error while checking mountbroker-root ancestors " "%d (%s)", errno, strerror (errno)); goto out; @@ -859,14 +883,16 @@ check_prepare_mountbroker_root (char *mountbroker_root) if (st2.st_uid != 0 || ((st2.st_mode & (S_IWGRP|S_IWOTH)) && !(st2.st_mode & S_ISVTX))) { - gf_log ("", GF_LOG_ERROR, + gf_msg ("", GF_LOG_ERROR, 0, + GD_MSG_DIR_PERM_LIBERAL, "permissions on ancestors of mountbroker-root " "directory are too liberal"); ret = -1; goto out; } if (!(st.st_mode & (S_IXGRP|S_IXOTH))) { - gf_log ("", GF_LOG_WARNING, + gf_msg ("", GF_LOG_WARNING, 0, + GD_MSG_DIR_PERM_STRICT, "permissions on ancestors of mountbroker-root " "directory are probably too strict"); } @@ -882,7 +908,8 @@ check_prepare_mountbroker_root (char *mountbroker_root) if (ret != -1) ret = sys_fstatat (dfd0, MB_HIVE, &st, AT_SYMLINK_NOFOLLOW); if (ret == -1 || st.st_mode != (S_IFDIR|0711)) { - gf_log ("", GF_LOG_ERROR, + gf_msg ("", GF_LOG_ERROR, errno, + GD_MSG_CREATE_DIR_FAILED, "failed to set up mountbroker-root directory %s", mountbroker_root); ret = -1; @@ -973,7 +1000,8 @@ _install_mount_spec (dict_t *opts, char *key, data_t *value, void *data) return 0; err: - gf_log ("", GF_LOG_ERROR, + gf_msg ("", GF_LOG_ERROR, 0, + GD_MSG_MOUNT_SPEC_INSTALL_FAIL, "adding %smount spec failed: label: %s desc: %s", georep ? GEOREP" " : "", label, pdesc); @@ -1038,14 +1066,14 @@ glusterd_init_uds_listener (xlator_t *this) ret = rpcsvc_register_notify (rpc, glusterd_uds_rpcsvc_notify, this); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Failed to register notify function"); goto out; } ret = rpcsvc_create_listeners (rpc, options, this->name); if (ret != 1) { - gf_log (this->name, GF_LOG_DEBUG, "Failed to create listener"); + gf_msg_debug (this->name, 0, "Failed to create listener"); goto out; } ret = 0; @@ -1067,7 +1095,9 @@ out: dict_unref (options); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to start glusterd " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_GLUSTERD_SOCK_LISTENER_START_FAIL, + "Failed to start glusterd " "unix domain socket listener."); if (rpc) { GF_FREE (rpc); @@ -1161,7 +1191,8 @@ glusterd_find_correct_var_run_dir (xlator_t *this, char *var_run_dir) */ ret = lstat (GLUSTERD_VAR_RUN_DIR, &buf); if (ret != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_FILE_OP_FAILED, "stat fails on %s, exiting. (errno = %d)", GLUSTERD_VAR_RUN_DIR, errno); goto out; @@ -1196,7 +1227,8 @@ glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir, ret = stat (abs_path, &buf); if ((ret != 0) && (ENOENT != errno)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_FILE_OP_FAILED, "stat fails on %s, exiting. (errno = %d)", abs_path, errno); ret = -1; @@ -1204,7 +1236,8 @@ glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir, } if ((!ret) && (!S_ISDIR(buf.st_mode))) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, ENOENT, + GD_MSG_DIR_NOT_FOUND, "Provided snap path %s is not a directory," "exiting", abs_path); ret = -1; @@ -1216,7 +1249,8 @@ glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir, ret = mkdir_p (abs_path, 0777, _gf_true); if (-1 == ret) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create directory %s" " ,errno = %d", abs_path, errno); goto out; @@ -1243,27 +1277,32 @@ glusterd_svc_init_all () /* Init SHD svc */ ret = glusterd_shdsvc_init (&(priv->shd_svc)); if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, "Failed to init shd service"); + gf_msg (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_FAILED_INIT_SHDSVC, + "Failed to init shd service"); goto out; } - gf_log (THIS->name, GF_LOG_DEBUG, "shd service initialized"); + gf_msg_debug (THIS->name, 0, "shd service initialized"); /* Init NFS svc */ ret = glusterd_nfssvc_init (&(priv->nfs_svc)); if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, "Failed to init nfs service"); + gf_msg (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_FAILED_INIT_NFSSVC, + "Failed to init nfs service"); goto out; } - gf_log (THIS->name, GF_LOG_DEBUG, "nfs service initialized"); + gf_msg_debug (THIS->name, 0, "nfs service initialized"); /* Init QuotaD svc */ ret = glusterd_quotadsvc_init (&(priv->quotad_svc)); if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, "Failed to init quotad " + gf_msg (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_FAILED_INIT_QUOTASVC, "Failed to init quotad " "service"); goto out; } - gf_log (THIS->name, GF_LOG_DEBUG, "quotad service initialized"); + gf_msg_debug (THIS->name, 0, "quotad service initialized"); /* Init BitD svc */ ret = glusterd_bitdsvc_init (&(priv->bitd_svc)); @@ -1319,7 +1358,8 @@ init (xlator_t *this) lim.rlim_max = 65536; if (setrlimit (RLIMIT_NOFILE, &lim) == -1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_SETXATTR_FAIL, "Failed to set 'ulimit -n " " 65536': %s", strerror(errno)); } else { @@ -1341,14 +1381,16 @@ init (xlator_t *this) ret = stat (workdir, &buf); if ((ret != 0) && (ENOENT != errno)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_DIR_OP_FAILED, "stat fails on %s, exiting. (errno = %d)", workdir, errno); exit (1); } if ((!ret) && (!S_ISDIR(buf.st_mode))) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, ENOENT, + GD_MSG_DIR_NOT_FOUND, "Provided working area %s is not a directory," "exiting", workdir); exit (1); @@ -1359,7 +1401,8 @@ init (xlator_t *this) ret = mkdir_p (workdir, 0777, _gf_true); if (-1 == ret) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create directory %s" " ,errno = %d", workdir, errno); exit (1); @@ -1382,8 +1425,9 @@ init (xlator_t *this) ret = glusterd_init_var_run_dirs (this, var_run_dir, GLUSTERD_DEFAULT_SNAPS_BRICK_DIR); if (ret) { - gf_log (this->name, GF_LOG_CRITICAL, "Unable to create " - "snap backend dir"); + gf_msg (this->name, GF_LOG_CRITICAL, 0, + GD_MSG_CREATE_DIR_FAILED, "Unable to create " + "snap backend folder"); exit (1); } @@ -1406,7 +1450,8 @@ init (xlator_t *this) ret = gf_cmd_log_init (cmd_log_filename); if (ret == -1) { - gf_log ("this->name", GF_LOG_CRITICAL, + gf_msg ("this->name", GF_LOG_CRITICAL, errno, + GD_MSG_FILE_OP_FAILED, "Unable to create cmd log file %s", cmd_log_filename); exit (1); } @@ -1416,7 +1461,8 @@ init (xlator_t *this) ret = mkdir (storedir, 0777); if ((-1 == ret) && (errno != EEXIST)) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create volume directory %s" " ,errno = %d", storedir, errno); exit (1); @@ -1427,7 +1473,8 @@ init (xlator_t *this) ret = mkdir (storedir, 0777); if ((-1 == ret) && (errno != EEXIST)) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create snaps directory %s" " ,errno = %d", storedir, errno); exit (1); @@ -1438,7 +1485,8 @@ init (xlator_t *this) ret = mkdir (storedir, 0777); if ((-1 == ret) && (errno != EEXIST)) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create peers directory %s" " ,errno = %d", storedir, errno); exit (1); @@ -1447,7 +1495,8 @@ init (xlator_t *this) snprintf (storedir, PATH_MAX, "%s/bricks", DEFAULT_LOG_FILE_DIRECTORY); ret = mkdir (storedir, 0777); if ((-1 == ret) && (errno != EEXIST)) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create logs directory %s" " ,errno = %d", storedir, errno); exit (1); @@ -1456,7 +1505,8 @@ init (xlator_t *this) snprintf (storedir, PATH_MAX, "%s/nfs", workdir); ret = mkdir (storedir, 0777); if ((-1 == ret) && (errno != EEXIST)) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create nfs directory %s" " ,errno = %d", storedir, errno); exit (1); @@ -1483,7 +1533,8 @@ init (xlator_t *this) snprintf (storedir, PATH_MAX, "%s/glustershd", workdir); ret = mkdir (storedir, 0777); if ((-1 == ret) && (errno != EEXIST)) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create glustershd directory %s" " ,errno = %d", storedir, errno); exit (1); @@ -1492,7 +1543,8 @@ init (xlator_t *this) snprintf (storedir, PATH_MAX, "%s/quotad", workdir); ret = mkdir (storedir, 0777); if ((-1 == ret) && (errno != EEXIST)) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create quotad directory %s" " ,errno = %d", storedir, errno); exit (1); @@ -1501,7 +1553,8 @@ init (xlator_t *this) snprintf (storedir, PATH_MAX, "%s/groups", workdir); ret = mkdir (storedir, 0777); if ((-1 == ret) && (errno != EEXIST)) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create glustershd directory %s" " ,errno = %d", storedir, errno); exit (1); @@ -1512,14 +1565,16 @@ init (xlator_t *this) goto out; rpc = rpcsvc_init (this, this->ctx, this->options, 64); if (rpc == NULL) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_RPC_INIT_FAIL, "failed to init rpc"); goto out; } ret = rpcsvc_register_notify (rpc, glusterd_rpcsvc_notify, this); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_RPCSVC_REG_NOTIFY_RETURNED, "rpcsvc_register_notify returned %d", ret); goto out; } @@ -1534,7 +1589,8 @@ init (xlator_t *this) ret = dict_set_str (this->options, "transport.socket.own-thread", "off"); if (ret != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "failed to clear own-thread"); goto out; } @@ -1557,14 +1613,16 @@ init (xlator_t *this) ret = dict_get_str (this->options, "transport-type", &transport_type); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to get transport type"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Failed to get transport type"); ret = -1; goto out; } total_transport = rpc_transport_count (transport_type); if (total_transport <= 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_RPC_TRANSPORT_COUNT_GET_FAIL, "failed to get total number of available tranpsorts"); ret = -1; goto out; @@ -1572,12 +1630,14 @@ init (xlator_t *this) ret = rpcsvc_create_listeners (rpc, this->options, this->name); if (ret < 1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_RPC_LISTENER_CREATE_FAIL, "creation of listener failed"); ret = -1; goto out; } else if (ret < total_transport) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_RPC_LISTENER_CREATE_FAIL, "creation of %d listeners failed, continuing with " "succeeded transport", (total_transport - ret)); } @@ -1637,20 +1697,22 @@ init (xlator_t *this) conf->base_port = GF_IANA_PRIV_PORTS_START; if (dict_get_uint32(this->options, "base-port", &conf->base_port) == 0) { - gf_log (this->name, GF_LOG_INFO, - "base-port override: %d", conf->base_port); + gf_msg (this->name, GF_LOG_INFO, 0, + GD_MSG_DICT_SET_FAILED, + "base-port override: %d", conf->base_port); } /* Set option to run bricks on valgrind if enabled in glusterd.vol */ conf->valgrind = _gf_false; ret = dict_get_str (this->options, "run-with-valgrind", &valgrind_str); if (ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "cannot get run-with-valgrind value"); } if (valgrind_str) { if (gf_string2boolean (valgrind_str, &(conf->valgrind))) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, EINVAL, + GD_MSG_INVALID_ENTRY, "run-with-valgrind value not a boolean string"); } } @@ -1671,7 +1733,8 @@ init (xlator_t *this) */ ret = glusterd_hooks_create_hooks_directory (conf->workdir); if (-1 == ret) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_DIR_OP_FAILED, "Unable to create hooks directory "); exit (1); } @@ -1705,7 +1768,8 @@ init (xlator_t *this) * */ ret = glusterd_restore_op_version (this); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_OP_VERS_RESTORE_FAIL, "Failed to restore op_version"); goto out; } -- cgit