d1681e
From 267c65ef6369f9becac151b1b517e0c74a1c8e8d Mon Sep 17 00:00:00 2001
d1681e
From: Raghavendra G <rgowdapp@redhat.com>
d1681e
Date: Wed, 30 May 2018 09:34:44 +0530
d1681e
Subject: [PATCH 300/305] protocol/client: Don't send fops till SETVOLUME is
d1681e
 complete
d1681e
d1681e
An earlier commit set conf->connected just after rpc layer sends
d1681e
RPC_CLNT_CONNECT event. However, success of socket level connection
d1681e
connection doesn't indicate brick stack is ready to receive fops, as
d1681e
an handshake has to be done b/w client and server after
d1681e
RPC_CLNT_CONNECT event. Any fop sent to brick in the window between,
d1681e
* protocol/client receiving RPC_CLNT_CONNECT event
d1681e
* protocol/client receiving a successful setvolume response
d1681e
d1681e
can end up accessing an uninitialized brick stack. So, set
d1681e
conf->connected only after a successful SETVOLUME.
d1681e
d1681e
>Change-Id: I139a03d2da6b0d95a0d68391fcf54b00e749decf
d1681e
>fixes: bz#1583937
d1681e
>Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
d1681e
d1681e
upstream patch: https://review.gluster.org/20101/
d1681e
BUG: 1588408
d1681e
Change-Id: I51a15a89afd1d275a44e5f279f1a685f64f10ced
d1681e
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/140963
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
d1681e
---
d1681e
 xlators/protocol/client/src/client.c | 7 ++++---
d1681e
 xlators/protocol/client/src/client.h | 5 +++++
d1681e
 2 files changed, 9 insertions(+), 3 deletions(-)
d1681e
d1681e
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
d1681e
index 6cb5b6b..26b0907 100644
d1681e
--- a/xlators/protocol/client/src/client.c
d1681e
+++ b/xlators/protocol/client/src/client.c
d1681e
@@ -2234,7 +2234,7 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
d1681e
         }
d1681e
         case RPC_CLNT_CONNECT:
d1681e
         {
d1681e
-                conf->connected = 1;
d1681e
+                conf->can_log_disconnect = 1;
d1681e
                 // connect happened, send 'get_supported_versions' mop
d1681e
 
d1681e
                 gf_msg_debug (this->name, 0, "got RPC_CLNT_CONNECT");
d1681e
@@ -2274,7 +2274,7 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
d1681e
                         client_register_grace_timer (this, conf);
d1681e
 
d1681e
                 if (!conf->skip_notify) {
d1681e
-                        if (conf->connected) {
d1681e
+                        if (conf->can_log_disconnect) {
d1681e
                                 if (!conf->disconnect_err_logged) {
d1681e
                                         gf_msg (this->name, GF_LOG_INFO, 0,
d1681e
                                                 PC_MSG_CLIENT_DISCONNECTED,
d1681e
@@ -2309,12 +2309,13 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
d1681e
                                         "CHILD_DOWN notify failed");
d1681e
 
d1681e
                 } else {
d1681e
-                        if (conf->connected)
d1681e
+                        if (conf->can_log_disconnect)
d1681e
                                 gf_msg_debug (this->name, 0,
d1681e
                                               "disconnected (skipped notify)");
d1681e
                 }
d1681e
 
d1681e
                 conf->connected = 0;
d1681e
+                conf->can_log_disconnect = 0;
d1681e
                 conf->skip_notify = 0;
d1681e
 
d1681e
                 if (conf->quick_reconnect) {
d1681e
diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h
d1681e
index c025b98..7e2c03c 100644
d1681e
--- a/xlators/protocol/client/src/client.h
d1681e
+++ b/xlators/protocol/client/src/client.h
d1681e
@@ -204,6 +204,11 @@ typedef struct clnt_conf {
d1681e
 
d1681e
         gf_boolean_t           child_up; /* Set to true, when child is up, and
d1681e
                                           * false, when child is down */
d1681e
+
d1681e
+        gf_boolean_t           can_log_disconnect; /* socket level connection is
d1681e
+                                                    * up, disconnects can be
d1681e
+                                                    * logged
d1681e
+                                                    */
d1681e
 } clnt_conf_t;
d1681e
 
d1681e
 typedef struct _client_fd_ctx {
d1681e
-- 
d1681e
1.8.3.1
d1681e