summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/cluster/afr/src/afr-self-heald.c73
-rw-r--r--xlators/cluster/afr/src/afr.c5
-rw-r--r--xlators/cluster/afr/src/afr.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c7
4 files changed, 20 insertions, 66 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
index 55ede78ad..622e2eb3f 100644
--- a/xlators/cluster/afr/src/afr-self-heald.c
+++ b/xlators/cluster/afr/src/afr-self-heald.c
@@ -651,63 +651,6 @@ out:
return;
}
-static int
-get_pathinfo_host (char *pathinfo, char *hostname, size_t size)
-{
- char *start = NULL;
- char *end = NULL;
- int ret = -1;
- int i = 0;
-
- if (!pathinfo)
- goto out;
-
- start = strchr (pathinfo, ':');
- if (!start)
- goto out;
- end = strrchr (pathinfo, ':');
- if (start == end)
- goto out;
-
- memset (hostname, 0, size);
- i = 0;
- while (++start != end)
- hostname[i++] = *start;
- ret = 0;
-out:
- return ret;
-}
-
-int
-afr_local_pathinfo (char *pathinfo, gf_boolean_t *local)
-{
- int ret = 0;
- char pathinfohost[1024] = {0};
- char localhost[1024] = {0};
- xlator_t *this = THIS;
-
- *local = _gf_false;
- ret = get_pathinfo_host (pathinfo, pathinfohost, sizeof (pathinfohost));
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Invalid pathinfo: %s",
- pathinfo);
- goto out;
- }
-
- ret = gethostname (localhost, sizeof (localhost));
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "gethostname() failed, "
- "reason: %s", strerror (errno));
- goto out;
- }
-
- if (!strcmp (localhost, pathinfohost))
- *local = _gf_true;
-out:
- return ret;
-}
-
-
int
afr_crawl_build_start_loc (xlator_t *this, afr_crawl_data_t *crawl_data,
loc_t *dirloc)
@@ -970,35 +913,33 @@ int
afr_find_child_position (xlator_t *this, int child, afr_child_pos_t *pos)
{
afr_private_t *priv = NULL;
+ afr_self_heald_t *shd = NULL;
dict_t *xattr_rsp = NULL;
loc_t loc = {0};
int ret = 0;
- gf_boolean_t local = _gf_false;
- char *pathinfo = NULL;
+ char *node_uuid = NULL;
priv = this->private;
+ shd = &priv->shd;
afr_build_root_loc (this, &loc);
ret = syncop_getxattr (priv->children[child], &loc, &xattr_rsp,
- GF_XATTR_PATHINFO_KEY);
+ GF_XATTR_NODE_UUID_KEY);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "getxattr failed on %s",
priv->children[child]->name);
goto out;
}
- ret = dict_get_str (xattr_rsp, GF_XATTR_PATHINFO_KEY, &pathinfo);
+ ret = dict_get_str (xattr_rsp, GF_XATTR_NODE_UUID_KEY, &node_uuid);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Pathinfo key not found on "
+ gf_log (this->name, GF_LOG_ERROR, "node-uuid key not found on "
"child %d", child);
goto out;
}
- ret = afr_local_pathinfo (pathinfo, &local);
- if (ret)
- goto out;
- if (local)
+ if (!strcmp (node_uuid, shd->node_uuid))
*pos = AFR_POS_LOCAL;
else
*pos = AFR_POS_REMOTE;
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 89a8e87fb..f6db7b9e9 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -416,6 +416,7 @@ init (xlator_t *this)
if (!this->itable)
goto out;
priv->root_inode = inode_ref (this->itable->root);
+ GF_OPTION_INIT ("node-uuid", priv->shd.node_uuid, str, out);
ret = 0;
out:
@@ -606,5 +607,9 @@ struct volume_options options[] = {
"this many bricks or present. Other quorum types "
"will OVERWRITE this value.",
},
+ { .key = {"node-uuid"},
+ .type = GF_OPTION_TYPE_STR,
+ .description = "Local glusterd uuid string",
+ },
{ .key = {NULL} },
};
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index fccb39b1a..954e9bb31 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -105,6 +105,7 @@ typedef struct afr_self_heald_ {
eh_t *healed;
eh_t *heal_failed;
eh_t *split_brain;
+ char *node_uuid;
} afr_self_heald_t;
typedef struct _afr_private {
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 38e9a987d..71616ebb8 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -2808,6 +2808,7 @@ glusterd_nodesvc_start (char *server)
char rundir[PATH_MAX] = {0,};
char sockfpath[PATH_MAX] = {0,};
char volfileid[256] = {0};
+ char glusterd_uuid_option[1024] = {0};
#ifdef DEBUG
char valgrind_logfile[PATH_MAX] = {0};
#endif
@@ -2867,6 +2868,12 @@ glusterd_nodesvc_start (char *server)
"-l", logfile,
"-S", sockfpath, NULL);
+ if (!strcmp (server, "glustershd")) {
+ snprintf (glusterd_uuid_option, sizeof (glusterd_uuid_option),
+ "*replicate*.node-uuid=%s", uuid_utoa (priv->uuid));
+ runner_add_args (&runner, "--xlator-option",
+ glusterd_uuid_option, NULL);
+ }
runner_log (&runner, "", GF_LOG_DEBUG,
"Starting the nfs/glustershd services");