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