From c4a608799a577a4f38139f6bb8a47da8efb0fec3 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Fri, 21 Jul 2017 16:38:14 +0530 Subject: 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 --- xlators/cluster/dht/src/dht-common.c | 20 +++++++++++++------- xlators/cluster/dht/src/dht-common.h | 18 ++++++++++++------ xlators/cluster/dht/src/dht-helper.c | 3 ++- xlators/cluster/dht/src/dht-rebalance.c | 18 +++++++++++++----- 4 files changed, 40 insertions(+), 19 deletions(-) (limited to 'xlators') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 1cc2f08abfb..c7069a9dbc0 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -3938,7 +3938,7 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int i = 0; int index = 0; int found = 0; - + nodeuuid_info_t *tmp_ptr = NULL; VALIDATE_OR_GOTO (frame, out); VALIDATE_OR_GOTO (frame->local, out); @@ -4023,8 +4023,8 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } conf->local_nodeuuids[index].count = count; - conf->local_nodeuuids[index].uuids - = GF_CALLOC (count, sizeof (uuid_t), 1); + conf->local_nodeuuids[index].elements + = GF_CALLOC (count, sizeof (nodeuuid_info_t), 1); /* The node-uuids are guaranteed to be returned in the same * order as the bricks @@ -4039,9 +4039,15 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, uuid_str = next_uuid_str) { next_uuid_str = strtok_r (NULL, " ", &saveptr); - gf_uuid_parse (uuid_str, - conf->local_nodeuuids[index].uuids[i]); + tmp_ptr = &(conf->local_nodeuuids[index].elements[i]); + gf_uuid_parse (uuid_str, tmp_ptr->uuid); + + if (!gf_uuid_compare (tmp_ptr->uuid, + conf->defrag->node_uuid)) { + tmp_ptr->info = REBAL_NODEUUID_MINE; + } i++; + tmp_ptr = NULL; } } @@ -4061,8 +4067,8 @@ dht_find_local_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, unwind: - GF_FREE (conf->local_nodeuuids[index].uuids); - conf->local_nodeuuids[index].uuids = NULL; + GF_FREE (conf->local_nodeuuids[index].elements); + conf->local_nodeuuids[index].elements = NULL; DHT_STACK_UNWIND (getxattr, frame, -1, local->op_errno, NULL, xdata); out: diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 9b39596f872..f3e2c5cf41e 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -10,6 +10,7 @@ #include #include +#include #include "dht-mem-types.h" #include "dht-messages.h" @@ -47,10 +48,10 @@ */ extern char *xattrs_to_heal[]; +/* Rebalance nodeuuid flags */ +#define REBAL_NODEUUID_MINE 0x01 -#include - typedef int (*dht_selfheal_dir_cbk_t) (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, @@ -515,10 +516,15 @@ typedef struct gf_tier_conf { char volname[GD_VOLUME_NAME_MAX + 1]; } gf_tier_conf_t; -typedef struct subvol_nodeuuids { - uuid_t *uuids; +typedef struct nodeuuid_info { + char info; /* Set to 1 is this is my node's uuid*/ + uuid_t uuid; /* Store the nodeuuid as well for debugging*/ +} nodeuuid_info_t; + +typedef struct subvol_nodeuuids_info { + nodeuuid_info_t *elements; int count; -} subvol_nodeuuid_t; +} subvol_nodeuuids_info_t; struct gf_defrag_info_ { @@ -662,7 +668,7 @@ struct dht_conf { /*local subvol storage for rebalance*/ xlator_t **local_subvols; - subvol_nodeuuid_t *local_nodeuuids; + subvol_nodeuuids_info_t *local_nodeuuids; int32_t local_subvols_cnt; /* diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index ee92a0b9c09..5c3d37ad104 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -1178,7 +1178,8 @@ dht_init_local_subvolumes (xlator_t *this, dht_conf_t *conf) gf_dht_mt_xlator_t); /* FIX FIX : do this dynamically*/ - conf->local_nodeuuids = GF_CALLOC (cnt, sizeof (subvol_nodeuuid_t), + conf->local_nodeuuids = GF_CALLOC (cnt, + sizeof (subvol_nodeuuids_info_t), gf_dht_nodeuuids_t); if (!conf->local_subvols || !conf->local_nodeuuids) { 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)); } } -- cgit