a3470f
From e849b8d24e97b7e8e9f0bd0ab7d49c748a5897fa Mon Sep 17 00:00:00 2001
a3470f
From: Sanju Rakonde <srakonde@redhat.com>
a3470f
Date: Wed, 1 Aug 2018 15:09:08 +0530
a3470f
Subject: [PATCH 334/351] glusterd: Bricks of a normal volumes should not
a3470f
 attach to gluster_shared_storage bricks
a3470f
a3470f
Problem: In a brick multiplexing environment, Bricks of a normal volume
a3470f
created by user are getting attached to the bricks of a volume
a3470f
"gluster_shared_storage" which is created by enabling the
a3470f
enable-shared-storage option. Mounting gluster_shared_storage
a3470f
has strict authentication checks. when we attach bricks of a normal
a3470f
volume to bricks of gluster_shared_storage, mounting the normal
a3470f
volume created by user will fail due to strict authentication checks.
a3470f
a3470f
Solution: We should not attach bricks of a normal volume to brick
a3470f
process of gluster_shared_storage volume and vice versa.
a3470f
a3470f
>fixes: bz#1610726
a3470f
>Change-Id: If1b5a2a02675789a2915ba480fb48c145449163d
a3470f
>Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
a3470f
a3470f
upstream patch: https://review.gluster.org/#/c/20604/
a3470f
a3470f
Change-Id: If1b5a2a02675789a2915ba480fb48c145449163d
a3470f
BUG: 1609163
a3470f
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/146221
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
---
a3470f
 .../glusterd/brick-mux-validation-in-cluster.t     | 51 ++++++++++++++++++++++
a3470f
 xlators/mgmt/glusterd/src/glusterd-utils.c         | 14 ++++++
a3470f
 2 files changed, 65 insertions(+)
a3470f
 create mode 100644 tests/bugs/glusterd/brick-mux-validation-in-cluster.t
a3470f
a3470f
diff --git a/tests/bugs/glusterd/brick-mux-validation-in-cluster.t b/tests/bugs/glusterd/brick-mux-validation-in-cluster.t
a3470f
new file mode 100644
a3470f
index 0000000..4e57038
a3470f
--- /dev/null
a3470f
+++ b/tests/bugs/glusterd/brick-mux-validation-in-cluster.t
a3470f
@@ -0,0 +1,51 @@
a3470f
+#!/bin/bash
a3470f
+
a3470f
+. $(dirname $0)/../../include.rc
a3470f
+. $(dirname $0)/../../cluster.rc
a3470f
+
a3470f
+function count_brick_processes {
a3470f
+        pgrep glusterfsd | wc -l
a3470f
+}
a3470f
+
a3470f
+cleanup;
a3470f
+
a3470f
+TEST launch_cluster 3
a3470f
+TEST $CLI_1 peer probe $H2;
a3470f
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count
a3470f
+
a3470f
+TEST $CLI_1 peer probe $H3;
a3470f
+EXPECT_WITHIN $PROBE_TIMEOUT 2 peer_count
a3470f
+
a3470f
+TEST $CLI_1 volume set all cluster.brick-multiplex on
a3470f
+#bug-1609163 - bricks of normal volume should not attach to bricks of gluster_shared_storage volume
a3470f
+
a3470f
+##Create, start and mount meta_volume i.e., shared_storage
a3470f
+TEST $CLI_1 volume create $META_VOL replica 3 $H1:$B1/${META_VOL}1 $H2:$B2/${META_VOL}1 $H3:$B3/${META_VOL}1
a3470f
+TEST $CLI_1 volume start $META_VOL
a3470f
+TEST mkdir -p $META_MNT
a3470f
+TEST glusterfs -s $H1 --volfile-id $META_VOL $META_MNT
a3470f
+
a3470f
+TEST $CLI_1 volume info gluster_shared_storage
a3470f
+
a3470f
+EXPECT 3 count_brick_processes
a3470f
+
a3470f
+#create and start a new volume
a3470f
+TEST $CLI_1 volume create $V0 replica 3 $H1:$B1/${V0}{1..3} $H2:$B2/${V0}{1..3}
a3470f
+TEST $CLI_1 volume start $V0
a3470f
+
a3470f
+# bricks of normal volume should not attach to bricks of gluster_shared_storage volume
a3470f
+EXPECT 5 count_brick_processes
a3470f
+
a3470f
+#bug-1549996 - stale brick processes on the nodes after volume deletion
a3470f
+
a3470f
+TEST $CLI_1 volume create $V1 replica 3 $H1:$B1/${V1}{1..3} $H2:$B2/${V1}{1..3}
a3470f
+TEST $CLI_1 volume start $V1
a3470f
+
a3470f
+EXPECT 5 count_brick_processes
a3470f
+
a3470f
+TEST $CLI_1 volume stop $V0
a3470f
+TEST $CLI_1 volume stop $V1
a3470f
+
a3470f
+EXPECT 3 count_brick_processes
a3470f
+
a3470f
+cleanup
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
a3470f
index fe9cc75..80204e4 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
a3470f
@@ -5710,6 +5710,7 @@ find_compat_brick_in_vol (glusterd_conf_t *conf,
a3470f
         int                     mux_limit               = -1;
a3470f
         int                     ret                     = -1;
a3470f
         gf_boolean_t            brick_status            = _gf_false;
a3470f
+        gf_boolean_t            is_shared_storage       = _gf_false;
a3470f
 
a3470f
         /*
a3470f
          * If comp_vol is provided, we have to check *volume* compatibility
a3470f
@@ -5717,6 +5718,19 @@ find_compat_brick_in_vol (glusterd_conf_t *conf,
a3470f
          */
a3470f
         if (comp_vol) {
a3470f
                 /*
a3470f
+                 * We should not attach bricks of a normal volume to bricks
a3470f
+                 * of shared storage volume.
a3470f
+                 */
a3470f
+                if (!strcmp (srch_vol->volname, GLUSTER_SHARED_STORAGE))
a3470f
+                        is_shared_storage = _gf_true;
a3470f
+
a3470f
+                if (!strcmp (comp_vol->volname, GLUSTER_SHARED_STORAGE)) {
a3470f
+                        if (!is_shared_storage)
a3470f
+                                return NULL;
a3470f
+                } else if (is_shared_storage)
a3470f
+                        return NULL;
a3470f
+
a3470f
+                /*
a3470f
                  * It's kind of a shame that we have to do this check in both
a3470f
                  * directions, but an option might only exist on one of the two
a3470f
                  * dictionaries and dict_foreach_match will only find that one.
a3470f
-- 
a3470f
1.8.3.1
a3470f