core: brick process is crashed at the time of spawn thread
Problem: brick is getting crashed at the time of calling pthread_detach after just call gf_thread_create.If sufficient resources are not available on the system pthread_create returns EAGAIN (non-negative) but the caller function expects negative error code in case of failure Solution: Change the condition in caller function to avoid the crash Change-Id: Ifeaa49f809957eb6c33aa9792f5af1b55566756d fixes: bz#1662906
This commit is contained in:
parent
fa7ae12870
commit
1e28c54c5e
@ -345,14 +345,21 @@ posix_reconfigure(xlator_t *this, dict_t *options)
|
||||
}
|
||||
|
||||
GF_OPTION_RECONF("reserve", priv->disk_reserve, options, uint32, out);
|
||||
if (priv->disk_reserve)
|
||||
posix_spawn_disk_space_check_thread(this);
|
||||
if (priv->disk_reserve) {
|
||||
ret = posix_spawn_disk_space_check_thread(this);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
||||
GF_OPTION_RECONF("health-check-interval", priv->health_check_interval,
|
||||
options, uint32, out);
|
||||
GF_OPTION_RECONF("health-check-timeout", priv->health_check_timeout,
|
||||
options, uint32, out);
|
||||
posix_spawn_health_check_thread(this);
|
||||
if (priv->health_check_interval) {
|
||||
ret = posix_spawn_health_check_thread(this);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
||||
GF_OPTION_RECONF("shared-brick-count", priv->shared_brick_count, options,
|
||||
int32, out);
|
||||
@ -958,23 +965,30 @@ posix_init(xlator_t *this)
|
||||
_private->disk_space_check_active = _gf_false;
|
||||
_private->disk_space_full = 0;
|
||||
GF_OPTION_INIT("reserve", _private->disk_reserve, uint32, out);
|
||||
if (_private->disk_reserve)
|
||||
posix_spawn_disk_space_check_thread(this);
|
||||
if (_private->disk_reserve) {
|
||||
ret = posix_spawn_disk_space_check_thread(this);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
||||
_private->health_check_active = _gf_false;
|
||||
GF_OPTION_INIT("health-check-interval", _private->health_check_interval,
|
||||
uint32, out);
|
||||
GF_OPTION_INIT("health-check-timeout", _private->health_check_timeout,
|
||||
uint32, out);
|
||||
if (_private->health_check_interval)
|
||||
posix_spawn_health_check_thread(this);
|
||||
|
||||
if (_private->health_check_interval) {
|
||||
ret = posix_spawn_health_check_thread(this);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
posix_janitor_timer_start(this);
|
||||
|
||||
pthread_mutex_init(&_private->fsync_mutex, NULL);
|
||||
pthread_cond_init(&_private->fsync_cond, NULL);
|
||||
INIT_LIST_HEAD(&_private->fsyncs);
|
||||
posix_spawn_ctx_janitor_thread(this);
|
||||
ret = posix_spawn_ctx_janitor_thread(this);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = gf_thread_create(&_private->fsyncer, NULL, posix_fsyncer, this,
|
||||
"posixfsy");
|
||||
|
@ -1597,7 +1597,7 @@ posix_ctx_janitor_thread_proc(void *data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
posix_spawn_ctx_janitor_thread(xlator_t *this)
|
||||
{
|
||||
struct posix_private *priv = NULL;
|
||||
@ -1618,7 +1618,7 @@ posix_spawn_ctx_janitor_thread(xlator_t *this)
|
||||
posix_ctx_janitor_thread_proc, this,
|
||||
"posixctxjan");
|
||||
|
||||
if (ret < 0) {
|
||||
if (ret) {
|
||||
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_THREAD_FAILED,
|
||||
"spawning janitor "
|
||||
"thread failed");
|
||||
@ -1628,6 +1628,7 @@ posix_spawn_ctx_janitor_thread(xlator_t *this)
|
||||
}
|
||||
unlock:
|
||||
UNLOCK(&priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -2193,7 +2194,7 @@ abort:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
posix_spawn_health_check_thread(xlator_t *xl)
|
||||
{
|
||||
struct posix_private *priv = NULL;
|
||||
@ -2215,7 +2216,7 @@ posix_spawn_health_check_thread(xlator_t *xl)
|
||||
|
||||
ret = gf_thread_create(&priv->health_check, NULL,
|
||||
posix_health_check_thread_proc, xl, "posixhc");
|
||||
if (ret < 0) {
|
||||
if (ret) {
|
||||
priv->health_check_interval = 0;
|
||||
priv->health_check_active = _gf_false;
|
||||
gf_msg(xl->name, GF_LOG_ERROR, errno, P_MSG_HEALTHCHECK_FAILED,
|
||||
@ -2227,6 +2228,7 @@ posix_spawn_health_check_thread(xlator_t *xl)
|
||||
}
|
||||
unlock:
|
||||
UNLOCK(&priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
@ -2309,7 +2311,7 @@ out:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
posix_spawn_disk_space_check_thread(xlator_t *xl)
|
||||
{
|
||||
struct posix_private *priv = NULL;
|
||||
@ -2328,7 +2330,7 @@ posix_spawn_disk_space_check_thread(xlator_t *xl)
|
||||
ret = gf_thread_create(&priv->disk_space_check, NULL,
|
||||
posix_disk_space_check_thread_proc, xl,
|
||||
"posix_reserve");
|
||||
if (ret < 0) {
|
||||
if (ret) {
|
||||
priv->disk_space_check_active = _gf_false;
|
||||
gf_msg(xl->name, GF_LOG_ERROR, errno, P_MSG_DISK_SPACE_CHECK_FAILED,
|
||||
"unable to setup disk space check thread");
|
||||
@ -2339,6 +2341,7 @@ posix_spawn_disk_space_check_thread(xlator_t *xl)
|
||||
}
|
||||
unlock:
|
||||
UNLOCK(&priv->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -362,10 +362,10 @@ posix_special_xattr(char **pattern, char *key);
|
||||
void
|
||||
__posix_fd_set_odirect(fd_t *fd, struct posix_fd *pfd, int opflags,
|
||||
off_t offset, size_t size);
|
||||
void
|
||||
int
|
||||
posix_spawn_health_check_thread(xlator_t *this);
|
||||
|
||||
void
|
||||
int
|
||||
posix_spawn_disk_space_check_thread(xlator_t *this);
|
||||
|
||||
void *
|
||||
@ -661,7 +661,7 @@ posix_cs_maintenance(xlator_t *this, fd_t *fd, loc_t *loc, int *pfd,
|
||||
int
|
||||
posix_check_dev_file(xlator_t *this, inode_t *inode, char *fop, int *op_errno);
|
||||
|
||||
void
|
||||
int
|
||||
posix_spawn_ctx_janitor_thread(xlator_t *this);
|
||||
|
||||
#endif /* _POSIX_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user