From 3f11b8e8ec6d78ebe33636b64130d5d133729f2c Mon Sep 17 00:00:00 2001 From: Dan Lambright Date: Thu, 28 May 2015 14:00:37 -0400 Subject: cluster/dht: maintain start state of rebalance daemon across graph switch. When we did a graph switch on a rebalance daemon, a second call to gf_degrag_start() was done. This lead to multiple threads doing migration. When multiple threads try to move the same file there can be deadlocks. Change-Id: I931ca7fe600022f245e3dccaabb1ad004f732c56 BUG: 1226005 Signed-off-by: Dan Lambright Reviewed-on: http://review.gluster.org/10977 Tested-by: NetBSD Build System Reviewed-by: Shyamsundar Ranganathan --- xlators/cluster/dht/src/dht-common.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index d42ef867e2..83aa9a26f4 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -24,6 +24,8 @@ #include #include +int run_defrag = 0; + int dht_link2 (xlator_t *this, call_frame_t *frame, int op_ret); int @@ -6892,11 +6894,16 @@ unlock: } } - /* rebalance is started with assert_no_child_down. So we do + /* Rebalance is started with assert_no_child_down. So we do * not need to handle CHILD_DOWN event here. + * + * If there is a graph switch, we should not restart the + * rebalance daemon. Use 'run_defrag' to indicate if the + * thread has already started. */ - if (conf->defrag) { + if (conf->defrag && !run_defrag) { if (methods->migration_needed(this)) { + run_defrag = 1; ret = gf_thread_create(&conf->defrag->th, NULL, gf_defrag_start, this); -- cgit