9ae3f9
From 86df0ced1cac0e3c48f6149bb2f5442f8548f89e Mon Sep 17 00:00:00 2001
9ae3f9
From: Sanju Rakonde <srakonde@redhat.com>
9ae3f9
Date: Wed, 25 Dec 2019 21:56:32 +0530
9ae3f9
Subject: [PATCH 390/449] glusterd: deafult options after volume reset
9ae3f9
9ae3f9
Problem: default option itransport.address-family is disappered
9ae3f9
in volume info output after a volume reset.
9ae3f9
9ae3f9
Cause: with 3.8.0 onwards volume option transport.address-family
9ae3f9
has default value, any volume which is created will have this
9ae3f9
option set. So, volume info will show this in its output. But,
9ae3f9
with reset volume, this option is not handled.
9ae3f9
9ae3f9
Solution: In glusterd_enable_default_options(), we should add this
9ae3f9
option along with other default options. This function is called
9ae3f9
by glusterd_options_reset() with volume reset command.
9ae3f9
9ae3f9
> upstream patch link: https://review.gluster.org/#/c/glusterfs/+/23921/
9ae3f9
> fixes: bz#1786478
9ae3f9
> Change-Id: I58f7aa24cf01f308c4efe6cae748cc3bc8b99b1d
9ae3f9
> Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
9ae3f9
9ae3f9
BUG: 1781710
9ae3f9
Change-Id: I58f7aa24cf01f308c4efe6cae748cc3bc8b99b1d
9ae3f9
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
9ae3f9
Reviewed-on: https://code.engineering.redhat.com/gerrit/202258
9ae3f9
Tested-by: RHGS Build Bot <nigelb@redhat.com>
9ae3f9
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
9ae3f9
---
9ae3f9
 tests/bugs/glusterd/optimized-basic-testcases.t |  5 +++++
9ae3f9
 xlators/mgmt/glusterd/src/glusterd-utils.c      | 23 +++++++++++++++++++++++
9ae3f9
 2 files changed, 28 insertions(+)
9ae3f9
9ae3f9
diff --git a/tests/bugs/glusterd/optimized-basic-testcases.t b/tests/bugs/glusterd/optimized-basic-testcases.t
9ae3f9
index d700b5e..c7e8c32 100644
9ae3f9
--- a/tests/bugs/glusterd/optimized-basic-testcases.t
9ae3f9
+++ b/tests/bugs/glusterd/optimized-basic-testcases.t
9ae3f9
@@ -69,6 +69,11 @@ TEST pidof glusterd;
9ae3f9
 TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2};
9ae3f9
 EXPECT 'Created' volinfo_field $V0 'Status';
9ae3f9
 
9ae3f9
+#bug-1786478 - default volume option after volume reset
9ae3f9
+addr_family=`volinfo_field $V0 'transport.address-family'`
9ae3f9
+TEST $CLI volume reset $V0
9ae3f9
+EXPECT $addr_family  volinfo_field $V0 'transport.address-family'
9ae3f9
+
9ae3f9
 #bug-955588 - uuid validation
9ae3f9
 
9ae3f9
 uuid=`grep UUID $GLUSTERD_WORKDIR/glusterd.info | cut -f2 -d=`
9ae3f9
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
9ae3f9
index c92cdf3..6654741 100644
9ae3f9
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
9ae3f9
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
9ae3f9
@@ -13032,6 +13032,11 @@ glusterd_enable_default_options(glusterd_volinfo_t *volinfo, char *option)
9ae3f9
     int ret = 0;
9ae3f9
     xlator_t *this = NULL;
9ae3f9
     glusterd_conf_t *conf = NULL;
9ae3f9
+#ifdef IPV6_DEFAULT
9ae3f9
+    char *addr_family = "inet6";
9ae3f9
+#else
9ae3f9
+    char *addr_family = "inet";
9ae3f9
+#endif
9ae3f9
 
9ae3f9
     this = THIS;
9ae3f9
     GF_ASSERT(this);
9ae3f9
@@ -13109,6 +13114,24 @@ glusterd_enable_default_options(glusterd_volinfo_t *volinfo, char *option)
9ae3f9
             }
9ae3f9
         }
9ae3f9
     }
9ae3f9
+
9ae3f9
+    if (conf->op_version >= GD_OP_VERSION_3_9_0) {
9ae3f9
+        if (!option || !strcmp("transport.address-family", option)) {
9ae3f9
+            if (volinfo->transport_type == GF_TRANSPORT_TCP) {
9ae3f9
+                ret = dict_set_dynstr_with_alloc(
9ae3f9
+                    volinfo->dict, "transport.address-family", addr_family);
9ae3f9
+                if (ret) {
9ae3f9
+                    gf_msg(this->name, GF_LOG_ERROR, errno,
9ae3f9
+                           GD_MSG_DICT_SET_FAILED,
9ae3f9
+                           "failed to set transport."
9ae3f9
+                           "address-family on %s",
9ae3f9
+                           volinfo->volname);
9ae3f9
+                    goto out;
9ae3f9
+                }
9ae3f9
+            }
9ae3f9
+        }
9ae3f9
+    }
9ae3f9
+
9ae3f9
     if (conf->op_version >= GD_OP_VERSION_7_0) {
9ae3f9
         ret = dict_set_dynstr_with_alloc(volinfo->dict,
9ae3f9
                                          "storage.fips-mode-rchecksum", "on");
9ae3f9
-- 
9ae3f9
1.8.3.1
9ae3f9