Blob Blame History Raw
From c12fb1731b7990f951d360bafe9eca49c27f5dcb Mon Sep 17 00:00:00 2001
From: Dan Lambright <dlambrig@redhat.com>
Date: Tue, 2 Jun 2015 18:48:19 -0400
Subject: [PATCH 55/57] cluster/tier: make attach/detach work with new rebalance logic

This is a backport of 10795

The new rebalance performance improvements added new
datastructures which were not initialized in the
tier case. Function dht_find_local_subvol_cbk() needs
to accept a list built by lower level DHT translators
in order to build the local subvolumes list.

> Change-Id: Iab03fc8e7fadc22debc08cd5bc781b9e3e270497
> BUG: 1222088
> Signed-off-by: Dan Lambright <dlambrig@redhat.com>
> Reviewed-on: http://review.gluster.org/10795
> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>

Change-Id: Id1fde62dce51bb91358214721b3c04ad2224c439
Signed-off-by: Dan Lambright <dlambrig@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/49749
Tested-by: Joseph Fernandes <josferna@redhat.com>
Reviewed-by: Joseph Fernandes <josferna@redhat.com>
Reviewed-by: Shyam Ranganathan <srangana@redhat.com>
---
 xlators/cluster/dht/src/dht-common.c    |   42 +++++++++++++++++++-----------
 xlators/cluster/dht/src/dht-rebalance.c |    9 +-----
 2 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 8870a30..868cd79 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -2627,6 +2627,9 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
         int           this_call_cnt = 0;
         int           ret           = 0;
         char         *uuid_str      = NULL;
+        char         *uuid_list     = NULL;
+        char         *next_uuid_str = NULL;
+        char         *saveptr       = NULL;
         uuid_t        node_uuid     = {0,};
 
 
@@ -2649,7 +2652,7 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
                         goto unlock;
                 }
 
-                ret = dict_get_str (xattr, local->xsel, &uuid_str);
+                ret = dict_get_str (xattr, local->xsel, &uuid_list);
 
                 if (ret < 0) {
                         gf_log (this->name, GF_LOG_ERROR, "Failed to "
@@ -2659,22 +2662,29 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
                         goto unlock;
                 }
 
-                if (gf_uuid_parse (uuid_str, node_uuid)) {
-                        gf_log (this->name, GF_LOG_ERROR, "Failed to parse uuid"
-                                " failed for %s", prev->this->name);
-                        local->op_ret = -1;
-                        local->op_errno = EINVAL;
-                        goto unlock;
-                }
+                for (uuid_str = strtok_r (uuid_list, " ", &saveptr);
+                     uuid_str;
+                     uuid_str = next_uuid_str) {
 
-                if (gf_uuid_compare (node_uuid, conf->defrag->node_uuid)) {
-                        gf_log (this->name, GF_LOG_DEBUG, "subvol %s does not"
-                                "belong to this node", prev->this->name);
-                } else {
-                        conf->local_subvols[(conf->local_subvols_cnt)++]
-                                                           = prev->this;
-                        gf_log (this->name, GF_LOG_DEBUG, "subvol %s belongs to"
-                                " this node", prev->this->name);
+                        next_uuid_str = strtok_r (NULL, " ", &saveptr);
+                        if (gf_uuid_parse (uuid_str, node_uuid)) {
+                                gf_log (this->name, GF_LOG_ERROR, "Failed to parse uuid"
+                                        " failed for %s", prev->this->name);
+                                local->op_ret = -1;
+                                local->op_errno = EINVAL;
+                                goto unlock;
+                        }
+
+                        if (gf_uuid_compare (node_uuid, conf->defrag->node_uuid)) {
+                                gf_log (this->name, GF_LOG_DEBUG, "subvol %s does not"
+                                        "belong to this node", prev->this->name);
+                        } else {
+                                conf->local_subvols[(conf->local_subvols_cnt)++]
+                                        = prev->this;
+                                gf_log (this->name, GF_LOG_DEBUG, "subvol %s belongs to"
+                                        " this node", prev->this->name);
+                                break;
+                        }
                 }
         }
 
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index 89cc3a8..38db3a1 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -2691,8 +2691,7 @@ gf_defrag_start_crawl (void *data)
                 goto out;
         }
 
-        if ((defrag->cmd != GF_DEFRAG_CMD_START_TIER) &&
-            (defrag->cmd != GF_DEFRAG_CMD_START_LAYOUT_FIX)) {
+        if (defrag->cmd != GF_DEFRAG_CMD_START_LAYOUT_FIX) {
                 migrate_data = dict_new ();
                 if (!migrate_data) {
                         defrag->total_failures++;
@@ -2789,11 +2788,7 @@ gf_defrag_start_crawl (void *data)
                 }
                 methods->migration_other(this, defrag);
                 if (defrag->cmd == GF_DEFRAG_CMD_START_DETACH_TIER) {
-                        migrate_data = dict_new ();
-                        if (!migrate_data) {
-                                ret = -1;
-                                goto out;
-                        }
+
                         ret = dict_set_str (migrate_data,
                                             GF_XATTR_FILE_MIGRATE_KEY,
                                             "force");
-- 
1.7.1