summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRajesh Amaravathi <rajesh.amaravathi@gmail.com>2011-09-19 16:43:50 +0530
committerVijay Bellur <vijay@gluster.com>2011-09-19 04:39:10 -0700
commit8ad4d3f53000724389db6003ca6d6d777b880017 (patch)
tree32efa44f6bba22f47e2fb56d351fe4ab2e0734fc /xlators
parent608f2d698569abc82cc671e81477e89e9c553bda (diff)
glusterd/top: volume top succeeds on partial brickpath
Rewrite of glusterd_volume_brickinfo_get in glusterd-utils.c An additional argument to glusterd_volume_brick_info_get_by_brick and glusterd_volume_brickinfo_get enables matching brick path in two ways: Complete or partial(ancestor and descendent paths matched). Change-Id: Ia87833a6f0c139599c3e40b59d60c64281b4084b BUG: 3271 Reviewed-on: http://review.gluster.com/162 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shishir Gowda <shishirng@gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c16
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-log-ops.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c14
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c78
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h12
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c3
7 files changed, 79 insertions, 60 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index faf4960df..655f8a96a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -192,7 +192,8 @@ brick_val:
ret = glusterd_volume_brickinfo_get (brickinfo->uuid,
brickinfo->hostname,
brickinfo->path,
- &tmpvolinfo, &tmpbrkinfo);
+ &tmpvolinfo, &tmpbrkinfo,
+ GF_PATH_PARTIAL);
if (!ret) {
ret = -1;
snprintf (err_str, sizeof (err_str), "Brick: %s:%s, %s"
@@ -352,7 +353,9 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
gf_log ("", GF_LOG_DEBUG, "Remove brick count %d brick: %s",
i, brick);
- ret = glusterd_volume_brickinfo_get_by_brick(brick, volinfo, &brickinfo);
+ ret = glusterd_volume_brickinfo_get_by_brick(brick, volinfo,
+ &brickinfo,
+ GF_PATH_COMPLETE);
if (ret) {
snprintf(err_str, 2048,"Incorrect brick %s for volume"
" %s", brick, cli_req.volname);
@@ -488,7 +491,8 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
while (i <= count) {
ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo,
- &brickinfo);
+ &brickinfo,
+ GF_PATH_PARTIAL);
if (ret)
goto out;
@@ -531,7 +535,8 @@ glusterd_op_perform_remove_brick (glusterd_volinfo_t *volinfo, char *brick,
if (!dup_brick)
goto out;
- ret = glusterd_volume_brickinfo_get_by_brick (dup_brick, volinfo, &brickinfo);
+ ret = glusterd_volume_brickinfo_get_by_brick (dup_brick, volinfo,
+ &brickinfo, GF_PATH_COMPLETE);
if (ret)
goto out;
@@ -660,7 +665,8 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr)
}
ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo,
- &brickinfo);
+ &brickinfo,
+ GF_PATH_PARTIAL);
if (!ret) {
gf_log ("", GF_LOG_ERROR, "Adding duplicate brick: %s",
brick);
diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
index 77275ca95..9d1c97826 100644
--- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
@@ -325,8 +325,8 @@ glusterd_op_stage_log_filename (dict_t *dict, char **op_errstr)
goto out;
if (strchr (brick, ':')) {
- ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo,
- NULL);
+ ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo, NULL,
+ GF_PATH_COMPLETE);
if (ret) {
snprintf (msg, sizeof (msg), "Incorrect brick %s "
"for volume %s", brick, volname);
@@ -402,8 +402,8 @@ glusterd_op_stage_log_rotate (dict_t *dict, char **op_errstr)
goto out;
if (strchr (brick, ':')) {
- ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo,
- NULL);
+ ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo, NULL,
+ GF_PATH_COMPLETE);
if (ret) {
snprintf (msg, sizeof (msg), "Incorrect brick %s "
"for volume %s", brick, volname);
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 14c9566ac..2b2a1e766 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -2566,7 +2566,8 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr)
}
ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo,
- &brickinfo);
+ &brickinfo,
+ GF_PATH_COMPLETE);
if (ret)
goto out;
if (glusterd_is_brick_started (brickinfo)) {
@@ -2655,8 +2656,9 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr)
case GF_CLI_STATS_TOP:
ret = dict_get_str (dict, "brick", &brick);
if (!ret) {
- ret = glusterd_volume_brickinfo_get_by_brick (brick,
- volinfo, &brickinfo);
+ ret = glusterd_volume_brickinfo_get_by_brick (brick, volinfo,
+ &brickinfo,
+ GF_PATH_COMPLETE);
if (ret)
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index 1f424f6c6..8b53fd7c4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -375,7 +375,8 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
}
ret = glusterd_volume_brickinfo_get_by_brick (src_brick, volinfo,
- &src_brickinfo);
+ &src_brickinfo,
+ GF_PATH_COMPLETE);
if (ret) {
snprintf (msg, sizeof (msg), "brick: %s does not exist in "
"volume: %s", src_brick, volname);
@@ -1473,7 +1474,8 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t *volinfo,
goto out;
ret = glusterd_volume_brickinfo_get_by_brick (old_brick, volinfo,
- &old_brickinfo);
+ &old_brickinfo,
+ GF_PATH_COMPLETE);
if (ret)
goto out;
@@ -1565,7 +1567,9 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
goto out;
}
- ret = glusterd_volume_brickinfo_get_by_brick (src_brick, volinfo, &src_brickinfo);
+ ret = glusterd_volume_brickinfo_get_by_brick (src_brick, volinfo,
+ &src_brickinfo,
+ GF_PATH_COMPLETE);
if (ret) {
gf_log ("", GF_LOG_DEBUG, "Unable to get src-brickinfo");
goto out;
@@ -1874,7 +1878,9 @@ glusterd_do_replace_brick (void *data)
goto out;
}
- ret = glusterd_volume_brickinfo_get_by_brick (src_brick, volinfo, &src_brickinfo);
+ ret = glusterd_volume_brickinfo_get_by_brick (src_brick, volinfo,
+ &src_brickinfo,
+ GF_PATH_COMPLETE);
if (ret) {
gf_log ("", GF_LOG_DEBUG, "Unable to get src-brickinfo");
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 209138aca..6393f1fca 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -710,7 +710,8 @@ out:
int32_t
glusterd_volume_brickinfo_get (uuid_t uuid, char *hostname, char *path,
glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t **brickinfo)
+ glusterd_brickinfo_t **brickinfo,
+ gf_path_match_t path_match)
{
glusterd_brickinfo_t *brickiter = NULL;
uuid_t peer_uuid = {0};
@@ -731,47 +732,38 @@ glusterd_volume_brickinfo_get (uuid_t uuid, char *hostname, char *path,
path_len = strlen (path);
list_for_each_entry (brickiter, &volinfo->bricks, brick_list) {
- if (uuid_is_null (brickiter->uuid)) {
- ret = glusterd_resolve_brick (brickiter);
- if (ret)
- goto out;
- }
+ if (uuid_is_null (brickiter->uuid) &&
+ glusterd_resolve_brick (brickiter))
+ goto out;
+ if (uuid_compare (peer_uuid, brickiter->uuid))
+ continue;
brick_path_len = strlen (brickiter->path);
smaller_path = min (brick_path_len, path_len);
if (smaller_path != path_len)
is_path_smaller = _gf_false;
- if ((!uuid_compare (peer_uuid, brickiter->uuid)) &&
- !strcmp (brickiter->path, path)) {
- gf_log ("", GF_LOG_INFO, "Found brick");
+
+ if (!strcmp (brickiter->path, path)) {
+ gf_log (THIS->name, GF_LOG_INFO, "Found brick");
ret = 0;
if (brickinfo)
*brickinfo = brickiter;
break;
- } else {
- if ((!uuid_compare (peer_uuid, brickiter->uuid)) &&
- !strncmp (brickiter->path, path, smaller_path)) {
- if (is_path_smaller == _gf_true) {
- if (brickiter->path[smaller_path] == '/') {
- ret = 0;
- gf_log ("", GF_LOG_INFO,
- "given path %s lies"
- " within %s", path,
- brickiter->path);
- *brickinfo = brickiter;
- break;
- }
- } else
- if (path[smaller_path] == '/') {
- gf_log ("", GF_LOG_INFO,
- "brick %s is a part of"
- " %s", brickiter->path,
- path);
- ret = 0;
- *brickinfo = brickiter;
- break;
- }
+ } else if (path_match == GF_PATH_PARTIAL &&
+ !strncmp (brickiter->path, path, smaller_path)) {
+ /* GF_PATH_PARTIAL:check during create, add-brick ops */
+ if (is_path_smaller == _gf_true &&
+ brickiter->path[smaller_path] == '/') {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "given path %s lies within brick %s",
+ path, brickiter->path);
+ } else if (path[smaller_path] == '/') {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "brick %s is a part of %s",
+ brickiter->path, path);
}
- ret = -1;
+ *brickinfo = brickiter;
+ ret = 0;
+ break;
}
}
@@ -783,7 +775,8 @@ out:
int32_t
glusterd_volume_brickinfo_get_by_brick (char *brick,
glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t **brickinfo)
+ glusterd_brickinfo_t **brickinfo,
+ gf_path_match_t path_match)
{
int32_t ret = -1;
char *hostname = NULL;
@@ -812,7 +805,7 @@ glusterd_volume_brickinfo_get_by_brick (char *brick,
}
ret = glusterd_volume_brickinfo_get (NULL, hostname, path, volinfo,
- brickinfo);
+ brickinfo, path_match);
out:
if (tmp_host)
GF_FREE (tmp_host);
@@ -831,7 +824,7 @@ glusterd_is_brick_decommissioned (glusterd_volinfo_t *volinfo, char *hostname,
int ret = -1;
ret = glusterd_volume_brickinfo_get (NULL, hostname, path, volinfo,
- &brickinfo);
+ &brickinfo, GF_PATH_COMPLETE);
if (ret)
goto out;
decommissioned = brickinfo->decommissioned;
@@ -2071,7 +2064,8 @@ glusterd_volinfo_copy_brick_portinfo (glusterd_volinfo_t *new_volinfo,
ret = glusterd_volume_brickinfo_get (new_brickinfo->uuid,
new_brickinfo->hostname,
new_brickinfo->path,
- old_volinfo, &old_brickinfo);
+ old_volinfo, &old_brickinfo,
+ GF_PATH_COMPLETE);
if ((0 == ret) && glusterd_is_brick_started (old_brickinfo)) {
new_brickinfo->port = old_brickinfo->port;
}
@@ -2097,7 +2091,8 @@ glusterd_volinfo_stop_stale_bricks (glusterd_volinfo_t *new_volinfo,
ret = glusterd_volume_brickinfo_get (old_brickinfo->uuid,
old_brickinfo->hostname,
old_brickinfo->path,
- new_volinfo, &new_brickinfo);
+ new_volinfo, &new_brickinfo,
+ GF_PATH_COMPLETE);
if (ret) {
ret = glusterd_brick_stop (old_volinfo, old_brickinfo);
if (ret)
@@ -2676,8 +2671,8 @@ glusterd_brickinfo_get (uuid_t uuid, char *hostname, char *path,
list_for_each_entry (volinfo, &priv->volumes, vol_list) {
ret = glusterd_volume_brickinfo_get (uuid, hostname, path,
- volinfo,
- brickinfo);
+ volinfo, brickinfo,
+ GF_PATH_COMPLETE);
if (!ret)
goto out;
}
@@ -3780,7 +3775,8 @@ glusterd_delete_brick (glusterd_volinfo_t* volinfo,
#ifdef DEBUG
ret = glusterd_volume_brickinfo_get (brickinfo->uuid,
brickinfo->hostname,
- brickinfo->path, volinfo, NULL);
+ brickinfo->path, volinfo,
+ NULL, GF_PATH_COMPLETE);
GF_ASSERT (0 == ret);
#endif
glusterd_delete_volfile (volinfo, brickinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index f06a1ce17..93fa763bd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -38,6 +38,12 @@
#include "rpc-clnt.h"
#include "protocol-common.h"
+/* For brick search using path: partial or complete */
+typedef enum {
+ GF_PATH_COMPLETE = 0,
+ GF_PATH_PARTIAL
+} gf_path_match_t;
+
struct glusterd_lock_ {
uuid_t owner;
time_t timestamp;
@@ -129,7 +135,8 @@ glusterd_is_cli_op_req (int32_t op);
int32_t
glusterd_volume_brickinfo_get_by_brick (char *brick,
glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t **brickinfo);
+ glusterd_brickinfo_t **brickinfo,
+ gf_path_match_t path_match);
int32_t
glusterd_is_local_addr (char *hostname);
@@ -245,7 +252,8 @@ glusterd_volume_brickinfos_delete (glusterd_volinfo_t *volinfo);
int32_t
glusterd_volume_brickinfo_get (uuid_t uuid, char *hostname, char *path,
glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t **brickinfo);
+ glusterd_brickinfo_t **brickinfo,
+ gf_path_match_t path_match);
int
glusterd_brickinfo_get (uuid_t uuid, char *hostname, char *path,
glusterd_brickinfo_t **brickinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 81ef4c605..560968def 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -175,7 +175,8 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
ret = glusterd_volume_brickinfo_get (brickinfo->uuid,
brickinfo->hostname,
brickinfo->path,
- &tmpvolinfo, &tmpbrkinfo);
+ &tmpvolinfo, &tmpbrkinfo,
+ GF_PATH_PARTIAL);
if (!ret) {
ret = -1;
snprintf (err_str, sizeof (err_str), "Brick: %s:%s, %s"