summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
authorSamikshan Bairagya <samikshan@gmail.com>2016-12-19 15:07:14 +0530
committerAtin Mukherjee <amukherj@redhat.com>2017-01-08 21:16:12 -0800
commit76fbeafbf56a61768c81f622b354e3c95a00e986 (patch)
tree0b8959761c59a86067368b6883feef2240578fbe /xlators/mgmt/glusterd/src/glusterd-utils.c
parent3fcd790d9ca01a95026026d64385c52b5476174d (diff)
glusterd: Get maximum supported op-version in a cluster
gluster volume get <VOLNAME> cluster.opversion gives us the current op-version on which the cluster is operating. There is no command that lets the user know the maximum supported op-version that the cluster can run on. This patch adds a new global option cluster.max-op-version, that can be used to retrieve the maximum supported op-version in a cluster. Usage: # gluster volume get all cluster.max-op-version Example output: Option Value ------ ----- cluster.max-op-version 30900 NOTE: The only way to test this feature for now is to set the GD_OP_VERSION_MAX macro to different values (30800 for 3.8,30900 for 3.9, and so on) and rebuild glusterd. Since the regression test framework currently doesn't have support to simulate these tests, there are no accompanying regression tests for this feature. It should be possible to add tests once glusto comes in and makes it easier to run a heterogeneous cluster. Change-Id: I547480ee5e7912664784643e436feb198b6d16d0 BUG: 1365822 Signed-off-by: Samikshan Bairagya <samikshan@gmail.com> Reviewed-on: http://review.gluster.org/16283 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c95
1 files changed, 94 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 998c5a0d5da..3227923a99e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -46,6 +46,7 @@
#include "glusterd-pmap.h"
#include "glusterfs-acl.h"
#include "glusterd-syncop.h"
+#include "glusterd-mgmt.h"
#include "glusterd-locks.h"
#include "glusterd-messages.h"
#include "glusterd-volgen.h"
@@ -8670,6 +8671,43 @@ out:
}
int
+glusterd_max_opversion_use_rsp_dict (dict_t *dst, dict_t *src)
+{
+ int ret = -1;
+ int src_max_opversion = -1;
+ int max_opversion = -1;
+
+ GF_VALIDATE_OR_GOTO (THIS->name, dst, out);
+ GF_VALIDATE_OR_GOTO (THIS->name, src, out);
+
+ ret = dict_get_int32 (dst, "max-opversion", &max_opversion);
+ if (ret)
+ gf_msg (THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "Maximum supported op-version not set in destination "
+ "dictionary");
+
+ ret = dict_get_int32 (src, "max-opversion", &src_max_opversion);
+ if (ret) {
+ gf_msg (THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
+ "Failed to get maximum supported op-version from source");
+ goto out;
+ }
+
+ if (max_opversion == -1 || src_max_opversion < max_opversion)
+ max_opversion = src_max_opversion;
+
+ ret = dict_set_int32 (dst, "max-opversion", max_opversion);
+ if (ret) {
+ gf_msg (THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
+ "Failed to set max op-version");
+ goto out;
+ }
+out:
+ return ret;
+}
+
+
+int
glusterd_volume_bitrot_scrub_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
{
int ret = -1;
@@ -10913,7 +10951,51 @@ out:
}
int
-glusterd_get_global_options_for_all_vols (dict_t *ctx, char **op_errstr)
+glusterd_get_global_max_op_version (rpcsvc_request_t *req, dict_t *ctx,
+ int count)
+{
+ int ret = -1;
+ char *def_val = NULL;
+ char dict_key[50] = {0,};
+
+ ret = glusterd_mgmt_v3_initiate_all_phases (req, GD_OP_MAX_OPVERSION,
+ ctx);
+
+ ret = dict_get_str (ctx, "max-opversion", &def_val);
+ if (ret) {
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
+ "Failed to get max-opversion value from"
+ " dictionary");
+ goto out;
+ }
+
+ sprintf (dict_key, "key%d", count);
+ ret = dict_set_str (ctx, dict_key, GLUSTERD_MAX_OP_VERSION_KEY);
+ if (ret) {
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to set %s in "
+ "dictionary", GLUSTERD_MAX_OP_VERSION_KEY);
+ goto out;
+ }
+
+ sprintf (dict_key, "value%d", count);
+ ret = dict_set_dynstr_with_alloc (ctx, dict_key, def_val);
+ if (ret) {
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
+ "Failed to set %s for key %s in dictionary",
+ def_val, GLUSTERD_MAX_OP_VERSION_KEY);
+ goto out;
+ }
+
+out:
+ return ret;
+}
+
+int
+glusterd_get_global_options_for_all_vols (rpcsvc_request_t *req, dict_t *ctx,
+ char **op_errstr)
{
int ret = -1;
int count = 0;
@@ -10973,6 +11055,17 @@ glusterd_get_global_options_for_all_vols (dict_t *ctx, char **op_errstr)
if (!all_opts && strcmp (key, allvolopt) != 0)
continue;
+ /* Found global option */
+ if (strcmp (allvolopt, GLUSTERD_MAX_OP_VERSION_KEY) == 0) {
+ count++;
+ ret = glusterd_get_global_max_op_version (req, ctx,
+ count);
+ if (ret)
+ goto out;
+ else
+ continue;
+ }
+
ret = dict_get_str (priv->opts, allvolopt, &def_val);
/* If global option isn't set explicitly */