summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-03-16 16:09:42 +0530
committerAnand Avati <avati@redhat.com>2012-03-18 00:33:28 -0700
commit642343cc55e6ea2b0d463d77334c34790c30080f (patch)
tree47aa3e890088463828e936b84ccb56b2fdc49152 /xlators/mgmt/glusterd
parentf159e2247b58441449ad8da13ddf5cc5d3887b93 (diff)
Self-heald: Handle errors gracefully and show errors to users
Change-Id: I5424ebfadb5b2773ee6f7370cc2867a555aa48dd BUG: 800352 Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/2962 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c15
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rpc-ops.c30
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c34
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h7
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c10
6 files changed, 64 insertions, 33 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index d96d6717eeb..ce9581644b1 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -2780,9 +2780,9 @@ _heal_volume_add_shd_rsp (dict_t *this, char *key, data_t *value, void *data)
int rxl_child_id = 0;
int brick_id = 0;
int int_len = 0;
- int brick_count = 0;
int ret = 0;
glusterd_heal_rsp_conv_t *rsp_ctx = NULL;
+ glusterd_brickinfo_t *brickinfo = NULL;
rsp_ctx = data;
rxl_end = strchr (key, '-');
@@ -2810,13 +2810,19 @@ _heal_volume_add_shd_rsp (dict_t *this, char *key, data_t *value, void *data)
volinfo = rsp_ctx->volinfo;
brick_id = rxl_id * volinfo->replica_count + rxl_child_id;
+ if (!strcmp (rxl_child_end, "status")) {
+ brickinfo = glusterd_get_brickinfo_by_position (volinfo,
+ brick_id);
+ if (!brickinfo)
+ goto out;
+ if (!glusterd_is_local_brick (rsp_ctx->this, volinfo,
+ brickinfo))
+ goto out;
+ }
new_value = data_copy (value);
snprintf (new_key, sizeof (new_key), "%d%s", brick_id, rxl_child_end);
dict_set (rsp_ctx->dict, new_key, new_value);
- ret = dict_get_int32 (rsp_ctx->dict, "count", &brick_count);
- if (brick_id >= brick_count)
- ret = dict_set_int32 (rsp_ctx->dict, "count", brick_id + 1);
out:
return;
}
@@ -2847,6 +2853,7 @@ glusterd_heal_volume_brick_rsp (dict_t *req_dict, dict_t *rsp_dict,
rsp_ctx.dict = op_ctx;
rsp_ctx.volinfo = volinfo;
+ rsp_ctx.this = THIS;
dict_foreach (rsp_dict, _heal_volume_add_shd_rsp, &rsp_ctx);
out:
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index bfc41b29252..1f32681a5a1 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -157,6 +157,7 @@ typedef struct glusterd_pr_brick_rsp_conv_t {
typedef struct glusterd_heal_rsp_conv_ {
dict_t *dict;
glusterd_volinfo_t *volinfo;
+ xlator_t *this;
} glusterd_heal_rsp_conv_t;
typedef struct glusterd_status_rsp_conv_ {
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
index c7931dbfafc..649156f4b33 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
@@ -111,11 +111,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
}
break;
}
- case GD_OP_HEAL_VOLUME:
- {
- glusterd_add_bricks_hname_path_to_dict (ctx);
- break;
- }
case GD_OP_PROFILE_VOLUME:
{
if (ctx && dict_get_int32 (ctx, "count", &count)) {
@@ -153,6 +148,7 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
case GD_OP_SET_VOLUME:
case GD_OP_LIST_VOLUME:
case GD_OP_CLEARLOCKS_VOLUME:
+ case GD_OP_HEAL_VOLUME:
{
/*nothing specific to be done*/
break;
@@ -1198,28 +1194,6 @@ out:
return ret;
}
-void
-_heal_volume_add_peer_rsp (dict_t *peer_dict, char *key, data_t *value,
- void *data)
-{
- int max_brick = 0;
- int peer_max_brick = 0;
- int ret = 0;
- dict_t *ctx_dict = data;
-
-
-
- ret = dict_get_int32 (ctx_dict, "count", &max_brick);
- ret = dict_get_int32 (peer_dict, "count", &peer_max_brick);
- if (peer_max_brick > max_brick)
- ret = dict_set_int32 (ctx_dict, "count", peer_max_brick);
- else
- ret = dict_set_int32 (ctx_dict, "count", max_brick);
- dict_del (peer_dict, "count");
- dict_copy (peer_dict, ctx_dict);
- return;
-}
-
int
glusterd_volume_heal_use_rsp_dict (dict_t *rsp_dict)
{
@@ -1236,7 +1210,7 @@ glusterd_volume_heal_use_rsp_dict (dict_t *rsp_dict)
if (!ctx_dict)
goto out;
- dict_foreach (rsp_dict, _heal_volume_add_peer_rsp, ctx_dict);
+ dict_copy (rsp_dict, ctx_dict);
out:
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 9cc436496ab..4b84039dfe6 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -3303,9 +3303,23 @@ glusterd_get_brickinfo (xlator_t *this, const char *brickname, int port,
return ret;
}
+glusterd_brickinfo_t*
+glusterd_get_brickinfo_by_position (glusterd_volinfo_t *volinfo, uint32_t pos)
+{
+ glusterd_brickinfo_t *tmpbrkinfo = NULL;
+
+ list_for_each_entry (tmpbrkinfo, &volinfo->bricks,
+ brick_list) {
+ if (pos == 0)
+ return tmpbrkinfo;
+ pos--;
+ }
+ return NULL;
+}
+
void
glusterd_set_brick_status (glusterd_brickinfo_t *brickinfo,
- gf_brick_status_t status)
+ gf_brick_status_t status)
{
GF_ASSERT (brickinfo);
brickinfo->status = status;
@@ -5139,3 +5153,21 @@ glusterd_uuid_to_hostname (uuid_t uuid)
return hostname;
}
+gf_boolean_t
+glusterd_is_local_brick (xlator_t *this, glusterd_volinfo_t *volinfo,
+ glusterd_brickinfo_t *brickinfo)
+{
+ gf_boolean_t local = _gf_false;
+ int ret = 0;
+ glusterd_conf_t *conf = NULL;
+
+ if (uuid_is_null (brickinfo->uuid)) {
+ ret = glusterd_resolve_brick (brickinfo);
+ if (ret)
+ goto out;
+ }
+ conf = this->private;
+ local = !uuid_compare (brickinfo->uuid, conf->uuid);
+out:
+ return local;
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 7b5a387c275..fa9f7737005 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -419,4 +419,11 @@ glusterd_add_node_to_dict (char *server, dict_t *dict, int count);
char *
glusterd_uuid_to_hostname (uuid_t uuid);
+
+glusterd_brickinfo_t*
+glusterd_get_brickinfo_by_position (glusterd_volinfo_t *volinfo, uint32_t pos);
+
+gf_boolean_t
+glusterd_is_local_brick (xlator_t *this, glusterd_volinfo_t *volinfo,
+ glusterd_brickinfo_t *brickinfo);
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index d6e58c1b844..93c00983a21 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -448,6 +448,7 @@ glusterd_handle_cli_heal_volume (rpcsvc_request_t *req)
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_HEAL_VOLUME;
char *volname = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
GF_ASSERT (req);
@@ -483,6 +484,15 @@ glusterd_handle_cli_heal_volume (rpcsvc_request_t *req)
gf_log ("glusterd", GF_LOG_INFO, "Received heal vol req"
"for volume %s", volname);
+ ret = glusterd_add_bricks_hname_path_to_dict (dict);
+ if (ret)
+ goto out;
+ ret = glusterd_volinfo_find (volname, &volinfo);
+ if (ret)
+ goto out;
+ ret = dict_set_int32 (dict, "count", volinfo->brick_count);
+ if (ret)
+ goto out;
ret = glusterd_op_begin (req, GD_OP_HEAL_VOLUME, dict);
gf_cmd_log ("volume heal","on volname: %s %s", volname,