diff options
author | N Balachandran <nbalacha@redhat.com> | 2017-07-21 16:38:14 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2017-10-10 08:58:39 +0000 |
commit | c4a608799a577a4f38139f6bb8a47da8efb0fec3 (patch) | |
tree | 802a7a12349accd458bea79d5e43e7afad3a1802 /xlators/cluster/dht/src/dht-rebalance.c | |
parent | d4eb4ef28073fc8f5430802d9de9344e551711bb (diff) |
cluster/dht: Don't store the entire uuid for subvols
Comparing the uuid string of the local node against that stored in the
local_subvol information is inefficient, especially as it is
done for every file to be migrated. The code has now been changed
to set the value of info to 1 if the nodeuuid is that of the node
making the comparison so this becomes an integer comparison.
Change-Id: I7491d59caad3b71dbf5facc94dcde0cd53962775
BUG: 1451434
Signed-off-by: N Balachandran <nbalacha@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-rebalance.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index e932eaa3add..dd29d7db05e 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -2447,7 +2447,12 @@ gf_defrag_ctx_subvols_init (dht_dfoffset_ctx_t *offset_var, xlator_t *this) { /* Return value * 0 : this node does not migrate the file * 1 : this node migrates the file + * + * Use the hash value of the gfid to determine which node will migrate files. + * Using the gfid instead of the name also ensures that the same node handles + * all hardlinks. */ + int gf_defrag_should_i_migrate (xlator_t *this, int local_subvol_index, uuid_t gfid) { @@ -2468,13 +2473,14 @@ gf_defrag_should_i_migrate (xlator_t *this, int local_subvol_index, uuid_t gfid) } str = uuid_utoa_r (gfid, buf); - ret = dht_hash_compute (this, 0, str, &hashval); if (ret == 0) { index = (hashval % conf->local_nodeuuids[i].count); - if (!gf_uuid_compare (conf->defrag->node_uuid, - conf->local_nodeuuids[i].uuids[index])) + if (conf->local_nodeuuids[i].elements[index].info + == REBAL_NODEUUID_MINE) { + /* Index matches this node's nodeuuid.*/ ret = 1; + } } return ret; } @@ -4306,7 +4312,7 @@ gf_defrag_start_crawl (void *data) xlator_t *old_THIS = NULL; int j = 0; gf_boolean_t fc_thread_started = _gf_false; - + uuid_t *uuid_ptr = NULL; this = data; if (!this) @@ -4444,10 +4450,12 @@ gf_defrag_start_crawl (void *data) for (i = 0 ; i < conf->local_subvols_cnt; i++) { gf_msg (this->name, GF_LOG_INFO, 0, 0, "local subvols " "are %s", conf->local_subvols[i]->name); + for (j = 0; j < conf->local_nodeuuids[i].count; j++) { + uuid_ptr = &(conf->local_nodeuuids[i].elements[j].uuid); gf_msg (this->name, GF_LOG_INFO, 0, 0, "node uuids are %s", - uuid_utoa(conf->local_nodeuuids[i].uuids[j])); + uuid_utoa(*uuid_ptr)); } } |