Blob Blame History Raw
From 04e697b79edd55680a319e6fdb5983a1e5686db9 Mon Sep 17 00:00:00 2001
From: Atin Mukherjee <amukherj@redhat.com>
Date: Wed, 3 Oct 2018 16:34:54 +0530
Subject: [PATCH 416/444] glusterd: ignore RPC events when glusterd is shutting
 down

When glusterd receives a SIGTERM while it receives RPC
connect/disconnect/destroy events, the thread might lead to a crash
while accessing rcu_read_lock () as the clean up thread might have
already freed up the resources. This is more observable when glusterd
comes up with upgrade mode = on during upgrade process.

The solution is to ignore these events if glusterd is already in the
middle of cleanup_and_exit ().

> upstream patch : https://review.gluster.org/#/c/glusterfs/+/21330/

>Fixes: bz#1635593
>Change-Id: I12831d31c2f689d4deb038b83b9421bd5cce26d9
>Signed-off-by: Atin Mukherjee <amukherj@redhat.com>

Change-Id: I12831d31c2f689d4deb038b83b9421bd5cce26d9
BUG: 1635071
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/154848
Reviewed-by: Sanju Rakonde <srakonde@redhat.com>
Tested-by: Sanju Rakonde <srakonde@redhat.com>
Tested-by: RHGS Build Bot <nigelb@redhat.com>
---
 xlators/mgmt/glusterd/src/glusterd-handler.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 861ff17..bf37e70 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -6340,6 +6340,7 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata,
         glusterd_peerctx_t   *peerctx     = NULL;
         gf_boolean_t         quorum_action = _gf_false;
         glusterd_volinfo_t   *volinfo     = NULL;
+        glusterfs_ctx_t      *ctx         = NULL;
         uuid_t               uuid;
 
         peerctx = mydata;
@@ -6355,7 +6356,14 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata,
                 GF_FREE (peerctx);
                 return 0;
         }
-
+        ctx = this->ctx;
+        GF_VALIDATE_OR_GOTO (this->name, ctx, out);
+        if (ctx->cleanup_started) {
+                gf_log (this->name, GF_LOG_INFO, "glusterd already received a "
+                        "SIGTERM, dropping the event %d for peer %s", event,
+                        peerctx->peername);
+                return 0;
+        }
         rcu_read_lock ();
 
         peerinfo = glusterd_peerinfo_find_by_generation (peerctx->peerinfo_gen);
-- 
1.8.3.1