|
|
21ab4e |
From 994b4f5337f9bba1b2ca966d52d78983fd4e32f0 Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Samikshan Bairagya <samikshan@gmail.com>
|
|
|
21ab4e |
Date: Fri, 23 Sep 2016 16:35:15 +0530
|
|
|
21ab4e |
Subject: [PATCH 318/361] glusterd, cli: Get global options through volume get
|
|
|
21ab4e |
functionality
|
|
|
21ab4e |
|
|
|
21ab4e |
Currently it is not possible to retrieve values of global options
|
|
|
21ab4e |
by using the 'gluster volume get' functionality if there are no
|
|
|
21ab4e |
volumes present. In order to get the global options one has to use
|
|
|
21ab4e |
'gluster volume get' with a specific volume name. This usage makes
|
|
|
21ab4e |
the illusion as though the option is set only on one volume, which
|
|
|
21ab4e |
is incorrect. When setting the global options, 'gluster volume set'
|
|
|
21ab4e |
provides a way to set them using the volume name as 'all'.
|
|
|
21ab4e |
|
|
|
21ab4e |
Similarly, retrieving the global options should be made possible by
|
|
|
21ab4e |
using the volume name 'all' with the 'gluster volume get'
|
|
|
21ab4e |
functionality. This patch adds that functionality to 'volume get'
|
|
|
21ab4e |
|
|
|
21ab4e |
Usage:
|
|
|
21ab4e |
# gluster volume get all <OPTION/all>
|
|
|
21ab4e |
|
|
|
21ab4e |
mainline:
|
|
|
21ab4e |
> BUG: 1378842
|
|
|
21ab4e |
> Reviewed-on: http://review.gluster.org/15563
|
|
|
21ab4e |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
(cherry picked from commit cef4fc694a6c5fd7e69f3780d43a590e67760af6)
|
|
|
21ab4e |
|
|
|
21ab4e |
BUG: 1433751
|
|
|
21ab4e |
Change-Id: Ic2fdb9eda69d4806d432dae26d117d9660fe6d4e
|
|
|
21ab4e |
Signed-off-by: Samikshan Bairagya <samikshan@gmail.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/101299
|
|
|
21ab4e |
Tested-by: Milind Changire <mchangir@redhat.com>
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
cli/src/cli-rpc-ops.c | 6 ++
|
|
|
21ab4e |
tests/bugs/cli/bug-1378842-volume-get-all.t | 26 ++++++
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd-handler.c | 39 +++++++++
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd-op-sm.c | 34 ++------
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd-utils.c | 120 +++++++++++++++++++++++++++
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd-utils.h | 36 ++++++++
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd.h | 1 +
|
|
|
21ab4e |
7 files changed, 233 insertions(+), 29 deletions(-)
|
|
|
21ab4e |
create mode 100644 tests/bugs/cli/bug-1378842-volume-get-all.t
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
|
|
|
21ab4e |
index 339d91b..cc395d7 100644
|
|
|
21ab4e |
--- a/cli/src/cli-rpc-ops.c
|
|
|
21ab4e |
+++ b/cli/src/cli-rpc-ops.c
|
|
|
21ab4e |
@@ -11459,12 +11459,18 @@ gf_cli_get_vol_opt_cbk (struct rpc_req *req, struct iovec *iov, int count,
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+ ret = dict_get_str (dict, "warning", &value);
|
|
|
21ab4e |
+ if (!ret) {
|
|
|
21ab4e |
+ cli_out ("%s", value);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
ret = dict_get_int32 (dict, "count", &count);
|
|
|
21ab4e |
if (ret) {
|
|
|
21ab4e |
gf_log ("cli", GF_LOG_ERROR, "Failed to retrieve count "
|
|
|
21ab4e |
"from the dictionary");
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
if (count <= 0) {
|
|
|
21ab4e |
gf_log ("cli", GF_LOG_ERROR, "Value of count :%d is "
|
|
|
21ab4e |
"invalid", count);
|
|
|
21ab4e |
diff --git a/tests/bugs/cli/bug-1378842-volume-get-all.t b/tests/bugs/cli/bug-1378842-volume-get-all.t
|
|
|
21ab4e |
new file mode 100644
|
|
|
21ab4e |
index 0000000..c798ce5
|
|
|
21ab4e |
--- /dev/null
|
|
|
21ab4e |
+++ b/tests/bugs/cli/bug-1378842-volume-get-all.t
|
|
|
21ab4e |
@@ -0,0 +1,26 @@
|
|
|
21ab4e |
+#!/bin/bash
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+. $(dirname $0)/../../include.rc
|
|
|
21ab4e |
+. $(dirname $0)/../../volume.rc
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+cleanup;
|
|
|
21ab4e |
+TEST glusterd
|
|
|
21ab4e |
+TEST pidof glusterd
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+TEST $CLI volume set all server-quorum-ratio 80
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+# Execute volume get without having an explicit option, this should fail
|
|
|
21ab4e |
+TEST ! $CLI volume get all
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+# Also volume get on an option not applicable for all volumes should fail
|
|
|
21ab4e |
+TEST ! $CLI volume get all cluster.tier-mode
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+# Execute volume get with an explicit global option
|
|
|
21ab4e |
+TEST $CLI volume get all server-quorum-ratio
|
|
|
21ab4e |
+EXPECT '80' volume_get_field all 'cluster.server-quorum-ratio'
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+# Execute volume get with 'all'
|
|
|
21ab4e |
+TEST $CLI volume get all all
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+cleanup;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
21ab4e |
index 664fe5b..dbe69d5 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
|
|
|
21ab4e |
@@ -4626,6 +4626,19 @@ glusterd_handle_barrier (rpcsvc_request_t *req)
|
|
|
21ab4e |
return glusterd_big_locked_handler (req, __glusterd_handle_barrier);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+static gf_boolean_t
|
|
|
21ab4e |
+gd_is_global_option (char *opt_key)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO (THIS->name, opt_key, out);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return (strcmp (opt_key, GLUSTERD_SHARED_STORAGE_KEY) == 0 ||
|
|
|
21ab4e |
+ strcmp (opt_key, GLUSTERD_QUORUM_RATIO_KEY) == 0 ||
|
|
|
21ab4e |
+ strcmp (opt_key, GLUSTERD_GLOBAL_OP_VERSION_KEY) == 0);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+out:
|
|
|
21ab4e |
+ return _gf_false;
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
int32_t
|
|
|
21ab4e |
glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
@@ -4638,6 +4651,7 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict)
|
|
|
21ab4e |
char *volname = NULL;
|
|
|
21ab4e |
char *value = NULL;
|
|
|
21ab4e |
char err_str[2048] = {0,};
|
|
|
21ab4e |
+ char warn_str[2048] = {0,};
|
|
|
21ab4e |
char dict_key[50] = {0,};
|
|
|
21ab4e |
xlator_t *this = NULL;
|
|
|
21ab4e |
glusterd_conf_t *priv = NULL;
|
|
|
21ab4e |
@@ -4663,6 +4677,12 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict)
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+ if (strcasecmp (volname, "all") == 0) {
|
|
|
21ab4e |
+ ret = glusterd_get_global_options_for_all_vols (dict,
|
|
|
21ab4e |
+ &rsp.op_errstr);
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
ret = dict_get_str (dict, "key", &key);
|
|
|
21ab4e |
if (ret) {
|
|
|
21ab4e |
snprintf (err_str, sizeof (err_str), "Failed to get key "
|
|
|
21ab4e |
@@ -4728,6 +4748,25 @@ glusterd_get_volume_opts (rpcsvc_request_t *req, dict_t *dict)
|
|
|
21ab4e |
orig_key = key;
|
|
|
21ab4e |
key = key_fixed;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
+ if (gd_is_global_option (key)) {
|
|
|
21ab4e |
+ snprintf (warn_str, sizeof (warn_str),
|
|
|
21ab4e |
+ "Warning: Support to get "
|
|
|
21ab4e |
+ "global option value using "
|
|
|
21ab4e |
+ "`volume get <volname>` will be "
|
|
|
21ab4e |
+ "deprecated from next release. "
|
|
|
21ab4e |
+ "Consider using `volume get all` "
|
|
|
21ab4e |
+ "instead for global options");
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ ret = dict_set_str (dict, "warning", warn_str);
|
|
|
21ab4e |
+ if (ret) {
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR,
|
|
|
21ab4e |
+ 0, GD_MSG_DICT_SET_FAILED,
|
|
|
21ab4e |
+ "Failed to set warning "
|
|
|
21ab4e |
+ "message in dictionary");
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
if (strcmp (key, "cluster.op-version") == 0) {
|
|
|
21ab4e |
sprintf (dict_key, "key%d", count);
|
|
|
21ab4e |
ret = dict_set_str(dict, dict_key, key);
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
|
|
|
21ab4e |
index 9ebdb9e..7cc864d 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
|
|
|
21ab4e |
@@ -63,38 +63,13 @@ glusterd_set_shared_storage (dict_t *dict, char *key, char *value,
|
|
|
21ab4e |
* all volumes, we can just add more entries to this *
|
|
|
21ab4e |
* table *
|
|
|
21ab4e |
*/
|
|
|
21ab4e |
-glusterd_all_vol_opts valid_all_vol_opts[] = {
|
|
|
21ab4e |
+glusterd_all_vol_opts valid_all_vol_opts[] = {
|
|
|
21ab4e |
{ GLUSTERD_QUORUM_RATIO_KEY },
|
|
|
21ab4e |
{ GLUSTERD_SHARED_STORAGE_KEY },
|
|
|
21ab4e |
+ { GLUSTERD_GLOBAL_OP_VERSION_KEY },
|
|
|
21ab4e |
{ NULL },
|
|
|
21ab4e |
};
|
|
|
21ab4e |
|
|
|
21ab4e |
-#define ALL_VOLUME_OPTION_CHECK(volname, key, ret, op_errstr, label) \
|
|
|
21ab4e |
- do { \
|
|
|
21ab4e |
- gf_boolean_t _all = !strcmp ("all", volname); \
|
|
|
21ab4e |
- gf_boolean_t _ratio = _gf_false; \
|
|
|
21ab4e |
- int32_t i = 0; \
|
|
|
21ab4e |
- \
|
|
|
21ab4e |
- for (i = 0; valid_all_vol_opts[i].option; i++) { \
|
|
|
21ab4e |
- if (!strcmp (key, valid_all_vol_opts[i].option)) { \
|
|
|
21ab4e |
- _ratio = _gf_true; \
|
|
|
21ab4e |
- break; \
|
|
|
21ab4e |
- } \
|
|
|
21ab4e |
- } \
|
|
|
21ab4e |
- \
|
|
|
21ab4e |
- if (_all && !_ratio) { \
|
|
|
21ab4e |
- ret = -1; \
|
|
|
21ab4e |
- *op_errstr = gf_strdup ("Not a valid option for all " \
|
|
|
21ab4e |
- "volumes"); \
|
|
|
21ab4e |
- goto label; \
|
|
|
21ab4e |
- } else if (!_all && _ratio) { \
|
|
|
21ab4e |
- ret = -1; \
|
|
|
21ab4e |
- *op_errstr = gf_strdup ("Not a valid option for " \
|
|
|
21ab4e |
- "single volume"); \
|
|
|
21ab4e |
- goto label; \
|
|
|
21ab4e |
- } \
|
|
|
21ab4e |
- } while (0)
|
|
|
21ab4e |
-
|
|
|
21ab4e |
static struct cds_list_head gd_op_sm_queue;
|
|
|
21ab4e |
synclock_t gd_op_sm_lock;
|
|
|
21ab4e |
glusterd_op_info_t opinfo = {{0},};
|
|
|
21ab4e |
@@ -1203,7 +1178,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
|
|
|
21ab4e |
goto cont;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
- ALL_VOLUME_OPTION_CHECK (volname, key, ret, op_errstr, out);
|
|
|
21ab4e |
+ ALL_VOLUME_OPTION_CHECK (volname, _gf_false, key, ret,
|
|
|
21ab4e |
+ op_errstr, out);
|
|
|
21ab4e |
ret = glusterd_validate_quorum_options (this, key, value,
|
|
|
21ab4e |
op_errstr);
|
|
|
21ab4e |
if (ret)
|
|
|
21ab4e |
@@ -1563,7 +1539,7 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr)
|
|
|
21ab4e |
ret = -1;
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
- ALL_VOLUME_OPTION_CHECK (volname, key, ret,
|
|
|
21ab4e |
+ ALL_VOLUME_OPTION_CHECK (volname, _gf_false, key, ret,
|
|
|
21ab4e |
op_errstr, out);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
}
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
21ab4e |
index 91cc12e..1f71d41 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
21ab4e |
@@ -93,6 +93,7 @@
|
|
|
21ab4e |
#define NLMV1_VERSION 1
|
|
|
21ab4e |
|
|
|
21ab4e |
extern struct volopt_map_entry glusterd_volopt_map[];
|
|
|
21ab4e |
+extern glusterd_all_vol_opts valid_all_vol_opts[];
|
|
|
21ab4e |
|
|
|
21ab4e |
static glusterd_lock_t lock;
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -10997,6 +10998,125 @@ out:
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
int
|
|
|
21ab4e |
+glusterd_get_global_options_for_all_vols (dict_t *ctx, char **op_errstr)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ int ret = -1;
|
|
|
21ab4e |
+ int count = 0;
|
|
|
21ab4e |
+ gf_boolean_t all_opts = _gf_false;
|
|
|
21ab4e |
+ gf_boolean_t key_found = _gf_false;
|
|
|
21ab4e |
+ glusterd_conf_t *priv = NULL;
|
|
|
21ab4e |
+ xlator_t *this = NULL;
|
|
|
21ab4e |
+ char *key = NULL;
|
|
|
21ab4e |
+ char *key_fixed = NULL;
|
|
|
21ab4e |
+ char dict_key[50] = {0,};
|
|
|
21ab4e |
+ char *def_val = NULL;
|
|
|
21ab4e |
+ char err_str[PATH_MAX] = {0,};
|
|
|
21ab4e |
+ char *allvolopt = NULL;
|
|
|
21ab4e |
+ int32_t i = 0;
|
|
|
21ab4e |
+ gf_boolean_t exists = _gf_false;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ this = THIS;
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO (THIS->name, this, out);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ priv = this->private;
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO (this->name, priv, out);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO (this->name, ctx, out);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ ret = dict_get_str (ctx, "key", &key);
|
|
|
21ab4e |
+ if (ret) {
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
+ GD_MSG_DICT_GET_FAILED,
|
|
|
21ab4e |
+ "Failed to get option key from dictionary");
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (strcasecmp (key, "all") == 0)
|
|
|
21ab4e |
+ all_opts = _gf_true;
|
|
|
21ab4e |
+ else {
|
|
|
21ab4e |
+ exists = glusterd_check_option_exists (key, &key_fixed);
|
|
|
21ab4e |
+ if (!exists) {
|
|
|
21ab4e |
+ snprintf (err_str, sizeof (err_str), "Option "
|
|
|
21ab4e |
+ "with name: %s does not exist", key);
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
|
|
|
21ab4e |
+ GD_MSG_UNKNOWN_KEY, "%s", err_str);
|
|
|
21ab4e |
+ if (key_fixed)
|
|
|
21ab4e |
+ snprintf (err_str, sizeof (err_str),
|
|
|
21ab4e |
+ "Did you mean %s?", key_fixed);
|
|
|
21ab4e |
+ ret = -1;
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ if (key_fixed)
|
|
|
21ab4e |
+ key = key_fixed;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ ALL_VOLUME_OPTION_CHECK ("all", _gf_true, key, ret, op_errstr, out);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ for (i = 0; valid_all_vol_opts[i].option; i++) {
|
|
|
21ab4e |
+ allvolopt = gf_strdup (valid_all_vol_opts[i].option);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (!all_opts && strcmp (key, allvolopt) != 0)
|
|
|
21ab4e |
+ continue;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ ret = dict_get_str (priv->opts, allvolopt, &def_val);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ /* If global option isn't set explicitly */
|
|
|
21ab4e |
+ if (!def_val) {
|
|
|
21ab4e |
+ if (!strcmp (allvolopt, GLUSTERD_GLOBAL_OP_VERSION_KEY))
|
|
|
21ab4e |
+ gf_asprintf (&def_val, "%d", priv->op_version);
|
|
|
21ab4e |
+ else if (!strcmp (allvolopt, GLUSTERD_QUORUM_RATIO_KEY))
|
|
|
21ab4e |
+ gf_asprintf (&def_val, "%d", 0);
|
|
|
21ab4e |
+ else if (!strcmp (allvolopt, GLUSTERD_SHARED_STORAGE_KEY))
|
|
|
21ab4e |
+ gf_asprintf (&def_val, "%s", "disable");
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ count++;
|
|
|
21ab4e |
+ sprintf (dict_key, "key%d", count);
|
|
|
21ab4e |
+ ret = dict_set_str (ctx, dict_key, allvolopt);
|
|
|
21ab4e |
+ if (ret) {
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
+ GD_MSG_DICT_SET_FAILED,
|
|
|
21ab4e |
+ "Failed to set %s in dictionary", allvolopt);
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ sprintf (dict_key, "value%d", count);
|
|
|
21ab4e |
+ ret = dict_set_dynstr_with_alloc (ctx, dict_key, def_val);
|
|
|
21ab4e |
+ if (ret) {
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
+ GD_MSG_DICT_SET_FAILED,
|
|
|
21ab4e |
+ "Failed to set %s for key %s in dictionary",
|
|
|
21ab4e |
+ def_val, allvolopt);
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ def_val = NULL;
|
|
|
21ab4e |
+ allvolopt = NULL;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (!all_opts)
|
|
|
21ab4e |
+ break;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ ret = dict_set_int32 (ctx, "count", count);
|
|
|
21ab4e |
+ if (ret) {
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
|
|
|
21ab4e |
+ "Failed to set count in dictionary");
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+out:
|
|
|
21ab4e |
+ if (ret && !all_opts && !key_found) {
|
|
|
21ab4e |
+ if (err_str == NULL)
|
|
|
21ab4e |
+ snprintf (err_str, sizeof (err_str),
|
|
|
21ab4e |
+ "option %s does not exist", key);
|
|
|
21ab4e |
+ if (*op_errstr == NULL)
|
|
|
21ab4e |
+ *op_errstr = gf_strdup (err_str);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ gf_msg_debug (THIS->name, 0, "Returning %d", ret);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return ret;
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+int
|
|
|
21ab4e |
glusterd_get_default_val_for_volopt (dict_t *ctx, gf_boolean_t all_opts,
|
|
|
21ab4e |
char *input_key, char *orig_key,
|
|
|
21ab4e |
glusterd_volinfo_t *volinfo,
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
21ab4e |
index b1493df..bbf4ef2 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
21ab4e |
@@ -32,6 +32,39 @@
|
|
|
21ab4e |
volinfo->volname, brickid);\
|
|
|
21ab4e |
} while (0)
|
|
|
21ab4e |
|
|
|
21ab4e |
+#define ALL_VOLUME_OPTION_CHECK(volname, get_opt, key, ret, op_errstr, label) \
|
|
|
21ab4e |
+ do { \
|
|
|
21ab4e |
+ gf_boolean_t _all = !strcmp ("all", volname); \
|
|
|
21ab4e |
+ gf_boolean_t _is_valid_opt = _gf_false; \
|
|
|
21ab4e |
+ int32_t i = 0; \
|
|
|
21ab4e |
+ \
|
|
|
21ab4e |
+ if (strcmp (key, "all") == 0 && !get_opt) { \
|
|
|
21ab4e |
+ ret = -1; \
|
|
|
21ab4e |
+ *op_errstr = gf_strdup ("Not a valid option to set"); \
|
|
|
21ab4e |
+ } \
|
|
|
21ab4e |
+ \
|
|
|
21ab4e |
+ for (i = 0; valid_all_vol_opts[i].option; i++) { \
|
|
|
21ab4e |
+ if (!strcmp (key, "all") || \
|
|
|
21ab4e |
+ !strcmp (key, valid_all_vol_opts[i].option)) { \
|
|
|
21ab4e |
+ _is_valid_opt = _gf_true; \
|
|
|
21ab4e |
+ break; \
|
|
|
21ab4e |
+ } \
|
|
|
21ab4e |
+ } \
|
|
|
21ab4e |
+ \
|
|
|
21ab4e |
+ if (_all && !_is_valid_opt) { \
|
|
|
21ab4e |
+ ret = -1; \
|
|
|
21ab4e |
+ *op_errstr = gf_strdup ("Not a valid option for all " \
|
|
|
21ab4e |
+ "volumes"); \
|
|
|
21ab4e |
+ goto label; \
|
|
|
21ab4e |
+ } else if (!_all && _is_valid_opt) { \
|
|
|
21ab4e |
+ ret = -1; \
|
|
|
21ab4e |
+ *op_errstr = gf_strdup ("Not a valid option for " \
|
|
|
21ab4e |
+ "single volume"); \
|
|
|
21ab4e |
+ goto label; \
|
|
|
21ab4e |
+ } \
|
|
|
21ab4e |
+ } while (0) \
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+
|
|
|
21ab4e |
struct glusterd_lock_ {
|
|
|
21ab4e |
uuid_t owner;
|
|
|
21ab4e |
time_t timestamp;
|
|
|
21ab4e |
@@ -628,6 +661,9 @@ int
|
|
|
21ab4e |
glusterd_get_volopt_content (dict_t *dict, gf_boolean_t xml_out);
|
|
|
21ab4e |
|
|
|
21ab4e |
int
|
|
|
21ab4e |
+glusterd_get_global_options_for_all_vols (dict_t *dict, char **op_errstr);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+int
|
|
|
21ab4e |
glusterd_get_default_val_for_volopt (dict_t *dict, gf_boolean_t all_opts,
|
|
|
21ab4e |
char *key, char *orig_key,
|
|
|
21ab4e |
glusterd_volinfo_t *volinfo,
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
21ab4e |
index ab7c03e..08a88ed 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
21ab4e |
@@ -43,6 +43,7 @@
|
|
|
21ab4e |
#define GLUSTERD_QUORUM_TYPE_KEY "cluster.server-quorum-type"
|
|
|
21ab4e |
#define GLUSTERD_QUORUM_RATIO_KEY "cluster.server-quorum-ratio"
|
|
|
21ab4e |
#define GLUSTERD_GLOBAL_OPT_VERSION "global-option-version"
|
|
|
21ab4e |
+#define GLUSTERD_GLOBAL_OP_VERSION_KEY "cluster.op-version"
|
|
|
21ab4e |
#define GLUSTERD_COMMON_PEM_PUB_FILE "/geo-replication/common_secret.pem.pub"
|
|
|
21ab4e |
#define GEO_CONF_MAX_OPT_VALS 6
|
|
|
21ab4e |
#define GLUSTERD_CREATE_HOOK_SCRIPT "/hooks/1/gsync-create/post/" \
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|