b7d4d7
From c963653a89c3f6466af9a3e8f19246a7907f7f8c Mon Sep 17 00:00:00 2001
b7d4d7
From: nik-redhat <nladha@redhat.com>
b7d4d7
Date: Thu, 30 Jul 2020 13:04:52 +0530
b7d4d7
Subject: [PATCH 512/517] glusterd: shared storage mount fails in ipv6
b7d4d7
 environment
b7d4d7
b7d4d7
Issue:
b7d4d7
In case of ipv6 environment, the mounting of glusterd_shared_storage
b7d4d7
volume fails as it doesn't recognises the ipv6 enviornment.
b7d4d7
b7d4d7
Fix:
b7d4d7
In case of ipv6 environment, the address-family is passed
b7d4d7
to the hooks script on creating shared-storage, then depending
b7d4d7
upon the address-family --xlator-option=transport.address-family=inet6
b7d4d7
option is added to the mount command, and the mounting succeeds.
b7d4d7
b7d4d7
>Fixes: #1406
b7d4d7
>
b7d4d7
>Change-Id: Ib1888c34d85e6c01618b0ba214cbe1f57576908d
b7d4d7
>Signed-off-by: nik-redhat <nladha@redhat.com>
b7d4d7
b7d4d7
Upstream patch: https://review.gluster.org/c/glusterfs/+/24797
b7d4d7
BUG: 1856574
b7d4d7
b7d4d7
Change-Id: Ib1888c34d85e6c01618b0ba214cbe1f57576908d
b7d4d7
Signed-off-by: nik-redhat <nladha@redhat.com>
b7d4d7
Reviewed-on: https://code.engineering.redhat.com/gerrit/221844
b7d4d7
Tested-by: RHGS Build Bot <nigelb@redhat.com>
b7d4d7
Reviewed-by: Srijan Sivakumar <ssivakum@redhat.com>
b7d4d7
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
b7d4d7
---
b7d4d7
 .../set/post/S32gluster_enable_shared_storage.sh      | 11 +++++++++--
b7d4d7
 xlators/mgmt/glusterd/src/glusterd-hooks.c            | 19 +++++++++++++++++++
b7d4d7
 2 files changed, 28 insertions(+), 2 deletions(-)
b7d4d7
b7d4d7
diff --git a/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh b/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh
b7d4d7
index 3bae37c..9597503 100755
b7d4d7
--- a/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh
b7d4d7
+++ b/extras/hook-scripts/set/post/S32gluster_enable_shared_storage.sh
b7d4d7
@@ -104,8 +104,15 @@ function check_volume_status()
b7d4d7
     echo $status
b7d4d7
 }
b7d4d7
 
b7d4d7
-mount_cmd="mount -t glusterfs $local_node_hostname:/gluster_shared_storage \
b7d4d7
-           /run/gluster/shared_storage"
b7d4d7
+key=`echo $5 | cut -d '=' -f 1`
b7d4d7
+val=`echo $5 | cut -d '=' -f 2`
b7d4d7
+if [ "$key" == "transport.address-family" ]; then
b7d4d7
+    mount_cmd="mount -t glusterfs -o xlator-option=transport.address-family=inet6 \
b7d4d7
+               $local_node_hostname:/gluster_shared_storage /var/run/gluster/shared_storage"
b7d4d7
+else
b7d4d7
+    mount_cmd="mount -t glusterfs $local_node_hostname:/gluster_shared_storage \
b7d4d7
+           /var/run/gluster/shared_storage"
b7d4d7
+fi
b7d4d7
 
b7d4d7
 if [ "$option" == "enable" ]; then
b7d4d7
     retry=0;
b7d4d7
diff --git a/xlators/mgmt/glusterd/src/glusterd-hooks.c b/xlators/mgmt/glusterd/src/glusterd-hooks.c
b7d4d7
index 216cdf7..4f0d775 100644
b7d4d7
--- a/xlators/mgmt/glusterd/src/glusterd-hooks.c
b7d4d7
+++ b/xlators/mgmt/glusterd/src/glusterd-hooks.c
b7d4d7
@@ -200,11 +200,16 @@ glusterd_hooks_set_volume_args(dict_t *dict, runner_t *runner)
b7d4d7
     int i = 0;
b7d4d7
     int count = 0;
b7d4d7
     int ret = -1;
b7d4d7
+    int flag = 0;
b7d4d7
     char query[1024] = {
b7d4d7
         0,
b7d4d7
     };
b7d4d7
     char *key = NULL;
b7d4d7
     char *value = NULL;
b7d4d7
+    char *inet_family = NULL;
b7d4d7
+    xlator_t *this = NULL;
b7d4d7
+    this = THIS;
b7d4d7
+    GF_ASSERT(this);
b7d4d7
 
b7d4d7
     ret = dict_get_int32(dict, "count", &count);
b7d4d7
     if (ret)
b7d4d7
@@ -228,9 +233,23 @@ glusterd_hooks_set_volume_args(dict_t *dict, runner_t *runner)
b7d4d7
             continue;
b7d4d7
 
b7d4d7
         runner_argprintf(runner, "%s=%s", key, value);
b7d4d7
+        if ((strncmp(key, "cluster.enable-shared-storage",
b7d4d7
+                     SLEN("cluster.enable-shared-storage")) == 0 ||
b7d4d7
+             strncmp(key, "enable-shared-storage",
b7d4d7
+                     SLEN("enable-shared-storage")) == 0) &&
b7d4d7
+            strncmp(value, "enable", SLEN("enable")) == 0)
b7d4d7
+            flag = 1;
b7d4d7
     }
b7d4d7
 
b7d4d7
     glusterd_hooks_add_custom_args(dict, runner);
b7d4d7
+    if (flag == 1) {
b7d4d7
+        ret = dict_get_str_sizen(this->options, "transport.address-family",
b7d4d7
+                                 &inet_family);
b7d4d7
+        if (!ret) {
b7d4d7
+            runner_argprintf(runner, "transport.address-family=%s",
b7d4d7
+                             inet_family);
b7d4d7
+        }
b7d4d7
+    }
b7d4d7
 
b7d4d7
     ret = 0;
b7d4d7
 out:
b7d4d7
-- 
b7d4d7
1.8.3.1
b7d4d7