7c2869
From 6722966d5e73f52d702b2e4d9987c5c372767a89 Mon Sep 17 00:00:00 2001
7c2869
From: Ravishankar N <ravishankar@redhat.com>
7c2869
Date: Mon, 2 Jul 2018 16:05:39 +0530
7c2869
Subject: [PATCH 680/685] glusterfsd: Do not process GLUSTERD_BRICK_XLATOR_OP
7c2869
 if graph is not ready
7c2869
7c2869
Patch in upstream master: https://review.gluster.org/#/c/20435/
7c2869
Patch in release-3.12: https://review.gluster.org/#/c/20436/
7c2869
7c2869
Problem:
7c2869
If glustershd gets restarted by glusterd due to node reboot/volume start force/
7c2869
or any thing that changes shd graph (add/remove brick), and index heal
7c2869
is launched via CLI, there can be a chance that shd receives this IPC
7c2869
before the graph is fully active. Thus when it accesses
7c2869
glusterfsd_ctx->active, it crashes.
7c2869
7c2869
Fix:
7c2869
Since glusterd does not really wait for the daemons it spawned to be
7c2869
fully initialized and can send the request as soon as rpc initialization has
7c2869
succeeded, we just handle it at shd. If glusterfs_graph_activate() is
7c2869
not yet done in shd but glusterd sends GD_OP_HEAL_VOLUME to shd,
7c2869
we fail the request.
7c2869
7c2869
Change-Id: If6cc07bc5455c4ba03458a36c28b63664496b17d
7c2869
BUG: 1595752
7c2869
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
7c2869
Reviewed-on: https://code.engineering.redhat.com/gerrit/143109
7c2869
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
7c2869
---
7c2869
 glusterfsd/src/glusterfsd-messages.h | 4 +++-
7c2869
 glusterfsd/src/glusterfsd-mgmt.c     | 6 ++++++
7c2869
 2 files changed, 9 insertions(+), 1 deletion(-)
7c2869
7c2869
diff --git a/glusterfsd/src/glusterfsd-messages.h b/glusterfsd/src/glusterfsd-messages.h
7c2869
index e9c28f7..e38a88b 100644
7c2869
--- a/glusterfsd/src/glusterfsd-messages.h
7c2869
+++ b/glusterfsd/src/glusterfsd-messages.h
7c2869
@@ -36,7 +36,7 @@
7c2869
  */
7c2869
 
7c2869
 #define GLFS_COMP_BASE          GLFS_MSGID_COMP_GLUSTERFSD
7c2869
-#define GLFS_NUM_MESSAGES       37
7c2869
+#define GLFS_NUM_MESSAGES       38
7c2869
 #define GLFS_MSGID_END          (GLFS_COMP_BASE + GLFS_NUM_MESSAGES + 1)
7c2869
 /* Messaged with message IDs */
7c2869
 #define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages"
7c2869
@@ -109,6 +109,8 @@
7c2869
 #define glusterfsd_msg_36 (GLFS_COMP_BASE + 36), "problem in xlator " \
7c2869
                         " loading."
7c2869
 #define glusterfsd_msg_37 (GLFS_COMP_BASE + 37), "failed to get dict value"
7c2869
+#define glusterfsd_msg_38 (GLFS_COMP_BASE + 38), "Not processing brick-op no."\
7c2869
+                        " %d since volume graph is not yet active."
7c2869
 
7c2869
 /*------------*/
7c2869
 #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
7c2869
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
7c2869
index bde49ba..076a68a 100644
7c2869
--- a/glusterfsd/src/glusterfsd-mgmt.c
7c2869
+++ b/glusterfsd/src/glusterfsd-mgmt.c
7c2869
@@ -671,6 +671,12 @@ glusterfs_handle_translator_op (rpcsvc_request_t *req)
7c2869
 
7c2869
         ctx = glusterfsd_ctx;
7c2869
         active = ctx->active;
7c2869
+        if (!active) {
7c2869
+                ret = -1;
7c2869
+                gf_msg (this->name, GF_LOG_ERROR, EAGAIN, glusterfsd_msg_38,
7c2869
+                        xlator_req.op);
7c2869
+                goto out;
7c2869
+        }
7c2869
         any = active->first;
7c2869
         input = dict_new ();
7c2869
         ret = dict_unserialize (xlator_req.input.input_val,
7c2869
-- 
7c2869
1.8.3.1
7c2869