summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawal@redhat.com>2019-04-05 09:46:24 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2019-04-08 14:02:26 +0000
commite26fc565990091ac18acd2859296029d3b7609b4 (patch)
tree1e565c68c2b1b5cfe9d8605a6c16c0ebad67e08d
parent3f9f00b2e5ec4ad845f3c8edef56fec0b4e4bbc1 (diff)
glusterfsd: Multiple shd processes are spawned on brick_mux environment
Problem: Multiple shd processes are spawned while starting volumes in the loop on brick_mux environment.glusterd spawn a process based on a pidfile and shd daemon is taking some time to update pid in pidfile due to that glusterd is not able to get shd pid Solution: Commit cd249f4cb783f8d79e79468c455732669e835a4f changed the code to update pidfile in parent for any gluster daemon after getting the status of forking child in parent.To resolve the same correct the condition update pidfile in parent only for glusterd and for rest of the daemon pidfile is updated in child > Change-Id: Ifd14797fa949562594a285ec82d58384ad717e81 > fixes: bz#1684404 > Signed-off-by: Mohit Agrawal <moagrawal@redhat.com> > (Cherry picked from commit 66986594a9023c49e61b32769b7e6b260b600626) > (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/22290/) Change-Id: Ie295e905c01f2749bc39da5511537cc9a85832e5 fixes: bz#1696513 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
-rw-r--r--glusterfsd/src/glusterfsd.c22
-rw-r--r--libglusterfs/src/common-utils.c5
2 files changed, 18 insertions, 9 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index f589ce69ecd..dfc3e14beaf 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -2438,9 +2438,6 @@ daemonize (glusterfs_ctx_t *ctx)
goto out;
if (cmd_args->no_daemon_mode) {
- ret = glusterfs_pidfile_update (ctx, getpid());
- if (ret)
- goto out;
goto postfork;
}
@@ -2496,13 +2493,26 @@ daemonize (glusterfs_ctx_t *ctx)
will be available to parent process on calling exit() */
if (err)
_exit (abs(err));
- ret = glusterfs_pidfile_update (ctx, child_pid);
- if (ret)
- _exit (1);
+
+ /* Update pid in parent only for glusterd process */
+ if (ctx->process_mode == GF_GLUSTERD_PROCESS) {
+ ret = glusterfs_pidfile_update(ctx, child_pid);
+ if (ret)
+ exit(1);
+ }
_exit (0);
}
postfork:
+ /* Update pid in child either process_mode is not belong to glusterd
+ or process is spawned in no daemon mode
+ */
+ if ((ctx->process_mode != GF_GLUSTERD_PROCESS) ||
+ (cmd_args->no_daemon_mode)) {
+ ret = glusterfs_pidfile_update(ctx, getpid());
+ if (ret)
+ goto out;
+ }
ret = gf_log_inject_timer_event (ctx);
glusterfs_signals_setup (ctx);
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index e2874602a84..8408bfe5eca 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -4000,15 +4000,14 @@ gf_is_service_running (char *pidfile, int *pid)
ret = lockf (fno, F_TEST, 0);
if (ret == -1)
running = _gf_true;
- if (!pid) {
- goto out;
- }
ret = fscanf (file, "%d", pid);
if (ret <= 0) {
gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
"Unable to read pidfile: %s", pidfile);
*pid = -1;
+ running = _gf_false;
+ goto out;
}
running = gf_is_pid_running (*pid);