9ae3f9
From ecaa0f10820f4b6e803021919ce59a43aedf356b Mon Sep 17 00:00:00 2001
9ae3f9
From: Ravishankar N <ravishankar@redhat.com>
9ae3f9
Date: Thu, 4 Jun 2020 16:15:35 +0530
9ae3f9
Subject: [PATCH 402/449] afr: wake up index healer threads
9ae3f9
9ae3f9
...whenever shd is re-enabled after disabling or there is a change in
9ae3f9
`cluster.heal-timeout`, without needing to restart shd or waiting for the
9ae3f9
current `cluster.heal-timeout` seconds to expire.
9ae3f9
9ae3f9
> Upstream patch link:https://review.gluster.org/#/c/glusterfs/+/23288/
9ae3f9
> Change-Id: Ia5ebd7c8e9f5b54cba3199c141fdd1af2f9b9bfe
9ae3f9
> fixes: bz#1744548
9ae3f9
> Reported-by: Glen Kiessling <glenk1973@hotmail.com>
9ae3f9
> Signed-off-by: Ravishankar N <ravishankar@redhat.com>
9ae3f9
9ae3f9
BUG: 1764091
9ae3f9
Change-Id: I42aa0807f09b5a09510fe9efb4a1697dad3410a3
9ae3f9
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
9ae3f9
Reviewed-on: https://code.engineering.redhat.com/gerrit/202368
9ae3f9
Tested-by: RHGS Build Bot <nigelb@redhat.com>
9ae3f9
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
9ae3f9
---
9ae3f9
 tests/bugs/replicate/bug-1744548-heal-timeout.t | 42 +++++++++++++++++++++++++
9ae3f9
 xlators/cluster/afr/src/afr-common.c            |  6 ++--
9ae3f9
 xlators/cluster/afr/src/afr-self-heald.c        | 14 ++++++---
9ae3f9
 xlators/cluster/afr/src/afr-self-heald.h        |  3 --
9ae3f9
 xlators/cluster/afr/src/afr.c                   | 10 ++++++
9ae3f9
 xlators/cluster/afr/src/afr.h                   |  2 ++
9ae3f9
 6 files changed, 66 insertions(+), 11 deletions(-)
9ae3f9
 create mode 100644 tests/bugs/replicate/bug-1744548-heal-timeout.t
9ae3f9
9ae3f9
diff --git a/tests/bugs/replicate/bug-1744548-heal-timeout.t b/tests/bugs/replicate/bug-1744548-heal-timeout.t
9ae3f9
new file mode 100644
9ae3f9
index 0000000..3cb73bc
9ae3f9
--- /dev/null
9ae3f9
+++ b/tests/bugs/replicate/bug-1744548-heal-timeout.t
9ae3f9
@@ -0,0 +1,42 @@
9ae3f9
+#!/bin/bash
9ae3f9
+
9ae3f9
+. $(dirname $0)/../../include.rc
9ae3f9
+. $(dirname $0)/../../volume.rc
9ae3f9
+. $(dirname $0)/../../afr.rc
9ae3f9
+
9ae3f9
+cleanup;
9ae3f9
+
9ae3f9
+TEST glusterd;
9ae3f9
+TEST pidof glusterd;
9ae3f9
+TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2}
9ae3f9
+TEST $CLI volume heal $V0 disable
9ae3f9
+TEST $CLI volume start $V0
9ae3f9
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}0
9ae3f9
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}1
9ae3f9
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}2
9ae3f9
+TEST ! $CLI volume heal $V0
9ae3f9
+
9ae3f9
+# Enable shd and verify that index crawl is triggered immediately.
9ae3f9
+TEST $CLI volume profile $V0 start
9ae3f9
+TEST $CLI volume profile $V0 info clear
9ae3f9
+TEST $CLI volume heal $V0 enable
9ae3f9
+TEST $CLI volume heal $V0
9ae3f9
+# Each brick does 3 opendirs, corresponding to dirty, xattrop and entry-changes
9ae3f9
+COUNT=`$CLI volume profile $V0 info incremental |grep OPENDIR|awk '{print $8}'|tr -d '\n'`
9ae3f9
+TEST [ "$COUNT" == "333" ]
9ae3f9
+
9ae3f9
+# Check that a change in heal-timeout is honoured immediately.
9ae3f9
+TEST $CLI volume set $V0 cluster.heal-timeout 5
9ae3f9
+sleep 10
9ae3f9
+COUNT=`$CLI volume profile $V0 info incremental |grep OPENDIR|awk '{print $8}'|tr -d '\n'`
9ae3f9
+# Two crawls must have happened.
9ae3f9
+TEST [ "$COUNT" == "666" ]
9ae3f9
+
9ae3f9
+# shd must not heal if it is disabled and heal-timeout is changed.
9ae3f9
+TEST $CLI volume heal $V0 disable
9ae3f9
+TEST $CLI volume profile $V0 info clear
9ae3f9
+TEST $CLI volume set $V0 cluster.heal-timeout 6
9ae3f9
+sleep 6
9ae3f9
+COUNT=`$CLI volume profile $V0 info incremental |grep OPENDIR|awk '{print $8}'|tr -d '\n'`
9ae3f9
+TEST [ -z $COUNT ]
9ae3f9
+cleanup;
9ae3f9
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
9ae3f9
index 3690b84..eef7fd2 100644
9ae3f9
--- a/xlators/cluster/afr/src/afr-common.c
9ae3f9
+++ b/xlators/cluster/afr/src/afr-common.c
9ae3f9
@@ -5613,10 +5613,8 @@ afr_notify(xlator_t *this, int32_t event, void *data, void *data2)
9ae3f9
          * b) Already heard from everyone, but we now got a child-up
9ae3f9
          *    event.
9ae3f9
          */
9ae3f9
-        if (have_heard_from_all && priv->shd.iamshd) {
9ae3f9
-            for (i = 0; i < priv->child_count; i++)
9ae3f9
-                if (priv->child_up[i])
9ae3f9
-                    afr_selfheal_childup(this, i);
9ae3f9
+        if (have_heard_from_all) {
9ae3f9
+            afr_selfheal_childup(this, priv);
9ae3f9
         }
9ae3f9
     }
9ae3f9
 out:
9ae3f9
diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
9ae3f9
index 7eb1207..95ac5f2 100644
9ae3f9
--- a/xlators/cluster/afr/src/afr-self-heald.c
9ae3f9
+++ b/xlators/cluster/afr/src/afr-self-heald.c
9ae3f9
@@ -1258,12 +1258,18 @@ out:
9ae3f9
     return ret;
9ae3f9
 }
9ae3f9
 
9ae3f9
-int
9ae3f9
-afr_selfheal_childup(xlator_t *this, int subvol)
9ae3f9
+void
9ae3f9
+afr_selfheal_childup(xlator_t *this, afr_private_t *priv)
9ae3f9
 {
9ae3f9
-    afr_shd_index_healer_spawn(this, subvol);
9ae3f9
+    int subvol = 0;
9ae3f9
 
9ae3f9
-    return 0;
9ae3f9
+    if (!priv->shd.iamshd)
9ae3f9
+        return;
9ae3f9
+    for (subvol = 0; subvol < priv->child_count; subvol++)
9ae3f9
+        if (priv->child_up[subvol])
9ae3f9
+            afr_shd_index_healer_spawn(this, subvol);
9ae3f9
+
9ae3f9
+    return;
9ae3f9
 }
9ae3f9
 
9ae3f9
 int
9ae3f9
diff --git a/xlators/cluster/afr/src/afr-self-heald.h b/xlators/cluster/afr/src/afr-self-heald.h
9ae3f9
index 7de7c43..1990539 100644
9ae3f9
--- a/xlators/cluster/afr/src/afr-self-heald.h
9ae3f9
+++ b/xlators/cluster/afr/src/afr-self-heald.h
9ae3f9
@@ -60,9 +60,6 @@ typedef struct {
9ae3f9
 } afr_self_heald_t;
9ae3f9
 
9ae3f9
 int
9ae3f9
-afr_selfheal_childup(xlator_t *this, int subvol);
9ae3f9
-
9ae3f9
-int
9ae3f9
 afr_selfheal_daemon_init(xlator_t *this);
9ae3f9
 
9ae3f9
 int
9ae3f9
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
9ae3f9
index 33258a0..8f9e71f 100644
9ae3f9
--- a/xlators/cluster/afr/src/afr.c
9ae3f9
+++ b/xlators/cluster/afr/src/afr.c
9ae3f9
@@ -141,6 +141,7 @@ reconfigure(xlator_t *this, dict_t *options)
9ae3f9
     afr_private_t *priv = NULL;
9ae3f9
     xlator_t *read_subvol = NULL;
9ae3f9
     int read_subvol_index = -1;
9ae3f9
+    int timeout_old = 0;
9ae3f9
     int ret = -1;
9ae3f9
     int index = -1;
9ae3f9
     char *qtype = NULL;
9ae3f9
@@ -150,6 +151,7 @@ reconfigure(xlator_t *this, dict_t *options)
9ae3f9
     char *locking_scheme = NULL;
9ae3f9
     gf_boolean_t consistent_io = _gf_false;
9ae3f9
     gf_boolean_t choose_local_old = _gf_false;
9ae3f9
+    gf_boolean_t enabled_old = _gf_false;
9ae3f9
 
9ae3f9
     priv = this->private;
9ae3f9
 
9ae3f9
@@ -255,11 +257,13 @@ reconfigure(xlator_t *this, dict_t *options)
9ae3f9
     GF_OPTION_RECONF("ensure-durability", priv->ensure_durability, options,
9ae3f9
                      bool, out);
9ae3f9
 
9ae3f9
+    enabled_old = priv->shd.enabled;
9ae3f9
     GF_OPTION_RECONF("self-heal-daemon", priv->shd.enabled, options, bool, out);
9ae3f9
 
9ae3f9
     GF_OPTION_RECONF("iam-self-heal-daemon", priv->shd.iamshd, options, bool,
9ae3f9
                      out);
9ae3f9
 
9ae3f9
+    timeout_old = priv->shd.timeout;
9ae3f9
     GF_OPTION_RECONF("heal-timeout", priv->shd.timeout, options, int32, out);
9ae3f9
 
9ae3f9
     GF_OPTION_RECONF("consistent-metadata", priv->consistent_metadata, options,
9ae3f9
@@ -283,6 +287,12 @@ reconfigure(xlator_t *this, dict_t *options)
9ae3f9
         consistent_io = _gf_false;
9ae3f9
     priv->consistent_io = consistent_io;
9ae3f9
 
9ae3f9
+    if (priv->shd.enabled) {
9ae3f9
+        if ((priv->shd.enabled != enabled_old) ||
9ae3f9
+            (timeout_old != priv->shd.timeout))
9ae3f9
+            afr_selfheal_childup(this, priv);
9ae3f9
+    }
9ae3f9
+
9ae3f9
     ret = 0;
9ae3f9
 out:
9ae3f9
     return ret;
9ae3f9
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
9ae3f9
index e731cfa..18f1a6a 100644
9ae3f9
--- a/xlators/cluster/afr/src/afr.h
9ae3f9
+++ b/xlators/cluster/afr/src/afr.h
9ae3f9
@@ -1332,4 +1332,6 @@ afr_lookup_has_quorum(call_frame_t *frame, xlator_t *this,
9ae3f9
 void
9ae3f9
 afr_mark_new_entry_changelog(call_frame_t *frame, xlator_t *this);
9ae3f9
 
9ae3f9
+void
9ae3f9
+afr_selfheal_childup(xlator_t *this, afr_private_t *priv);
9ae3f9
 #endif /* __AFR_H__ */
9ae3f9
-- 
9ae3f9
1.8.3.1
9ae3f9