a3470f
From df02eac6436c86e75aed23f8ba61a061d8db9f35 Mon Sep 17 00:00:00 2001
a3470f
From: Kotresh HR <khiremat@redhat.com>
a3470f
Date: Tue, 17 Oct 2017 11:28:43 -0400
a3470f
Subject: [PATCH 087/128] glusterd: Validate changelog on geo-rep volume
a3470f
a3470f
If geo-rep is configured on volume, don't allow
a3470f
to disable changelog.
a3470f
a3470f
Backport of:
a3470f
a3470f
> Upstream Patch: https://review.gluster.org/18540
a3470f
> Change-Id: I7d1ba8b2939c8fe6ee6c59fb923d9aa1bdab553c
a3470f
> BUG: 1503227
a3470f
> Signed-off-by: Kotresh HR <khiremat@redhat.com>
a3470f
a3470f
Change-Id: I7d1ba8b2939c8fe6ee6c59fb923d9aa1bdab553c
a3470f
BUG: 1498391
a3470f
Signed-off-by: Kotresh HR <khiremat@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/124533
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
---
a3470f
 xlators/mgmt/glusterd/src/glusterd-messages.h |  9 ++++-
a3470f
 xlators/mgmt/glusterd/src/glusterd-volgen.c   | 53 +++++++++++++++++++++++++++
a3470f
 2 files changed, 61 insertions(+), 1 deletion(-)
a3470f
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
a3470f
index fb2079f..225d59b 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
a3470f
@@ -41,7 +41,7 @@
a3470f
 
a3470f
 #define GLUSTERD_COMP_BASE      GLFS_MSGID_GLUSTERD
a3470f
 
a3470f
-#define GLFS_NUM_MESSAGES       613
a3470f
+#define GLFS_NUM_MESSAGES       614
a3470f
 
a3470f
 #define GLFS_MSGID_END          (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1)
a3470f
 /* Messaged with message IDs */
a3470f
@@ -4961,6 +4961,12 @@
a3470f
  */
a3470f
 #define GD_MSG_PORTS_EXHAUSTED (GLUSTERD_COMP_BASE + 612)
a3470f
 
a3470f
+/*!
a3470f
+ * @messageid
a3470f
+ * @diagnosis
a3470f
+ * @recommendedaction
a3470f
+ *
a3470f
+ */
a3470f
 #define GD_MSG_GANESHA_NOT_RUNNING                  (GLUSTERD_COMP_BASE + 613)
a3470f
 /*!
a3470f
  * @messageid
a3470f
@@ -4968,6 +4974,7 @@
a3470f
  * @recommendedaction
a3470f
  *
a3470f
  */
a3470f
+#define GD_MSG_CHANGELOG_GET_FAIL (GLUSTERD_COMP_BASE + 614)
a3470f
 
a3470f
 /*------------*/
a3470f
 
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
a3470f
index 97049ac..8ff76d6 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
a3470f
@@ -1209,6 +1209,56 @@ loglevel_option_handler (volgen_graph_t *graph,
a3470f
 }
a3470f
 
a3470f
 static int
a3470f
+server_check_changelog_off (volgen_graph_t *graph, struct volopt_map_entry *vme,
a3470f
+                            glusterd_volinfo_t *volinfo)
a3470f
+{
a3470f
+        gf_boolean_t enabled = _gf_false;
a3470f
+        int ret = 0;
a3470f
+
a3470f
+        GF_ASSERT (volinfo);
a3470f
+        GF_ASSERT (vme);
a3470f
+
a3470f
+        if (strcmp (vme->option, "changelog") != 0)
a3470f
+                return 0;
a3470f
+
a3470f
+        ret = gf_string2boolean (vme->value, &enabled);
a3470f
+        if (ret || enabled)
a3470f
+                goto out;
a3470f
+
a3470f
+        ret = glusterd_volinfo_get_boolean (volinfo, VKEY_CHANGELOG);
a3470f
+        if (ret < 0) {
a3470f
+                gf_msg ("glusterd", GF_LOG_WARNING, 0,
a3470f
+                        GD_MSG_CHANGELOG_GET_FAIL,
a3470f
+                        "failed to get the changelog status");
a3470f
+                ret = -1;
a3470f
+                goto out;
a3470f
+        }
a3470f
+
a3470f
+        if (ret) {
a3470f
+                enabled = _gf_false;
a3470f
+                glusterd_check_geo_rep_configured (volinfo, &enabled);
a3470f
+
a3470f
+                if (enabled) {
a3470f
+                        gf_msg ("glusterd", GF_LOG_WARNING, 0,
a3470f
+                                GD_MSG_XLATOR_SET_OPT_FAIL,
a3470f
+                                GEOREP" sessions active"
a3470f
+                                "for the volume %s, cannot disable changelog ",
a3470f
+                                volinfo->volname);
a3470f
+                        set_graph_errstr (graph,
a3470f
+                                          VKEY_CHANGELOG" cannot be disabled "
a3470f
+                                          "while "GEOREP" sessions exist");
a3470f
+                        ret = -1;
a3470f
+                        goto out;
a3470f
+                }
a3470f
+        }
a3470f
+
a3470f
+        ret = 0;
a3470f
+ out:
a3470f
+        gf_msg_debug ("glusterd", 0, "Returning %d", ret);
a3470f
+        return ret;
a3470f
+}
a3470f
+
a3470f
+static int
a3470f
 server_check_marker_off (volgen_graph_t *graph, struct volopt_map_entry *vme,
a3470f
                          glusterd_volinfo_t *volinfo)
a3470f
 {
a3470f
@@ -1424,6 +1474,9 @@ server_spec_option_handler (volgen_graph_t *graph,
a3470f
                 ret = server_check_marker_off (graph, vme, volinfo);
a3470f
 
a3470f
         if (!ret)
a3470f
+                ret = server_check_changelog_off (graph, vme, volinfo);
a3470f
+
a3470f
+        if (!ret)
a3470f
                 ret = loglevel_option_handler (graph, vme, "brick");
a3470f
 
a3470f
         if (!ret)
a3470f
-- 
a3470f
1.8.3.1
a3470f