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