7f4c2a
From 67b8b290c6a46dcc0dc20e3589f9c1f58110f332 Mon Sep 17 00:00:00 2001
7f4c2a
From: Dan Lambright <dlambrig@redhat.com>
7f4c2a
Date: Tue, 2 Jun 2015 14:46:46 -0400
7f4c2a
Subject: [PATCH 53/57] cluster/dht: maintain start state of rebalance daemon across graph switch
7f4c2a
7f4c2a
This is a backport of 10977
7f4c2a
7f4c2a
When we did a graph switch on a rebalance daemon, a second call
7f4c2a
to gf_degrag_start() was done. This lead to multiple threads
7f4c2a
doing migration. When multiple threads try to move the same
7f4c2a
file there can be deadlocks.
7f4c2a
7f4c2a
> Change-Id: I931ca7fe600022f245e3dccaabb1ad004f732c56
7f4c2a
> BUG: 1226005
7f4c2a
> Signed-off-by: Dan Lambright <dlambrig@redhat.com>
7f4c2a
> Reviewed-on: http://review.gluster.org/10977
7f4c2a
> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
7f4c2a
> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
7f4c2a
7f4c2a
Change-Id: I7797492cc6f32c0bf155b542d51184eb9a84a53d
7f4c2a
BUG: 1227469
7f4c2a
Signed-off-by: Dan Lambright <dlambrig@redhat.com>
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/49748
7f4c2a
Reviewed-by: Joseph Fernandes <josferna@redhat.com>
7f4c2a
Tested-by: Joseph Fernandes <josferna@redhat.com>
7f4c2a
Reviewed-by: Shyam Ranganathan <srangana@redhat.com>
7f4c2a
---
7f4c2a
 xlators/cluster/dht/src/dht-common.c |   12 ++++++++++--
7f4c2a
 1 files changed, 10 insertions(+), 2 deletions(-)
7f4c2a
7f4c2a
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
7f4c2a
index a3a48ea..6d70f82 100644
7f4c2a
--- a/xlators/cluster/dht/src/dht-common.c
7f4c2a
+++ b/xlators/cluster/dht/src/dht-common.c
7f4c2a
@@ -37,6 +37,9 @@ dht_removexattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame);
7f4c2a
 int
7f4c2a
 dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame);
7f4c2a
 
7f4c2a
+int run_defrag = 0;
7f4c2a
+
7f4c2a
+
7f4c2a
 int
7f4c2a
 dht_aggregate_quota_xattr (dict_t *dst, char *key, data_t *value)
7f4c2a
 {
7f4c2a
@@ -6895,11 +6898,16 @@ unlock:
7f4c2a
                         }
7f4c2a
                 }
7f4c2a
 
7f4c2a
-                /* rebalance is started with assert_no_child_down. So we do
7f4c2a
+                /* Rebalance is started with assert_no_child_down. So we do
7f4c2a
                  * not need to handle CHILD_DOWN event here.
7f4c2a
+                 *
7f4c2a
+                 * If there is a graph switch, we should not restart the
7f4c2a
+                 * rebalance daemon. Use 'run_defrag' to indicate if the
7f4c2a
+                 * thread has already started.
7f4c2a
                  */
7f4c2a
-                if (conf->defrag) {
7f4c2a
+                 if (conf->defrag && !run_defrag) {
7f4c2a
                         if (methods->migration_needed(this)) {
7f4c2a
+                                run_defrag = 1;
7f4c2a
                                 ret = gf_thread_create(&conf->defrag->th,
7f4c2a
                                                        NULL,
7f4c2a
                                                        gf_defrag_start, this);
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a