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