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