diff options
author | Ravishankar N <ravishankar@redhat.com> | 2015-04-15 22:53:21 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-04-27 22:40:31 -0700 |
commit | d4889b2cfd29e6ecc911d2b29d1f85d516a66eaf (patch) | |
tree | a702c6323d43561d79d2236b8cb7087e5207b2b7 /xlators/mgmt/glusterd/src/glusterd-volgen.c | |
parent | 70a729e9751e45e266f7462443dcf2b6be3cecbe (diff) |
arbiter: load arbiter xlator on every 3rd brick of a replica 3 AFR subvol
Logic for adding the 'glusterd_brickinfo->group' member and using it to
find the brick positon has been taken from http://review.gluster.org/#/c/9919.
Thanks to Jeff Darcy for that.
This patch is a part of the arbiter logic implementation for 3 way AFR
details of which can be found at http://review.gluster.org/#/c/9656/
Change-Id: Idbfe4f29ee8e098e0102def8f38b32314316b188
BUG: 1199985
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/10257
Tested-by: NetBSD Build System
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 86 |
1 files changed, 72 insertions, 14 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index faaf5d59a48..a149e9916df 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1502,12 +1502,26 @@ brick_graph_add_arbiter (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, dict_t *set_dict, glusterd_brickinfo_t *brickinfo) { xlator_t *xl = NULL; + glusterd_brickinfo_t *next = NULL; + glusterd_brickinfo_t *last = NULL; int ret = -1; if (volinfo->arbiter_count != 1) return 0; - /*TODO: Parse brickinfo and add the arbiter xlator only if brick is the - * last brick (i.e. 3rd brick) of the replcia pair.*/ + + /* Find the last brick in the same group. */ + last = brickinfo; + for (;;) { + next = list_next (last, &volinfo->bricks, + glusterd_brickinfo_t, brick_list); + if (!next || (next->group != brickinfo->group)) { + break; + } + last = next; + } + if (last != brickinfo) + return 0; + xl = volgen_graph_add (graph, "features/arbiter", volinfo->volname); if (!xl) goto out; @@ -1571,6 +1585,22 @@ out: return ret; } +void +assign_brick_groups (glusterd_volinfo_t *volinfo) +{ + glusterd_brickinfo_t *brickinfo = NULL; + uint16_t group_num = 0; + int in_group = 0; + + list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { + brickinfo->group = group_num; + if (++in_group >= volinfo->replica_count) { + in_group = 0; + ++group_num; + } + } +} + static int brick_graph_add_changelog (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, dict_t *set_dict, glusterd_brickinfo_t *brickinfo) @@ -3087,6 +3117,43 @@ out: } static int +volgen_graph_build_afr_clusters (volgen_graph_t *graph, + glusterd_volinfo_t *volinfo) +{ + int i = 0; + int ret = 0; + int clusters = 0; + char *replicate_args[] = {"cluster/replicate", + "%s-replicate-%d"}; + xlator_t *afr = NULL; + char option[32] = {0}; + + clusters = volgen_link_bricks_from_list_tail (graph, volinfo, + replicate_args[0], + replicate_args[1], + volinfo->brick_count, + volinfo->replica_count); + if (clusters < 0) + goto out; + + if (!volinfo->arbiter_count) + goto out; + + afr = first_of (graph); + sprintf(option, "%d", volinfo->arbiter_count); + for (i = 0; i < clusters; i++) { + ret = xlator_set_option (afr, "arbiter-count", option); + if (ret) { + clusters = -1; + goto out; + } + afr = afr->next; + } +out: + return clusters; +} + +static int volume_volgen_graph_build_clusters (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, gf_boolean_t is_quotad) @@ -3116,13 +3183,7 @@ volume_volgen_graph_build_clusters (volgen_graph_t *graph, /* All other cases, it will have one or the other cluster type */ switch (volinfo->type) { case GF_CLUSTER_TYPE_REPLICATE: - clusters = volgen_link_bricks_from_list_tail - (graph, volinfo, - replicate_args[0], - replicate_args[1], - volinfo->brick_count, - volinfo->replica_count); - + clusters = volgen_graph_build_afr_clusters (graph, volinfo); if (clusters < 0) goto out; break; @@ -3146,11 +3207,7 @@ volume_volgen_graph_build_clusters (volgen_graph_t *graph, /* Replicate after the clients, then stripe */ if (volinfo->replica_count == 0) goto out; - clusters = volgen_link_bricks_from_list_tail (graph, volinfo, - replicate_args[0], - replicate_args[1], - volinfo->brick_count, - volinfo->replica_count); + clusters = volgen_graph_build_afr_clusters (graph, volinfo); if (clusters < 0) goto out; @@ -4473,6 +4530,7 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo) if (ret == -1) return -1; + assign_brick_groups (volinfo); get_vol_tstamp_file (tstamp_file, volinfo); if (ret) { |