|
|
14f8ab |
From faaaa3452ceec6afcc18cffc9beca3fe19841cce Mon Sep 17 00:00:00 2001
|
|
|
14f8ab |
From: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
14f8ab |
Date: Thu, 3 Jan 2019 17:44:18 +0530
|
|
|
14f8ab |
Subject: [PATCH 104/124] afr/shd: Cleanup self heal daemon resources during
|
|
|
14f8ab |
afr fini
|
|
|
14f8ab |
|
|
|
14f8ab |
We were not properly cleaning self-heal daemon resources
|
|
|
14f8ab |
during afr fini. This patch will clean the same.
|
|
|
14f8ab |
|
|
|
14f8ab |
Backport of: https://review.gluster.org/#/c/glusterfs/+/22151/
|
|
|
14f8ab |
|
|
|
14f8ab |
>Change-Id: I597860be6f781b195449e695d871b8667a418d5a
|
|
|
14f8ab |
>updates: bz#1659708
|
|
|
14f8ab |
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
14f8ab |
|
|
|
14f8ab |
Change-Id: I7be981b9c2476c8cacadea6b14d74234f67b714f
|
|
|
14f8ab |
BUG: 1471742
|
|
|
14f8ab |
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
14f8ab |
Reviewed-on: https://code.engineering.redhat.com/gerrit/167845
|
|
|
14f8ab |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
14f8ab |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
14f8ab |
---
|
|
|
14f8ab |
libglusterfs/src/syncop-utils.c | 8 +++++
|
|
|
14f8ab |
xlators/cluster/afr/src/afr-self-heald.c | 2 ++
|
|
|
14f8ab |
xlators/cluster/afr/src/afr.c | 57 ++++++++++++++++++++++++++++++++
|
|
|
14f8ab |
3 files changed, 67 insertions(+)
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/libglusterfs/src/syncop-utils.c b/libglusterfs/src/syncop-utils.c
|
|
|
14f8ab |
index be03527..b842142 100644
|
|
|
14f8ab |
--- a/libglusterfs/src/syncop-utils.c
|
|
|
14f8ab |
+++ b/libglusterfs/src/syncop-utils.c
|
|
|
14f8ab |
@@ -350,6 +350,11 @@ syncop_mt_dir_scan(call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid,
|
|
|
14f8ab |
gf_boolean_t cond_init = _gf_false;
|
|
|
14f8ab |
gf_boolean_t mut_init = _gf_false;
|
|
|
14f8ab |
gf_dirent_t entries;
|
|
|
14f8ab |
+ xlator_t *this = NULL;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (frame) {
|
|
|
14f8ab |
+ this = frame->this;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
/*For this functionality to be implemented in general, we need
|
|
|
14f8ab |
* synccond_t infra which doesn't block the executing thread. Until then
|
|
|
14f8ab |
@@ -397,6 +402,9 @@ syncop_mt_dir_scan(call_frame_t *frame, xlator_t *subvol, loc_t *loc, int pid,
|
|
|
14f8ab |
|
|
|
14f8ab |
list_for_each_entry_safe(entry, tmp, &entries.list, list)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
+ if (this && this->cleanup_starting)
|
|
|
14f8ab |
+ goto out;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
list_del_init(&entry->list);
|
|
|
14f8ab |
if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) {
|
|
|
14f8ab |
gf_dirent_entry_free(entry);
|
|
|
14f8ab |
diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
|
|
|
14f8ab |
index 7eb1207..8bc4720 100644
|
|
|
14f8ab |
--- a/xlators/cluster/afr/src/afr-self-heald.c
|
|
|
14f8ab |
+++ b/xlators/cluster/afr/src/afr-self-heald.c
|
|
|
14f8ab |
@@ -373,6 +373,7 @@ afr_shd_sweep_prepare(struct subvol_healer *healer)
|
|
|
14f8ab |
|
|
|
14f8ab |
time(&event->start_time);
|
|
|
14f8ab |
event->end_time = 0;
|
|
|
14f8ab |
+ _mask_cancellation();
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
void
|
|
|
14f8ab |
@@ -394,6 +395,7 @@ afr_shd_sweep_done(struct subvol_healer *healer)
|
|
|
14f8ab |
|
|
|
14f8ab |
if (eh_save_history(shd->statistics[healer->subvol], history) < 0)
|
|
|
14f8ab |
GF_FREE(history);
|
|
|
14f8ab |
+ _unmask_cancellation();
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
int
|
|
|
14f8ab |
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
|
|
|
14f8ab |
index 33258a0..a0a7551 100644
|
|
|
14f8ab |
--- a/xlators/cluster/afr/src/afr.c
|
|
|
14f8ab |
+++ b/xlators/cluster/afr/src/afr.c
|
|
|
14f8ab |
@@ -611,13 +611,70 @@ init(xlator_t *this)
|
|
|
14f8ab |
out:
|
|
|
14f8ab |
return ret;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
+void
|
|
|
14f8ab |
+afr_destroy_healer_object(xlator_t *this, struct subvol_healer *healer)
|
|
|
14f8ab |
+{
|
|
|
14f8ab |
+ int ret = -1;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (!healer)
|
|
|
14f8ab |
+ return;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (healer->running) {
|
|
|
14f8ab |
+ /*
|
|
|
14f8ab |
+ * If there are any resources to cleanup, We need
|
|
|
14f8ab |
+ * to do that gracefully using pthread_cleanup_push
|
|
|
14f8ab |
+ */
|
|
|
14f8ab |
+ ret = gf_thread_cleanup_xint(healer->thread);
|
|
|
14f8ab |
+ if (ret)
|
|
|
14f8ab |
+ gf_msg(this->name, GF_LOG_WARNING, 0, AFR_MSG_SELF_HEAL_FAILED,
|
|
|
14f8ab |
+ "Failed to clean up healer threads.");
|
|
|
14f8ab |
+ healer->thread = 0;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ pthread_cond_destroy(&healer->cond);
|
|
|
14f8ab |
+ pthread_mutex_destroy(&healer->mutex);
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+void
|
|
|
14f8ab |
+afr_selfheal_daemon_fini(xlator_t *this)
|
|
|
14f8ab |
+{
|
|
|
14f8ab |
+ struct subvol_healer *healer = NULL;
|
|
|
14f8ab |
+ afr_self_heald_t *shd = NULL;
|
|
|
14f8ab |
+ afr_private_t *priv = NULL;
|
|
|
14f8ab |
+ int i = 0;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ priv = this->private;
|
|
|
14f8ab |
+ if (!priv)
|
|
|
14f8ab |
+ return;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ shd = &priv->shd;
|
|
|
14f8ab |
+ if (!shd->iamshd)
|
|
|
14f8ab |
+ return;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ for (i = 0; i < priv->child_count; i++) {
|
|
|
14f8ab |
+ healer = &shd->index_healers[i];
|
|
|
14f8ab |
+ afr_destroy_healer_object(this, healer);
|
|
|
14f8ab |
|
|
|
14f8ab |
+ healer = &shd->full_healers[i];
|
|
|
14f8ab |
+ afr_destroy_healer_object(this, healer);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (shd->statistics[i])
|
|
|
14f8ab |
+ eh_destroy(shd->statistics[i]);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ GF_FREE(shd->index_healers);
|
|
|
14f8ab |
+ GF_FREE(shd->full_healers);
|
|
|
14f8ab |
+ GF_FREE(shd->statistics);
|
|
|
14f8ab |
+ if (shd->split_brain)
|
|
|
14f8ab |
+ eh_destroy(shd->split_brain);
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
void
|
|
|
14f8ab |
fini(xlator_t *this)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
afr_private_t *priv = NULL;
|
|
|
14f8ab |
|
|
|
14f8ab |
priv = this->private;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ afr_selfheal_daemon_fini(this);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
LOCK(&priv->lock);
|
|
|
14f8ab |
if (priv->timer != NULL) {
|
|
|
14f8ab |
gf_timer_call_cancel(this->ctx, priv->timer);
|
|
|
14f8ab |
--
|
|
|
14f8ab |
1.8.3.1
|
|
|
14f8ab |
|