21ab4e
From c58fcc9cfff6d7858febcc53847cda7624c2d982 Mon Sep 17 00:00:00 2001
21ab4e
From: Ashish Pandey <aspandey@redhat.com>
21ab4e
Date: Thu, 22 Jun 2017 17:06:40 +0530
21ab4e
Subject: [PATCH 532/539] ec: Increase notification in all the cases
21ab4e
21ab4e
Problem:
21ab4e
"gluster v heal <volname> info" is taking
21ab4e
long time to respond when a brick is down.
21ab4e
21ab4e
RCA:
21ab4e
Heal info command does virtual mount.
21ab4e
EC wait for 10 seconds, before sending UP call to upper xlator,
21ab4e
to get notification (DOWN or UP) from all the bricks.
21ab4e
21ab4e
Currently, we are increasing ec->xl_notify_count based on
21ab4e
the current status of the brick. So, if a DOWN event notification
21ab4e
has come and brick is already down, we are not increasing
21ab4e
ec->xl_notify_count in ec_handle_down.
21ab4e
21ab4e
Solution:
21ab4e
Handle DOWN even as notification irrespective of what
21ab4e
is the current status of brick.
21ab4e
21ab4e
>Change-Id: I0acac0db7ec7622d4c0584692e88ad52f45a910f
21ab4e
>BUG: 1464091
21ab4e
>Signed-off-by: Ashish Pandey <aspandey@redhat.com>
21ab4e
>Reviewed-on: https://review.gluster.org/17606
21ab4e
>Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
21ab4e
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
21ab4e
>Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
21ab4e
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
>Signed-off-by: Ashish Pandey <aspandey@redhat.com>
21ab4e
21ab4e
Change-Id: I0acac0db7ec7622d4c0584692e88ad52f45a910f
21ab4e
BUG: 1463108
21ab4e
Signed-off-by: Ashish Pandey <aspandey@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/110286
21ab4e
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
21ab4e
---
21ab4e
 xlators/cluster/ec/src/ec.c | 51 ++++++++++++++++++---------------------------
21ab4e
 1 file changed, 20 insertions(+), 31 deletions(-)
21ab4e
21ab4e
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
21ab4e
index bad5578..f1aeea7 100644
21ab4e
--- a/xlators/cluster/ec/src/ec.c
21ab4e
+++ b/xlators/cluster/ec/src/ec.c
21ab4e
@@ -401,35 +401,6 @@ ec_launch_notify_timer (xlator_t *this, ec_t *ec)
21ab4e
         }
21ab4e
 }
21ab4e
 
21ab4e
-void
21ab4e
-ec_handle_up (xlator_t *this, ec_t *ec, int32_t idx)
21ab4e
-{
21ab4e
-        if (((ec->xl_up >> idx) & 1) == 0) { /* Duplicate event */
21ab4e
-                if (((ec->xl_notify >> idx) & 1) == 0) {
21ab4e
-                        ec->xl_notify |= 1ULL << idx;
21ab4e
-                        ec->xl_notify_count++;
21ab4e
-                }
21ab4e
-                ec->xl_up |= 1ULL << idx;
21ab4e
-                ec->xl_up_count++;
21ab4e
-        }
21ab4e
-}
21ab4e
-
21ab4e
-void
21ab4e
-ec_handle_down (xlator_t *this, ec_t *ec, int32_t idx)
21ab4e
-{
21ab4e
-        if (((ec->xl_up >> idx) & 1) != 0) { /* Duplicate event */
21ab4e
-                gf_msg_debug (this->name, 0, "Child %d is DOWN", idx);
21ab4e
-
21ab4e
-                if (((ec->xl_notify >> idx) & 1) == 0) {
21ab4e
-                        ec->xl_notify |= 1ULL << idx;
21ab4e
-                        ec->xl_notify_count++;
21ab4e
-                }
21ab4e
-
21ab4e
-                ec->xl_up ^= 1ULL << idx;
21ab4e
-                ec->xl_up_count--;
21ab4e
-        }
21ab4e
-}
21ab4e
-
21ab4e
 gf_boolean_t
21ab4e
 ec_disable_delays(ec_t *ec)
21ab4e
 {
21ab4e
@@ -446,6 +417,22 @@ ec_pending_fops_completed(ec_t *ec)
21ab4e
         }
21ab4e
 }
21ab4e
 
21ab4e
+static void
21ab4e
+ec_set_up_state(ec_t *ec, uintptr_t index_mask, uintptr_t new_state)
21ab4e
+{
21ab4e
+        uintptr_t current_state = 0;
21ab4e
+
21ab4e
+        if ((ec->xl_notify & index_mask) == 0) {
21ab4e
+                ec->xl_notify |= index_mask;
21ab4e
+                ec->xl_notify_count++;
21ab4e
+        }
21ab4e
+        current_state = ec->xl_up & index_mask;
21ab4e
+        if (current_state != new_state) {
21ab4e
+                ec->xl_up ^= index_mask;
21ab4e
+                ec->xl_up_count += (current_state ? -1 : 1);
21ab4e
+        }
21ab4e
+}
21ab4e
+
21ab4e
 int32_t
21ab4e
 ec_notify (xlator_t *this, int32_t event, void *data, void *data2)
21ab4e
 {
21ab4e
@@ -459,6 +446,7 @@ ec_notify (xlator_t *this, int32_t event, void *data, void *data2)
21ab4e
         int32_t           orig_event = event;
21ab4e
         struct gf_upcall *up_data   = NULL;
21ab4e
         struct gf_upcall_cache_invalidation *up_ci = NULL;
21ab4e
+        uintptr_t mask = 0;
21ab4e
 
21ab4e
         gf_msg_trace (this->name, 0, "NOTIFY(%d): %p, %p",
21ab4e
                 event, data, data2);
21ab4e
@@ -510,10 +498,11 @@ ec_notify (xlator_t *this, int32_t event, void *data, void *data2)
21ab4e
         if (idx < ec->nodes) { /* CHILD_* events */
21ab4e
                 old_event = ec_get_event_from_state (ec);
21ab4e
 
21ab4e
+                mask = 1ULL << idx;
21ab4e
                 if (event == GF_EVENT_CHILD_UP) {
21ab4e
-                        ec_handle_up (this, ec, idx);
21ab4e
+                    ec_set_up_state(ec, mask, mask);
21ab4e
                 } else if (event == GF_EVENT_CHILD_DOWN) {
21ab4e
-                        ec_handle_down (this, ec, idx);
21ab4e
+                    ec_set_up_state(ec, mask, 0);
21ab4e
                 }
21ab4e
 
21ab4e
                 event = ec_get_event_from_state (ec);
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e