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