summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2015-11-17 14:00:10 +0530
committerKaushal M <kaushal@redhat.com>2015-11-19 01:06:10 -0800
commitdb506cec11cdb2235aac7b6a896b4071bdcc6ae3 (patch)
treef958c138451f02a0bb9713ae4cf6eb3b4f9f7ad4 /xlators/mgmt
parent6c3895fd132765a5ad098b9ef35e037be7d116b1 (diff)
mgmt/gluster: Handle tier brick volgen
Index xlator watches only some xattrs based on type of volume. i.e. disperse/afr. When the volume becomes tiered then index is not adding these options in the volfile leading to no maintenance of indices. Thus no proactive self-heals. With this fix, we write brick volfiles considering the type of volume they belong to. BUG: 1250803 Change-Id: Ibe8f2d4ad5cb350306ab7ca0753e0f9a40b96a26 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/12595 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c74
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c95
3 files changed, 128 insertions, 45 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index a529fd3ca3f..6f24e9274ff 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -94,6 +94,79 @@ extern struct volopt_map_entry glusterd_volopt_map[];
static glusterd_lock_t lock;
+static int
+_brick_for_each (glusterd_volinfo_t *volinfo, dict_t *mod_dict,
+ void *data,
+ int (*fn) (glusterd_volinfo_t *, glusterd_brickinfo_t *,
+ dict_t *mod_dict, void *))
+{
+ int ret = 0;
+ glusterd_brickinfo_t *brickinfo = NULL;
+ xlator_t *this = THIS;
+
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ gf_msg_debug (this->name, 0, "Found a brick - %s:%s",
+ brickinfo->hostname, brickinfo->path);
+ ret = fn (volinfo, brickinfo, mod_dict, data);
+ if (ret)
+ goto out;
+ }
+out:
+ return ret;
+}
+
+int
+glusterd_volume_brick_for_each (glusterd_volinfo_t *volinfo, void *data,
+ int (*fn) (glusterd_volinfo_t *, glusterd_brickinfo_t *,
+ dict_t *mod_dict, void *))
+{
+ dict_t *mod_dict = NULL;
+ glusterd_volinfo_t *dup_volinfo = NULL;
+ int ret = 0;
+
+ if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
+ ret = _brick_for_each (volinfo, NULL, data, fn);
+ if (ret)
+ goto out;
+ } else {
+ ret = glusterd_create_sub_tier_volinfo (volinfo, &dup_volinfo,
+ _gf_true,
+ volinfo->volname);
+ if (ret)
+ goto out;
+
+ mod_dict = dict_new();
+ if (!mod_dict) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = dict_set_str (mod_dict, "hot-brick", "on");
+ if (ret)
+ goto out;
+
+ ret = _brick_for_each (dup_volinfo, mod_dict, data, fn);
+ if (ret)
+ goto out;
+ GF_FREE (dup_volinfo);
+ dup_volinfo = NULL;
+ ret = glusterd_create_sub_tier_volinfo (volinfo, &dup_volinfo,
+ _gf_false,
+ volinfo->volname);
+ if (ret)
+ goto out;
+ ret = _brick_for_each (dup_volinfo, NULL, data, fn);
+ if (ret)
+ goto out;
+ }
+out:
+ if (dup_volinfo)
+ glusterd_volinfo_delete (dup_volinfo);
+
+ if (mod_dict)
+ dict_unref (mod_dict);
+ return ret;
+}
int32_t
glusterd_get_lock_owner (uuid_t *uuid)
@@ -649,6 +722,7 @@ glusterd_create_sub_tier_volinfo (glusterd_volinfo_t *volinfo,
return ret;
}
+ gf_uuid_copy ((*dup_volinfo)->volume_id, volinfo->volume_id);
(*dup_volinfo)->is_snap_volume = volinfo->is_snap_volume;
(*dup_volinfo)->status = volinfo->status;
memcpy (&(*dup_volinfo)->tier_info, &volinfo->tier_info,
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 42e037b417f..b7302c8cb91 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -675,4 +675,8 @@ glusterd_defrag_rpc_put (glusterd_defrag_info_t *defrag);
int32_t
glusterd_count_connected_peers (int32_t *count);
+int
+glusterd_volume_brick_for_each (glusterd_volinfo_t *volinfo, void *data,
+ int (*fn) (glusterd_volinfo_t *, glusterd_brickinfo_t *,
+ dict_t *mod_dict, void *));
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 43a9a6585d6..ddd4aaef768 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -37,6 +37,11 @@
#include "glusterd-svc-helper.h"
#include "glusterd-snapd-svc-helper.h"
+struct gd_validate_reconf_opts {
+ dict_t *options;
+ char **op_errstr;
+};
+
extern struct volopt_map_entry glusterd_volopt_map[];
#define RPC_SET_OPT(XL, CLI_OPT, XLATOR_OPT, ERROR_CMD) do { \
@@ -1678,8 +1683,8 @@ brick_graph_add_changetimerecorder (volgen_graph_t *graph,
char *brickname = NULL;
char *path = NULL;
char *volname = NULL;
- int bricknum = 0;
char index_basepath[PATH_MAX] = {0};
+ char *hotbrick = NULL;
if (!graph || !volinfo || !set_dict || !brickinfo)
goto out;
@@ -1694,18 +1699,12 @@ brick_graph_add_changetimerecorder (volgen_graph_t *graph,
if (ret)
goto out;
- bricknum = 0;
- cds_list_for_each_entry_safe (brickiter, tmp, &volinfo->bricks,
- brick_list) {
- if (brickiter == brickinfo)
- break;
- bricknum++;
- }
- if (bricknum < volinfo->tier_info.hot_brick_count) {
- ret = xlator_set_option (xl, "hot-brick", "on");
- } else {
- ret = xlator_set_option (xl, "hot-brick", "off");
- }
+ if (!set_dict || dict_get_str (set_dict, "hot-brick", &hotbrick))
+ hotbrick = "off";
+
+ ret = xlator_set_option (xl, "hot-brick", hotbrick);
+ if (ret)
+ goto out;
brickname = strrchr(path, '/') + 1;
snprintf (index_basepath, sizeof (index_basepath), "%s.db",
@@ -4897,7 +4896,8 @@ out:
static int
glusterd_generate_brick_volfile (glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t *brickinfo)
+ glusterd_brickinfo_t *brickinfo,
+ dict_t *mod_dict, void *data)
{
volgen_graph_t graph = {0,};
char filename[PATH_MAX] = {0,};
@@ -4908,7 +4908,7 @@ glusterd_generate_brick_volfile (glusterd_volinfo_t *volinfo,
get_brick_filepath (filename, volinfo, brickinfo);
- ret = build_server_graph (&graph, volinfo, NULL, brickinfo);
+ ret = build_server_graph (&graph, volinfo, mod_dict, brickinfo);
if (!ret)
ret = volgen_write_volfile (&graph, filename);
@@ -5117,16 +5117,10 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo)
}
}
- cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- gf_msg_debug (this->name, 0,
- "Found a brick - %s:%s", brickinfo->hostname,
- brickinfo->path);
-
- ret = glusterd_generate_brick_volfile (volinfo, brickinfo);
- if (ret)
- goto out;
-
- }
+ ret = glusterd_volume_brick_for_each (volinfo, NULL,
+ glusterd_generate_brick_volfile);
+ if (ret)
+ goto out;
ret = 0;
@@ -5684,7 +5678,7 @@ glusterd_create_rb_volfiles (glusterd_volinfo_t *volinfo,
{
int ret = -1;
- ret = glusterd_generate_brick_volfile (volinfo, brickinfo);
+ ret = glusterd_generate_brick_volfile (volinfo, brickinfo, NULL, NULL);
if (!ret)
ret = generate_client_volfiles (volinfo, GF_CLIENT_TRUSTED);
if (!ret)
@@ -5893,23 +5887,42 @@ validate_clientopts (glusterd_volinfo_t *volinfo,
int
validate_brickopts (glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t *brickinfo,
- dict_t *val_dict,
- char **op_errstr)
+ glusterd_brickinfo_t *brickinfo, dict_t *mod_dict,
+ void *reconf)
{
- volgen_graph_t graph = {0,};
- int ret = -1;
+ volgen_graph_t graph = {0,};
+ int ret = -1;
+ struct gd_validate_reconf_opts *brickreconf = reconf;
+ dict_t *val_dict = brickreconf->options;
+ char **op_errstr = brickreconf->op_errstr;
+ dict_t *full_dict = NULL;
GF_ASSERT (volinfo);
graph.errstr = op_errstr;
+ full_dict = dict_new();
+ if (!full_dict) {
+ ret = -1;
+ goto out;
+ }
+
+ if (mod_dict)
+ dict_copy (mod_dict, full_dict);
+
+ if (val_dict)
+ dict_copy (val_dict, full_dict);
+
- ret = build_server_graph (&graph, volinfo, val_dict, brickinfo);
+ ret = build_server_graph (&graph, volinfo, full_dict, brickinfo);
if (!ret)
ret = graph_reconf_validateopt (&graph.graph, op_errstr);
volgen_graph_free (&graph);
+out:
+ if (full_dict)
+ dict_unref (full_dict);
+
gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -5921,20 +5934,12 @@ glusterd_validate_brickreconf (glusterd_volinfo_t *volinfo,
{
glusterd_brickinfo_t *brickinfo = NULL;
int ret = -1;
+ struct gd_validate_reconf_opts brickreconf = {0};
- cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- gf_msg_debug ("glusterd", 0,
- "Validating %s", brickinfo->hostname);
-
- ret = validate_brickopts (volinfo, brickinfo, val_dict,
- op_errstr);
- if (ret)
- goto out;
- }
-
- ret = 0;
-
-out:
+ brickreconf.options = val_dict;
+ brickreconf.op_errstr = op_errstr;
+ ret = glusterd_volume_brick_for_each (volinfo, &brickreconf,
+ validate_brickopts);
return ret;
}