diff options
author | Pranith Kumar K <pranithk@gluster.com> | 2012-04-03 11:13:09 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-04-05 05:15:46 -0700 |
commit | 3e27f277951e9369517bdd16170639f587d3fb9d (patch) | |
tree | c8392d593dc77c52647986872614f9538f8d5213 | |
parent | 73e2c0dec5b432c788cd80c4210b887517188f3d (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>
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heald.c | 73 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr.c | 5 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr.h | 1 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 7 |
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 55ede78ad63..622e2eb3f69 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 89a8e87fbc3..f6db7b9e948 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 fccb39b1a86..954e9bb319f 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 38e9a987dcf..71616ebb842 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"); |