summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-volgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c349
1 files changed, 228 insertions, 121 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 75d19911333..0164cbe1de8 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -83,7 +83,9 @@ xlator_instantiate_va (const char *type, const char *format, va_list arg)
return xl;
error:
- gf_log ("", GF_LOG_ERROR, "creating xlator of type %s failed",
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_XLATOR_CREATE_FAIL,
+ "creating xlator of type %s failed",
type);
GF_FREE (volname);
if (xl)
@@ -114,7 +116,8 @@ volgen_xlator_link (xlator_t *pxl, xlator_t *cxl)
ret = glusterfs_xlator_link (pxl, cxl);
if (ret == -1) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY,
"Out of memory, cannot link xlators %s <- %s",
pxl->name, cxl->name);
}
@@ -131,7 +134,9 @@ volgen_graph_link (volgen_graph_t *graph, xlator_t *xl)
if (graph->graph.first)
ret = volgen_xlator_link (xl, graph->graph.first);
if (ret == -1) {
- gf_log ("", GF_LOG_ERROR, "failed to add graph entry %s",
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_GRAPH_ENTRY_ADD_FAIL,
+ "failed to add graph entry %s",
xl->name);
return -1;
@@ -206,7 +211,8 @@ xlator_set_option (xlator_t *xl, char *key, char *value)
dval = gf_strdup (value);
if (!dval) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, errno,
+ GD_MSG_NO_MEMORY,
"failed to set xlator opt: %s[%s] = %s",
xl->name, key, value);
@@ -577,7 +583,8 @@ volgen_dict_get (dict_t *dict, char *key, char **value)
ret = volgen_graph_set_options_generic (NULL, dict, &vme,
&optget_option_handler);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Out of memory");
+ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out of memory");
return -1;
}
@@ -638,7 +645,9 @@ glusterd_volinfo_get_boolean (glusterd_volinfo_t *volinfo, char *key)
if (val)
ret = gf_string2boolean (val, &enabled);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "value for %s option is not valid", key);
+ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY,
+ "value for %s option is not valid", key);
return -1;
}
@@ -745,7 +754,8 @@ glusterd_check_option_exists (char *key, char **completion)
if (completion) {
ret = option_complete (key, completion);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY,
"Out of memory");
return -1;
}
@@ -772,7 +782,8 @@ glusterd_check_option_exists (char *key, char **completion)
trie:
ret = volopt_trie (key, completion);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_ERROR_ENCOUNTERED,
"Some error occurred during keyword hinting");
}
@@ -789,7 +800,8 @@ glusterd_volopt_validate (glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
xlator_t *this = THIS;
if (!dict || !key || !value) {
- gf_log_callingfn (this->name, GF_LOG_WARNING, "Invalid "
+ gf_msg_callingfn (this->name, GF_LOG_WARNING, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Invalid "
"Arguments (dict=%p, key=%s, value=%s)", dict,
key, value);
return -1;
@@ -824,7 +836,8 @@ glusterd_get_trans_type_rb (gf_transport_type ttype)
gf_asprintf (&trans_type, "tcp");
break;
default:
- gf_log (THIS->name, GF_LOG_ERROR, "Unknown "
+ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Unknown "
"transport type");
}
@@ -844,7 +857,7 @@ _xl_link_children (xlator_t *parent, xlator_t *children, size_t child_count)
for (trav = children; --seek; trav = trav->next);
for (; child_count--; trav = trav->prev) {
ret = volgen_xlator_link (parent, trav);
- gf_log (THIS->name, GF_LOG_DEBUG, "%s:%s", parent->name,
+ gf_msg_debug (THIS->name, 0, "%s:%s", parent->name,
trav->name);
if (ret)
goto out;
@@ -923,8 +936,10 @@ volgen_apply_filters (char *orig_volfile)
goto free_fp;
}
if (runcmd(filterpath,orig_volfile,NULL)) {
- gf_log("",GF_LOG_ERROR,"failed to run filter %.*s",
- (int)sizeof(entry.d_name), entry.d_name);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_FILTER_RUN_FAILED,
+ "failed to run filter %.*s",
+ (int)sizeof(entry.d_name), entry.d_name);
}
free_fp:
GF_FREE(filterpath);
@@ -951,8 +966,8 @@ volgen_write_volfile (volgen_graph_t *graph, char *filename)
fd = creat (ftmp, S_IRUSR | S_IWUSR);
if (fd < 0) {
- gf_log (this->name, GF_LOG_ERROR, "%s",
- strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "file creation failed");
goto error;
}
@@ -966,8 +981,9 @@ volgen_write_volfile (volgen_graph_t *graph, char *filename)
goto error;
if (fclose (f) != 0) {
- gf_log (THIS->name, GF_LOG_ERROR, "fclose on the file %s "
- "failed (%s)", ftmp, strerror (errno));
+ gf_msg (THIS->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "fclose on the file %s "
+ "failed", ftmp);
/*
* Even though fclose has failed here, we have to set f to NULL.
* Otherwise when the code path goes to error, there again we
@@ -995,7 +1011,8 @@ volgen_write_volfile (volgen_graph_t *graph, char *filename)
if (f)
fclose (f);
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"failed to create volfile %s", filename);
return -1;
@@ -1093,7 +1110,8 @@ get_vol_nfs_transport_type (glusterd_volinfo_t *volinfo, char *tt)
{
if (volinfo->transport_type == GF_TRANSPORT_BOTH_TCP_RDMA) {
strcpy (tt, "tcp");
- gf_log ("glusterd", GF_LOG_INFO,
+ gf_msg ("glusterd", GF_LOG_INFO, 0,
+ GD_MSG_DEFAULT_OPT_INFO,
"The default transport type for tcp,rdma volume "
"is tcp if option is not defined by the user ");
} else
@@ -1200,7 +1218,9 @@ server_check_marker_off (volgen_graph_t *graph, struct volopt_map_entry *vme,
ret = glusterd_volinfo_get_boolean (volinfo, VKEY_MARKER_XTIME);
if (ret < 0) {
- gf_log ("", GF_LOG_WARNING, "failed to get the marker status");
+ gf_msg ("glusterd", GF_LOG_WARNING, 0,
+ GD_MSG_MARKER_STATUS_GET_FAIL,
+ "failed to get the marker status");
ret = -1;
goto out;
}
@@ -1210,7 +1230,9 @@ server_check_marker_off (volgen_graph_t *graph, struct volopt_map_entry *vme,
glusterd_check_geo_rep_configured (volinfo, &enabled);
if (enabled) {
- gf_log ("", GF_LOG_WARNING, GEOREP" sessions active"
+ gf_msg ("glusterd", GF_LOG_WARNING, 0,
+ GD_MSG_MARKER_DISABLE_FAIL,
+ GEOREP" sessions active"
"for the volume %s, cannot disable marker "
,volinfo->volname);
set_graph_errstr (graph,
@@ -1223,7 +1245,7 @@ server_check_marker_off (volgen_graph_t *graph, struct volopt_map_entry *vme,
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -1347,8 +1369,9 @@ volgen_graph_set_xl_options (volgen_graph_t *graph, dict_t *dict)
for (trav = first_of (graph); trav; trav = trav->next) {
if (fnmatch(xlator_match, trav->type, FNM_NOESCAPE) == 0) {
- gf_log ("glusterd", GF_LOG_DEBUG, "Setting log level for xlator: %s",
- trav->type);
+ gf_msg_debug ("glusterd", 0,
+ "Setting log level for xlator: %s",
+ trav->type);
ret = xlator_set_option (trav, "log-level", loglevel);
if (ret)
break;
@@ -1887,7 +1910,8 @@ brick_graph_add_ro (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (dict_get_str_boolean (set_dict, "features.read-only", 0) &&
dict_get_str_boolean (set_dict, "features.worm", 0)) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_msg (THIS->name, GF_LOG_ERROR, errno,
+ GD_MSG_DICT_GET_FAILED,
"read-only and worm cannot be set together");
ret = -1;
goto out;
@@ -1918,7 +1942,8 @@ brick_graph_add_worm (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (dict_get_str_boolean (set_dict, "features.read-only", 0) &&
dict_get_str_boolean (set_dict, "features.worm", 0)) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_INCOMPATIBLE_VALUE,
"read-only and worm cannot be set together");
ret = -1;
goto out;
@@ -1996,7 +2021,8 @@ brick_graph_add_upcall (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
xl = volgen_graph_add (graph, "features/upcall", volinfo->volname);
if (!xl) {
- gf_log ("glusterd", GF_LOG_WARNING,
+ gf_msg ("glusterd", GF_LOG_WARNING, 0,
+ GD_MSG_GRAPH_FEATURE_ADD_FAIL,
"failed to add features/upcall to graph");
goto out;
}
@@ -2048,7 +2074,8 @@ brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (dict_get_str (set_dict, SSL_CERT_DEPTH_OPT, &value) == 0) {
ret = xlator_set_option (xl, "ssl-cert-depth", value);
if (ret) {
- gf_log ("glusterd", GF_LOG_WARNING,
+ gf_msg ("glusterd", GF_LOG_WARNING, 0,
+ GD_MSG_XLATOR_SET_OPT_FAIL,
"failed to set ssl-cert-depth");
return -1;
}
@@ -2057,7 +2084,8 @@ brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (dict_get_str (set_dict, SSL_CIPHER_LIST_OPT, &value) == 0) {
ret = xlator_set_option (xl, "ssl-cipher-list", value);
if (ret) {
- gf_log ("glusterd", GF_LOG_WARNING,
+ gf_msg ("glusterd", GF_LOG_WARNING, 0,
+ GD_MSG_XLATOR_SET_OPT_FAIL,
"failed to set ssl-cipher-list");
return -1;
}
@@ -2140,7 +2168,8 @@ brick_graph_add_pump (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (dict_get_str (set_dict, SSL_CERT_DEPTH_OPT, &value) == 0) {
ret = xlator_set_option (rbxl, "ssl-cert-depth", value);
if (ret) {
- gf_log ("glusterd", GF_LOG_WARNING,
+ gf_msg ("glusterd", GF_LOG_WARNING, errno,
+ GD_MSG_DICT_GET_FAILED,
"failed to set ssl-cert-depth");
return -1;
}
@@ -2150,7 +2179,8 @@ brick_graph_add_pump (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
ret = xlator_set_option (rbxl, "ssl-cipher-list",
value);
if (ret) {
- gf_log ("glusterd", GF_LOG_WARNING,
+ gf_msg ("glusterd", GF_LOG_WARNING, errno,
+ GD_MSG_DICT_GET_FAILED,
"failed to set ssl-cipher-list");
return -1;
}
@@ -2332,7 +2362,8 @@ server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
ret = server_graph_table[i].builder (graph, volinfo, set_dict,
param);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Builing graph "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_BUILD_GRAPH_FAILED, "Builing graph "
"failed for server graph table entry: %d", i);
goto out;
}
@@ -2353,7 +2384,8 @@ server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (!ret) {
ret = dict_get_str (set_dict, "loglevel", &loglevel);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "could not get both"
+ gf_msg ("glusterd", GF_LOG_ERROR, errno,
+ GD_MSG_DICT_GET_FAILED, "could not get both"
" translator name and loglevel for log level request");
goto out;
}
@@ -2439,21 +2471,23 @@ end_sethelp_xml_doc (xmlTextWriterPtr writer)
ret = xmlTextWriterEndElement(writer);
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR, "Could not end an "
- "xmlElemetnt");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_XML_TEXT_WRITE_FAIL, "Could not end an "
+ "xmlElement");
ret = -1;
goto out;
}
ret = xmlTextWriterEndDocument (writer);
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR, "Could not end an "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_XML_TEXT_WRITE_FAIL, "Could not end an "
"xmlDocument");
ret = -1;
goto out;
}
ret = 0;
out:
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -2465,7 +2499,8 @@ init_sethelp_xml_doc (xmlTextWriterPtr *writer, xmlBufferPtr *buf)
*buf = xmlBufferCreateSize (8192);
if (buf == NULL) {
- gf_log ("glusterd", GF_LOG_ERROR, "Error creating the xml "
+ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Error creating the xml "
"buffer");
ret = -1;
goto out;
@@ -2475,7 +2510,8 @@ init_sethelp_xml_doc (xmlTextWriterPtr *writer, xmlBufferPtr *buf)
*writer = xmlNewTextWriterMemory(*buf, 0);
if (writer == NULL) {
- gf_log ("glusterd", GF_LOG_ERROR, " Error creating the xml "
+ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, " Error creating the xml "
"writer");
ret = -1;
goto out;
@@ -2483,15 +2519,17 @@ init_sethelp_xml_doc (xmlTextWriterPtr *writer, xmlBufferPtr *buf)
ret = xmlTextWriterStartDocument(*writer, "1.0", "UTF-8", "yes");
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR, "Error While starting the "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_XML_DOC_START_FAIL, "Error While starting the "
"xmlDoc");
goto out;
}
ret = xmlTextWriterStartElement(*writer, (xmlChar *)"options");
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR, "Could not create an "
- "xmlElemetnt");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_XML_ELE_CREATE_FAIL, "Could not create an "
+ "xmlElement");
ret = -1;
goto out;
}
@@ -2500,7 +2538,7 @@ init_sethelp_xml_doc (xmlTextWriterPtr *writer, xmlBufferPtr *buf)
ret = 0;
out:
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -2516,7 +2554,8 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name,
ret = xmlTextWriterStartElement(writer, (xmlChar *) "option");
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR, "Could not create an "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_XML_ELE_CREATE_FAIL, "Could not create an "
"xmlElemetnt");
ret = -1;
goto out;
@@ -2525,7 +2564,8 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name,
ret = xmlTextWriterWriteFormatElement(writer, (xmlChar*)"defaultValue",
"%s", def_val);
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR, "Could not create an "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_XML_ELE_CREATE_FAIL, "Could not create an "
"xmlElemetnt");
ret = -1;
goto out;
@@ -2534,7 +2574,8 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name,
ret = xmlTextWriterWriteFormatElement(writer, (xmlChar *)"description",
"%s", dscrpt );
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR, "Could not create an "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_XML_ELE_CREATE_FAIL, "Could not create an "
"xmlElemetnt");
ret = -1;
goto out;
@@ -2543,7 +2584,8 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name,
ret = xmlTextWriterWriteFormatElement(writer, (xmlChar *) "name", "%s",
name);
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR, "Could not create an "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_XML_ELE_CREATE_FAIL, "Could not create an "
"xmlElemetnt");
ret = -1;
goto out;
@@ -2551,7 +2593,8 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name,
ret = xmlTextWriterEndElement(writer);
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR, "Could not end an "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_XML_ELE_CREATE_FAIL, "Could not end an "
"xmlElemetnt");
ret = -1;
goto out;
@@ -2559,7 +2602,7 @@ xml_add_volset_element (xmlTextWriterPtr writer, const char *name,
ret = 0;
out:
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -2602,10 +2645,11 @@ _get_xlator_opt_key_from_vme ( struct volopt_map_entry *vme, char **key)
}
}
if (ret)
- gf_log ("glusterd", GF_LOG_ERROR, "Wrong entry found in "
+ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "Wrong entry found in "
"glusterd_volopt_map entry %s", vme->key);
else
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -2702,7 +2746,8 @@ volgen_graph_build_client (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (dict_get_str (set_dict, SSL_CERT_DEPTH_OPT, &value) == 0) {
ret = xlator_set_option (xl, "ssl-cert-depth", value);
if (ret) {
- gf_log ("glusterd", GF_LOG_WARNING,
+ gf_msg ("glusterd", GF_LOG_WARNING, errno,
+ GD_MSG_DICT_GET_FAILED,
"failed to set ssl-cert-depth");
goto err;
}
@@ -2711,7 +2756,8 @@ volgen_graph_build_client (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (dict_get_str (set_dict, SSL_CIPHER_LIST_OPT, &value) == 0) {
ret = xlator_set_option (xl, "ssl-cipher-list", value);
if (ret) {
- gf_log ("glusterd", GF_LOG_WARNING,
+ gf_msg ("glusterd", GF_LOG_WARNING, errno,
+ GD_MSG_DICT_GET_FAILED,
"failed to set ssl-cipher-list");
goto err;
}
@@ -2736,7 +2782,8 @@ volgen_graph_build_clients (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
volname = volinfo->volname;
if (volinfo->brick_count == 0) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOLUME_INCONSISTENCY,
"volume inconsistency: brick count is 0");
goto out;
}
@@ -2744,7 +2791,8 @@ volgen_graph_build_clients (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if ((volinfo->type != GF_CLUSTER_TYPE_TIER) &&
(volinfo->dist_leaf_count < volinfo->brick_count) &&
((volinfo->brick_count % volinfo->dist_leaf_count) != 0)) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOLUME_INCONSISTENCY,
"volume inconsistency: "
"total number of bricks (%d) is not divisible with "
"number of bricks per cluster (%d) in a multi-cluster "
@@ -2773,7 +2821,8 @@ volgen_graph_build_clients (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
}
if (i != volinfo->brick_count) {
- gf_log ("", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOLUME_INCONSISTENCY,
"volume inconsistency: actual number of bricks (%d) "
"differs from brick count (%d)", i,
volinfo->brick_count);
@@ -2916,14 +2965,16 @@ volgen_graph_build_snapview_client (volgen_graph_t *graph,
**/
ret = volgen_xlator_link (graph->graph.first, prev_top);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "failed to link the "
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_XLATOR_LINK_FAIL, "failed to link the "
"snapview-client to distribute");
goto out;
}
ret = volgen_xlator_link (graph->graph.first, prot_clnt);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "failed to link the "
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_XLATOR_LINK_FAIL, "failed to link the "
"snapview-client to snapview-server");
goto out;
}
@@ -2944,14 +2995,18 @@ _xl_is_client_decommissioned (xlator_t *xl, glusterd_volinfo_t *volinfo)
ret = xlator_get_option (xl, "remote-host", &hostname);
if (ret) {
GF_ASSERT (0);
- gf_log ("glusterd", GF_LOG_ERROR, "Failed to get remote-host "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_REMOTE_HOST_GET_FAIL,
+ "Failed to get remote-host "
"from client %s", xl->name);
goto out;
}
ret = xlator_get_option (xl, "remote-subvolume", &path);
if (ret) {
GF_ASSERT (0);
- gf_log ("glusterd", GF_LOG_ERROR, "Failed to get remote-host "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_REMOTE_HOST_GET_FAIL,
+ "Failed to get remote-host "
"from client %s", xl->name);
goto out;
}
@@ -3041,7 +3096,8 @@ volgen_graph_build_dht_cluster (volgen_graph_t *graph,
/* NUFA and Switch section */
if (dict_get_str_boolean (volinfo->dict, "cluster.nufa", 0) &&
dict_get_str_boolean (volinfo->dict, "cluster.switch", 0)) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_msg (THIS->name, GF_LOG_ERROR, errno,
+ GD_MSG_DICT_GET_FAILED,
"nufa and switch cannot be set together");
ret = -1;
goto out;
@@ -3238,7 +3294,9 @@ volume_volgen_graph_build_clusters (volgen_graph_t *graph,
break;
default:
- gf_log ("", GF_LOG_ERROR, "volume inconsistency: "
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOLUME_INCONSISTENCY,
+ "volume inconsistency: "
"unrecognized clustering type");
goto out;
}
@@ -3293,38 +3351,50 @@ graph_set_generic_options (xlator_t *this, volgen_graph_t *graph,
&loglevel_option_handler);
if (ret)
- gf_log (this->name, GF_LOG_WARNING, "changing %s log level"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_GRAPH_SET_OPT_FAIL,
+ "changing %s log level"
" failed", identifier);
ret = volgen_graph_set_options_generic (graph, set_dict, "client",
&sys_loglevel_option_handler);
if (ret)
- gf_log (this->name, GF_LOG_WARNING, "changing %s syslog "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_GRAPH_SET_OPT_FAIL,
+ "changing %s syslog "
"level failed", identifier);
ret = volgen_graph_set_options_generic (graph, set_dict, "client",
&logger_option_handler);
if (ret)
- gf_log (this->name, GF_LOG_WARNING, "changing %s logger"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_GRAPH_SET_OPT_FAIL,
+ "changing %s logger"
" failed", identifier);
ret = volgen_graph_set_options_generic (graph, set_dict, "client",
&log_format_option_handler);
if (ret)
- gf_log (this->name, GF_LOG_WARNING, "changing %s log format"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_GRAPH_SET_OPT_FAIL,
+ "changing %s log format"
" failed", identifier);
ret = volgen_graph_set_options_generic (graph, set_dict, "client",
&log_buf_size_option_handler);
if (ret)
- gf_log (this->name, GF_LOG_WARNING, "Failed to change "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_GRAPH_SET_OPT_FAIL,
+ "Failed to change "
"log-buf-size option");
ret = volgen_graph_set_options_generic (graph, set_dict, "client",
&log_flush_timeout_option_handler);
if (ret)
- gf_log (this->name, GF_LOG_WARNING, "Failed to change "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_GRAPH_SET_OPT_FAIL,
+ "Failed to change "
"log-flush-timeout option");
return 0;
}
@@ -3499,7 +3569,9 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (volinfo->is_snap_volume) {
xl = volgen_graph_add (graph, "features/read-only", volname);
if (!xl) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to add "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GRAPH_FEATURE_ADD_FAIL,
+ "Failed to add "
"read-only feature to the graph of %s "
"snapshot with %s origin volume",
volname, volinfo->parent_volname);
@@ -3577,7 +3649,8 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
ob = _gf_false;
ret = gf_string2boolean (tmp, &ob);
if (!ret && ob) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_ROOT_SQUASH_ENABLED,
"root-squash is enabled. Please turn it"
" off to change read-after-open "
"option");
@@ -3646,7 +3719,9 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
ret = 0;
}
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "setting "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_ROOT_SQUASH_FAILED,
+ "setting "
"open behind option as part of root "
"squash failed");
goto out;
@@ -3658,8 +3733,9 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
ret = dict_set_str (set_dict, "client.send-gids",
ret ? "false" : "true");
if (ret)
- gf_log (THIS->name, GF_LOG_WARNING, "changing client"
- " protocol option failed");
+ gf_msg (THIS->name, GF_LOG_WARNING, errno,
+ GD_MSG_DICT_SET_FAILED, "changing client"
+ " protocol option failed");
}
ret = client_graph_set_perf_options(graph, volinfo, set_dict);
@@ -3689,7 +3765,8 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
ret = dict_get_str_boolean (set_dict, "ganesha.enable", _gf_false);
if (ret == -1) {
- gf_log (this->name, GF_LOG_WARNING, "setting ganesha.enable"
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ GD_MSG_DICT_GET_FAILED, "setting ganesha.enable"
"option failed.");
goto out;
}
@@ -3698,8 +3775,10 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
xl = volgen_graph_add (graph, "features/ganesha", volname);
if (!xl) {
- gf_log (this->name, GF_LOG_ERROR, "failed to add"
- "add features/ganesha to graph");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_GRAPH_FEATURE_ADD_FAIL,
+ "failed to add"
+ "add features/ganesha to graph");
ret = -1;
goto out;
}
@@ -4246,7 +4325,9 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict)
set_dict = dict_new ();
if (!set_dict) {
- gf_log ("", GF_LOG_ERROR, "Out of memory");
+ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY,
+ "Out of memory");
return -1;
}
@@ -4277,7 +4358,8 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict)
ret = gf_asprintf (&skey, "rpc-auth.addr.%s.allow",
voliter->volname);
if (ret == -1) {
- gf_log ("", GF_LOG_ERROR, "Out of memory");
+ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out of memory");
goto out;
}
ret = xlator_set_option (nfsxl, skey, "*");
@@ -4288,7 +4370,8 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict)
ret = gf_asprintf (&skey, "nfs3.%s.volume-id",
voliter->volname);
if (ret == -1) {
- gf_log ("", GF_LOG_ERROR, "Out of memory");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_NO_MEMORY, "Out of memory");
goto out;
}
ret = xlator_set_option (nfsxl, skey, uuid_utoa (voliter->volume_id));
@@ -4376,12 +4459,13 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict)
}
if (ret)
- gf_log ("glusterd", GF_LOG_WARNING, "Could not set "
+ gf_msg ("glusterd", GF_LOG_WARNING, 0,
+ GD_MSG_GRAPH_SET_OPT_FAIL, "Could not set "
"vol-options for the volume %s", voliter->volname);
}
out:
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
dict_destroy (set_dict);
return ret;
@@ -4427,14 +4511,18 @@ glusterd_is_valid_volfpath (char *volname, char *brick)
ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Failed to create brickinfo"
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_BRICKINFO_CREATE_FAIL,
+ "Failed to create brickinfo"
" 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_VOLINFO_STORE_FAIL,
+ "Failed to create volinfo");
ret = 0;
goto out;
}
@@ -4522,7 +4610,8 @@ build_quotad_graph (volgen_graph_t *graph, dict_t *mod_dict)
ret = gf_asprintf(&skey, "%s.volume-id", voliter->volname);
if (ret == -1) {
- gf_log("", GF_LOG_ERROR, "Out of memory");
+ gf_msg ("glusterd", GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY, "Out of memory");
goto out;
}
ret = xlator_set_option(quotad_xl, skey, voliter->volname);
@@ -4627,13 +4716,15 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo)
if (ret) {
ret = open (tstamp_file, O_WRONLY|O_CREAT|O_EXCL, 0600);
if (ret == -1 && errno == EEXIST) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"timestamp file exist");
ret = -2;
}
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR, "failed to create "
- "%s (%s)", tstamp_file, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED,
+ "failed to create "
+ "%s", tstamp_file);
return -1;
}
if (ret >= 0) {
@@ -4649,7 +4740,8 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo)
ret = gf_set_timestamp (parent_tstamp_file,
tstamp_file);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_TSTAMP_SET_FAIL,
"Unable to set atime and mtime"
" of %s as of %s", tstamp_file,
parent_tstamp_file);
@@ -4662,14 +4754,16 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo)
if (ret == -1 && errno == ENOENT)
ret = 0;
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR, "failed to unlink "
- "%s (%s)", tstamp_file, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED,
+ "failed to unlink "
+ "%s", tstamp_file);
return -1;
}
}
cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Found a brick - %s:%s", brickinfo->hostname,
brickinfo->path);
@@ -4682,7 +4776,7 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo)
ret = 0;
out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -4758,7 +4852,8 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo,
type);
}
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY,
"Received invalid transport-type");
goto out;
}
@@ -4773,7 +4868,8 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo,
/* Generate volfile for rebalance process */
ret = dict_set_int32 (dict, "rebalance-volfile-creation", _gf_true);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DICT_SET_FAILED,
"Failed to set rebalance-volfile-creation");
goto out;
}
@@ -4784,7 +4880,8 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo,
filepath,
dict);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"Failed to create rebalance volfile for %s",
volinfo->volname);
goto out;
@@ -4794,7 +4891,7 @@ out:
if (dict)
dict_unref (dict);
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -4820,7 +4917,8 @@ glusterd_snapdsvc_generate_volfile (volgen_graph_t *graph,
if (!ret) {
ret = dict_get_str (set_dict, "loglevel", &loglevel);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "could not get both"
+ gf_msg ("glusterd", GF_LOG_ERROR, errno,
+ GD_MSG_DICT_GET_FAILED, "could not get both"
" translator name and loglevel for log level "
"request");
return -1;
@@ -4857,7 +4955,8 @@ glusterd_snapdsvc_generate_volfile (volgen_graph_t *graph,
if (dict_get_str (set_dict, SSL_CERT_DEPTH_OPT, &value) == 0) {
ret = xlator_set_option (xl, "ssl-cert-depth", value);
if (ret) {
- gf_log ("glusterd", GF_LOG_WARNING,
+ gf_msg ("glusterd", GF_LOG_WARNING, 0,
+ GD_MSG_XLATOR_SET_OPT_FAIL,
"failed to set ssl-cert-depth");
return -1;
}
@@ -4866,7 +4965,8 @@ glusterd_snapdsvc_generate_volfile (volgen_graph_t *graph,
if (dict_get_str (set_dict, SSL_CIPHER_LIST_OPT, &value) == 0) {
ret = xlator_set_option (xl, "ssl-cipher-list", value);
if (ret) {
- gf_log ("glusterd", GF_LOG_WARNING,
+ gf_msg ("glusterd", GF_LOG_WARNING, 0,
+ GD_MSG_XLATOR_SET_OPT_FAIL,
"failed to set ssl-cipher-list");
return -1;
}
@@ -5268,21 +5368,24 @@ glusterd_create_volfiles (glusterd_volinfo_t *volinfo)
ret = generate_brick_volfiles (volinfo);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"Could not generate volfiles for bricks");
goto out;
}
ret = generate_client_volfiles (volinfo, GF_CLIENT_TRUSTED);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"Could not generate trusted client volfiles");
goto out;
}
ret = generate_client_volfiles (volinfo, GF_CLIENT_OTHER);
if (ret)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_VOLFILE_CREATE_FAIL,
"Could not generate client volfiles");
out:
@@ -5337,8 +5440,10 @@ glusterd_delete_volfile (glusterd_volinfo_t *volinfo,
get_brick_filepath (filename, volinfo, brickinfo);
ret = unlink (filename);
if (ret)
- gf_log ("glusterd", GF_LOG_ERROR, "failed to delete file: %s, "
- "reason: %s", filename, strerror (errno));
+ gf_msg ("glusterd", GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED,
+ "failed to delete file: %s",
+ filename);
return ret;
}
@@ -5365,7 +5470,7 @@ validate_shdopts (glusterd_volinfo_t *volinfo,
volgen_graph_free (&graph);
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
out:
dict_del (val_dict, "graph-check");
return ret;
@@ -5394,7 +5499,8 @@ validate_nfsopts (glusterd_volinfo_t *volinfo,
snprintf (err_str, sizeof (err_str), "Changing nfs "
"transport type is allowed only for volumes "
"of transport type tcp,rdma");
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_OP_UNSUPPORTED, "%s", err_str);
*op_errstr = gf_strdup (err_str);
ret = -1;
goto out;
@@ -5410,7 +5516,8 @@ validate_nfsopts (glusterd_volinfo_t *volinfo,
ret = dict_set_str (val_dict, "volume-name", volinfo->volname);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set volume name");
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DICT_SET_FAILED, "Failed to set volume name");
goto out;
}
@@ -5423,7 +5530,7 @@ validate_nfsopts (glusterd_volinfo_t *volinfo,
out:
if (dict_get (val_dict, "volume-name"))
dict_del (val_dict, "volume-name");
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -5446,7 +5553,7 @@ validate_clientopts (glusterd_volinfo_t *volinfo,
volgen_graph_free (&graph);
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -5469,7 +5576,7 @@ validate_brickopts (glusterd_volinfo_t *volinfo,
volgen_graph_free (&graph);
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -5482,7 +5589,7 @@ glusterd_validate_brickreconf (glusterd_volinfo_t *volinfo,
int ret = -1;
cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- gf_log ("", GF_LOG_DEBUG,
+ gf_msg_debug ("glusterd", 0,
"Validating %s", brickinfo->hostname);
ret = validate_brickopts (volinfo, brickinfo, val_dict,
@@ -5525,32 +5632,32 @@ glusterd_validate_globalopts (glusterd_volinfo_t *volinfo,
ret = glusterd_validate_brickreconf (volinfo, val_dict, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_DEBUG,
+ gf_msg_debug ("glusterd", 0,
"Could not Validate bricks");
goto out;
}
ret = validate_clientopts (volinfo, val_dict, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_DEBUG,
+ gf_msg_debug ("glusterd", 0,
"Could not Validate client");
goto out;
}
ret = validate_nfsopts (volinfo, val_dict, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "Could not Validate nfs");
+ gf_msg_debug ("glusterd", 0, "Could not Validate nfs");
goto out;
}
ret = validate_shdopts (volinfo, val_dict, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "Could not Validate self-heald");
+ gf_msg_debug ("glusterd", 0, "Could not Validate self-heald");
goto out;
}
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -5582,34 +5689,34 @@ glusterd_validate_reconfopts (glusterd_volinfo_t *volinfo, dict_t *val_dict,
ret = glusterd_validate_brickreconf (volinfo, val_dict, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_DEBUG,
+ gf_msg_debug ("glusterd", 0,
"Could not Validate bricks");
goto out;
}
ret = validate_clientopts (volinfo, val_dict, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_DEBUG,
+ gf_msg_debug ("glusterd", 0,
"Could not Validate client");
goto out;
}
ret = validate_nfsopts (volinfo, val_dict, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "Could not Validate nfs");
+ gf_msg_debug ("glusterd", 0, "Could not Validate nfs");
goto out;
}
ret = validate_shdopts (volinfo, val_dict, op_errstr);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "Could not Validate self-heald");
+ gf_msg_debug ("glusterd", 0, "Could not Validate self-heald");
goto out;
}
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}