From a5a5a32ee96a6a481f34edd4084b34a19715c4e4 Mon Sep 17 00:00:00 2001
From: Jeff Darcy <jdarcy@redhat.com>
Date: Fri, 17 Feb 2017 09:42:46 -0500
Subject: [PATCH 336/361] glusterd: take conn->lock around operations on
conn->reconnect
Failure to do this could lead to a race in which a timer would be
removed twice concurrently, corrupting the timer list (because
gf_timer_call_cancel has no internal protection against this) and
possibly causing a crash.
mainline:
> BUG: 1421721
> Reviewed-on: https://review.gluster.org/16662
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
(cherry picked from commit d92ca253ef73086e496a410e7dba62467a9759da)
BUG: 1417815
Change-Id: Ic1a8b612d436daec88fd6cee935db0ae81a47d5c
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/101317
Tested-by: Milind Changire <mchangir@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
tests/bugs/core/bug-1421721-mpx-toggle.t | 25 +++++++++++++++++++++++++
xlators/mgmt/glusterd/src/glusterd-utils.c | 3 ++-
2 files changed, 27 insertions(+), 1 deletion(-)
create mode 100644 tests/bugs/core/bug-1421721-mpx-toggle.t
diff --git a/tests/bugs/core/bug-1421721-mpx-toggle.t b/tests/bugs/core/bug-1421721-mpx-toggle.t
new file mode 100644
index 0000000..231be5b
--- /dev/null
+++ b/tests/bugs/core/bug-1421721-mpx-toggle.t
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+
+write_a_file () {
+ echo $1 > $2
+}
+
+TEST glusterd
+TEST $CLI volume create $V0 $H0:$B0/${V0}[0,1]
+
+TEST $CLI volume set all cluster.brick-multiplex on
+TEST $CLI volume start $V0
+
+TEST $GFS -s $H0 --volfile-id=$V0 $M0
+TEST write_a_file "hello" $M0/a_file
+
+TEST force_umount $M0
+TEST $CLI volume stop $V0
+
+TEST $CLI volume set all cluster.brick-multiplex off
+TEST $CLI volume start $V0
+
+cleanup
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 9a294a8..66b3d54 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1862,10 +1862,11 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
if (rpc) {
brickinfo->rpc = NULL;
conn = &rpc->conn;
+ pthread_mutex_lock (&conn->lock);
if (conn->reconnect) {
(void ) gf_timer_call_cancel (rpc->ctx, conn->reconnect);
- //rpc_clnt_unref (rpc);
}
+ pthread_mutex_unlock (&conn->lock);
rpc_clnt_unref (rpc);
}
--
1.8.3.1