diff options
author | Kaushal M <kaushal@gluster.com> | 2011-08-10 17:57:04 +0530 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-08-17 21:02:23 -0700 |
commit | c0180cc22f5f52f5776c74a6d1ae90100dbb5087 (patch) | |
tree | 4afb66cab55a76e7783ff7492d4a2141da3286ba | |
parent | cef6d3596fcbda71c19e66c5a6de502847aece9e (diff) |
glusterd: fix for volume stop causing inconsistent volume status
This fixes problem caused by race between glusterd and glusterfsd
occuring when they try to unlink pidfile during volume stop, which led
to the volume being stopped, but the status of the volume remained in
started state.
Change-Id: Ia99bb1a1fc6c78db138211538dfd10c577e82917
BUG: 3147
Reviewed-on: http://review.gluster.com/206
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 12 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 5 |
2 files changed, 10 insertions, 7 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 5ea542ab013..b79753519b3 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -1201,7 +1201,7 @@ glusterfs_pidfile_setup (glusterfs_ctx_t *ctx) int glusterfs_pidfile_cleanup (glusterfs_ctx_t *ctx) { - cmd_args_t *cmd_args = NULL; + cmd_args_t *cmd_args = NULL; cmd_args = &ctx->cmd_args; @@ -1209,18 +1209,18 @@ glusterfs_pidfile_cleanup (glusterfs_ctx_t *ctx) return 0; gf_log ("glusterfsd", GF_LOG_TRACE, - "pidfile %s unlocking", + "pidfile %s cleanup", cmd_args->pid_file); - lockf (fileno (ctx->pidfp), F_ULOCK, 0); - fclose (ctx->pidfp); - ctx->pidfp = NULL; - if (ctx->cmd_args.pid_file) { unlink (ctx->cmd_args.pid_file); ctx->cmd_args.pid_file = NULL; } + lockf (fileno (ctx->pidfp), F_ULOCK, 0); + fclose (ctx->pidfp); + ctx->pidfp = NULL; + return 0; } diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 1cdb0faa49a..fb7f75c523b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -886,6 +886,9 @@ glusterd_service_stop (const char *service, char *pidfile, int sig, if (ret && (ENOENT != errno)) { gf_log ("", GF_LOG_ERROR, "Unable to " "unlink stale pidfile: %s", pidfile); + } else if (ret && (ENOENT == errno)){ + ret = 0; + gf_log ("", GF_LOG_INFO, "Brick already stopped"); } goto out; } @@ -1224,7 +1227,7 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo, ret = glusterd_service_stop ("brick", pidfile, SIGTERM, _gf_false); if (ret == 0) { glusterd_set_brick_status (brickinfo, GF_BRICK_STOPPED); - ret = glusterd_brick_unlink_socket_file (volinfo, brickinfo); + (void) glusterd_brick_unlink_socket_file (volinfo, brickinfo); } return ret; } |