21ab4e
From eb9d5dc96befec76eb2e1960e522ede1dc87551c Mon Sep 17 00:00:00 2001
21ab4e
From: Gaurav Yadav <gyadav@redhat.com>
21ab4e
Date: Sun, 21 May 2017 12:31:29 +0530
21ab4e
Subject: [PATCH 466/473] glusterd : volume profile command on one of the node
21ab4e
 crashes glusterd
21ab4e
21ab4e
When volume profile command is issued on one of the node glusterd
21ab4e
crashes. Its a race condition which may hit when profile command and
21ab4e
status command is being executed from node A and node B respectively.
21ab4e
While doing so event GD_OP_STATE_BRICK_OP_SENT/GD_OP_STATE_BRICK_COMMITTED
21ab4e
is being triggered. As handling of event is not thread safe, hence context
21ab4e
got modify and glusterd crashes.
21ab4e
21ab4e
With the fix now we are validating the context before using it.
21ab4e
21ab4e
> Reviewed-on: https://review.gluster.org/17350
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Samikshan Bairagya <samikshan@gmail.com>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
21ab4e
Change-Id: Ic07c3cdc5644677b0e40ff0fac6fcca834158913
21ab4e
BUG: 1452205
21ab4e
Signed-off-by: Gaurav Yadav <gyadav@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/106947
21ab4e
Reviewed-by: Samikshan Bairagya <sbairagy@redhat.com>
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 xlators/mgmt/glusterd/src/glusterd-op-sm.c | 11 ++++++-----
21ab4e
 1 file changed, 6 insertions(+), 5 deletions(-)
21ab4e
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
index 8ebece6..f82a8f1 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
@@ -7511,7 +7511,7 @@ out:
21ab4e
 static int
21ab4e
 glusterd_op_ac_rcvd_brick_op_acc (glusterd_op_sm_event_t *event, void *ctx)
21ab4e
 {
21ab4e
-        int                     ret = 0;
21ab4e
+        int                     ret = -1;
21ab4e
         glusterd_op_brick_rsp_ctx_t *ev_ctx = NULL;
21ab4e
         char                        *op_errstr = NULL;
21ab4e
         glusterd_op_t               op = GD_OP_NONE;
21ab4e
@@ -7522,13 +7522,14 @@ glusterd_op_ac_rcvd_brick_op_acc (glusterd_op_sm_event_t *event, void *ctx)
21ab4e
         xlator_t                    *this = NULL;
21ab4e
 
21ab4e
         this = THIS;
21ab4e
-        GF_ASSERT (this);
21ab4e
-        GF_ASSERT (event);
21ab4e
-        GF_ASSERT (ctx);
21ab4e
+        GF_VALIDATE_OR_GOTO ("glusterd", this, out);
21ab4e
+        GF_VALIDATE_OR_GOTO (this->name, event, out);
21ab4e
+        GF_VALIDATE_OR_GOTO (this->name, ctx, out);
21ab4e
         ev_ctx = ctx;
21ab4e
+        GF_VALIDATE_OR_GOTO(this->name, ev_ctx, out);
21ab4e
 
21ab4e
         req_ctx = ev_ctx->commit_ctx;
21ab4e
-        GF_ASSERT (req_ctx);
21ab4e
+        GF_VALIDATE_OR_GOTO (this->name, req_ctx, out);
21ab4e
 
21ab4e
         op = req_ctx->op;
21ab4e
         op_ctx = glusterd_op_get_ctx ();
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e