diff options
-rw-r--r-- | libglusterfs/src/glusterfs.h | 1 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 31 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 28 | ||||
-rw-r--r-- | xlators/cluster/dht/src/tier.c | 50 |
4 files changed, 55 insertions, 55 deletions
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 08ab754d398..ee5c21d43d5 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -87,6 +87,7 @@ #define GF_XATTR_NODE_UUID_KEY "trusted.glusterfs.node-uuid" #define GF_XATTR_LIST_NODE_UUIDS_KEY "trusted.glusterfs.list-node-uuids" #define GF_REBAL_FIND_LOCAL_SUBVOL "glusterfs.find-local-subvol" +#define GF_REBAL_OLD_FIND_LOCAL_SUBVOL "glusterfs.old-find-local-subvol" #define GF_XATTR_VOL_ID_KEY "trusted.glusterfs.volume-id" #define GF_XATTR_LOCKINFO_KEY "trusted.glusterfs.lockinfo" #define GF_META_LOCK_KEY "glusterfs.lock-migration-meta-lock" diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 272a639aee6..8c6df4a811a 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -2982,7 +2982,8 @@ dht_vgetxattr_fill_and_set (dht_local_t *local, dict_t **dict, xlator_t *this, (void) dht_fill_pathinfo_xattr (this, local, xattr_buf, local->alloc_len, flag, layout_buf); - } else if (XATTR_IS_NODE_UUID (local->xsel)) { + } else if ((XATTR_IS_NODE_UUID (local->xsel)) + || (XATTR_IS_NODE_UUID_LIST (local->xsel))) { (void) snprintf (xattr_buf, local->alloc_len, "%s", local->xattr_val); } else { @@ -3574,6 +3575,31 @@ dht_getxattr (call_frame_t *frame, xlator_t *this, if (key && DHT_IS_DIR(layout) && (!strcmp (key, GF_REBAL_FIND_LOCAL_SUBVOL))) { ret = gf_asprintf + (&node_uuid_key, "%s", GF_XATTR_LIST_NODE_UUIDS_KEY); + if (ret == -1 || !node_uuid_key) { + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_NO_MEMORY, + "Failed to copy key"); + op_errno = ENOMEM; + goto err; + } + (void) strncpy (local->xsel, node_uuid_key, 256); + cnt = local->call_cnt = conf->subvolume_cnt; + for (i = 0; i < cnt; i++) { + STACK_WIND_COOKIE (frame, dht_find_local_subvol_cbk, + conf->subvolumes[i], + conf->subvolumes[i], + conf->subvolumes[i]->fops->getxattr, + loc, node_uuid_key, xdata); + } + if (node_uuid_key) + GF_FREE (node_uuid_key); + return 0; + } + + if (key && DHT_IS_DIR(layout) && + (!strcmp (key, GF_REBAL_OLD_FIND_LOCAL_SUBVOL))) { + ret = gf_asprintf (&node_uuid_key, "%s", GF_XATTR_NODE_UUID_KEY); if (ret == -1 || !node_uuid_key) { gf_msg (this->name, GF_LOG_ERROR, 0, @@ -3608,7 +3634,8 @@ dht_getxattr (call_frame_t *frame, xlator_t *this, if (key && DHT_IS_DIR(layout) && (XATTR_IS_PATHINFO (key) - || (strcmp (key, GF_XATTR_NODE_UUID_KEY) == 0))) { + || (strcmp (key, GF_XATTR_NODE_UUID_KEY) == 0) + || (strcmp (key, GF_XATTR_LIST_NODE_UUIDS_KEY) == 0))) { (void) strncpy (local->xsel, key, 256); cnt = local->call_cnt = layout->cnt; for (i = 0; i < cnt; i++) { diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 7bbd5956028..09bfac2dd1f 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -4037,21 +4037,41 @@ dht_get_local_subvols_and_nodeuuids (xlator_t *this, dht_conf_t *conf, loc_t *loc) { - dict_t *dict = NULL; - int ret = -1; + dict_t *dict = NULL; + gf_defrag_info_t *defrag = NULL; + int ret = -1; + + defrag = conf->defrag; + if (defrag->cmd != GF_DEFRAG_CMD_START_TIER) { /* Find local subvolumes */ + ret = syncop_getxattr (this, loc, &dict, + GF_REBAL_FIND_LOCAL_SUBVOL, + NULL, NULL); + if (ret && (ret != -ENODATA)) { + + gf_msg (this->name, GF_LOG_ERROR, -ret, 0, "local " + "subvolume determination failed with error: %d", + -ret); + ret = -1; + goto out; + } + + if (!ret) + goto out; + } + ret = syncop_getxattr (this, loc, &dict, - GF_REBAL_FIND_LOCAL_SUBVOL, + GF_REBAL_OLD_FIND_LOCAL_SUBVOL, NULL, NULL); if (ret) { + gf_msg (this->name, GF_LOG_ERROR, -ret, 0, "local " "subvolume determination failed with error: %d", -ret); ret = -1; goto out; } - ret = 0; out: return ret; diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index 01b6ada3677..c8667228c59 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -202,13 +202,6 @@ tier_check_same_node (xlator_t *this, loc_t *loc, gf_defrag_info_t *defrag) dict_t *dict = NULL; char *uuid_str = NULL; uuid_t node_uuid = {0,}; - char *dup_str = NULL; - char *str = NULL; - char *save_ptr = NULL; - int count = 0; - uint32_t hashval = 0; - int32_t index = 0; - char buf[GF_UUID_BUF_SIZE] = {0,}; GF_VALIDATE_OR_GOTO ("tier", this, out); GF_VALIDATE_OR_GOTO (this->name, loc, out); @@ -222,56 +215,16 @@ tier_check_same_node (xlator_t *this, loc_t *loc, gf_defrag_info_t *defrag) goto out; } - - /* This returns multiple node-uuids now - one for each brick - * of the subvol. - */ - if (dict_get_str (dict, GF_XATTR_NODE_UUID_KEY, &uuid_str) < 0) { gf_msg (this->name, GF_LOG_ERROR, 0, DHT_MSG_LOG_TIER_ERROR, - "Failed to get node-uuid for %s", loc->path); + "Failed to get node-uuids for %s", loc->path); goto out; } - dup_str = gf_strdup (uuid_str); - str = dup_str; - - /* How many uuids returned? - * No need to check if one of these is that of the current node. - */ - - count = 1; - while ((str = strchr (str, ' '))) { - count++; - str++; - } - - /* Only one node-uuid - pure distribute? */ - if (count == 1) - goto check_node; - - uuid_utoa_r (loc->gfid, buf); - ret = dht_hash_compute (this, 0, buf, &hashval); - if (ret == 0) { - index = (hashval % count); - } - - count = 0; - str = dup_str; - while ((uuid_str = strtok_r (str, " ", &save_ptr))) { - if (count == index) - break; - count++; - str = NULL; - } - - -check_node: if (gf_uuid_parse (uuid_str, node_uuid)) { gf_msg (this->name, GF_LOG_ERROR, 0, DHT_MSG_LOG_TIER_ERROR, "uuid_parse failed for %s", loc->path); - ret = -1; goto out; } @@ -287,7 +240,6 @@ out: if (dict) dict_unref(dict); - GF_FREE (dup_str); return ret; } |