Blob Blame History Raw
From 3779c6ce05b04d8a4ec2a4971f0987e471afb33f Mon Sep 17 00:00:00 2001
From: Atin Mukherjee <amukherj@redhat.com>
Date: Fri, 21 Oct 2016 18:27:45 +0530
Subject: [PATCH 153/157] glusterd: use GF_BRICK_STOPPING as intermediate brickinfo->status state

On a volume stop trigger glusterd issues a brick-op to terminate the brick
process during brick-op phase , however in the commit-op glusterd once again
tries to kill the same process if it exists and then mark the brickinfo->status
flag to GF_BRICK_STOPPED. In the former case, if brick is successfully killed
there is a possibility that GlusterD will receive RPC_CLNT_DISCONNECT from the
said brick process before even the commit op phase is executed and hence by that
time brickinfo->status will still be set to GF_BRICK_STARTED.

BRICK_DISCONNECT event should be only sent if a brick has been killed and not
through a volume stop/remove brick trigger, however due to this trace, this
event is also sent out on a volume stop.

Fix is to introduce an intermediate state GF_BRICK_STOPPING which can be used to
mark the brick status at brick op phase of volume stop/remove brick to avoid
sending spurious BRICK_DISCONNECT events on a volume stop trigger.

This patch fixes BZ 1385561 as well

>Reviewed-on: http://review.gluster.org/15699
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Kaushal M <kaushal@redhat.com>

Change-Id: Ieed4450e1c988715e0f9958be44faa6b14be81e1
BUG: 1387544
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/89352
---
 xlators/mgmt/glusterd/src/glusterd-op-sm.c |    3 ++-
 xlators/mgmt/glusterd/src/glusterd.h       |    1 +
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 0528fbd..fcad97c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -577,7 +577,8 @@ glusterd_brick_op_build_payload (glusterd_op_t op, glusterd_brickinfo_t *brickin
                         goto out;
                 brick_req->op = GLUSTERD_BRICK_TERMINATE;
                 brick_req->name = "";
-        break;
+                glusterd_set_brick_status (brickinfo, GF_BRICK_STOPPING);
+                break;
         case GD_OP_PROFILE_VOLUME:
                 brick_req = GF_CALLOC (1, sizeof (*brick_req),
                                        gf_gld_mt_mop_brick_req_t);
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 8695ab9..23b7623 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -189,6 +189,7 @@ typedef struct {
 typedef enum gf_brick_status {
         GF_BRICK_STOPPED,
         GF_BRICK_STARTED,
+        GF_BRICK_STOPPING,
 } gf_brick_status_t;
 
 struct glusterd_brickinfo {
-- 
1.7.1