f338ef
From f0c3af09fd919e3646aae2821b0d6bfe4e2fd89c Mon Sep 17 00:00:00 2001
f338ef
From: Mohammed Rafi KC <rkavunga@redhat.com>
f338ef
Date: Thu, 11 Jul 2019 12:45:58 +0530
f338ef
Subject: [PATCH 237/255] Revert "ec/fini: Fix race between xlator cleanup and
f338ef
 on going async fop"
f338ef
f338ef
This reverts commit 9fd966aa6879ac9867381629f82eca24b950d731.
f338ef
f338ef
BUG: 1471742
f338ef
Change-Id: I557ec138174b01d8b8f8d090acd34c179e2c632d
f338ef
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
f338ef
Reviewed-on: https://code.engineering.redhat.com/gerrit/175946
f338ef
Tested-by: RHGS Build Bot <nigelb@redhat.com>
f338ef
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
f338ef
---
f338ef
 xlators/cluster/ec/src/ec-common.c | 10 ----------
f338ef
 xlators/cluster/ec/src/ec-common.h |  2 --
f338ef
 xlators/cluster/ec/src/ec-data.c   |  4 +---
f338ef
 xlators/cluster/ec/src/ec-heal.c   | 17 ++---------------
f338ef
 xlators/cluster/ec/src/ec-types.h  |  1 -
f338ef
 xlators/cluster/ec/src/ec.c        | 37 ++++++++++++-------------------------
f338ef
 6 files changed, 15 insertions(+), 56 deletions(-)
f338ef
f338ef
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
f338ef
index 35c2256..e2e582f 100644
f338ef
--- a/xlators/cluster/ec/src/ec-common.c
f338ef
+++ b/xlators/cluster/ec/src/ec-common.c
f338ef
@@ -2956,13 +2956,3 @@ ec_manager(ec_fop_data_t *fop, int32_t error)
f338ef
 
f338ef
     __ec_manager(fop, error);
f338ef
 }
f338ef
-
f338ef
-gf_boolean_t
f338ef
-__ec_is_last_fop(ec_t *ec)
f338ef
-{
f338ef
-    if ((list_empty(&ec->pending_fops)) &&
f338ef
-        (GF_ATOMIC_GET(ec->async_fop_count) == 0)) {
f338ef
-        return _gf_true;
f338ef
-    }
f338ef
-    return _gf_false;
f338ef
-}
f338ef
diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h
f338ef
index bf6c97d..e948342 100644
f338ef
--- a/xlators/cluster/ec/src/ec-common.h
f338ef
+++ b/xlators/cluster/ec/src/ec-common.h
f338ef
@@ -204,6 +204,4 @@ void
f338ef
 ec_reset_entry_healing(ec_fop_data_t *fop);
f338ef
 char *
f338ef
 ec_msg_str(ec_fop_data_t *fop);
f338ef
-gf_boolean_t
f338ef
-__ec_is_last_fop(ec_t *ec);
f338ef
 #endif /* __EC_COMMON_H__ */
f338ef
diff --git a/xlators/cluster/ec/src/ec-data.c b/xlators/cluster/ec/src/ec-data.c
f338ef
index 8d2d9a1..6ef9340 100644
f338ef
--- a/xlators/cluster/ec/src/ec-data.c
f338ef
+++ b/xlators/cluster/ec/src/ec-data.c
f338ef
@@ -202,13 +202,11 @@ ec_handle_last_pending_fop_completion(ec_fop_data_t *fop, gf_boolean_t *notify)
f338ef
 {
f338ef
     ec_t *ec = fop->xl->private;
f338ef
 
f338ef
-    *notify = _gf_false;
f338ef
-
f338ef
     if (!list_empty(&fop->pending_list)) {
f338ef
         LOCK(&ec->lock);
f338ef
         {
f338ef
             list_del_init(&fop->pending_list);
f338ef
-            *notify = __ec_is_last_fop(ec);
f338ef
+            *notify = list_empty(&ec->pending_fops);
f338ef
         }
f338ef
         UNLOCK(&ec->lock);
f338ef
     }
f338ef
diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c
f338ef
index 237fea2..8844c29 100644
f338ef
--- a/xlators/cluster/ec/src/ec-heal.c
f338ef
+++ b/xlators/cluster/ec/src/ec-heal.c
f338ef
@@ -2814,20 +2814,8 @@ int
f338ef
 ec_replace_heal_done(int ret, call_frame_t *heal, void *opaque)
f338ef
 {
f338ef
     ec_t *ec = opaque;
f338ef
-    gf_boolean_t last_fop = _gf_false;
f338ef
 
f338ef
-    if (GF_ATOMIC_DEC(ec->async_fop_count) == 0) {
f338ef
-        LOCK(&ec->lock);
f338ef
-        {
f338ef
-            last_fop = __ec_is_last_fop(ec);
f338ef
-        }
f338ef
-        UNLOCK(&ec->lock);
f338ef
-    }
f338ef
     gf_msg_debug(ec->xl->name, 0, "getxattr on bricks is done ret %d", ret);
f338ef
-
f338ef
-    if (last_fop)
f338ef
-        ec_pending_fops_completed(ec);
f338ef
-
f338ef
     return 0;
f338ef
 }
f338ef
 
f338ef
@@ -2881,15 +2869,14 @@ ec_launch_replace_heal(ec_t *ec)
f338ef
 {
f338ef
     int ret = -1;
f338ef
 
f338ef
+    if (!ec)
f338ef
+        return ret;
f338ef
     ret = synctask_new(ec->xl->ctx->env, ec_replace_brick_heal_wrap,
f338ef
                        ec_replace_heal_done, NULL, ec);
f338ef
-
f338ef
     if (ret < 0) {
f338ef
         gf_msg_debug(ec->xl->name, 0, "Heal failed for replace brick ret = %d",
f338ef
                      ret);
f338ef
-        ec_replace_heal_done(-1, NULL, ec);
f338ef
     }
f338ef
-
f338ef
     return ret;
f338ef
 }
f338ef
 
f338ef
diff --git a/xlators/cluster/ec/src/ec-types.h b/xlators/cluster/ec/src/ec-types.h
f338ef
index 4dbf4a3..1c295c0 100644
f338ef
--- a/xlators/cluster/ec/src/ec-types.h
f338ef
+++ b/xlators/cluster/ec/src/ec-types.h
f338ef
@@ -643,7 +643,6 @@ struct _ec {
f338ef
     uintptr_t xl_notify;      /* Bit flag representing
f338ef
                                  notification for bricks. */
f338ef
     uintptr_t node_mask;
f338ef
-    gf_atomic_t async_fop_count; /* Number of on going asynchronous fops. */
f338ef
     xlator_t **xl_list;
f338ef
     gf_lock_t lock;
f338ef
     gf_timer_t *timer;
f338ef
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
f338ef
index f0d58c0..df5912c 100644
f338ef
--- a/xlators/cluster/ec/src/ec.c
f338ef
+++ b/xlators/cluster/ec/src/ec.c
f338ef
@@ -355,7 +355,6 @@ ec_notify_cbk(void *data)
f338ef
     ec_t *ec = data;
f338ef
     glusterfs_event_t event = GF_EVENT_MAXVAL;
f338ef
     gf_boolean_t propagate = _gf_false;
f338ef
-    gf_boolean_t launch_heal = _gf_false;
f338ef
 
f338ef
     LOCK(&ec->lock);
f338ef
     {
f338ef
@@ -385,11 +384,6 @@ ec_notify_cbk(void *data)
f338ef
              * still bricks DOWN, they will be healed when they
f338ef
              * come up. */
f338ef
             ec_up(ec->xl, ec);
f338ef
-
f338ef
-            if (ec->shd.iamshd && !ec->shutdown) {
f338ef
-                launch_heal = _gf_true;
f338ef
-                GF_ATOMIC_INC(ec->async_fop_count);
f338ef
-            }
f338ef
         }
f338ef
 
f338ef
         propagate = _gf_true;
f338ef
@@ -397,12 +391,13 @@ ec_notify_cbk(void *data)
f338ef
 unlock:
f338ef
     UNLOCK(&ec->lock);
f338ef
 
f338ef
-    if (launch_heal) {
f338ef
-        /* We have just brought the volume UP, so we trigger
f338ef
-         * a self-heal check on the root directory. */
f338ef
-        ec_launch_replace_heal(ec);
f338ef
-    }
f338ef
     if (propagate) {
f338ef
+        if ((event == GF_EVENT_CHILD_UP) && ec->shd.iamshd) {
f338ef
+            /* We have just brought the volume UP, so we trigger
f338ef
+             * a self-heal check on the root directory. */
f338ef
+            ec_launch_replace_heal(ec);
f338ef
+        }
f338ef
+
f338ef
         default_notify(ec->xl, event, NULL);
f338ef
     }
f338ef
 }
f338ef
@@ -430,7 +425,7 @@ ec_disable_delays(ec_t *ec)
f338ef
 {
f338ef
     ec->shutdown = _gf_true;
f338ef
 
f338ef
-    return __ec_is_last_fop(ec);
f338ef
+    return list_empty(&ec->pending_fops);
f338ef
 }
f338ef
 
f338ef
 void
f338ef
@@ -608,10 +603,7 @@ ec_notify(xlator_t *this, int32_t event, void *data, void *data2)
f338ef
         if (event == GF_EVENT_CHILD_UP) {
f338ef
             /* We need to trigger a selfheal if a brick changes
f338ef
              * to UP state. */
f338ef
-            if (ec_set_up_state(ec, mask, mask) && ec->shd.iamshd &&
f338ef
-                !ec->shutdown) {
f338ef
-                needs_shd_check = _gf_true;
f338ef
-            }
f338ef
+            needs_shd_check = ec_set_up_state(ec, mask, mask);
f338ef
         } else if (event == GF_EVENT_CHILD_DOWN) {
f338ef
             ec_set_up_state(ec, mask, 0);
f338ef
         }
f338ef
@@ -641,21 +633,17 @@ ec_notify(xlator_t *this, int32_t event, void *data, void *data2)
f338ef
             }
f338ef
         } else {
f338ef
             propagate = _gf_false;
f338ef
-            needs_shd_check = _gf_false;
f338ef
-        }
f338ef
-
f338ef
-        if (needs_shd_check) {
f338ef
-            GF_ATOMIC_INC(ec->async_fop_count);
f338ef
         }
f338ef
     }
f338ef
 unlock:
f338ef
     UNLOCK(&ec->lock);
f338ef
 
f338ef
 done:
f338ef
-    if (needs_shd_check) {
f338ef
-        ec_launch_replace_heal(ec);
f338ef
-    }
f338ef
     if (propagate) {
f338ef
+        if (needs_shd_check && ec->shd.iamshd) {
f338ef
+            ec_launch_replace_heal(ec);
f338ef
+        }
f338ef
+
f338ef
         error = default_notify(this, event, data);
f338ef
     }
f338ef
 
f338ef
@@ -717,7 +705,6 @@ init(xlator_t *this)
f338ef
     ec->xl = this;
f338ef
     LOCK_INIT(&ec->lock);
f338ef
 
f338ef
-    GF_ATOMIC_INIT(ec->async_fop_count, 0);
f338ef
     INIT_LIST_HEAD(&ec->pending_fops);
f338ef
     INIT_LIST_HEAD(&ec->heal_waiting);
f338ef
     INIT_LIST_HEAD(&ec->healing);
f338ef
-- 
f338ef
1.8.3.1
f338ef