summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2014-04-29 19:12:20 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2014-05-06 02:40:53 -0700
commitfb173e9a10d62d49cc8b57c6b3c5bbdf1b326c18 (patch)
tree4b800351c78c3a70e3b6ffb3e8edb583bf58a55e /xlators/mgmt
parent86fccad56d2ffd6c65e1571ff87dbf625b8ce55e (diff)
glusterd: Allow bumping up the cluster op-version
This patch allows a user to bump up the cluster op-version by doing # gluster volume set all cluster.op-version <OP-VERSION> The op-version will be bumped only if - all the peers in the cluster support it, and - the new op-version is greater than the current cluster op-version This set operation will not do any other change other than changing and saving the cluster op-version in the glusterd.info file. It will NOT, - change any existing volume - add the option to the global options list - fix the cluster op-version to the given version, it can be bumped up by other volume set commands. Change-Id: I084b4fcc45e79dc2ca7b7680d7bb371bb175af39 BUG: 1092592 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.org/7603 Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c73
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c4
2 files changed, 77 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index d6d72516c67..c2b4c26b286 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -894,6 +894,54 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
if (key_fixed)
key = key_fixed;
+
+ /* Check if the key is cluster.op-version and set
+ * local_new_op_version to the value given if possible.
+ */
+ if (strcmp (key, "cluster.op-version") == 0) {
+ if (!all_vol) {
+ ret = -1;
+ snprintf (errstr, sizeof (errstr), "Option \""
+ "%s\" is not valid for a single "
+ "volume", key);
+ goto out;
+ }
+ /* Check if cluster.op-version is the only option being
+ * set
+ */
+ if (count != 1) {
+ ret = -1;
+ snprintf (errstr, sizeof (errstr), "Option \""
+ "%s\" cannot be set along with other "
+ "options", key);
+ goto out;
+ }
+ /* Just reusing the variable, but I'm using it for
+ * storing the op-version from value
+ */
+ ret = gf_string2uint (value, &local_key_op_version);
+ if (ret) {
+ snprintf (errstr, sizeof (errstr), "invalid "
+ "number format \"%s\" in option "
+ "\"%s\"", value, key);
+ gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
+ goto out;
+ }
+
+ if (local_key_op_version > GD_OP_VERSION_MAX ||
+ local_key_op_version < GD_OP_VERSION_MIN) {
+ ret = -1;
+ snprintf (errstr, sizeof (errstr),
+ "Required op_version (%d) is not "
+ "supported", local_key_op_version);
+ gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
+ goto out;
+ }
+ if (local_key_op_version > local_new_op_version)
+ local_new_op_version = local_key_op_version;
+ goto cont;
+ }
+
ALL_VOLUME_OPTION_CHECK (volname, key, ret, op_errstr, out);
ret = glusterd_validate_quorum_options (this, key, value,
op_errstr);
@@ -979,6 +1027,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
if (ret)
goto out;
+cont:
if (origin_glusterd) {
ret = dict_set_uint32 (dict, "new-op-version",
local_new_op_version);
@@ -1717,6 +1766,7 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict)
dict_t *dup_opt = NULL;
char *next_version = NULL;
gf_boolean_t quorum_action = _gf_false;
+ uint32_t op_version = 0;
conf = this->private;
ret = dict_get_str (dict, "key1", &key);
@@ -1739,6 +1789,29 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict)
if (key_fixed)
key = key_fixed;
+ /* If the key is cluster.op-version, set conf->op_version to the value
+ * if needed and save it.
+ */
+ if (strcmp(key, "cluster.op-version") == 0) {
+ ret = 0;
+
+ ret = gf_string2uint (value, &op_version);
+ if (ret)
+ goto out;
+
+ if (op_version >= conf->op_version) {
+ conf->op_version = op_version;
+ ret = glusterd_store_global_info (this);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to store op-version.");
+ }
+ }
+ /* No need to save cluster.op-version in conf->opts
+ */
+ goto out;
+ }
+
ret = -1;
dup_opt = dict_new ();
if (!dup_opt)
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index b8eb8a56582..4cc3c2d69fa 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -1590,6 +1590,10 @@ struct volopt_map_entry glusterd_volopt_map[] = {
.value = "120",
.op_version = 4
},
+ { .key = "cluster.op-version",
+ .voltype = "mgmt/glusterd",
+ .op_version = 4
+ },
{ .key = NULL
}
};