From 4fca129115215816589ce03d23375b23a163d7f6 Mon Sep 17 00:00:00 2001
From: moagrawa <moagrawa@redhat.com>
Date: Fri, 9 Jun 2017 13:53:28 +0530
Subject: [PATCH 492/509] glusterfsd: Sometime brick process is crashed after
enable brick mux
Problem: glusterfsd is getting Segfault while running bug-1432542-mpx-restart-crash.t
in a loop in while brick mux is enabled.
Solution: Change the index_worker code as well as notify code in index.c
to cleanup index_worker thread appropriately.
> BUG: 1459402
> Change-Id: Id036664dc34309dd3f6e54746fc2724182cb074f
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
> Reviewed-on: https://review.gluster.org/17471
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
> (cherry picked from commit 0a07cffbf363e35e9617e5d4ef605f26ede06f05)
BUG: 1459400
Change-Id: I85171a2d4aa6414d86195f93486fc63b2c2a2864
Signed-off-by: moagrawa <moagrawa@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/108648
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
xlators/features/index/src/index.c | 24 ++++++++++++++++++------
xlators/features/index/src/index.h | 1 +
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c
index ef5a60c..29437d0 100644
--- a/xlators/features/index/src/index.c
+++ b/xlators/features/index/src/index.c
@@ -199,6 +199,8 @@ index_worker (void *data)
xlator_t *this = NULL;
call_stub_t *stub = NULL;
int ret = 0;
+ gf_boolean_t bye = _gf_false;
+
THIS = data;
this = data;
@@ -208,16 +210,27 @@ index_worker (void *data)
pthread_mutex_lock (&priv->mutex);
{
while (list_empty (&priv->callstubs)) {
+ if (priv->down) {
+ bye = _gf_true;/*Avoid wait*/
+ break;
+ }
ret = pthread_cond_wait (&priv->cond,
&priv->mutex);
+ if (priv->down) {
+ bye = _gf_true;
+ break;
+ }
}
-
- stub = __index_dequeue (&priv->callstubs);
+ if (!bye)
+ stub = __index_dequeue (&priv->callstubs);
}
pthread_mutex_unlock (&priv->mutex);
if (stub) /* guard against spurious wakeups */
call_resume (stub);
+ stub = NULL;
+ if (bye)
+ break;
}
return NULL;
@@ -2378,6 +2391,7 @@ init (xlator_t *this)
/*init indices files counts*/
count = index_fetch_link_count (this, XATTROP);
index_set_link_count (priv, count, XATTROP);
+ priv->down = _gf_false;
ret = gf_thread_create (&priv->thread, &w_attr, index_worker, this);
if (ret) {
@@ -2500,10 +2514,8 @@ notify (xlator_t *this, int event, void *data, ...)
switch (event) {
case GF_EVENT_CLEANUP:
- if (priv->thread) {
- (void) gf_thread_cleanup_xint (priv->thread);
- priv->thread = 0;
- }
+ priv->down = _gf_true;
+ pthread_cond_broadcast (&priv->cond);
break;
}
diff --git a/xlators/features/index/src/index.h b/xlators/features/index/src/index.h
index f622cec..ae9091d 100644
--- a/xlators/features/index/src/index.h
+++ b/xlators/features/index/src/index.h
@@ -61,6 +61,7 @@ typedef struct index_priv {
dict_t *complete_watchlist;
int64_t pending_count;
pthread_t thread;
+ gf_boolean_t down;
} index_priv_t;
typedef struct index_local {
--
1.8.3.1