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