summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-self-heald.c
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-04-03 11:13:09 +0530
committerVijay Bellur <vijay@gluster.com>2012-04-05 05:15:46 -0700
commit3e27f277951e9369517bdd16170639f587d3fb9d (patch)
treec8392d593dc77c52647986872614f9538f8d5213 /xlators/cluster/afr/src/afr-self-heald.c
parent73e2c0dec5b432c788cd80c4210b887517188f3d (diff)
self-heald: Add node-uuid option for determining brick position
Change-Id: Ia60981da7473d74682d86286e4d540568c8de25b BUG: 807556 Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/3074 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heald.c')
-rw-r--r--xlators/cluster/afr/src/afr-self-heald.c73
1 files changed, 7 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;