a3470f
From f5326dd5cfd3c2fae01bc62aa6e0725b501faa3a Mon Sep 17 00:00:00 2001
a3470f
From: Atin Mukherjee <amukherj@redhat.com>
a3470f
Date: Sun, 1 Apr 2018 22:10:30 +0530
a3470f
Subject: [PATCH 311/325] glusterd: show brick online after port registration
a3470f
a3470f
	Upstream-patch: https://review.gluster.org/19804
a3470f
a3470f
gluster-block project needs a dependency check to see if all the bricks
a3470f
are online before bringing up the relevant gluster-block services. While
a3470f
the patch https://review.gluster.org/#/c/19785/ attempts to write the
a3470f
script but brick should be only marked as online only when the
a3470f
pmap_signin is completed.
a3470f
a3470f
While this is perfectly fine for non brick multiplexing, but with brick
a3470f
multiplexing this patch still doesn't eliminate the race completely as
a3470f
the attach_req call is asynchrnous and glusterd immediately marks the
a3470f
port as registerd.
a3470f
a3470f
 >Fixes: bz#1563273
a3470f
BUG: 1598356
a3470f
Change-Id: I81db54b88f7315e1b24e0234beebe00de6429f9d
a3470f
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/143591
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
a3470f
---
a3470f
 xlators/mgmt/glusterd/src/glusterd-utils.c | 5 +++--
a3470f
 1 file changed, 3 insertions(+), 2 deletions(-)
a3470f
a3470f
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
a3470f
index 5e9213c..e08c053 100644
a3470f
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
a3470f
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
a3470f
@@ -5967,6 +5967,7 @@ glusterd_brick_start (glusterd_volinfo_t *volinfo,
a3470f
                         (void) pmap_registry_bind (this,
a3470f
                                         brickinfo->port, brickinfo->path,
a3470f
                                         GF_PMAP_PORT_BRICKSERVER, NULL);
a3470f
+                        brickinfo->port_registered = _gf_true;
a3470f
                         /*
a3470f
                          * This will unfortunately result in a separate RPC
a3470f
                          * connection per brick, even though they're all in
a3470f
@@ -5976,7 +5977,6 @@ glusterd_brick_start (glusterd_volinfo_t *volinfo,
a3470f
                          * TBD: re-use RPC connection across bricks
a3470f
                          */
a3470f
                         if (is_brick_mx_enabled ()) {
a3470f
-                                brickinfo->port_registered = _gf_true;
a3470f
                                 ret = glusterd_get_sock_from_brick_pid (pid, socketpath,
a3470f
                                                                         sizeof(socketpath));
a3470f
                                 if (ret) {
a3470f
@@ -7083,7 +7083,8 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo,
a3470f
         GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv);
a3470f
 
a3470f
         if (glusterd_is_brick_started (brickinfo)) {
a3470f
-                if (gf_is_service_running (pidfile, &pid)) {
a3470f
+                if (gf_is_service_running (pidfile, &pid) &&
a3470f
+                    brickinfo->port_registered) {
a3470f
                         brick_online = _gf_true;
a3470f
                 } else {
a3470f
                         pid = -1;
a3470f
-- 
a3470f
1.8.3.1
a3470f