|
|
21ab4e |
From 55ff7df215ec706fccded198ff873643459fbf88 Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Susant Palai <spalai@redhat.com>
|
|
|
21ab4e |
Date: Wed, 21 Jun 2017 17:52:45 +0530
|
|
|
21ab4e |
Subject: [PATCH 538/539] cluster/rebalance: Use GF_XATTR_LIST_NODE_UUIDS_KEY
|
|
|
21ab4e |
to figure out local subvols.
|
|
|
21ab4e |
|
|
|
21ab4e |
Afr has introduced a new key GF_XATTR_LIST_NODE_UUIDS_KEY,
|
|
|
21ab4e |
through which rebalance will figure out its local subvolumes.(Reference
|
|
|
21ab4e |
bugid=1463250)
|
|
|
21ab4e |
|
|
|
21ab4e |
key: GF_XATTR_NODE_UUID_KEY will continue to serve it's old
|
|
|
21ab4e |
purpose of returning the first afr chiild.
|
|
|
21ab4e |
|
|
|
21ab4e |
test: prove tests/basic/distribute/rebal-all-nodes-migrate.t
|
|
|
21ab4e |
|
|
|
21ab4e |
> BUG: 1463648
|
|
|
21ab4e |
> Signed-off-by: Susant Palai <spalai@redhat.com>
|
|
|
21ab4e |
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
21ab4e |
> Reviewed-on: https://review.gluster.org/17595
|
|
|
21ab4e |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> Reviewed-by: Amar Tumballi <amarts@redhat.com>
|
|
|
21ab4e |
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
|
|
|
21ab4e |
> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
|
|
|
21ab4e |
|
|
|
21ab4e |
Change-Id: I4d602feda2a05b29d2210c712a07a4ac6b8bc112
|
|
|
21ab4e |
BUG: 1462693
|
|
|
21ab4e |
Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/110577
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
libglusterfs/src/glusterfs.h | 1 +
|
|
|
21ab4e |
xlators/cluster/dht/src/dht-common.c | 31 ++++++++++++++++++--
|
|
|
21ab4e |
xlators/cluster/dht/src/dht-rebalance.c | 29 +++++++++++++++----
|
|
|
21ab4e |
xlators/cluster/dht/src/tier.c | 50 +--------------------------------
|
|
|
21ab4e |
4 files changed, 55 insertions(+), 56 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
|
|
|
21ab4e |
index 2856990..d812aa7 100644
|
|
|
21ab4e |
--- a/libglusterfs/src/glusterfs.h
|
|
|
21ab4e |
+++ b/libglusterfs/src/glusterfs.h
|
|
|
21ab4e |
@@ -86,6 +86,7 @@
|
|
|
21ab4e |
#define GF_XATTR_NODE_UUID_KEY "trusted.glusterfs.node-uuid"
|
|
|
21ab4e |
#define GF_XATTR_LIST_NODE_UUIDS_KEY "trusted.glusterfs.list-node-uuids"
|
|
|
21ab4e |
#define GF_REBAL_FIND_LOCAL_SUBVOL "glusterfs.find-local-subvol"
|
|
|
21ab4e |
+#define GF_REBAL_OLD_FIND_LOCAL_SUBVOL "glusterfs.old-find-local-subvol"
|
|
|
21ab4e |
#define GF_XATTR_VOL_ID_KEY "trusted.glusterfs.volume-id"
|
|
|
21ab4e |
#define GF_XATTR_LOCKINFO_KEY "trusted.glusterfs.lockinfo"
|
|
|
21ab4e |
#define GF_META_LOCK_KEY "glusterfs.lock-migration-meta-lock"
|
|
|
21ab4e |
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
|
|
|
21ab4e |
index 480dcbf..567990b 100644
|
|
|
21ab4e |
--- a/xlators/cluster/dht/src/dht-common.c
|
|
|
21ab4e |
+++ b/xlators/cluster/dht/src/dht-common.c
|
|
|
21ab4e |
@@ -2978,7 +2978,8 @@ dht_vgetxattr_fill_and_set (dht_local_t *local, dict_t **dict, xlator_t *this,
|
|
|
21ab4e |
(void) dht_fill_pathinfo_xattr (this, local, xattr_buf,
|
|
|
21ab4e |
local->alloc_len, flag,
|
|
|
21ab4e |
layout_buf);
|
|
|
21ab4e |
- } else if (XATTR_IS_NODE_UUID (local->xsel)) {
|
|
|
21ab4e |
+ } else if ((XATTR_IS_NODE_UUID (local->xsel))
|
|
|
21ab4e |
+ || (XATTR_IS_NODE_UUID_LIST (local->xsel))) {
|
|
|
21ab4e |
(void) snprintf (xattr_buf, local->alloc_len, "%s",
|
|
|
21ab4e |
local->xattr_val);
|
|
|
21ab4e |
} else {
|
|
|
21ab4e |
@@ -3570,6 +3571,31 @@ dht_getxattr (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
if (key && DHT_IS_DIR(layout) &&
|
|
|
21ab4e |
(!strcmp (key, GF_REBAL_FIND_LOCAL_SUBVOL))) {
|
|
|
21ab4e |
ret = gf_asprintf
|
|
|
21ab4e |
+ (&node_uuid_key, "%s", GF_XATTR_LIST_NODE_UUIDS_KEY);
|
|
|
21ab4e |
+ if (ret == -1 || !node_uuid_key) {
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
+ DHT_MSG_NO_MEMORY,
|
|
|
21ab4e |
+ "Failed to copy key");
|
|
|
21ab4e |
+ op_errno = ENOMEM;
|
|
|
21ab4e |
+ goto err;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ (void) strncpy (local->xsel, node_uuid_key, 256);
|
|
|
21ab4e |
+ cnt = local->call_cnt = conf->subvolume_cnt;
|
|
|
21ab4e |
+ for (i = 0; i < cnt; i++) {
|
|
|
21ab4e |
+ STACK_WIND_COOKIE (frame, dht_find_local_subvol_cbk,
|
|
|
21ab4e |
+ conf->subvolumes[i],
|
|
|
21ab4e |
+ conf->subvolumes[i],
|
|
|
21ab4e |
+ conf->subvolumes[i]->fops->getxattr,
|
|
|
21ab4e |
+ loc, node_uuid_key, xdata);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ if (node_uuid_key)
|
|
|
21ab4e |
+ GF_FREE (node_uuid_key);
|
|
|
21ab4e |
+ return 0;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (key && DHT_IS_DIR(layout) &&
|
|
|
21ab4e |
+ (!strcmp (key, GF_REBAL_OLD_FIND_LOCAL_SUBVOL))) {
|
|
|
21ab4e |
+ ret = gf_asprintf
|
|
|
21ab4e |
(&node_uuid_key, "%s", GF_XATTR_NODE_UUID_KEY);
|
|
|
21ab4e |
if (ret == -1 || !node_uuid_key) {
|
|
|
21ab4e |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
@@ -3604,7 +3630,8 @@ dht_getxattr (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
|
|
|
21ab4e |
if (key && DHT_IS_DIR(layout) &&
|
|
|
21ab4e |
(XATTR_IS_PATHINFO (key)
|
|
|
21ab4e |
- || (strcmp (key, GF_XATTR_NODE_UUID_KEY) == 0))) {
|
|
|
21ab4e |
+ || (strcmp (key, GF_XATTR_NODE_UUID_KEY) == 0)
|
|
|
21ab4e |
+ || (strcmp (key, GF_XATTR_LIST_NODE_UUIDS_KEY) == 0))) {
|
|
|
21ab4e |
(void) strncpy (local->xsel, key, 256);
|
|
|
21ab4e |
cnt = local->call_cnt = layout->cnt;
|
|
|
21ab4e |
for (i = 0; i < cnt; i++) {
|
|
|
21ab4e |
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
21ab4e |
index 5fa7139..3777527 100644
|
|
|
21ab4e |
--- a/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
21ab4e |
+++ b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
21ab4e |
@@ -4102,21 +4102,40 @@ dht_get_local_subvols_and_nodeuuids (xlator_t *this, dht_conf_t *conf,
|
|
|
21ab4e |
loc_t *loc)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
|
|
|
21ab4e |
- dict_t *dict = NULL;
|
|
|
21ab4e |
- int ret = -1;
|
|
|
21ab4e |
+ dict_t *dict = NULL;
|
|
|
21ab4e |
+ gf_defrag_info_t *defrag = NULL;
|
|
|
21ab4e |
+ int ret = -1;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ defrag = conf->defrag;
|
|
|
21ab4e |
|
|
|
21ab4e |
+ if (defrag->cmd != GF_DEFRAG_CMD_START_TIER) {
|
|
|
21ab4e |
/* Find local subvolumes */
|
|
|
21ab4e |
+ ret = syncop_getxattr (this, loc, &dict,
|
|
|
21ab4e |
+ GF_REBAL_FIND_LOCAL_SUBVOL,
|
|
|
21ab4e |
+ NULL, NULL);
|
|
|
21ab4e |
+ if (ret && (ret != -ENODATA)) {
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR, -ret, 0, "local "
|
|
|
21ab4e |
+ "subvolume determination failed with error: %d",
|
|
|
21ab4e |
+ -ret);
|
|
|
21ab4e |
+ ret = -1;
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (!ret)
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
ret = syncop_getxattr (this, loc, &dict,
|
|
|
21ab4e |
- GF_REBAL_FIND_LOCAL_SUBVOL,
|
|
|
21ab4e |
+ GF_REBAL_OLD_FIND_LOCAL_SUBVOL,
|
|
|
21ab4e |
NULL, NULL);
|
|
|
21ab4e |
if (ret) {
|
|
|
21ab4e |
- gf_msg (this->name, GF_LOG_ERROR, 0, 0, "local "
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR, -ret, 0, "local "
|
|
|
21ab4e |
"subvolume determination failed with error: %d",
|
|
|
21ab4e |
-ret);
|
|
|
21ab4e |
ret = -1;
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
-
|
|
|
21ab4e |
ret = 0;
|
|
|
21ab4e |
out:
|
|
|
21ab4e |
return ret;
|
|
|
21ab4e |
diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c
|
|
|
21ab4e |
index 0f6651d..b4f0edd 100644
|
|
|
21ab4e |
--- a/xlators/cluster/dht/src/tier.c
|
|
|
21ab4e |
+++ b/xlators/cluster/dht/src/tier.c
|
|
|
21ab4e |
@@ -203,13 +203,6 @@ tier_check_same_node (xlator_t *this, loc_t *loc, gf_defrag_info_t *defrag)
|
|
|
21ab4e |
dict_t *dict = NULL;
|
|
|
21ab4e |
char *uuid_str = NULL;
|
|
|
21ab4e |
uuid_t node_uuid = {0,};
|
|
|
21ab4e |
- char *dup_str = NULL;
|
|
|
21ab4e |
- char *str = NULL;
|
|
|
21ab4e |
- char *save_ptr = NULL;
|
|
|
21ab4e |
- int count = 0;
|
|
|
21ab4e |
- uint32_t hashval = 0;
|
|
|
21ab4e |
- int32_t index = 0;
|
|
|
21ab4e |
- char buf[GF_UUID_BUF_SIZE] = {0,};
|
|
|
21ab4e |
|
|
|
21ab4e |
|
|
|
21ab4e |
GF_VALIDATE_OR_GOTO ("tier", this, out);
|
|
|
21ab4e |
@@ -224,56 +217,16 @@ tier_check_same_node (xlator_t *this, loc_t *loc, gf_defrag_info_t *defrag)
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
-
|
|
|
21ab4e |
- /* This returns multiple node-uuids now - one for each brick
|
|
|
21ab4e |
- * of the subvol.
|
|
|
21ab4e |
- */
|
|
|
21ab4e |
-
|
|
|
21ab4e |
if (dict_get_str (dict, GF_XATTR_NODE_UUID_KEY, &uuid_str) < 0) {
|
|
|
21ab4e |
gf_msg (this->name, GF_LOG_ERROR, 0, DHT_MSG_LOG_TIER_ERROR,
|
|
|
21ab4e |
- "Failed to get node-uuid for %s", loc->path);
|
|
|
21ab4e |
+ "Failed to get node-uuids for %s", loc->path);
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
- dup_str = gf_strdup (uuid_str);
|
|
|
21ab4e |
- str = dup_str;
|
|
|
21ab4e |
-
|
|
|
21ab4e |
- /* How many uuids returned?
|
|
|
21ab4e |
- * No need to check if one of these is that of the current node.
|
|
|
21ab4e |
- */
|
|
|
21ab4e |
-
|
|
|
21ab4e |
- count = 1;
|
|
|
21ab4e |
- while ((str = strchr (str, ' '))) {
|
|
|
21ab4e |
- count++;
|
|
|
21ab4e |
- str++;
|
|
|
21ab4e |
- }
|
|
|
21ab4e |
-
|
|
|
21ab4e |
- /* Only one node-uuid - pure distribute? */
|
|
|
21ab4e |
- if (count == 1)
|
|
|
21ab4e |
- goto check_node;
|
|
|
21ab4e |
-
|
|
|
21ab4e |
- uuid_utoa_r (loc->gfid, buf);
|
|
|
21ab4e |
- ret = dht_hash_compute (this, 0, buf, &hashval);
|
|
|
21ab4e |
- if (ret == 0) {
|
|
|
21ab4e |
- index = (hashval % count);
|
|
|
21ab4e |
- }
|
|
|
21ab4e |
-
|
|
|
21ab4e |
- count = 0;
|
|
|
21ab4e |
- str = dup_str;
|
|
|
21ab4e |
- while ((uuid_str = strtok_r (str, " ", &save_ptr))) {
|
|
|
21ab4e |
- if (count == index)
|
|
|
21ab4e |
- break;
|
|
|
21ab4e |
- count++;
|
|
|
21ab4e |
- str = NULL;
|
|
|
21ab4e |
- }
|
|
|
21ab4e |
-
|
|
|
21ab4e |
-
|
|
|
21ab4e |
-check_node:
|
|
|
21ab4e |
|
|
|
21ab4e |
if (gf_uuid_parse (uuid_str, node_uuid)) {
|
|
|
21ab4e |
gf_msg (this->name, GF_LOG_ERROR, 0, DHT_MSG_LOG_TIER_ERROR,
|
|
|
21ab4e |
"uuid_parse failed for %s", loc->path);
|
|
|
21ab4e |
- ret = -1;
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -289,7 +242,6 @@ out:
|
|
|
21ab4e |
if (dict)
|
|
|
21ab4e |
dict_unref(dict);
|
|
|
21ab4e |
|
|
|
21ab4e |
- GF_FREE (dup_str);
|
|
|
21ab4e |
return ret;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|