|
|
887953 |
From 5989899b7aa5cc86e589c5ff20560476b959d98b Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
887953 |
Date: Fri, 11 Jan 2019 12:42:20 +0530
|
|
|
887953 |
Subject: [PATCH 503/506] core: brick process is crashed at the time of spawn
|
|
|
887953 |
thread
|
|
|
887953 |
|
|
|
887953 |
Problem: brick is getting crashed at the time of calling
|
|
|
887953 |
pthread_detach after just call gf_thread_create.If
|
|
|
887953 |
sufficient resources are not available on the system
|
|
|
887953 |
pthread_create returns EAGAIN (non-negative) but the
|
|
|
887953 |
caller function expects negative error code in case of failure
|
|
|
887953 |
|
|
|
887953 |
Solution: Change the condition in caller function to avoid the crash
|
|
|
887953 |
|
|
|
887953 |
> Change-Id: Ifeaa49f809957eb6c33aa9792f5af1b55566756d
|
|
|
887953 |
> fixes: bz#1662906
|
|
|
887953 |
> (Cherry pick from commit 1e28c54c5ec8d84ec8a22493161314010992918e)
|
|
|
887953 |
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/21976/)
|
|
|
887953 |
|
|
|
887953 |
Change-Id: I9e5c3de4b98236de22f834d66268ab21001817a1
|
|
|
887953 |
BUG: 1662828
|
|
|
887953 |
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/160409
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
xlators/storage/posix/src/posix-helpers.c | 15 ++++++-----
|
|
|
887953 |
xlators/storage/posix/src/posix.c | 31 +++++++++++++++++------
|
|
|
887953 |
xlators/storage/posix/src/posix.h | 6 ++---
|
|
|
887953 |
3 files changed, 35 insertions(+), 17 deletions(-)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
|
|
|
887953 |
index ed5d3e55e..1137f1c41 100644
|
|
|
887953 |
--- a/xlators/storage/posix/src/posix-helpers.c
|
|
|
887953 |
+++ b/xlators/storage/posix/src/posix-helpers.c
|
|
|
887953 |
@@ -1322,7 +1322,7 @@ posix_janitor_thread_proc (void *data)
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
|
|
|
887953 |
-void
|
|
|
887953 |
+int
|
|
|
887953 |
posix_spawn_janitor_thread (xlator_t *this)
|
|
|
887953 |
{
|
|
|
887953 |
struct posix_private *priv = NULL;
|
|
|
887953 |
@@ -1337,7 +1337,7 @@ posix_spawn_janitor_thread (xlator_t *this)
|
|
|
887953 |
posix_janitor_thread_proc,
|
|
|
887953 |
this, "posixjan");
|
|
|
887953 |
|
|
|
887953 |
- if (ret < 0) {
|
|
|
887953 |
+ if (ret) {
|
|
|
887953 |
gf_msg (this->name, GF_LOG_ERROR, errno,
|
|
|
887953 |
P_MSG_THREAD_FAILED, "spawning janitor "
|
|
|
887953 |
"thread failed");
|
|
|
887953 |
@@ -1349,6 +1349,7 @@ posix_spawn_janitor_thread (xlator_t *this)
|
|
|
887953 |
}
|
|
|
887953 |
unlock:
|
|
|
887953 |
UNLOCK (&priv->lock);
|
|
|
887953 |
+ return ret;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
static int
|
|
|
887953 |
@@ -1822,7 +1823,7 @@ abort:
|
|
|
887953 |
return NULL;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
-void
|
|
|
887953 |
+int
|
|
|
887953 |
posix_spawn_health_check_thread (xlator_t *xl)
|
|
|
887953 |
{
|
|
|
887953 |
struct posix_private *priv = NULL;
|
|
|
887953 |
@@ -1845,7 +1846,7 @@ posix_spawn_health_check_thread (xlator_t *xl)
|
|
|
887953 |
ret = gf_thread_create (&priv->health_check, NULL,
|
|
|
887953 |
posix_health_check_thread_proc,
|
|
|
887953 |
xl, "posixhc");
|
|
|
887953 |
- if (ret < 0) {
|
|
|
887953 |
+ if (ret) {
|
|
|
887953 |
priv->health_check_interval = 0;
|
|
|
887953 |
priv->health_check_active = _gf_false;
|
|
|
887953 |
gf_msg (xl->name, GF_LOG_ERROR, errno,
|
|
|
887953 |
@@ -1858,6 +1859,7 @@ posix_spawn_health_check_thread (xlator_t *xl)
|
|
|
887953 |
}
|
|
|
887953 |
unlock:
|
|
|
887953 |
UNLOCK (&priv->lock);
|
|
|
887953 |
+ return ret;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
void
|
|
|
887953 |
@@ -1940,7 +1942,7 @@ out:
|
|
|
887953 |
return NULL;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
-void
|
|
|
887953 |
+int
|
|
|
887953 |
posix_spawn_disk_space_check_thread (xlator_t *xl)
|
|
|
887953 |
{
|
|
|
887953 |
struct posix_private *priv = NULL;
|
|
|
887953 |
@@ -1959,7 +1961,7 @@ posix_spawn_disk_space_check_thread (xlator_t *xl)
|
|
|
887953 |
ret = gf_thread_create (&priv->disk_space_check, NULL,
|
|
|
887953 |
posix_disk_space_check_thread_proc,
|
|
|
887953 |
xl, "posix_reserve");
|
|
|
887953 |
- if (ret < 0) {
|
|
|
887953 |
+ if (ret) {
|
|
|
887953 |
priv->disk_space_check_active = _gf_false;
|
|
|
887953 |
gf_msg (xl->name, GF_LOG_ERROR, errno,
|
|
|
887953 |
P_MSG_DISK_SPACE_CHECK_FAILED,
|
|
|
887953 |
@@ -1971,6 +1973,7 @@ posix_spawn_disk_space_check_thread (xlator_t *xl)
|
|
|
887953 |
}
|
|
|
887953 |
unlock:
|
|
|
887953 |
UNLOCK (&priv->lock);
|
|
|
887953 |
+ return ret;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
int
|
|
|
887953 |
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
|
|
|
887953 |
index 591119ea9..8a6282d29 100644
|
|
|
887953 |
--- a/xlators/storage/posix/src/posix.c
|
|
|
887953 |
+++ b/xlators/storage/posix/src/posix.c
|
|
|
887953 |
@@ -7317,12 +7317,19 @@ reconfigure (xlator_t *this, dict_t *options)
|
|
|
887953 |
|
|
|
887953 |
GF_OPTION_RECONF ("reserve", priv->disk_reserve,
|
|
|
887953 |
options, uint32, out);
|
|
|
887953 |
- if (priv->disk_reserve)
|
|
|
887953 |
- posix_spawn_disk_space_check_thread (this);
|
|
|
887953 |
+ if (priv->disk_reserve) {
|
|
|
887953 |
+ ret = posix_spawn_disk_space_check_thread (this);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto out;
|
|
|
887953 |
+ }
|
|
|
887953 |
|
|
|
887953 |
GF_OPTION_RECONF ("health-check-interval", priv->health_check_interval,
|
|
|
887953 |
options, uint32, out);
|
|
|
887953 |
- posix_spawn_health_check_thread (this);
|
|
|
887953 |
+ if (priv->health_check_interval) {
|
|
|
887953 |
+ ret = posix_spawn_health_check_thread (this);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto out;
|
|
|
887953 |
+ }
|
|
|
887953 |
|
|
|
887953 |
GF_OPTION_RECONF ("shared-brick-count", priv->shared_brick_count,
|
|
|
887953 |
options, int32, out);
|
|
|
887953 |
@@ -7925,20 +7932,28 @@ init (xlator_t *this)
|
|
|
887953 |
_private->disk_space_full = 0;
|
|
|
887953 |
GF_OPTION_INIT ("reserve",
|
|
|
887953 |
_private->disk_reserve, uint32, out);
|
|
|
887953 |
- if (_private->disk_reserve)
|
|
|
887953 |
- posix_spawn_disk_space_check_thread (this);
|
|
|
887953 |
+ if (_private->disk_reserve) {
|
|
|
887953 |
+ ret = posix_spawn_disk_space_check_thread (this);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto out;
|
|
|
887953 |
+ }
|
|
|
887953 |
|
|
|
887953 |
_private->health_check_active = _gf_false;
|
|
|
887953 |
GF_OPTION_INIT ("health-check-interval",
|
|
|
887953 |
_private->health_check_interval, uint32, out);
|
|
|
887953 |
- if (_private->health_check_interval)
|
|
|
887953 |
- posix_spawn_health_check_thread (this);
|
|
|
887953 |
+ if (_private->health_check_interval) {
|
|
|
887953 |
+ ret = posix_spawn_health_check_thread (this);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto out;
|
|
|
887953 |
+ }
|
|
|
887953 |
|
|
|
887953 |
pthread_mutex_init (&_private->janitor_lock, NULL);
|
|
|
887953 |
pthread_cond_init (&_private->janitor_cond, NULL);
|
|
|
887953 |
INIT_LIST_HEAD (&_private->janitor_fds);
|
|
|
887953 |
|
|
|
887953 |
- posix_spawn_janitor_thread (this);
|
|
|
887953 |
+ ret = posix_spawn_janitor_thread (this);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto out;
|
|
|
887953 |
|
|
|
887953 |
pthread_mutex_init (&_private->fsync_mutex, NULL);
|
|
|
887953 |
pthread_cond_init (&_private->fsync_cond, NULL);
|
|
|
887953 |
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
|
|
|
887953 |
index bda41726c..cb8dc8acc 100644
|
|
|
887953 |
--- a/xlators/storage/posix/src/posix.h
|
|
|
887953 |
+++ b/xlators/storage/posix/src/posix.h
|
|
|
887953 |
@@ -305,7 +305,7 @@ int posix_handle_pair (xlator_t *this, const char *real_path, char *key,
|
|
|
887953 |
data_t *value, int flags, struct iatt *stbuf);
|
|
|
887953 |
int posix_fhandle_pair (xlator_t *this, int fd, char *key, data_t *value,
|
|
|
887953 |
int flags, struct iatt *stbuf);
|
|
|
887953 |
-void posix_spawn_janitor_thread (xlator_t *this);
|
|
|
887953 |
+int posix_spawn_janitor_thread (xlator_t *this);
|
|
|
887953 |
int posix_acl_xattr_set (xlator_t *this, const char *path, dict_t *xattr_req);
|
|
|
887953 |
int posix_gfid_heal (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req);
|
|
|
887953 |
int posix_entry_create_xattr_set (xlator_t *this, const char *path,
|
|
|
887953 |
@@ -320,9 +320,9 @@ gf_boolean_t posix_special_xattr (char **pattern, char *key);
|
|
|
887953 |
void
|
|
|
887953 |
__posix_fd_set_odirect (fd_t *fd, struct posix_fd *pfd, int opflags,
|
|
|
887953 |
off_t offset, size_t size);
|
|
|
887953 |
-void posix_spawn_health_check_thread (xlator_t *this);
|
|
|
887953 |
+int posix_spawn_health_check_thread (xlator_t *this);
|
|
|
887953 |
|
|
|
887953 |
-void posix_spawn_disk_space_check_thread (xlator_t *this);
|
|
|
887953 |
+int posix_spawn_disk_space_check_thread (xlator_t *this);
|
|
|
887953 |
|
|
|
887953 |
void *posix_fsyncer (void *);
|
|
|
887953 |
int
|
|
|
887953 |
--
|
|
|
887953 |
2.20.1
|
|
|
887953 |
|