summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2012-07-31 11:31:16 +0530
committerAnand Avati <avati@redhat.com>2012-08-02 13:38:53 -0700
commit1e4a2354b57a1eb173f31a15bf96b2e174fa34a5 (patch)
tree7d47fb5dca27b8eab1b6073ccedc9b56425bf5a4 /xlators/mgmt/glusterd
parent36827add0f55d674768ff9c90c5fbb636ae99054 (diff)
glusterd: Made volume set help/help-xml a non-cluster operation.
- Retained apparent redundant checks in stage, commit phase of set volume for the help options for backward compatibility Change-Id: Iaefe3805d6b5eeeced2e7e4870830edf3e61dc87 BUG: 844696 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.com/3761 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c38
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c39
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.h6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c43
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.h2
7 files changed, 87 insertions, 54 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index ccec91f..8d24b08 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -1014,6 +1014,8 @@ glusterd_handle_set_volume (rpcsvc_request_t *req)
char *key = NULL;
char *value = NULL;
char *volname = NULL;
+ char *op_errstr = NULL;
+ gf_boolean_t help = _gf_false;
GF_ASSERT (req);
@@ -1047,22 +1049,25 @@ glusterd_handle_set_volume (rpcsvc_request_t *req)
goto out;
}
+ if (strcmp (volname, "help") == 0 ||
+ strcmp (volname, "help-xml") == 0) {
+ ret = glusterd_volset_help (dict, &op_errstr);
+ help = _gf_true;
+ goto out;
+ }
+
ret = dict_get_str (dict, "key1", &key);
if (ret) {
- if (strcmp (volname, "help-xml") && strcmp (volname, "help")) {
- gf_log ("", GF_LOG_WARNING, "Unable to get key, while "
- "handling volume set for %s",volname);
- goto out;
- }
+ gf_log ("", GF_LOG_WARNING, "Unable to get key, while "
+ "handling volume set for %s",volname);
+ goto out;
}
ret = dict_get_str (dict, "value1", &value);
if (ret) {
- if (strcmp (volname, "help-xml") && strcmp (volname, "help")) {
- gf_log ("", GF_LOG_WARNING, "Unable to get value, while"
- "handling volume set for %s",volname);
- goto out;
- }
+ gf_log ("", GF_LOG_WARNING, "Unable to get value, while"
+ "handling volume set for %s",volname);
+ goto out;
}
@@ -1071,17 +1076,20 @@ glusterd_handle_set_volume (rpcsvc_request_t *req)
ret = glusterd_op_begin (req, GD_OP_SET_VOLUME, dict);
gf_cmd_log ("volume set", "volume-name:%s: key:%s, value:%s %s",
volname, key, value, (ret == 0)? "SUCCEDED" : "FAILED" );
-out:
+out:
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret) {
- if (dict)
- dict_unref (dict);
+ if (help)
+ ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, dict,
+ (op_errstr)? op_errstr:"");
+ else if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
- }
+ if (op_errstr)
+ GF_FREE (op_errstr);
+
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index d469743..d883ea4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -338,15 +338,14 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
goto out;
}
- if ( dict_count == 0 ) {
- /*No options would be specified of volume set help */
+ if (dict_count == 0) {
+ /*No options would be specified of volume set help */
if (dict_get (dict, "help" )) {
ret = 0;
goto out;
}
if (dict_get (dict, "help-xml" )) {
-
#if (HAVE_LIB_XML)
ret = 0;
goto out;
@@ -1018,25 +1017,6 @@ glusterd_start_bricks (glusterd_volinfo_t *volinfo)
}
static int
-glusterd_volset_help (dict_t *dict)
-{
- int ret = -1;
- gf_boolean_t xml_out = _gf_false;
-
- if (dict_get (dict, "help" ))
- xml_out = _gf_false;
- else if (dict_get (dict, "help-xml" ))
- xml_out = _gf_true;
- else
- goto out;
-
- ret = glusterd_get_volopt_content (xml_out);
- out:
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
- return ret;
-}
-
-static int
glusterd_op_set_volume (dict_t *dict)
{
int ret = 0;
@@ -1049,6 +1029,7 @@ glusterd_op_set_volume (dict_t *dict)
char *key_fixed = NULL;
char *value = NULL;
char str[50] = {0, };
+ char *op_errstr = NULL;
gf_boolean_t global_opt = _gf_false;
glusterd_volinfo_t *voliter = NULL;
int32_t dict_count = 0;
@@ -1066,12 +1047,14 @@ glusterd_op_set_volume (dict_t *dict)
}
if (dict_count == 0) {
- ret = glusterd_volset_help (dict);
- if (ret)
- gf_log (this->name, GF_LOG_ERROR, "Volume set"
- " help internal error");
+ ret = glusterd_volset_help (NULL, &op_errstr);
+ if (ret) {
+ op_errstr = (op_errstr)? op_errstr:
+ "Volume set help internal error";
+ gf_log (this->name, GF_LOG_ERROR, op_errstr);
+ }
goto out;
- }
+ }
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
@@ -1898,7 +1881,7 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr)
if (strcmp (volname, "help") &&
strcmp (volname, "help-xml")) {
ret = glusterd_dict_set_volid
- (dict, volname, op_errstr);
+ (dict, volname, op_errstr);
if (ret)
goto out;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index 7316b6f..5d8244b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -201,6 +201,12 @@ int32_t
glusterd_op_commit_perform (glusterd_op_t op, dict_t *req, char **op_errstr,
dict_t* dict);
+int32_t
+glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx);
+
+int32_t
+glusterd_op_txn_complete ();
+
void *
glusterd_op_get_ctx ();
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 987615a..e58c007 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -5614,3 +5614,46 @@ out:
gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
return ret;
}
+
+int
+glusterd_volset_help (dict_t *dict, char **op_errstr)
+{
+ int ret = -1;
+ gf_boolean_t xml_out = _gf_false;
+
+ if (!dict) {
+ if (!(dict = glusterd_op_get_ctx ())) {
+ ret = 0;
+ goto out;
+ }
+ }
+
+ if (dict_get (dict, "help" )) {
+ xml_out = _gf_false;
+
+ } else if (dict_get (dict, "help-xml" )) {
+ xml_out = _gf_true;
+#if (HAVE_LIB_XML)
+ ret = 0;
+#else
+ gf_log (this->name, GF_LOG_ERROR,
+ "libxml not present in the system");
+ if (op_errstr)
+ *op_errstr = gf_strdup ("Error: xml libraries not "
+ "present to produce "
+ "xml-output");
+ goto out;
+#endif
+
+ } else {
+ goto out;
+ }
+
+ ret = glusterd_get_volopt_content (dict, xml_out);
+ if (ret && op_errstr)
+ *op_errstr = gf_strdup ("Failed to get volume options help");
+ out:
+
+ gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index c538345..0233a65 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -441,4 +441,6 @@ glusterd_check_files_identical (char *filename1, char *filename2,
gf_boolean_t *identical);
void
glusterd_volinfo_reset_defrag_stats (glusterd_volinfo_t *volinfo);
+int
+glusterd_volset_help (dict_t *dict, char **op_errstr);
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 099f557..0593e24 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -2041,7 +2041,7 @@ get_key_from_volopt ( struct volopt_map_entry *vme, char **key)
}
int
-glusterd_get_volopt_content (gf_boolean_t xml_out)
+glusterd_get_volopt_content (dict_t * ctx, gf_boolean_t xml_out)
{
char *xlator_type = NULL;
@@ -2055,7 +2055,6 @@ glusterd_get_volopt_content (gf_boolean_t xml_out)
char output_string[16384] = {0, };
char *output = NULL;
char tmp_str[1024] = {0, };
- dict_t *ctx = NULL;
#if (HAVE_LIB_XML)
xmlTextWriterPtr writer = NULL;
xmlBufferPtr buf = NULL;
@@ -2067,14 +2066,6 @@ glusterd_get_volopt_content (gf_boolean_t xml_out)
}
#endif
- ctx = glusterd_op_get_ctx ();
-
- if (!ctx) {
- /*extract the vol-set-help output only in host glusterd*/
- ret = 0;
- goto out;
- }
-
INIT_LIST_HEAD (&vol_opt_handle.list);
for (vme = &glusterd_volopt_map[0]; vme->key; vme++) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h
index 9e8370c..5d623b2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.h
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h
@@ -93,7 +93,7 @@ glusterd_check_voloption_flags (char *key, int32_t flags);
gf_boolean_t
glusterd_is_valid_volfpath (char *volname, char *brick);
int generate_brick_volfiles (glusterd_volinfo_t *volinfo);
-int glusterd_get_volopt_content (gf_boolean_t xml_out);
+int glusterd_get_volopt_content (dict_t *dict, gf_boolean_t xml_out);
char*
glusterd_get_trans_type_rb (gf_transport_type ttype);
int