|
|
3604df |
From f856824bcbe2ced66a848cdb1a66600ae15158c9 Mon Sep 17 00:00:00 2001
|
|
|
3604df |
From: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
3604df |
Date: Fri, 18 Nov 2016 13:30:08 +0530
|
|
|
3604df |
Subject: [PATCH 191/206] performance/io-threads: Exit threads in fini() as
|
|
|
3604df |
well
|
|
|
3604df |
|
|
|
3604df |
Problem:
|
|
|
3604df |
io-threads starts the thread in 'init()' but doesn't clean them up
|
|
|
3604df |
on 'fini()'. It relies on PARENT_DOWN to exit threads but there can
|
|
|
3604df |
be cases where event before PARENT_UP the graph init code can think
|
|
|
3604df |
of issuing fini(). This code path is hit when glfs_init() is called
|
|
|
3604df |
on a volume that is in 'stopped' state. It leads to a crash in ganesha
|
|
|
3604df |
process, because the io-thread tries to access freed memory.
|
|
|
3604df |
|
|
|
3604df |
Fix:
|
|
|
3604df |
Ideal fix would be to wait for all fops in io-thread list to be completed on
|
|
|
3604df |
PARENT_DOWN, and have fini() do cleanup of threads. Because there is no proper
|
|
|
3604df |
documentation about how PARENT_DOWN/fini are supposed to be used,
|
|
|
3604df |
we are getting different kinds of sequences in different higher level protocols.
|
|
|
3604df |
So for now cleaning up in both PARENT_DOWN and fini(). Fuse doesn't call fini()
|
|
|
3604df |
gfapi is not calling PARENT_DOWN in some cases, so for now I don't see
|
|
|
3604df |
another way out.
|
|
|
3604df |
|
|
|
3604df |
>BUG: 1396793
|
|
|
3604df |
>Change-Id: I9c9154e7d57198dbaff0f30d3ffc25f6d8088aec
|
|
|
3604df |
>Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
3604df |
>Reviewed-on: http://review.gluster.org/15888
|
|
|
3604df |
>Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
3604df |
>Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
|
|
|
3604df |
>(cherry picked from commit 25817a8c868b6c1b8149117f13e4216a99e453aa)
|
|
|
3604df |
|
|
|
3604df |
BUG: 1393526
|
|
|
3604df |
Change-Id: Id55e7c2f3e90c013d40e59bfbfb3f1583b8c4061
|
|
|
3604df |
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
3604df |
Reviewed-on: https://code.engineering.redhat.com/gerrit/91096
|
|
|
3604df |
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
|
|
|
3604df |
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
|
|
|
3604df |
---
|
|
|
3604df |
xlators/performance/io-threads/src/io-threads.c | 41 ++++++++++++++++++-------
|
|
|
3604df |
xlators/performance/io-threads/src/io-threads.h | 2 ++
|
|
|
3604df |
2 files changed, 32 insertions(+), 11 deletions(-)
|
|
|
3604df |
|
|
|
3604df |
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c
|
|
|
3604df |
index 394be8a..72a8208 100644
|
|
|
3604df |
--- a/xlators/performance/io-threads/src/io-threads.c
|
|
|
3604df |
+++ b/xlators/performance/io-threads/src/io-threads.c
|
|
|
3604df |
@@ -964,6 +964,7 @@ init (xlator_t *this)
|
|
|
3604df |
"pthread_cond_init failed (%d)", ret);
|
|
|
3604df |
goto out;
|
|
|
3604df |
}
|
|
|
3604df |
+ conf->cond_inited = _gf_true;
|
|
|
3604df |
|
|
|
3604df |
if ((ret = pthread_mutex_init(&conf->mutex, NULL)) != 0) {
|
|
|
3604df |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
3604df |
@@ -971,6 +972,7 @@ init (xlator_t *this)
|
|
|
3604df |
"pthread_mutex_init failed (%d)", ret);
|
|
|
3604df |
goto out;
|
|
|
3604df |
}
|
|
|
3604df |
+ conf->mutex_inited = _gf_true;
|
|
|
3604df |
|
|
|
3604df |
set_stack_size (conf);
|
|
|
3604df |
|
|
|
3604df |
@@ -1025,22 +1027,27 @@ out:
|
|
|
3604df |
return ret;
|
|
|
3604df |
}
|
|
|
3604df |
|
|
|
3604df |
+static void
|
|
|
3604df |
+iot_exit_threads (iot_conf_t *conf)
|
|
|
3604df |
+{
|
|
|
3604df |
+ pthread_mutex_lock (&conf->mutex);
|
|
|
3604df |
+ {
|
|
|
3604df |
+ conf->down = _gf_true;
|
|
|
3604df |
+ /*Let all the threads know that xl is going down*/
|
|
|
3604df |
+ pthread_cond_broadcast (&conf->cond);
|
|
|
3604df |
+ while (conf->curr_count)/*Wait for threads to exit*/
|
|
|
3604df |
+ pthread_cond_wait (&conf->cond, &conf->mutex);
|
|
|
3604df |
+ }
|
|
|
3604df |
+ pthread_mutex_unlock (&conf->mutex);
|
|
|
3604df |
+}
|
|
|
3604df |
+
|
|
|
3604df |
int
|
|
|
3604df |
notify (xlator_t *this, int32_t event, void *data, ...)
|
|
|
3604df |
{
|
|
|
3604df |
iot_conf_t *conf = this->private;
|
|
|
3604df |
|
|
|
3604df |
- if (GF_EVENT_PARENT_DOWN == event) {
|
|
|
3604df |
- pthread_mutex_lock (&conf->mutex);
|
|
|
3604df |
- {
|
|
|
3604df |
- conf->down = _gf_true;
|
|
|
3604df |
- /*Let all the threads know that xl is going down*/
|
|
|
3604df |
- pthread_cond_broadcast (&conf->cond);
|
|
|
3604df |
- while (conf->curr_count)/*Wait for threads to exit*/
|
|
|
3604df |
- pthread_cond_wait (&conf->cond, &conf->mutex);
|
|
|
3604df |
- }
|
|
|
3604df |
- pthread_mutex_unlock (&conf->mutex);
|
|
|
3604df |
- }
|
|
|
3604df |
+ if (GF_EVENT_PARENT_DOWN == event)
|
|
|
3604df |
+ iot_exit_threads (conf);
|
|
|
3604df |
|
|
|
3604df |
default_notify (this, event, data);
|
|
|
3604df |
|
|
|
3604df |
@@ -1052,6 +1059,18 @@ fini (xlator_t *this)
|
|
|
3604df |
{
|
|
|
3604df |
iot_conf_t *conf = this->private;
|
|
|
3604df |
|
|
|
3604df |
+ if (!conf)
|
|
|
3604df |
+ return;
|
|
|
3604df |
+
|
|
|
3604df |
+ if (conf->mutex_inited && conf->cond_inited)
|
|
|
3604df |
+ iot_exit_threads (conf);
|
|
|
3604df |
+
|
|
|
3604df |
+ if (conf->cond_inited)
|
|
|
3604df |
+ pthread_cond_destroy (&conf->cond);
|
|
|
3604df |
+
|
|
|
3604df |
+ if (conf->mutex_inited)
|
|
|
3604df |
+ pthread_mutex_destroy (&conf->mutex);
|
|
|
3604df |
+
|
|
|
3604df |
GF_FREE (conf);
|
|
|
3604df |
|
|
|
3604df |
this->private = NULL;
|
|
|
3604df |
diff --git a/xlators/performance/io-threads/src/io-threads.h b/xlators/performance/io-threads/src/io-threads.h
|
|
|
3604df |
index cb984f0..fa955b5 100644
|
|
|
3604df |
--- a/xlators/performance/io-threads/src/io-threads.h
|
|
|
3604df |
+++ b/xlators/performance/io-threads/src/io-threads.h
|
|
|
3604df |
@@ -80,6 +80,8 @@ struct iot_conf {
|
|
|
3604df |
size_t stack_size;
|
|
|
3604df |
|
|
|
3604df |
gf_boolean_t down; /*PARENT_DOWN event is notified*/
|
|
|
3604df |
+ gf_boolean_t mutex_inited;
|
|
|
3604df |
+ gf_boolean_t cond_inited;
|
|
|
3604df |
struct iot_least_throttle throttle;
|
|
|
3604df |
};
|
|
|
3604df |
|
|
|
3604df |
--
|
|
|
3604df |
2.9.3
|
|
|
3604df |
|