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