12a457
From 0ab4ff660512d0b8bb539e93c2b3a970860a0ba0 Mon Sep 17 00:00:00 2001
12a457
From: Atin Mukherjee <amukherj@redhat.com>
12a457
Date: Tue, 26 Apr 2016 12:46:18 +0530
12a457
Subject: [PATCH 090/104] glusterd: fix validation of lower op-version check in volume set
12a457
12a457
Backport of http://review.gluster.org/14077
12a457
            http://review.gluster.org/14069
12a457
12a457
Commit 2d87a98 introduced a validation to fail lowering down the
12a457
cluster.op-version. Commit 2eb8758 actually changed the variable value from
12a457
cluster's op-version to volume's op-version which resulted the logic go for a
12a457
toss.
12a457
12a457
Change-Id: I70df32b75c3a3fe47dc840c4a655059e5b124bca
12a457
BUG: 1101702
12a457
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
12a457
Reviewed-on: http://review.gluster.org/14069
12a457
Smoke: Gluster Build System <jenkins@build.gluster.com>
12a457
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
12a457
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
12a457
Reviewed-by: Kaushal M <kaushal@redhat.com>
12a457
Reviewed-on: http://review.gluster.org/14077
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/73088
12a457
---
12a457
 .../bug-1315186-reject-lowering-down-op-version.t  |   22 ++++++++++++++++++++
12a457
 xlators/mgmt/glusterd/src/glusterd-op-sm.c         |    4 +-
12a457
 2 files changed, 24 insertions(+), 2 deletions(-)
12a457
 create mode 100644 tests/bugs/glusterd/bug-1315186-reject-lowering-down-op-version.t
12a457
12a457
diff --git a/tests/bugs/glusterd/bug-1315186-reject-lowering-down-op-version.t b/tests/bugs/glusterd/bug-1315186-reject-lowering-down-op-version.t
12a457
new file mode 100644
12a457
index 0000000..4bd6eaa
12a457
--- /dev/null
12a457
+++ b/tests/bugs/glusterd/bug-1315186-reject-lowering-down-op-version.t
12a457
@@ -0,0 +1,22 @@
12a457
+#! /bin/bash
12a457
+
12a457
+. $(dirname $0)/../../include.rc
12a457
+
12a457
+# The test validates that lowering down the op-version should fail
12a457
+
12a457
+cleanup
12a457
+
12a457
+TEST glusterd
12a457
+TEST pidof glusterd
12a457
+
12a457
+#volume create is just to ensure glusterd.info file is created
12a457
+TEST $CLI volume create $V0 $H0:$B0/b1
12a457
+
12a457
+GDWD=$($CLI system getwd)
12a457
+OP_VERS_ORIG=$(grep 'operating-version' ${GDWD}/glusterd.info | cut -d '=' -f 2)
12a457
+OP_VERS_NEW=`expr $OP_VERS_ORIG-1`
12a457
+
12a457
+TEST ! $CLI volume set all $V0 cluster.op-version $OP_VERS_NEW
12a457
+
12a457
+cleanup;
12a457
+
12a457
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
12a457
index 51a5c34..2d40552 100644
12a457
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
12a457
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
12a457
@@ -1145,7 +1145,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
12a457
                                         "%s", errstr);
12a457
                                 goto out;
12a457
                         }
12a457
-                        if (local_key_op_version > local_new_op_version) {
12a457
+                        if (local_key_op_version > priv->op_version) {
12a457
                                 local_new_op_version = local_key_op_version;
12a457
                         } else {
12a457
                                 ret = -1;
12a457
@@ -1154,7 +1154,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
12a457
                                           " not be equal or lower than current"
12a457
                                           " cluster op-version (%d).",
12a457
                                           local_key_op_version,
12a457
-                                          local_new_op_version);
12a457
+                                          priv->op_version);
12a457
                                 gf_msg (this->name, GF_LOG_ERROR, 0,
12a457
                                         GD_MSG_VERSION_UNSUPPORTED,
12a457
                                         "%s", errstr);
12a457
-- 
12a457
1.7.1
12a457