From 67b8b290c6a46dcc0dc20e3589f9c1f58110f332 Mon Sep 17 00:00:00 2001 From: Dan Lambright Date: Tue, 2 Jun 2015 14:46:46 -0400 Subject: [PATCH 53/57] cluster/dht: maintain start state of rebalance daemon across graph switch This is a backport of 10977 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 Change-Id: I7797492cc6f32c0bf155b542d51184eb9a84a53d BUG: 1227469 Signed-off-by: Dan Lambright Reviewed-on: https://code.engineering.redhat.com/gerrit/49748 Reviewed-by: Joseph Fernandes Tested-by: Joseph Fernandes Reviewed-by: Shyam Ranganathan --- xlators/cluster/dht/src/dht-common.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index a3a48ea..6d70f82 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -37,6 +37,9 @@ dht_removexattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); int dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); +int run_defrag = 0; + + int dht_aggregate_quota_xattr (dict_t *dst, char *key, data_t *value) { @@ -6895,11 +6898,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); -- 1.7.1