12a457
From fb5d0c543922c01acdfa7858efdeb206293c484b Mon Sep 17 00:00:00 2001
12a457
From: Susant Palai <spalai@redhat.com>
12a457
Date: Fri, 15 Apr 2016 05:15:33 -0400
12a457
Subject: [PATCH 096/104] dht/rebalance: Handle GF_DEFRAG_STOP
12a457
12a457
Backport of http://review.gluster.org/14004
12a457
12a457
Problem: On a rebal stop, the migrator threads don't intimate the
12a457
crawler thread to wake up in case it is waiting on signal from
12a457
migrator thread.
12a457
12a457
BUG: 1326663
12a457
Change-Id: Ib1c2a6cccae5eef07650193cb9461ba390a89a00
12a457
Reviewed-by: N Balachandran <nbalacha@redhat.com>
12a457
Reviewed-on: http://review.gluster.org/14076
12a457
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
12a457
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
12a457
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
12a457
Smoke: Gluster Build System <jenkins@build.gluster.com>
12a457
Signed-off-by: Susant Palai <spalai@redhat.com>
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/73093
12a457
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
12a457
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
12a457
---
12a457
 xlators/cluster/dht/src/dht-rebalance.c |   17 +++++++++++++++++
12a457
 1 files changed, 17 insertions(+), 0 deletions(-)
12a457
12a457
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
12a457
index de24135..f41aa22 100644
12a457
--- a/xlators/cluster/dht/src/dht-rebalance.c
12a457
+++ b/xlators/cluster/dht/src/dht-rebalance.c
12a457
@@ -2074,6 +2074,10 @@ gf_defrag_task (void *opaque)
12a457
         while (true) {
12a457
 
12a457
                 if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
12a457
+                        pthread_cond_broadcast (
12a457
+                                &defrag->rebalance_crawler_alarm);
12a457
+                        pthread_cond_broadcast (
12a457
+                                &defrag->parallel_migration_cond);
12a457
                         goto out;
12a457
                 }
12a457
 
12a457
@@ -2137,6 +2141,13 @@ gf_defrag_task (void *opaque)
12a457
 
12a457
                                         defrag->defrag_status =
12a457
                                                        GF_DEFRAG_STATUS_FAILED;
12a457
+
12a457
+                                        pthread_cond_broadcast (
12a457
+                                             &defrag->rebalance_crawler_alarm);
12a457
+
12a457
+                                        pthread_cond_broadcast (
12a457
+                                             &defrag->parallel_migration_cond);
12a457
+
12a457
                                         goto out;
12a457
                                 }
12a457
 
12a457
@@ -2195,10 +2206,16 @@ gf_defrag_get_entry (xlator_t *this, int i, struct dht_container **container,
12a457
         xlator_t               *hashed_subvol   = NULL;
12a457
         xlator_t               *cached_subvol   = NULL;
12a457
 
12a457
+        if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
12a457
+                ret = -1;
12a457
+                goto out;
12a457
+        }
12a457
+
12a457
         if (dir_dfmeta->offset_var[i].readdir_done == 1) {
12a457
                 ret = 0;
12a457
                 goto out;
12a457
         }
12a457
+
12a457
         if (dir_dfmeta->fetch_entries[i] == 1) {
12a457
                 ret = syncop_readdirp (conf->local_subvols[i], fd, 131072,
12a457
                                        dir_dfmeta->offset_var[i].offset,
12a457
-- 
12a457
1.7.1
12a457