e3c68b
From f6d967cd70ff41a0f93c54d50128c468e9d5dea9 Mon Sep 17 00:00:00 2001
e3c68b
From: Mohammed Rafi KC <rkavunga@redhat.com>
e3c68b
Date: Thu, 11 Jul 2019 12:49:21 +0530
e3c68b
Subject: [PATCH 244/255] Revert "ec/shd: Cleanup self heal daemon resources
e3c68b
 during ec fini"
e3c68b
e3c68b
This reverts commit edc238e40060773f5f5fd59fcdad8ae27d65749f.
e3c68b
e3c68b
BUG: 1471742
e3c68b
Change-Id: If6cb5941b964f005454a21a67938b354ef1a2037
e3c68b
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
e3c68b
Reviewed-on: https://code.engineering.redhat.com/gerrit/175953
e3c68b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e3c68b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e3c68b
---
e3c68b
 libglusterfs/src/syncop-utils.c          |  2 -
e3c68b
 xlators/cluster/afr/src/afr-self-heald.c |  5 ---
e3c68b
 xlators/cluster/ec/src/ec-heald.c        | 77 +++++---------------------------
e3c68b
 xlators/cluster/ec/src/ec-heald.h        |  3 --
e3c68b
 xlators/cluster/ec/src/ec-messages.h     |  3 +-
e3c68b
 xlators/cluster/ec/src/ec.c              | 47 -------------------
e3c68b
 6 files changed, 13 insertions(+), 124 deletions(-)
e3c68b
e3c68b
diff --git a/libglusterfs/src/syncop-utils.c b/libglusterfs/src/syncop-utils.c
e3c68b
index 4167db4..b842142 100644
e3c68b
--- a/libglusterfs/src/syncop-utils.c
e3c68b
+++ b/libglusterfs/src/syncop-utils.c
e3c68b
@@ -354,8 +354,6 @@ syncop_mt_dir_scan(call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid,
e3c68b
 
e3c68b
     if (frame) {
e3c68b
         this = frame->this;
e3c68b
-    } else {
e3c68b
-        this = THIS;
e3c68b
     }
e3c68b
 
e3c68b
     /*For this functionality to be implemented in general, we need
e3c68b
diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
e3c68b
index 522fe5d..8bc4720 100644
e3c68b
--- a/xlators/cluster/afr/src/afr-self-heald.c
e3c68b
+++ b/xlators/cluster/afr/src/afr-self-heald.c
e3c68b
@@ -524,11 +524,6 @@ afr_shd_full_heal(xlator_t *subvol, gf_dirent_t *entry, loc_t *parent,
e3c68b
     afr_private_t *priv = NULL;
e3c68b
 
e3c68b
     priv = this->private;
e3c68b
-
e3c68b
-    if (this->cleanup_starting) {
e3c68b
-        return -ENOTCONN;
e3c68b
-    }
e3c68b
-
e3c68b
     if (!priv->shd.enabled)
e3c68b
         return -EBUSY;
e3c68b
 
e3c68b
diff --git a/xlators/cluster/ec/src/ec-heald.c b/xlators/cluster/ec/src/ec-heald.c
e3c68b
index edf5e11..cba111a 100644
e3c68b
--- a/xlators/cluster/ec/src/ec-heald.c
e3c68b
+++ b/xlators/cluster/ec/src/ec-heald.c
e3c68b
@@ -71,11 +71,6 @@ disabled_loop:
e3c68b
             break;
e3c68b
     }
e3c68b
 
e3c68b
-    if (ec->shutdown) {
e3c68b
-        healer->running = _gf_false;
e3c68b
-        return -1;
e3c68b
-    }
e3c68b
-
e3c68b
     ret = healer->rerun;
e3c68b
     healer->rerun = 0;
e3c68b
 
e3c68b
@@ -246,11 +241,9 @@ ec_shd_index_sweep(struct subvol_healer *healer)
e3c68b
         goto out;
e3c68b
     }
e3c68b
 
e3c68b
-    _mask_cancellation();
e3c68b
     ret = syncop_mt_dir_scan(NULL, subvol, &loc, GF_CLIENT_PID_SELF_HEALD,
e3c68b
                              healer, ec_shd_index_heal, xdata,
e3c68b
                              ec->shd.max_threads, ec->shd.wait_qlength);
e3c68b
-    _unmask_cancellation();
e3c68b
 out:
e3c68b
     if (xdata)
e3c68b
         dict_unref(xdata);
e3c68b
@@ -270,11 +263,6 @@ ec_shd_full_heal(xlator_t *subvol, gf_dirent_t *entry, loc_t *parent,
e3c68b
     int ret = 0;
e3c68b
 
e3c68b
     ec = this->private;
e3c68b
-
e3c68b
-    if (this->cleanup_starting) {
e3c68b
-        return -ENOTCONN;
e3c68b
-    }
e3c68b
-
e3c68b
     if (ec->xl_up_count <= ec->fragments) {
e3c68b
         return -ENOTCONN;
e3c68b
     }
e3c68b
@@ -317,15 +305,11 @@ ec_shd_full_sweep(struct subvol_healer *healer, inode_t *inode)
e3c68b
 {
e3c68b
     ec_t *ec = NULL;
e3c68b
     loc_t loc = {0};
e3c68b
-    int ret = -1;
e3c68b
 
e3c68b
     ec = healer->this->private;
e3c68b
     loc.inode = inode;
e3c68b
-    _mask_cancellation();
e3c68b
-    ret = syncop_ftw(ec->xl_list[healer->subvol], &loc,
e3c68b
-                     GF_CLIENT_PID_SELF_HEALD, healer, ec_shd_full_heal);
e3c68b
-    _unmask_cancellation();
e3c68b
-    return ret;
e3c68b
+    return syncop_ftw(ec->xl_list[healer->subvol], &loc,
e3c68b
+                      GF_CLIENT_PID_SELF_HEALD, healer, ec_shd_full_heal);
e3c68b
 }
e3c68b
 
e3c68b
 void *
e3c68b
@@ -333,16 +317,13 @@ ec_shd_index_healer(void *data)
e3c68b
 {
e3c68b
     struct subvol_healer *healer = NULL;
e3c68b
     xlator_t *this = NULL;
e3c68b
-    int run = 0;
e3c68b
 
e3c68b
     healer = data;
e3c68b
     THIS = this = healer->this;
e3c68b
     ec_t *ec = this->private;
e3c68b
 
e3c68b
     for (;;) {
e3c68b
-        run = ec_shd_healer_wait(healer);
e3c68b
-        if (run == -1)
e3c68b
-            break;
e3c68b
+        ec_shd_healer_wait(healer);
e3c68b
 
e3c68b
         if (ec->xl_up_count > ec->fragments) {
e3c68b
             gf_msg_debug(this->name, 0, "starting index sweep on subvol %s",
e3c68b
@@ -371,12 +352,16 @@ ec_shd_full_healer(void *data)
e3c68b
 
e3c68b
     rootloc.inode = this->itable->root;
e3c68b
     for (;;) {
e3c68b
-        run = ec_shd_healer_wait(healer);
e3c68b
-        if (run < 0) {
e3c68b
-            break;
e3c68b
-        } else if (run == 0) {
e3c68b
-            continue;
e3c68b
+        pthread_mutex_lock(&healer->mutex);
e3c68b
+        {
e3c68b
+            run = __ec_shd_healer_wait(healer);
e3c68b
+            if (!run)
e3c68b
+                healer->running = _gf_false;
e3c68b
         }
e3c68b
+        pthread_mutex_unlock(&healer->mutex);
e3c68b
+
e3c68b
+        if (!run)
e3c68b
+            break;
e3c68b
 
e3c68b
         if (ec->xl_up_count > ec->fragments) {
e3c68b
             gf_msg(this->name, GF_LOG_INFO, 0, EC_MSG_FULL_SWEEP_START,
e3c68b
@@ -577,41 +562,3 @@ out:
e3c68b
     dict_del(output, this->name);
e3c68b
     return ret;
e3c68b
 }
e3c68b
-
e3c68b
-void
e3c68b
-ec_destroy_healer_object(xlator_t *this, struct subvol_healer *healer)
e3c68b
-{
e3c68b
-    if (!healer)
e3c68b
-        return;
e3c68b
-
e3c68b
-    pthread_cond_destroy(&healer->cond);
e3c68b
-    pthread_mutex_destroy(&healer->mutex);
e3c68b
-}
e3c68b
-
e3c68b
-void
e3c68b
-ec_selfheal_daemon_fini(xlator_t *this)
e3c68b
-{
e3c68b
-    struct subvol_healer *healer = NULL;
e3c68b
-    ec_self_heald_t *shd = NULL;
e3c68b
-    ec_t *priv = NULL;
e3c68b
-    int i = 0;
e3c68b
-
e3c68b
-    priv = this->private;
e3c68b
-    if (!priv)
e3c68b
-        return;
e3c68b
-
e3c68b
-    shd = &priv->shd;
e3c68b
-    if (!shd->iamshd)
e3c68b
-        return;
e3c68b
-
e3c68b
-    for (i = 0; i < priv->nodes; i++) {
e3c68b
-        healer = &shd->index_healers[i];
e3c68b
-        ec_destroy_healer_object(this, healer);
e3c68b
-
e3c68b
-        healer = &shd->full_healers[i];
e3c68b
-        ec_destroy_healer_object(this, healer);
e3c68b
-    }
e3c68b
-
e3c68b
-    GF_FREE(shd->index_healers);
e3c68b
-    GF_FREE(shd->full_healers);
e3c68b
-}
e3c68b
diff --git a/xlators/cluster/ec/src/ec-heald.h b/xlators/cluster/ec/src/ec-heald.h
e3c68b
index 8184cf4..2eda2a7 100644
e3c68b
--- a/xlators/cluster/ec/src/ec-heald.h
e3c68b
+++ b/xlators/cluster/ec/src/ec-heald.h
e3c68b
@@ -24,7 +24,4 @@ ec_selfheal_daemon_init(xlator_t *this);
e3c68b
 void
e3c68b
 ec_shd_index_healer_wake(ec_t *ec);
e3c68b
 
e3c68b
-void
e3c68b
-ec_selfheal_daemon_fini(xlator_t *this);
e3c68b
-
e3c68b
 #endif /* __EC_HEALD_H__ */
e3c68b
diff --git a/xlators/cluster/ec/src/ec-messages.h b/xlators/cluster/ec/src/ec-messages.h
e3c68b
index ce299bb..7c28808 100644
e3c68b
--- a/xlators/cluster/ec/src/ec-messages.h
e3c68b
+++ b/xlators/cluster/ec/src/ec-messages.h
e3c68b
@@ -55,7 +55,6 @@ GLFS_MSGID(EC, EC_MSG_INVALID_CONFIG, EC_MSG_HEAL_FAIL,
e3c68b
            EC_MSG_CONFIG_XATTR_INVALID, EC_MSG_EXTENSION, EC_MSG_EXTENSION_NONE,
e3c68b
            EC_MSG_EXTENSION_UNKNOWN, EC_MSG_EXTENSION_UNSUPPORTED,
e3c68b
            EC_MSG_EXTENSION_FAILED, EC_MSG_NO_GF, EC_MSG_MATRIX_FAILED,
e3c68b
-           EC_MSG_DYN_CREATE_FAILED, EC_MSG_DYN_CODEGEN_FAILED,
e3c68b
-           EC_MSG_THREAD_CLEANUP_FAILED);
e3c68b
+           EC_MSG_DYN_CREATE_FAILED, EC_MSG_DYN_CODEGEN_FAILED);
e3c68b
 
e3c68b
 #endif /* !_EC_MESSAGES_H_ */
e3c68b
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
e3c68b
index 264582a..3c8013e 100644
e3c68b
--- a/xlators/cluster/ec/src/ec.c
e3c68b
+++ b/xlators/cluster/ec/src/ec.c
e3c68b
@@ -429,51 +429,6 @@ ec_disable_delays(ec_t *ec)
e3c68b
 }
e3c68b
 
e3c68b
 void
e3c68b
-ec_cleanup_healer_object(ec_t *ec)
e3c68b
-{
e3c68b
-    struct subvol_healer *healer = NULL;
e3c68b
-    ec_self_heald_t *shd = NULL;
e3c68b
-    void *res = NULL;
e3c68b
-    int i = 0;
e3c68b
-    gf_boolean_t is_join = _gf_false;
e3c68b
-
e3c68b
-    shd = &ec->shd;
e3c68b
-    if (!shd->iamshd)
e3c68b
-        return;
e3c68b
-
e3c68b
-    for (i = 0; i < ec->nodes; i++) {
e3c68b
-        healer = &shd->index_healers[i];
e3c68b
-        pthread_mutex_lock(&healer->mutex);
e3c68b
-        {
e3c68b
-            healer->rerun = 1;
e3c68b
-            if (healer->running) {
e3c68b
-                pthread_cond_signal(&healer->cond);
e3c68b
-                is_join = _gf_true;
e3c68b
-            }
e3c68b
-        }
e3c68b
-        pthread_mutex_unlock(&healer->mutex);
e3c68b
-        if (is_join) {
e3c68b
-            pthread_join(healer->thread, &res;;
e3c68b
-            is_join = _gf_false;
e3c68b
-        }
e3c68b
-
e3c68b
-        healer = &shd->full_healers[i];
e3c68b
-        pthread_mutex_lock(&healer->mutex);
e3c68b
-        {
e3c68b
-            healer->rerun = 1;
e3c68b
-            if (healer->running) {
e3c68b
-                pthread_cond_signal(&healer->cond);
e3c68b
-                is_join = _gf_true;
e3c68b
-            }
e3c68b
-        }
e3c68b
-        pthread_mutex_unlock(&healer->mutex);
e3c68b
-        if (is_join) {
e3c68b
-            pthread_join(healer->thread, &res;;
e3c68b
-            is_join = _gf_false;
e3c68b
-        }
e3c68b
-    }
e3c68b
-}
e3c68b
-void
e3c68b
 ec_pending_fops_completed(ec_t *ec)
e3c68b
 {
e3c68b
     if (ec->shutdown) {
e3c68b
@@ -589,7 +544,6 @@ ec_notify(xlator_t *this, int32_t event, void *data, void *data2)
e3c68b
         /* If there aren't pending fops running after we have waken up
e3c68b
          * them, we immediately propagate the notification. */
e3c68b
         propagate = ec_disable_delays(ec);
e3c68b
-        ec_cleanup_healer_object(ec);
e3c68b
         goto unlock;
e3c68b
     }
e3c68b
 
e3c68b
@@ -805,7 +759,6 @@ failed:
e3c68b
 void
e3c68b
 fini(xlator_t *this)
e3c68b
 {
e3c68b
-    ec_selfheal_daemon_fini(this);
e3c68b
     __ec_destroy_private(this);
e3c68b
 }
e3c68b
 
e3c68b
-- 
e3c68b
1.8.3.1
e3c68b