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