d2787b
From 2d172144810956225eac3599c943416c4a7e25d0 Mon Sep 17 00:00:00 2001
d2787b
From: Ravishankar N <ravishankar@redhat.com>
d2787b
Date: Tue, 8 Dec 2020 20:30:23 +0530
d2787b
Subject: [PATCH 489/511] glusterd: fix bug in enabling granular-entry-heal
d2787b
d2787b
Upstream patch details:
d2787b
/------------------------------------------------------------------------------/
d2787b
commit f5e1eb87d4af44be3b317b7f99ab88f89c2f0b1a meant to enable  the
d2787b
volume option only for replica volumes but inadvertently enabled
d2787b
it for all volume types. Fixing it now.
d2787b
d2787b
Also found a bug in glusterd where disabling the option on plain
d2787b
distribute was succeeding even though setting it in the fist place
d2787b
fails. Fixed that too.
d2787b
d2787b
>Fixes: #1483
d2787b
>Change-Id: Icb6c169a8eec44cc4fb4dd636405d3b3485e91b4
d2787b
>Reported-by: Sheetal Pamecha <spamecha@redhat.com>
d2787b
>Signed-off-by: Ravishankar N <ravishankar@redhat.com>
d2787b
Upstream Patch: https://github.com/gluster/glusterfs/pull/1752
d2787b
/------------------------------------------------------------------------------/
d2787b
d2787b
BUG: 1890506
d2787b
Change-Id: Id63655dac08d2cfda4899d7ee0efe96e72cd6986
d2787b
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
d2787b
Reviewed-on: https://code.engineering.redhat.com/gerrit/220556
d2787b
Tested-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d2787b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d2787b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d2787b
---
d2787b
 tests/basic/afr/granular-esh/cli.t              | 30 ++++++++++++++++++++-----
d2787b
 xlators/mgmt/glusterd/src/glusterd-utils.c      |  3 ++-
d2787b
 xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 12 +++++-----
d2787b
 3 files changed, 34 insertions(+), 11 deletions(-)
d2787b
d2787b
diff --git a/tests/basic/afr/granular-esh/cli.t b/tests/basic/afr/granular-esh/cli.t
d2787b
index 995d93e..5ab2e39 100644
d2787b
--- a/tests/basic/afr/granular-esh/cli.t
d2787b
+++ b/tests/basic/afr/granular-esh/cli.t
d2787b
@@ -11,25 +11,38 @@ TESTS_EXPECTED_IN_LOOP=4
d2787b
 TEST glusterd
d2787b
 TEST pidof glusterd
d2787b
 
d2787b
-TEST   $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
d2787b
-# Test that enabling the option should work on a newly created volume
d2787b
-TEST   $CLI volume set $V0 cluster.granular-entry-heal on
d2787b
-TEST   $CLI volume set $V0 cluster.granular-entry-heal off
d2787b
-
d2787b
 #########################
d2787b
 ##### DISPERSE TEST #####
d2787b
 #########################
d2787b
 # Execute the same command on a disperse volume and make sure it fails.
d2787b
 TEST $CLI volume create $V1 disperse 3 redundancy 1 $H0:$B0/${V1}{0,1,2}
d2787b
+EXPECT "no" volume_get_field $V1 cluster.granular-entry-heal
d2787b
+TEST $CLI volume start $V1
d2787b
+TEST ! $CLI volume heal $V1 granular-entry-heal enable
d2787b
+TEST ! $CLI volume heal $V1 granular-entry-heal disable
d2787b
+
d2787b
+TEST $CLI volume stop $V1
d2787b
+TEST $CLI volume delete $V1
d2787b
+
d2787b
+#########################
d2787b
+##### PLAIN DISTRIBUTE TEST #####
d2787b
+#########################
d2787b
+# Execute the same command on a distribute volume and make sure it fails.
d2787b
+TEST $CLI volume create $V1 $H0:$B0/${V1}{0,1,2}
d2787b
+EXPECT "no" volume_get_field $V1 cluster.granular-entry-heal
d2787b
 TEST $CLI volume start $V1
d2787b
 TEST ! $CLI volume heal $V1 granular-entry-heal enable
d2787b
 TEST ! $CLI volume heal $V1 granular-entry-heal disable
d2787b
+TEST $CLI volume stop $V1
d2787b
+TEST $CLI volume delete $V1
d2787b
 
d2787b
 #######################
d2787b
 ###### TIER TEST ######
d2787b
 #######################
d2787b
 # Execute the same command on a disperse + replicate tiered volume and make
d2787b
 # sure the option is set on the replicate leg of the volume
d2787b
+TEST $CLI volume create $V1 disperse 3 redundancy 1 $H0:$B0/${V1}{0,1,2}
d2787b
+TEST $CLI volume start $V1
d2787b
 TEST $CLI volume tier $V1 attach replica 2 $H0:$B0/${V1}{3,4}
d2787b
 TEST $CLI volume heal $V1 granular-entry-heal enable
d2787b
 EXPECT "enable" volume_get_field $V1 cluster.granular-entry-heal
d2787b
@@ -52,10 +65,17 @@ TEST kill_brick $V1 $H0 $B0/${V1}3
d2787b
 # failed.
d2787b
 TEST ! $CLI volume heal $V1 granular-entry-heal enable
d2787b
 EXPECT "disable" volume_get_field $V1 cluster.granular-entry-heal
d2787b
+TEST $CLI volume stop $V1
d2787b
+TEST $CLI volume delete $V1
d2787b
 
d2787b
 ######################
d2787b
 ### REPLICATE TEST ###
d2787b
 ######################
d2787b
+TEST   $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2}
d2787b
+EXPECT "on" volume_get_field $V0 cluster.granular-entry-heal
d2787b
+# Test that enabling the option should work on a newly created volume
d2787b
+TEST   $CLI volume set $V0 cluster.granular-entry-heal on
d2787b
+TEST   $CLI volume set $V0 cluster.granular-entry-heal off
d2787b
 TEST   $CLI volume start $V0
d2787b
 TEST   $CLI volume set $V0 cluster.data-self-heal off
d2787b
 TEST   $CLI volume set $V0 cluster.metadata-self-heal off
d2787b
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
d2787b
index bd17a82..ad3750e 100644
d2787b
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
d2787b
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
d2787b
@@ -13183,7 +13183,8 @@ glusterd_enable_default_options(glusterd_volinfo_t *volinfo, char *option)
d2787b
     }
d2787b
 
d2787b
     if ((conf->op_version >= GD_OP_VERSION_7_1) &&
d2787b
-        (volinfo->status == GLUSTERD_STATUS_NONE)) {
d2787b
+        (volinfo->status == GLUSTERD_STATUS_NONE) &&
d2787b
+        (volinfo->type == GF_CLUSTER_TYPE_REPLICATE)) {
d2787b
         ret = dict_set_dynstr_with_alloc(volinfo->dict,
d2787b
                                          "cluster.granular-entry-heal", "on");
d2787b
         if (ret) {
d2787b
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
d2787b
index 134b04c..09e6ead 100644
d2787b
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
d2787b
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
d2787b
@@ -621,11 +621,13 @@ glusterd_handle_heal_options_enable_disable(rpcsvc_request_t *req, dict_t *dict,
d2787b
         goto out;
d2787b
     }
d2787b
 
d2787b
-    if (((heal_op == GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE) ||
d2787b
-         (heal_op == GF_SHD_OP_GRANULAR_ENTRY_HEAL_DISABLE)) &&
d2787b
-        (volinfo->type == GF_CLUSTER_TYPE_DISPERSE)) {
d2787b
-        ret = -1;
d2787b
-        goto out;
d2787b
+    if ((heal_op == GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE) ||
d2787b
+        (heal_op == GF_SHD_OP_GRANULAR_ENTRY_HEAL_DISABLE)) {
d2787b
+        if ((volinfo->type != GF_CLUSTER_TYPE_REPLICATE) &&
d2787b
+            (volinfo->type != GF_CLUSTER_TYPE_TIER)) {
d2787b
+            ret = -1;
d2787b
+            goto out;
d2787b
+        }
d2787b
     }
d2787b
 
d2787b
     if ((heal_op == GF_SHD_OP_HEAL_ENABLE) ||
d2787b
-- 
d2787b
1.8.3.1
d2787b