From 4f905163211f8d439c6e102d3ffd1bffb34f5c26 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Wed, 7 May 2014 18:17:11 +0530 Subject: glusterd: On gaining quorum spawn_daemons in new thread During startup, if a glusterd has peers, it waits till quorum is obtained to spawn bricks and other services. If peers are not present, the daemons are started during glusterd' startup itself. The spawning of daemons as a quorum action was done without using a seperate thread, unlike the spawn on startup. Since, quotad was launched using the blocking runner_run api, this leads to the thread being blocked. The calling thread is almost always the epoll thread and this leads to a deadlock. The runner_run call blocks the epoll thread waiting for quotad to start, as a result glusterd cannot serve any requests. But the startup of quotad is blocked as it cannot fetch the volfile from glusterd. The fix for this is to launch the spawn daemons task in a seperate thread. This will free up the epoll thread and prevents the above deadlock from happening. Change-Id: Ife47b3591223cdfdfb2b4ea8dcd73e63f18e8749 BUG: 1095585 Signed-off-by: Kaushal M Reviewed-on: http://review.gluster.org/7703 Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System Tested-by: Krishnan Parthasarathi --- xlators/mgmt/glusterd/src/glusterd-utils.c | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 1134d29dc5b..bb44b255dd4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -5800,6 +5800,9 @@ glusterd_nodesvc_start (char *server, gf_boolean_t wait) glusterd_nodesvc_set_socket_filepath (rundir, MY_UUID, sockfpath, sizeof (sockfpath)); + if (gf_is_service_running(pidfile, NULL)) + goto connect; + runinit (&runner); if (priv->valgrind) { @@ -5848,7 +5851,7 @@ glusterd_nodesvc_start (char *server, gf_boolean_t wait) } synclock_lock (&priv->big_lock); } - +connect: if (ret == 0) { glusterd_nodesvc_connect (server, sockfpath); } @@ -12737,3 +12740,30 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume, char **op_er out: return ret; } + +static int +gd_default_synctask_cbk (int ret, call_frame_t *frame, void *opaque) +{ + glusterd_conf_t *priv = THIS->private; + synclock_unlock (&priv->big_lock); + return ret; +} + +void +glusterd_launch_synctask (synctask_fn_t fn, void *opaque) +{ + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + int ret = -1; + + this = THIS; + priv = this->private; + + synclock_lock (&priv->big_lock); + ret = synctask_new (this->ctx->env, fn, gd_default_synctask_cbk, NULL, + opaque); + if (ret) + gf_log (this->name, GF_LOG_CRITICAL, "Failed to spawn bricks" + " and other volume related services"); +} + -- cgit