From 72a7a6ea78289b2897f9846dc4e111f442dd2788 Mon Sep 17 00:00:00 2001 From: Nandaja Varma Date: Wed, 18 Mar 2015 15:17:45 +0530 Subject: sm/glusterd: Porting messages to new logging framework Change-Id: I391d1ac6a7b312461187c2e8c6f14d09a0238950 BUG: 1194640 Signed-off-by: Nandaja Varma Reviewed-on: http://review.gluster.org/9927 Reviewed-by: Atin Mukherjee Tested-by: NetBSD Build System Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 711 ++++++++++++++++++----------- 1 file changed, 454 insertions(+), 257 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 01244409146..56887e35323 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -200,12 +200,13 @@ glusterd_generate_txn_id (dict_t *dict, uuid_t **txn_id) ret = dict_set_bin (dict, "transaction_id", *txn_id, sizeof (**txn_id)); if (ret) { - gf_log ("", GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Failed to set transaction id."); goto out; } - gf_log ("", GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Transaction_id = %s", uuid_utoa (**txn_id)); out: if (ret && *txn_id) { @@ -249,13 +250,13 @@ glusterd_get_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo) (*opinfo) = opinfo_obj->opinfo; - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Successfully got opinfo for transaction ID : %s", uuid_utoa (*txn_id)); ret = 0; out: - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -303,7 +304,7 @@ glusterd_set_txn_opinfo (uuid_t *txn_id, glusterd_op_info_t *opinfo) opinfo_obj->opinfo = (*opinfo); - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Successfully set opinfo for transaction ID : %s", uuid_utoa (*txn_id)); ret = 0; @@ -312,7 +313,7 @@ out: if (opinfo_obj) GF_FREE (opinfo_obj); - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -330,14 +331,18 @@ glusterd_clear_txn_opinfo (uuid_t *txn_id) GF_ASSERT (priv); if (!txn_id) { - gf_log ("", GF_LOG_ERROR, "Empty transaction id received."); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_TRANS_ID_GET_FAIL, + "Empty transaction id received."); ret = -1; goto out; } ret = glusterd_get_txn_opinfo (txn_id, &txn_op_info); if (ret) { - gf_log ("", GF_LOG_ERROR, "Transaction opinfo not found"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_TRANS_OPINFO_GET_FAIL, + "Transaction opinfo not found"); goto out; } @@ -346,13 +351,13 @@ glusterd_clear_txn_opinfo (uuid_t *txn_id) dict_del(priv->glusterd_txn_opinfo, uuid_utoa (*txn_id)); - gf_log ("", GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Successfully cleared opinfo for transaction ID : %s", uuid_utoa (*txn_id)); ret = 0; out: - gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -433,7 +438,7 @@ glusterd_op_sm_inject_all_acc (uuid_t *txn_id) { int32_t ret = -1; ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACC, txn_id, NULL); - gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug ("glusterd", 0, "Returning %d", ret); return ret; } @@ -622,7 +627,7 @@ glusterd_brick_op_build_payload (glusterd_op_t op, glusterd_brickinfo_t *brickin out: if (ret && brick_req) GF_FREE (brick_req); - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -676,7 +681,7 @@ glusterd_node_op_build_payload (glusterd_op_t op, gd1_mgmt_brick_op_req **req, out: if (ret && brick_req) GF_FREE (brick_req); - gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (THIS->name, 0, "Returning %d", ret); return ret; } @@ -826,7 +831,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) ret = dict_get_uint32 (dict, "new-op-version", &new_op_version); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Failed to get new_op_version"); goto out; } @@ -837,7 +843,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) snprintf (errstr, sizeof (errstr), "Required op_version (%d) is not " "supported", new_op_version); - gf_log (this->name, GF_LOG_ERROR, "%s", errstr); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_UNSUPPORTED_VERSION, "%s", + errstr); goto out; } } @@ -845,7 +853,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) ret = dict_get_int32 (dict, "count", &dict_count); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Count(dict),not set in Volume-Set"); goto out; } @@ -863,14 +872,16 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) goto out; #else ret = -1; - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_MODULE_NOT_INSTALLED, "libxml not present in the system"); *op_errstr = gf_strdup ("Error: xml libraries not " "present to produce xml-output"); goto out; #endif } - gf_log (this->name, GF_LOG_ERROR, "No options received "); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_NO_OPTIONS_GIVEN, "No options received "); *op_errstr = gf_strdup ("Options not specified"); ret = -1; goto out; @@ -878,7 +889,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, + "Unable to get volume name"); goto out; } @@ -887,14 +900,16 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) if (!exists) { snprintf (errstr, sizeof (errstr), FMTSTR_CHECK_VOL_EXISTS, volname); - gf_log (this->name, GF_LOG_ERROR, "%s", errstr); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, "%s", errstr); ret = -1; goto out; } ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, volname); goto out; } @@ -918,21 +933,22 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) sprintf (str, "value%d", count); ret = dict_get_str (dict, str, &value); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "invalid key,value pair in 'volume set'"); ret = -1; goto out; } if (strcmp (key, "config.memory-accounting") == 0) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "enabling memory accounting for volume %s", volname); ret = 0; } if (strcmp (key, "config.transport") == 0) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "changing transport-type for volume %s", volname); ret = 0; @@ -970,7 +986,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) } if (!exists) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, "Option with name: %s does not exist", key); ret = snprintf (errstr, sizeof (errstr), "option : %s does not exist", @@ -1014,7 +1031,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) snprintf (errstr, sizeof (errstr), "invalid " "number format \"%s\" in option " "\"%s\"", value, key); - gf_log (this->name, GF_LOG_ERROR, "%s", errstr); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, "%s", errstr); goto out; } @@ -1024,7 +1042,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) snprintf (errstr, sizeof (errstr), "Required op_version (%d) is not " "supported", local_key_op_version); - gf_log (this->name, GF_LOG_ERROR, "%s", errstr); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VERSION_UNSUPPORTED, + "%s", errstr); goto out; } if (local_key_op_version > local_new_op_version) @@ -1046,14 +1066,16 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) if (origin_glusterd) { ret = dict_set_uint32 (dict, str, local_key_op_version); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Failed to set key-op-version in dict"); goto out; } } else if (check_op_version) { ret = dict_get_uint32 (dict, str, &key_op_version); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Failed to get key-op-version from" " dict"); goto out; @@ -1063,7 +1085,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) snprintf (errstr, sizeof (errstr), "option: %s op-version mismatch", key); - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_OP_VERSION_MISMATCH, "%s, required op-version = %"PRIu32", " "available op-version = %"PRIu32, errstr, key_op_version, @@ -1098,7 +1121,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) if (strchr (value, '/')) { snprintf (errstr, sizeof (errstr), "Path is not allowed as option"); - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_SET_FAIL, "Unable to set the options in 'volume " "set': %s", errstr); ret = -1; @@ -1121,17 +1145,24 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) /* Checks whether a directory with given option exists or not */ if (!stat(trash_path, &stbuf)) { - snprintf (errstr, sizeof (errstr), - "Path %s exists", value); - gf_log (this->name, GF_LOG_ERROR, - "Unable to set the options in " - "'volume set': %s", errstr); + snprintf (errstr, + sizeof (errstr), + "Path %s exists", + value); + gf_msg (this->name, + GF_LOG_ERROR, + 0, GD_MSG_VOL_SET_FAIL, + "Unable to set the " + "options in " + "'volume set': %s", + errstr); ret = -1; goto out; } else { - gf_log (this->name, GF_LOG_DEBUG, - "Directory with given name " - "does not exists, continuing"); + gf_msg_debug (this->name, 0, + "Directory with given " + "name does not exists," + " continuing"); } if (volinfo->status == GLUSTERD_STATUS_STARTED @@ -1140,9 +1171,13 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) whether bricks are online */ snprintf (errstr, sizeof (errstr), "One or more bricks are down"); - gf_log (this->name, GF_LOG_ERROR, - "Unable to set the options in " - "'volume set': %s", errstr); + gf_msg (this->name, + GF_LOG_ERROR, 0, + GD_MSG_VOL_SET_FAIL, + "Unable to set the " + "options in " + "'volume set': %s", + errstr); ret = -1; goto out; } @@ -1157,7 +1192,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) snprintf (errstr, sizeof (errstr), "Trash translator is not enabled. Use " "volume set %s trash on", volname); - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_SET_FAIL, "Unable to set the options in 'volume " "set': %s", errstr); ret = -1; @@ -1166,7 +1202,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) ret = dict_set_str (val_dict, key, value); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Unable to set the options in 'volume set'"); ret = -1; goto out; @@ -1188,7 +1225,9 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) } if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Could not create " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOLFILE_CREATE_FAIL, + "Could not create " "temp volfile, some option failed: %s", *op_errstr); goto out; @@ -1213,7 +1252,8 @@ cont: ret = dict_set_uint32 (dict, "new-op-version", local_new_op_version); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Failed to set new-op-version in dict"); goto out; } @@ -1226,7 +1266,8 @@ cont: ret = dict_set_uint32 (dict, "check-op-version", _gf_true); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Failed to set check-op-version in dict"); goto out; } @@ -1248,11 +1289,11 @@ out: if (ret) { if (!(*op_errstr)) { *op_errstr = gf_strdup ("Error, Validation Failed"); - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Error, Cannot Validate option :%s", *op_errstr); } else { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Error, Cannot Validate option"); } } @@ -1277,7 +1318,8 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr) ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); goto out; } @@ -1303,7 +1345,8 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr) ret = dict_get_str (dict, "key", &key); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to get option key"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get option key"); goto out; } if (strcmp(key, "all")) { @@ -1337,7 +1380,7 @@ out: *op_errstr = gf_strdup (msg); } - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -1403,7 +1446,7 @@ glusterd_op_stage_sync_volume (dict_t *dict, char **op_errstr) } out: - gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug ("glusterd", 0, "Returning %d", ret); return ret; } @@ -1458,7 +1501,8 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); goto out; } @@ -1567,7 +1611,7 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr) *op_errstr = gf_strdup ("Validation Failed for Status"); } - gf_log (this->name, GF_LOG_DEBUG, "Returning: %d", ret); + gf_msg_debug (this->name, 0, "Returning: %d", ret); return ret; } @@ -1652,7 +1696,8 @@ glusterd_op_stage_stats_volume (dict_t *dict, char **op_errstr) if (_gf_false == glusterd_is_volume_started (volinfo)) { snprintf (msg, sizeof (msg), "Volume %s is not started.", volinfo->volname); - gf_log ("glusterd", GF_LOG_ERROR, "%s", msg); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_STARTED, "%s", msg); ret = -1; goto out; } @@ -1663,7 +1708,7 @@ out: gf_log ("glusterd", GF_LOG_ERROR, "%s", msg); *op_errstr = gf_strdup (msg); } - gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug ("glusterd", 0, "Returning %d", ret); return ret; } @@ -1689,7 +1734,7 @@ _delete_reconfig_opt (dict_t *this, char *key, data_t *value, void *data) } } - gf_log ("", GF_LOG_DEBUG, "deleting dict with key=%s,value=%s", + gf_msg_debug ("glusterd", 0, "deleting dict with key=%s,value=%s", key, value->data); dict_del (this, key); /**Delete scrubber (pause/resume) option from the dictionary if bitrot @@ -1746,7 +1791,7 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, } else { value = dict_get (volinfo->dict, key); if (!value) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "no value set for option %s", key); goto out; } @@ -1765,7 +1810,9 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, ret = glusterd_create_volfiles_and_notify_services (volinfo); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to create volfile for" + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOLFILE_CREATE_FAIL, + "Unable to create volfile for" " 'volume reset'"); ret = -1; goto out; @@ -1785,7 +1832,7 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo, char *key, out: GF_FREE (key_fixed); - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -1807,7 +1854,8 @@ glusterd_op_reset_all_volume_options (xlator_t *this, dict_t *dict) conf = this->private; ret = dict_get_str (dict, "key", &key); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to get key"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Failed to get key"); goto out; } @@ -1818,7 +1866,8 @@ glusterd_op_reset_all_volume_options (xlator_t *this, dict_t *dict) if (strcmp (key, "all")) { ret = glusterd_check_option_exists (key, &key_fixed); if (ret <= 0) { - gf_log (this->name, GF_LOG_ERROR, "Option %s does not " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, "Option %s does not " "exist", key); ret = -1; goto out; @@ -1884,7 +1933,7 @@ out: if (dup_opt) dict_unref (dup_opt); - gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); + gf_msg_debug (this->name, 0, "returning %d", ret); if (quorum_action) glusterd_do_quorum_action (); GF_FREE (next_version); @@ -1906,7 +1955,8 @@ glusterd_op_reset_volume (dict_t *dict, char **op_rspstr) this = THIS; ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name" ); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); goto out; } @@ -1921,20 +1971,23 @@ glusterd_op_reset_volume (dict_t *dict, char **op_rspstr) ret = dict_get_str (dict, "key", &key); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to get option key"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get option key"); goto out; } ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - gf_log (this->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, volname); goto out; } if (strcmp (key, "all") && glusterd_check_option_exists (key, &key_fixed) != 1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, "volinfo dict inconsistency: option %s not found", key); ret = -1; @@ -1975,7 +2028,7 @@ out: if (quorum_action) glusterd_do_quorum_action (); - gf_log (this->name, GF_LOG_DEBUG, "'volume reset' returning %d", ret); + gf_msg_debug (this->name, 0, "'volume reset' returning %d", ret); return ret; } @@ -2005,7 +2058,8 @@ glusterd_start_bricks (glusterd_volinfo_t *volinfo) cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { ret = glusterd_brick_start (volinfo, brickinfo, _gf_false); if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, + gf_msg (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_BRICK_DISCONNECTED, "Failed to start %s:%s for %s", brickinfo->hostname, brickinfo->path, volinfo->volname); @@ -2040,14 +2094,16 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict, ret = dict_get_str (dict, "value1", &value); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "invalid key,value pair in 'volume set'"); goto out; } ret = glusterd_check_option_exists (key, &key_fixed); if (ret <= 0) { - gf_log (this->name, GF_LOG_ERROR, "Invalid key %s", key); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_UNKNOWN_KEY, "Invalid key %s", key); ret = -1; goto out; } @@ -2076,7 +2132,8 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict, conf->op_version = op_version; 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_OP_VERS_STORE_FAIL, "Failed to store op-version."); } } @@ -2132,7 +2189,7 @@ out: if (dup_opt) dict_unref (dup_opt); - gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); + gf_msg_debug (this->name, 0, "returning %d", ret); if (quorum_action) glusterd_do_quorum_action (); GF_FREE (next_version); @@ -2246,14 +2303,17 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) ret = dict_get_int32 (dict, "count", &dict_count); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Count(dict),not set in Volume-Set"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, + "Count(dict),not set in Volume-Set"); goto out; } if (dict_count == 0) { ret = glusterd_volset_help (NULL, &op_errstr); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "%s", + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_SET_FAIL, "%s", (op_errstr)? op_errstr: "Volume set help internal error"); } @@ -2264,7 +2324,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); goto out; } @@ -2276,7 +2337,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - gf_log (this->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, volname); goto out; } @@ -2288,7 +2350,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) if (check_op_version) { ret = dict_get_uint32 (dict, "new-op-version", &new_op_version); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get new op-version from dict"); goto out; } @@ -2304,7 +2367,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) sprintf (str, "value%d", count); ret = dict_get_str (dict, str, &value); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "invalid key,value pair in 'volume set'"); ret = -1; goto out; @@ -2356,7 +2420,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) value = gf_strdup (value); if (!value) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_SET_FAIL, "Unable to set the options in 'volume set'"); ret = -1; goto out; @@ -2390,7 +2455,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) } if (count == 1) { - gf_log (this->name, GF_LOG_ERROR, "No options received "); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_NO_OPTIONS_GIVEN, "No options received "); ret = -1; goto out; } @@ -2402,7 +2468,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) priv->op_version = new_op_version; 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_OP_VERS_STORE_FAIL, "Failed to store op-version"); goto out; } @@ -2418,7 +2485,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) } ret = glusterd_create_volfiles_and_notify_services (volinfo); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOLFILE_CREATE_FAIL, "Unable to create volfile for" " 'volume set'"); ret = -1; @@ -2432,7 +2500,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) if (GLUSTERD_STATUS_STARTED == volinfo->status) { ret = glusterd_svcs_reconfigure (volinfo); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_SVC_RESTART_FAIL, "Unable to restart services"); goto out; } @@ -2453,7 +2522,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) ret = glusterd_create_volfiles_and_notify_services (volinfo); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOLFILE_CREATE_FAIL, "Unable to create volfile for" " 'volume set'"); ret = -1; @@ -2468,7 +2538,8 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) if (GLUSTERD_STATUS_STARTED == volinfo->status) { ret = glusterd_svcs_reconfigure (volinfo); if (ret) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_NFS_SERVER_START_FAIL, "Unable to restart NFS-Server"); goto out; } @@ -2478,7 +2549,7 @@ glusterd_op_set_volume (dict_t *dict, char **errstr) out: GF_FREE (key_fixed); - gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret); + gf_msg_debug (this->name, 0, "returning %d", ret); if (quorum_action) glusterd_do_quorum_action (); return ret; @@ -2522,7 +2593,8 @@ glusterd_op_sync_volume (dict_t *dict, char **op_errstr, if (!ret) { ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - gf_log ("", GF_LOG_ERROR, "Volume with name: %s " + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, "Volume with name: %s " "not exists", volname); goto out; } @@ -2551,7 +2623,7 @@ glusterd_op_sync_volume (dict_t *dict, char **op_errstr, ret = dict_set_int32 (rsp_dict, "count", vol_count); out: - gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug ("glusterd", 0, "Returning %d", ret); return ret; } @@ -2570,7 +2642,8 @@ glusterd_add_profile_volume_options (glusterd_volinfo_t *volinfo) ret = dict_set_str (volinfo->dict, latency_key, "on"); if (ret) { - gf_log ("glusterd", GF_LOG_ERROR, "failed to set the volume %s " + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "failed to set the volume %s " "option %s value %s", volinfo->volname, latency_key, "on"); goto out; @@ -2578,13 +2651,14 @@ glusterd_add_profile_volume_options (glusterd_volinfo_t *volinfo) ret = dict_set_str (volinfo->dict, fd_stats_key, "on"); if (ret) { - gf_log ("glusterd", GF_LOG_ERROR, "failed to set the volume %s " + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "failed to set the volume %s " "option %s value %s", volinfo->volname, fd_stats_key, "on"); goto out; } out: - gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug ("glusterd", 0, "Returning %d", ret); return ret; } @@ -2614,7 +2688,8 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "volume name get failed"); goto out; } @@ -2623,13 +2698,15 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, snprintf (msg, sizeof (msg), "Volume %s does not exists", volname); - gf_log ("", GF_LOG_ERROR, "%s", msg); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, "%s", msg); goto out; } ret = dict_get_int32 (dict, "op", &stats_op); if (ret) { - gf_log ("glusterd", GF_LOG_ERROR, "volume profile op get failed"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "volume profile op get failed"); goto out; } @@ -2651,7 +2728,8 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, break; default: GF_ASSERT (0); - gf_log ("glusterd", GF_LOG_ERROR, "Invalid profile op: %d", + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, "Invalid profile op: %d", stats_op); ret = -1; goto out; @@ -2660,8 +2738,10 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, ret = glusterd_create_volfiles_and_notify_services (volinfo); if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to create volfile for" - " 'volume set'"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOLFILE_CREATE_FAIL, + "Unable to create volfile for" + " 'volume set'"); ret = -1; goto out; } @@ -2677,7 +2757,7 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr, ret = 0; out: - gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug ("glusterd", 0, "Returning %d", ret); return ret; } @@ -2703,7 +2783,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, ret = dict_get_int32 (volinfo->rebal.dict, "count", &count); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Failed to get brick count"); goto out; } @@ -2711,7 +2792,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, snprintf (dict_key, sizeof (dict_key), "%s.count", prefix); ret = dict_set_int32 (dict, dict_key, count); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Failed to set brick count in dict"); goto out; } @@ -2722,7 +2804,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, ret = dict_get_str (volinfo->rebal.dict, brick_key, &brick); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get %s", brick_key); goto out; } @@ -2732,7 +2815,8 @@ _add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, brick_key); ret = dict_set_str (dict, dict_key, brick); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Failed to add brick to dict"); goto out; } @@ -2767,7 +2851,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) snprintf (key, sizeof (key), "task%d", index); ret = _add_remove_bricks_to_dict (dict, volinfo, key); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_ADD_REMOVE_BRICK_FAIL, "Failed to add remove bricks to dict"); goto out; } @@ -2778,7 +2863,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) default: ret = -1; - gf_log (this->name, GF_LOG_ERROR, "%s operation doesn't have a" + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_NO_TASK_ID, "%s operation doesn't have a" " task_id", gd_op_list[op]); goto out; } @@ -2786,7 +2872,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) snprintf (key, sizeof (key), "task%d.type", index); ret = dict_set_str (dict, key, (char *)gd_op_list[op]); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Error setting task type in dict"); goto out; } @@ -2798,7 +2885,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) goto out; ret = dict_set_dynstr (dict, key, uuid_str); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Error setting task id in dict"); goto out; } @@ -2808,7 +2896,8 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index) snprintf (key, sizeof (key), "task%d.status", index); ret = dict_set_int32 (dict, key, status); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Error setting task status in dict"); goto out; } @@ -2833,7 +2922,8 @@ glusterd_aggregate_task_status (dict_t *rsp_dict, glusterd_volinfo_t *volinfo) ret = _add_task_to_dict (rsp_dict, volinfo, volinfo->rebal.op, tasks); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Failed to add task details to dict"); goto out; } @@ -2842,7 +2932,8 @@ glusterd_aggregate_task_status (dict_t *rsp_dict, glusterd_volinfo_t *volinfo) ret = dict_set_int32 (rsp_dict, "tasks", tasks); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Error setting tasks count in dict"); goto out; } @@ -2893,7 +2984,8 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, if ((cmd & GF_CLI_STATUS_ALL)) { ret = glusterd_get_all_volnames (rsp_dict); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOLNAMES_GET_FAIL, "failed to get all volume " "names for status"); } @@ -2912,7 +3004,8 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Volume with name: %s " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, "Volume with name: %s " "does not exist", volname); goto out; } @@ -3104,19 +3197,22 @@ glusterd_op_status_volume (dict_t *dict, char **op_errstr, ret = dict_set_int32 (rsp_dict, "brick-index-max", brick_index); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Error setting brick-index-max to dict"); goto out; } ret = dict_set_int32 (rsp_dict, "other-count", other_count); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Error setting other-count to dict"); goto out; } ret = dict_set_int32 (rsp_dict, "count", node_count); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Error setting node count to dict"); goto out; } @@ -3134,7 +3230,7 @@ glusterd_op_status_volume (dict_t *dict, 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; } @@ -3144,7 +3240,7 @@ glusterd_op_ac_none (glusterd_op_sm_event_t *event, void *ctx) { int ret = 0; - gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); + gf_msg_debug (THIS->name, 0, "Returning with %d", ret); return ret; } @@ -3200,7 +3296,8 @@ glusterd_op_ac_send_lock (glusterd_op_sm_event_t *event, void *ctx) ret = proc->fn (NULL, this, peerinfo); if (ret) { rcu_read_unlock (); - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_LOCK_REQ_SEND_FAIL, "Failed to send lock request " "for operation 'Volume %s' to " "peer %s", @@ -3223,7 +3320,8 @@ glusterd_op_ac_send_lock (glusterd_op_sm_event_t *event, void *ctx) peerinfo); if (ret) { rcu_read_unlock (); - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "failed to set peerinfo"); dict_unref (dict); goto out; @@ -3232,7 +3330,8 @@ glusterd_op_ac_send_lock (glusterd_op_sm_event_t *event, void *ctx) ret = proc->fn (NULL, this, dict); if (ret) { rcu_read_unlock (); - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_MGMTV3_LOCK_REQ_SEND_FAIL, "Failed to send mgmt_v3 lock " "request for operation " "'Volume %s' to peer %s", @@ -3257,7 +3356,7 @@ out: if (ret) ret = glusterd_op_sm_locking_failed (&event->txn_id); - gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); + gf_msg_debug (this->name, 0, "Returning with %d", ret); return ret; } @@ -3360,7 +3459,7 @@ glusterd_op_ac_send_unlock (glusterd_op_sm_event_t *event, void *ctx) if (!opinfo.pending_count) ret = glusterd_op_sm_inject_all_acc (&event->txn_id); - gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); + gf_msg_debug (this->name, 0, "Returning with %d", ret); return ret; } @@ -3376,7 +3475,7 @@ glusterd_op_ac_ack_drain (glusterd_op_sm_event_t *event, void *ctx) ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACK, &event->txn_id, NULL); - gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); + gf_msg_debug (THIS->name, 0, "Returning with %d", ret); return ret; } @@ -3416,13 +3515,15 @@ glusterd_op_ac_lock (glusterd_op_sm_event_t *event, void *ctx) } else { ret = dict_get_str (lock_ctx->dict, "volname", &volname); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to acquire volname"); else { ret = glusterd_mgmt_v3_lock (volname, lock_ctx->uuid, &op_errno, "vol"); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_MGMTV3_LOCK_GET_FAIL, "Unable to acquire lock for %s", volname); goto out; @@ -3444,7 +3545,7 @@ out: dict_unref (lock_ctx->dict); } - gf_log (THIS->name, GF_LOG_DEBUG, "Lock Returned %d", ret); + gf_msg_debug (THIS->name, 0, "Lock Returned %d", ret); return ret; } @@ -3476,13 +3577,15 @@ glusterd_op_ac_unlock (glusterd_op_sm_event_t *event, void *ctx) } else { ret = dict_get_str (lock_ctx->dict, "volname", &volname); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to acquire volname"); else { ret = glusterd_mgmt_v3_unlock (volname, lock_ctx->uuid, "vol"); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_MGMTV3_UNLOCK_FAIL, "Unable to release lock for %s", volname); goto out; @@ -3505,7 +3608,7 @@ out: dict_unref (lock_ctx->dict); } - gf_log (this->name, GF_LOG_DEBUG, "Unlock Returned %d", ret); + gf_msg_debug (this->name, 0, "Unlock Returned %d", ret); if (priv->pending_quorum_action) glusterd_do_quorum_action (); @@ -3525,7 +3628,7 @@ glusterd_op_ac_local_unlock (glusterd_op_sm_event_t *event, void *ctx) ret = glusterd_unlock (*originator); - gf_log (THIS->name, GF_LOG_DEBUG, "Unlock Returned %d", ret); + gf_msg_debug (THIS->name, 0, "Unlock Returned %d", ret); return ret; } @@ -3546,7 +3649,7 @@ glusterd_op_ac_rcvd_lock_acc (glusterd_op_sm_event_t *event, void *ctx) ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACC, &event->txn_id, NULL); - gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (THIS->name, 0, "Returning %d", ret); out: return ret; @@ -3648,7 +3751,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) op = glusterd_op_get_op (); ctx = (void*)glusterd_op_get_ctx (); if (!ctx) { - gf_log (this->name, GF_LOG_ERROR, "Null Context for " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_NO_OPTIONS_GIVEN, "Null Context for " "op %d", op); ret = -1; goto out; @@ -3658,7 +3762,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) #define GD_SYNC_OPCODE_KEY "sync-mgmt-operation" ret = dict_get_int32 (op_ctx, GD_SYNC_OPCODE_KEY, (int32_t*)&op); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to get volume" + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Failed to get volume" " operation"); goto out; } @@ -3674,7 +3779,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) ret = dict_set_int32 (dict, "port", glusterfs_port); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Failed to set port in " "dictionary"); goto out; @@ -3704,7 +3810,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) { ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, 0, + GD_MSG_DICT_GET_FAILED, "volname is not present in " "operation ctx"); goto out; @@ -3727,7 +3834,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) dict_t *dict = ctx; ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, 0, + GD_MSG_DICT_GET_FAILED, "volname is not present in " "operation ctx"); goto out; @@ -3752,7 +3860,8 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) ret = dict_get_uint32 (dict, "cmd", &status_cmd); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Status command not present " "in op ctx"); goto out; @@ -3865,14 +3974,18 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx) rsp_dict = dict_new(); if (!rsp_dict) { - gf_log (this->name, GF_LOG_ERROR, "Failed to create rsp_dict"); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + GD_MSG_DICT_CREATE_FAIL, + "Failed to create rsp_dict"); ret = -1; goto out; } ret = glusterd_op_build_payload (&dict, &op_errstr, NULL); if (ret) { - gf_log (this->name, GF_LOG_ERROR, LOGSTR_BUILD_PAYLOAD, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL, + LOGSTR_BUILD_PAYLOAD, gd_op_list[op]); if (op_errstr == NULL) gf_asprintf (&op_errstr, OPERRSTR_BUILD_PAYLOAD); @@ -3891,7 +4004,8 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx) ret = glusterd_op_stage_validate (op, dict, &op_errstr, rsp_dict); if (ret) { - gf_log (this->name, GF_LOG_ERROR, LOGSTR_STAGE_FAIL, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VALIDATE_FAILED, LOGSTR_STAGE_FAIL, gd_op_list[op], "localhost", (op_errstr) ? ":" : " ", (op_errstr) ? op_errstr : " "); if (op_errstr == NULL) @@ -3924,14 +4038,16 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx) ret = dict_set_static_ptr (dict, "peerinfo", peerinfo); if (ret) { rcu_read_unlock (); - gf_log (this->name, GF_LOG_ERROR, "failed to " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "failed to " "set peerinfo"); goto out; } ret = proc->fn (NULL, this, dict); if (ret) { - gf_log (this->name, GF_LOG_WARNING, "Failed to " + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_STAGE_REQ_SEND_FAIL, "Failed to " "send stage request for operation " "'Volume %s' to peer %s", gd_op_list[op], peerinfo->hostname); @@ -3955,14 +4071,14 @@ out: opinfo.op_ret = ret; } - gf_log (this->name, GF_LOG_DEBUG, "Sent stage op request for " + gf_msg_debug (this->name, 0, "Sent stage op request for " "'Volume %s' to %d peers", gd_op_list[op], opinfo.pending_count); if (!opinfo.pending_count) ret = glusterd_op_sm_inject_all_acc (&event->txn_id); - gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); + gf_msg_debug (this->name, 0, "Returning with %d", ret); return ret; @@ -3996,7 +4112,7 @@ glusterd_op_volume_dict_uuid_to_hostname (dict_t *dict, const char *key_fmt, if (ret) continue; - gf_log (this->name, GF_LOG_DEBUG, "Got uuid %s", + gf_msg_debug (this->name, 0, "Got uuid %s", uuid_str); ret = gf_uuid_parse (uuid_str, uuid); @@ -4008,11 +4124,12 @@ glusterd_op_volume_dict_uuid_to_hostname (dict_t *dict, const char *key_fmt, hostname = glusterd_uuid_to_hostname (uuid); if (hostname) { - gf_log (this->name, GF_LOG_DEBUG, "%s -> %s", + gf_msg_debug (this->name, 0, "%s -> %s", uuid_str, hostname); ret = dict_set_dynstr (dict, key, hostname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Error setting hostname %s to dict", hostname); GF_FREE (hostname); @@ -4022,7 +4139,7 @@ glusterd_op_volume_dict_uuid_to_hostname (dict_t *dict, const char *key_fmt, } out: - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -4056,7 +4173,8 @@ reassign_defrag_status (dict_t *dict, char *key, gf_defrag_status_t *status) ret = dict_set_int32(dict, key, *status); if (ret) - gf_log (THIS->name, GF_LOG_WARNING, + gf_msg (THIS->name, GF_LOG_WARNING, 0, + GD_MSG_DICT_SET_FAILED, "failed to reset defrag %s in dict", key); return ret; @@ -4078,13 +4196,15 @@ glusterd_op_check_peer_defrag_status (dict_t *dict, int count) ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (THIS->name, GF_LOG_WARNING, "Unable to get volume name"); + gf_msg (THIS->name, GF_LOG_WARNING, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); goto out; } ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - gf_log (THIS->name, GF_LOG_WARNING, FMTSTR_CHECK_VOL_EXISTS, + gf_msg (THIS->name, GF_LOG_WARNING, 0, + GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, volname); goto out; } @@ -4101,7 +4221,8 @@ glusterd_op_check_peer_defrag_status (dict_t *dict, int count) snprintf (key, 256, "status-%d", i); ret = dict_get_int32 (dict, key, (int32_t *)&status); if (ret) { - gf_log (THIS->name, GF_LOG_WARNING, + gf_msg (THIS->name, GF_LOG_WARNING, 0, + GD_MSG_DICT_GET_FAILED, "failed to get defrag %s", key); goto out; } @@ -4214,7 +4335,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) op_ctx = glusterd_op_get_ctx(); if (!op_ctx) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, 0, + GD_MSG_OPCTX_NULL, "Operation context is not present."); goto out; } @@ -4223,13 +4345,13 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) case GD_OP_STATUS_VOLUME: ret = dict_get_uint32 (op_ctx, "cmd", &cmd); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Failed to get status cmd"); goto out; } if (!glusterd_is_volume_status_modify_op_ctx (cmd)) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "op_ctx modification not required for status " "operation being performed"); goto out; @@ -4238,14 +4360,14 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) ret = dict_get_int32 (op_ctx, "brick-index-max", &brick_index_max); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Failed to get brick-index-max"); goto out; } ret = dict_get_int32 (op_ctx, "other-count", &other_count); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Failed to get other-count"); goto out; } @@ -4287,7 +4409,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) "brick%d.peerid", i); uuid = gf_strdup (uuid_str); if (!uuid) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "unable to create dup of" " uuid_str"); continue; @@ -4305,7 +4427,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) "brick%d.path", 0, count); if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_CONVERSION_FAILED, "Failed uuid to hostname conversion"); break; @@ -4317,7 +4440,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) ret = dict_get_int32 (op_ctx, "count", &count); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Failed to get brick count"); goto out; } @@ -4326,7 +4449,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) "%d-brick", 1, (count + 1)); if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_CONVERSION_FAILED, "Failed uuid to hostname conversion"); break; @@ -4337,7 +4461,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) case GD_OP_DEFRAG_BRICK_VOLUME: ret = dict_get_int32 (op_ctx, "count", &count); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Failed to get count"); goto out; } @@ -4360,7 +4484,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) "node-name-%d", i); uuid = gf_strdup (uuid_str); if (!uuid) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "unable to create dup of" " uuid_str"); continue; @@ -4378,18 +4502,20 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) "node-name-%d", 1, (count + 1)); if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_CONVERSION_FAILED, "Failed uuid to hostname conversion"); ret = glusterd_op_check_peer_defrag_status (op_ctx, count); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DEFRAG_STATUS_UPDATE_FAIL, "Failed to reset defrag status for fix-layout"); break; default: ret = 0; - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "op_ctx modification not required"); break; @@ -4397,7 +4523,8 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) out: if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_OPCTX_UPDATE_FAIL, "op_ctx modification failed"); return; } @@ -4477,7 +4604,9 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx) ret = glusterd_op_build_payload (&dict, &op_errstr, NULL); if (ret) { - gf_log (this->name, GF_LOG_ERROR, LOGSTR_BUILD_PAYLOAD, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL, + LOGSTR_BUILD_PAYLOAD, gd_op_list[op]); if (op_errstr == NULL) gf_asprintf (&op_errstr, OPERRSTR_BUILD_PAYLOAD); @@ -4487,7 +4616,8 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx) ret = glusterd_op_commit_perform (op, dict, &op_errstr, NULL); //rsp_dict invalid for source if (ret) { - gf_log (this->name, GF_LOG_ERROR, LOGSTR_COMMIT_FAIL, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_COMMIT_OP_FAIL, LOGSTR_COMMIT_FAIL, gd_op_list[op], "localhost", (op_errstr) ? ":" : " ", (op_errstr) ? op_errstr : " "); if (op_errstr == NULL) @@ -4517,13 +4647,16 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx) ret = dict_set_static_ptr (dict, "peerinfo", peerinfo); if (ret) { rcu_read_unlock (); - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "failed to set peerinfo"); goto out; } ret = proc->fn (NULL, this, dict); if (ret) { - gf_log (this->name, GF_LOG_WARNING, "Failed to " + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_COMMIT_REQ_SEND_FAIL, + "Failed to " "send commit request for operation " "'Volume %s' to peer %s", gd_op_list[op], peerinfo->hostname); @@ -4535,7 +4668,7 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx) rcu_read_unlock (); opinfo.pending_count = pending_count; - gf_log (this->name, GF_LOG_DEBUG, "Sent commit op req for 'Volume %s' " + gf_msg_debug (this->name, 0, "Sent commit op req for 'Volume %s' " "to %d peers", gd_op_list[op], opinfo.pending_count); out: if (dict) @@ -4557,7 +4690,7 @@ out: } err: - gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); + gf_msg_debug (this->name, 0, "Returning with %d", ret); return ret; @@ -4580,7 +4713,7 @@ glusterd_op_ac_rcvd_stage_op_acc (glusterd_op_sm_event_t *event, void *ctx) &event->txn_id, NULL); out: - gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (THIS->name, 0, "Returning %d", ret); return ret; } @@ -4602,7 +4735,7 @@ glusterd_op_ac_stage_op_failed (glusterd_op_sm_event_t *event, void *ctx) &event->txn_id, NULL); out: - gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (THIS->name, 0, "Returning %d", ret); return ret; } @@ -4624,7 +4757,7 @@ glusterd_op_ac_commit_op_failed (glusterd_op_sm_event_t *event, void *ctx) &event->txn_id, NULL); out: - gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (THIS->name, 0, "Returning %d", ret); return ret; } @@ -4646,7 +4779,8 @@ glusterd_op_ac_brick_op_failed (glusterd_op_sm_event_t *event, void *ctx) ret = glusterd_remove_pending_entry (&opinfo.pending_bricks, ev_ctx->pending_node->node); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "unknown response received "); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_UNKNOWN_RESPONSE, "unknown response received "); ret = -1; free_errstr = _gf_true; goto out; @@ -4673,7 +4807,7 @@ out: if (free_errstr && ev_ctx->op_errstr) GF_FREE (ev_ctx->op_errstr); GF_FREE (ctx); - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -4700,7 +4834,8 @@ glusterd_op_ac_rcvd_commit_op_acc (glusterd_op_sm_event_t *event, void *ctx) if (op == GD_OP_REPLACE_BRICK) { ret = glusterd_op_sm_inject_all_acc (&event->txn_id); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Couldn't start " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_RBOP_START_FAIL, "Couldn't start " "replace-brick operation."); goto out; } @@ -4744,7 +4879,7 @@ glusterd_op_ac_rcvd_unlock_acc (glusterd_op_sm_event_t *event, void *ctx) ret = glusterd_op_sm_inject_event (GD_OP_EVENT_ALL_ACC, &event->txn_id, NULL); - gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (THIS->name, 0, "Returning %d", ret); out: return ret; @@ -4814,14 +4949,16 @@ glusterd_op_txn_complete (uuid_t *txn_id) ret = glusterd_unlock (MY_UUID); /* unlock cant/shouldnt fail here!! */ if (ret) - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, 0, + GD_MSG_GLUSTERD_UNLOCK_FAIL, "Unable to clear local lock, ret: %d", ret); else - gf_log (this->name, GF_LOG_DEBUG, "Cleared local lock"); + gf_msg_debug (this->name, 0, "Cleared local lock"); } else { ret = dict_get_str (ctx, "volname", &volname); if (ret) - gf_log ("", GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + GD_MSG_DICT_GET_FAILED, "No Volume name present. " "Locks have not been held."); @@ -4829,7 +4966,8 @@ glusterd_op_txn_complete (uuid_t *txn_id) ret = glusterd_mgmt_v3_unlock (volname, MY_UUID, "vol"); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_MGMTV3_UNLOCK_FAIL, "Unable to release lock for %s", volname); } @@ -4839,7 +4977,9 @@ glusterd_op_txn_complete (uuid_t *txn_id) op_errno, req, ctx, op_errstr); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Responding to cli failed, " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_NO_CLI_RESP, + "Responding to cli failed, " "ret: %d", ret); //Ignore this error, else state machine blocks ret = 0; @@ -4855,10 +4995,11 @@ glusterd_op_txn_complete (uuid_t *txn_id) /* Clearing the transaction opinfo */ ret = glusterd_clear_txn_opinfo (txn_id); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_TRANS_OPINFO_CLEAR_FAIL, "Unable to clear transaction's opinfo"); - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -4871,7 +5012,7 @@ glusterd_op_ac_unlocked_all (glusterd_op_sm_event_t *event, void *ctx) ret = glusterd_op_txn_complete (&event->txn_id); - gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (THIS->name, 0, "Returning %d", ret); return ret; } @@ -4898,7 +5039,8 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx) rsp_dict = dict_new (); if (!rsp_dict) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + GD_MSG_DICT_CREATE_FAIL, "Failed to get new dictionary"); return -1; } @@ -4907,7 +5049,8 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx) rsp_dict); if (status) { - gf_log (this->name, GF_LOG_ERROR, "Stage failed on operation" + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VALIDATE_FAILED, "Stage failed on operation" " 'Volume %s', Status : %d", gd_op_list[req_ctx->op], status); } @@ -4924,7 +5067,8 @@ glusterd_op_ac_stage_op (glusterd_op_sm_event_t *event, void *ctx) ret = dict_set_bin (rsp_dict, "transaction_id", txn_id, sizeof(*txn_id)); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Failed to set transaction id."); goto out; } @@ -4936,7 +5080,7 @@ out: if (op_errstr && (strcmp (op_errstr, ""))) GF_FREE (op_errstr); - gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); + gf_msg_debug (this->name, 0, "Returning with %d", ret); if (rsp_dict) dict_unref (rsp_dict); @@ -5020,7 +5164,8 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx) } if (status) - gf_log (this->name, GF_LOG_ERROR, "Commit of operation " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_COMMIT_OP_FAIL, "Commit of operation " "'Volume %s' failed: %d", gd_op_list[req_ctx->op], status); @@ -5036,7 +5181,8 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx) ret = dict_set_bin (rsp_dict, "transaction_id", txn_id, sizeof(*txn_id)); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Failed to set transaction id."); goto out; } @@ -5051,7 +5197,7 @@ out: if (rsp_dict) dict_unref (rsp_dict); - gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); + gf_msg_debug (this->name, 0, "Returning with %d", ret); return ret; } @@ -5078,7 +5224,7 @@ glusterd_op_ac_send_commit_failed (glusterd_op_sm_event_t *event, void *ctx) opinfo.op_errstr = NULL; } - gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); + gf_msg_debug (THIS->name, 0, "Returning with %d", ret); return ret; } @@ -5221,11 +5367,12 @@ glusterd_op_stage_validate (glusterd_op_t op, dict_t *dict, char **op_errstr, break; default: - gf_log (this->name, GF_LOG_ERROR, "Unknown op %s", + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, "Unknown op %s", gd_op_list[op]); } - gf_log (this->name, GF_LOG_DEBUG, "OP = %d. Returning %d", op, ret); + gf_msg_debug (this->name, 0, "OP = %d. Returning %d", op, ret); return ret; } @@ -5343,7 +5490,8 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr, break; default: - gf_log (this->name, GF_LOG_ERROR, "Unknown op %s", + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, "Unknown op %s", gd_op_list[op]); break; } @@ -5351,7 +5499,7 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr, if (ret == 0) glusterd_op_commit_hook (op, dict, GD_COMMIT_HOOK_POST); - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -5373,7 +5521,8 @@ glusterd_bricks_select_stop_volume (dict_t *dict, char **op_errstr, ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, FMTSTR_CHECK_VOL_EXISTS, + gf_msg (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, FMTSTR_CHECK_VOL_EXISTS, volname); gf_asprintf (op_errstr, FMTSTR_CHECK_VOL_EXISTS, volname); goto out; @@ -5420,26 +5569,29 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr, ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to get volume name"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get volume name"); goto out; } ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to allocate memory"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, "Unable to allocate memory"); goto out; } ret = dict_get_int32 (dict, "count", &count); if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to get count"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get count"); goto out; } ret = dict_get_int32 (dict, "command", &command); if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to get command"); + gf_log ("glusterd", GF_LOG_ERROR, "Unable to get command"); goto out; } @@ -5448,7 +5600,8 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr, ret = dict_get_int32 (dict, "force", &force); if (ret) { - gf_log (THIS->name, GF_LOG_INFO, "force flag is not set"); + gf_msg (THIS->name, GF_LOG_INFO, 0, + GD_MSG_DICT_GET_FAILED, "force flag is not set"); ret = 0; goto out; } @@ -5458,7 +5611,8 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr, ret = dict_get_str (dict, key, &brick); if (ret) { - gf_log ("glusterd", GF_LOG_ERROR, "Unable to get brick"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get brick"); goto out; } @@ -5514,7 +5668,8 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "volume name get failed"); goto out; } @@ -5524,13 +5679,15 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, volname); *op_errstr = gf_strdup (msg); - gf_log ("", GF_LOG_ERROR, "%s", msg); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, "%s", msg); goto out; } ret = dict_get_int32 (dict, "op", &stats_op); if (ret) { - gf_log ("glusterd", GF_LOG_ERROR, "volume profile op get failed"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "volume profile op get failed"); goto out; } @@ -5544,7 +5701,9 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, if (ret) { if (!priv->nfs_svc.online) { ret = -1; - gf_log (this->name, GF_LOG_ERROR, "NFS server" + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_NFS_SERVER_NOT_RUNNING, + "NFS server" " is not running"); goto out; } @@ -5587,7 +5746,9 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, if (ret) { if (!priv->nfs_svc.online) { ret = -1; - gf_log (this->name, GF_LOG_ERROR, "NFS server" + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_NFS_SERVER_NOT_RUNNING, + "NFS server" " is not running"); goto out; } @@ -5652,7 +5813,8 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, default: GF_ASSERT (0); - gf_log ("glusterd", GF_LOG_ERROR, "Invalid profile op: %d", + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, "Invalid profile op: %d", stats_op); ret = -1; goto out; @@ -5661,7 +5823,7 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr, out: - gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug ("glusterd", 0, "Returning %d", ret); return ret; } @@ -5884,7 +6046,8 @@ glusterd_bricks_select_snap (dict_t *dict, char **op_errstr, ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to get" + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get" " volname"); goto out; } @@ -5914,7 +6077,7 @@ glusterd_bricks_select_snap (dict_t *dict, char **op_errstr, ret = 0; out: - gf_log (THIS->name, GF_LOG_DEBUG, "Returning ret %d", ret); + gf_msg_debug (THIS->name, 0, "Returning ret %d", ret); return ret; } @@ -5938,7 +6101,9 @@ fill_shd_status_for_local_bricks (dict_t *dict, glusterd_volinfo_t *volinfo, cmd_replica_index = get_replica_index_for_per_replica_cmd (volinfo, req_dict); if (cmd_replica_index == -1) { - gf_log (THIS->name, GF_LOG_ERROR, "Could not find the " + gf_msg (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_REPLICA_INDEX_GET_FAIL, + "Could not find the " "replica index for per replica type command"); ret = -1; goto out; @@ -5966,14 +6131,16 @@ fill_shd_status_for_local_bricks (dict_t *dict, glusterd_volinfo_t *volinfo, uuid_utoa(MY_UUID)); ret = dict_set_dynstr (dict, key, gf_strdup(value)); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to" + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Unable to" "set the dictionary for shd status msg"); goto out; } snprintf (key, sizeof (key), "%d-shd-status",index); ret = dict_set_str (dict, key, "off"); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to" + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_SET_FAILED, "Unable to" " set dictionary for shd status msg"); goto out; } @@ -6008,7 +6175,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "volume name get failed"); goto out; } @@ -6018,13 +6186,15 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, volname); *op_errstr = gf_strdup (msg); - gf_log ("", GF_LOG_ERROR, "%s", msg); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, "%s", msg); goto out; } ret = dict_get_int32 (dict, "heal-op", (int32_t*)&heal_op); if (ret || (heal_op == GF_SHD_OP_INVALID)) { - gf_log ("glusterd", GF_LOG_ERROR, "heal op invalid"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "heal op invalid"); goto out; } @@ -6033,7 +6203,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, case GF_SHD_OP_STATISTICS_HEAL_COUNT: if (!priv->shd_svc.online) { if (!rsp_dict) { - gf_log (this->name, GF_LOG_ERROR, "Received " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_OPCTX_NULL, "Received " "empty ctx."); goto out; } @@ -6043,7 +6214,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, ALL_HEAL_XL, dict); if (ret) - gf_log (this->name, GF_LOG_ERROR, "Unable to " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_SHD_STATUS_SET_FAIL, "Unable to " "fill the shd status for the local " "bricks"); goto out; @@ -6053,7 +6225,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, case GF_SHD_OP_STATISTICS_HEAL_COUNT_PER_REPLICA: if (!priv->shd_svc.online) { if (!rsp_dict) { - gf_log (this->name, GF_LOG_ERROR, "Received " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_OPCTX_NULL, "Received " "empty ctx."); goto out; } @@ -6062,7 +6235,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, PER_HEAL_XL, dict); if (ret) - gf_log (this->name, GF_LOG_ERROR, "Unable to " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_SHD_STATUS_SET_FAIL, "Unable to " "fill the shd status for the local" " bricks."); goto out; @@ -6096,7 +6270,8 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, if (!hxlator_count) goto out; if (hxlator_count == -1) { - gf_log (this->name, GF_LOG_ERROR, "Could not determine the" + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_XLATOR_COUNT_GET_FAIL, "Could not determine the" "translator count"); ret = -1; goto out; @@ -6119,7 +6294,7 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr, } out: - gf_log (THIS->name, GF_LOG_DEBUG, "Returning ret %d", ret); + gf_msg_debug (THIS->name, 0, "Returning ret %d", ret); return ret; } @@ -6140,7 +6315,8 @@ glusterd_bricks_select_rebalance_volume (dict_t *dict, char **op_errstr, ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log ("glusterd", GF_LOG_ERROR, "volume name get failed"); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "volume name get failed"); goto out; } @@ -6150,7 +6326,8 @@ glusterd_bricks_select_rebalance_volume (dict_t *dict, char **op_errstr, volname); *op_errstr = gf_strdup (msg); - gf_log ("", GF_LOG_ERROR, "%s", msg); + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, "%s", msg); goto out; } pending_node = GF_CALLOC (1, sizeof (*pending_node), @@ -6194,7 +6371,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, ret = dict_get_int32 (dict, "cmd", &cmd); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to get status type"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get status type"); goto out; } @@ -6219,7 +6397,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, } ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to get volname"); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get volname"); goto out; } ret = glusterd_volinfo_find (volname, &volinfo); @@ -6230,7 +6409,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, if ( (cmd & GF_CLI_STATUS_BRICK) != 0) { ret = dict_get_str (dict, "brick", &brickname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get brick"); goto out; } @@ -6259,7 +6439,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, } else if ((cmd & GF_CLI_STATUS_NFS) != 0) { if (!priv->nfs_svc.online) { ret = -1; - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_NFS_SERVER_NOT_RUNNING, "NFS server is not running"); goto out; } @@ -6278,7 +6459,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, } else if ((cmd & GF_CLI_STATUS_SHD) != 0) { if (!priv->shd_svc.online) { ret = -1; - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_SELF_HEALD_DISABLED, "Self-heal daemon is not running"); goto out; } @@ -6296,7 +6478,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, ret = 0; } else if ((cmd & GF_CLI_STATUS_QUOTAD) != 0) { if (!priv->quotad_svc.online) { - gf_log (this->name, GF_LOG_ERROR, "Quotad is not " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_QUOTAD_NOT_RUNNING, "Quotad is not " "running"); ret = -1; goto out; @@ -6353,7 +6536,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, ret = 0; } else if ((cmd & GF_CLI_STATUS_SNAPD) != 0) { if (!volinfo->snapd.svc.online) { - gf_log (this->name, GF_LOG_ERROR, "snapd is not " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_SNAPD_NOT_RUNNING, "snapd is not " "running"); ret = -1; goto out; @@ -6361,7 +6545,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, pending_node = GF_CALLOC (1, sizeof (*pending_node), gf_gld_mt_pending_node_t); if (!pending_node) { - gf_log (this->name, GF_LOG_ERROR, "failed to allocate " + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + GD_MSG_NO_MEMORY, "failed to allocate " "memory for pending node"); ret = -1; goto out; @@ -6385,7 +6570,8 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr, gf_gld_mt_pending_node_t); if (!pending_node) { ret = -1; - gf_log (THIS->name ,GF_LOG_ERROR, + gf_msg (THIS->name, GF_LOG_ERROR, ENOMEM, + GD_MSG_NO_MEMORY, "Unable to allocate memory"); goto out; } @@ -6417,13 +6603,15 @@ glusterd_bricks_select_barrier (dict_t *dict, struct cds_list_head *selected) 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"); goto out; } ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, "Failed to find volume %s", + gf_msg (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_FOUND, "Failed to find volume %s", volname); goto out; } @@ -6446,7 +6634,7 @@ glusterd_bricks_select_barrier (dict_t *dict, struct cds_list_head *selected) } out: - gf_log(THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (THIS->name, 0, "Returning %d", ret); return ret; } @@ -6475,7 +6663,9 @@ glusterd_op_ac_send_brick_op (glusterd_op_sm_event_t *event, void *ctx) ret = glusterd_op_build_payload (&req_ctx->dict, &op_errstr, NULL); if (ret) { - gf_log (this->name, GF_LOG_ERROR, LOGSTR_BUILD_PAYLOAD, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL, + LOGSTR_BUILD_PAYLOAD, gd_op_list[op]); if (op_errstr == NULL) gf_asprintf (&op_errstr, @@ -6499,7 +6689,7 @@ glusterd_op_ac_send_brick_op (glusterd_op_sm_event_t *event, void *ctx) } out: - gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret); + gf_msg_debug (this->name, 0, "Returning with %d", ret); return ret; } @@ -6535,7 +6725,8 @@ glusterd_op_ac_rcvd_brick_op_acc (glusterd_op_sm_event_t *event, void *ctx) ret = glusterd_remove_pending_entry (&opinfo.pending_bricks, pending_entry); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "unknown response received "); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_UNKNOWN_RESPONSE, "unknown response received "); ret = -1; goto out; } @@ -6556,7 +6747,7 @@ out: if (ev_ctx->rsp_dict) dict_unref (ev_ctx->rsp_dict); GF_FREE (ev_ctx); - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (this->name, 0, "Returning %d", ret); return ret; } @@ -6613,7 +6804,7 @@ glusterd_op_bricks_select (glusterd_op_t op, dict_t *dict, char **op_errstr, break; } - gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (THIS->name, 0, "Returning %d", ret); return ret; } @@ -6948,7 +7139,7 @@ glusterd_op_sm_inject_event (glusterd_op_sm_event_type_t event_type, if (txn_id) gf_uuid_copy (event->txn_id, *txn_id); - gf_log (THIS->name, GF_LOG_DEBUG, "Enqueue event: '%s'", + gf_msg_debug (THIS->name, 0, "Enqueue event: '%s'", glusterd_op_sm_event_name_get (event->event)); cds_list_add_tail (&event->list, &gd_op_sm_queue); @@ -7016,7 +7207,8 @@ glusterd_op_sm () ret = synclock_trylock (&gd_op_sm_lock); if (ret) { lock_err = errno; - gf_log (this->name, GF_LOG_ERROR, "lock failed due to %s", + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_LOCK_FAIL, "lock failed due to %s", strerror (lock_err)); goto lock_failed; } @@ -7028,17 +7220,18 @@ glusterd_op_sm () cds_list_del_init (&event->list); event_type = event->event; - gf_log (this->name, GF_LOG_DEBUG, "Dequeued event of " + gf_msg_debug (this->name, 0, "Dequeued event of " "type: '%s'", glusterd_op_sm_event_name_get(event_type)); - gf_log (this->name, GF_LOG_DEBUG, "transaction ID = %s", + gf_msg_debug (this->name, 0, "transaction ID = %s", uuid_utoa (event->txn_id)); ret = glusterd_get_txn_opinfo (&event->txn_id, &txn_op_info); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_TRANS_OPINFO_GET_FAIL, "Unable to get transaction's opinfo"); glusterd_destroy_op_event_ctx (event); GF_FREE (event); @@ -7056,7 +7249,8 @@ glusterd_op_sm () ret = handler (event, event->ctx); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_HANDLER_RETURNED, "handler returned: %d", ret); glusterd_destroy_op_event_ctx (event); GF_FREE (event); @@ -7067,7 +7261,8 @@ glusterd_op_sm () event_type); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_EVENT_STATE_TRANSITION_FAIL, "Unable to transition" "state from '%s' to '%s'", glusterd_op_sm_state_name_get(opinfo.state.state), @@ -7082,14 +7277,16 @@ glusterd_op_sm () /* Clearing the transaction opinfo */ ret = glusterd_clear_txn_opinfo(&event->txn_id); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_TRANS_OPINFO_CLEAR_FAIL, "Unable to clear " "transaction's opinfo"); } else { ret = glusterd_set_txn_opinfo (&event->txn_id, &opinfo); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_TRANS_OPINFO_SET_FAIL, "Unable to set " "transaction's opinfo"); } -- cgit