diff options
author | Mohammed Rafi KC <rkavunga@redhat.com> | 2015-09-07 14:46:33 +0530 |
---|---|---|
committer | Dan Lambright <dlambrig@redhat.com> | 2015-10-09 10:00:11 -0700 |
commit | d777b2feaf55347177d6786657d68cc0547f7f73 (patch) | |
tree | fa3d3bc517fb43299f232b6e962aa24d67d11ca5 /xlators | |
parent | 9e0c2c9d5e9b4f5df644911e29be4a611e0d2d42 (diff) |
tiering/glusterd: keep afr/ec xlators name constant
afr uses the translator name for locking purpose,
so it is mandatory to keep afr/ec xlators name constant
across graph change
currently when a tier is attached, afr names are appended
either with hot or cold. ie that breaks the above
mentioned constraint.
Backport of>
>Change-Id: I3699dcdaa8190bab3ba81cbc01e8fa126d37ba0d
>BUG: 1261276
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
>Reviewed-on: http://review.gluster.org/12134
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
>Tested-by: Gluster Build System <jenkins@build.gluster.com>
>Reviewed-by: Dan Lambright <dlambrig@redhat.com>
>Tested-by: Dan Lambright <dlambrig@redhat.com>
(cherry picked from commit 4ad9bc5faca60528345f1e9c95c22bd8402162c0)
Change-Id: I7bf5f22f112f1df1c05a0a8503d56029509d6292
BUG: 1261744
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
Reviewed-on: http://review.gluster.org/12323
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Tested-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 14 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 120 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 8 |
3 files changed, 112 insertions, 30 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index 982e96b4970..dbd7264da56 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -2319,7 +2319,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) int start_remove = 0; uint32_t commit_hash = 0; int defrag_cmd = 0; - + int detach_commit = 0; + void *tier_info = NULL; this = THIS; GF_ASSERT (this); @@ -2443,6 +2444,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) case GF_OP_CMD_DETACH_COMMIT: case GF_OP_CMD_DETACH_COMMIT_FORCE: glusterd_op_perform_detach_tier (volinfo); + detach_commit = 1; /* fall through */ case GF_OP_CMD_COMMIT_FORCE: @@ -2532,6 +2534,13 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) goto out; i++; } + + if (detach_commit) { + /* Clear related information from volinfo */ + tier_info = ((void *)(&volinfo->tier_info)); + memset (tier_info, 0, sizeof (volinfo->tier_info)); + } + if (start_remove) volinfo->rebal.dict = dict_ref (bricks_dict); @@ -2625,9 +2634,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr) if (GLUSTERD_STATUS_STARTED == volinfo->status) ret = glusterd_svcs_manager (volinfo); } - out: - if (ret && err_str[0] && op_errstr) + if (ret && err_str[0] && op_errstr) *op_errstr = gf_strdup (err_str); GF_FREE (brick_tmpstr); diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index bbe7cb89bfa..2b4ca74ab97 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -2832,11 +2832,11 @@ static int volgen_link_bricks (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, char *xl_type, char *xl_namefmt, size_t child_count, - size_t sub_count, + size_t sub_count, size_t start_count, xlator_t *trav) { int i = 0; - int j = 0; + int j = start_count; xlator_t *xl = NULL; char *volname = NULL; int ret = -1; @@ -2871,6 +2871,50 @@ out: } static int +volgen_link_bricks_from_list_tail_start (volgen_graph_t *graph, + glusterd_volinfo_t *volinfo, + char *xl_type, + char *xl_namefmt, size_t child_count, + size_t sub_count, size_t start_count) +{ + xlator_t *trav = NULL; + size_t cnt = child_count; + + if (!cnt) + return -1; + + for (trav = first_of(graph); --cnt; trav = trav->next) + ; + + return volgen_link_bricks (graph, volinfo, + xl_type, + xl_namefmt, + child_count, + sub_count, start_count, + trav); +} + +static int +volgen_link_bricks_from_list_head_start (volgen_graph_t *graph, + glusterd_volinfo_t *volinfo, + char *xl_type, + char *xl_namefmt, size_t child_count, + size_t sub_count, size_t start_count) +{ + xlator_t *trav = NULL; + + for (trav = first_of(graph); trav->next; trav = trav->next) + ; + + return volgen_link_bricks (graph, volinfo, + xl_type, + xl_namefmt, + child_count, + sub_count, start_count, + trav); +} + +static int volgen_link_bricks_from_list_tail (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, char *xl_type, @@ -2880,6 +2924,9 @@ volgen_link_bricks_from_list_tail (volgen_graph_t *graph, xlator_t *trav = NULL; size_t cnt = child_count; + if (!cnt) + return -1; + for (trav = first_of(graph); --cnt; trav = trav->next) ; @@ -2887,7 +2934,7 @@ volgen_link_bricks_from_list_tail (volgen_graph_t *graph, xl_type, xl_namefmt, child_count, - sub_count, + sub_count, 0, trav); } @@ -2906,7 +2953,7 @@ volgen_link_bricks_from_list_head (volgen_graph_t *graph, xl_type, xl_namefmt, child_count, - sub_count, + sub_count, 0, trav); } @@ -3109,7 +3156,7 @@ volgen_graph_build_dht_cluster (volgen_graph_t *graph, else name_fmt = "%s-dht"; - clusters = volgen_link_bricks_from_list_tail (graph, volinfo, + clusters = volgen_link_bricks_from_list_tail (graph, volinfo, voltype, name_fmt, child_count, @@ -3150,12 +3197,19 @@ volgen_graph_build_ec_clusters (volgen_graph_t *graph, "%s-disperse-%d"}; xlator_t *ec = NULL; char option[32] = {0}; + int start_count = 0; - clusters = volgen_link_bricks_from_list_tail (graph, volinfo, - disperse_args[0], - disperse_args[1], - volinfo->brick_count, - volinfo->disperse_count); + if (volinfo->tier_info.cur_tier_hot && + volinfo->tier_info.cold_type == GF_CLUSTER_TYPE_DISPERSE) + start_count = volinfo->tier_info.cold_brick_count/ + volinfo->tier_info.cold_disperse_count; + + clusters = volgen_link_bricks_from_list_tail_start (graph, volinfo, + disperse_args[0], + disperse_args[1], + volinfo->brick_count, + volinfo->disperse_count, + start_count); if (clusters < 0) goto out; @@ -3185,12 +3239,18 @@ volgen_graph_build_afr_clusters (volgen_graph_t *graph, "%s-replicate-%d"}; xlator_t *afr = NULL; char option[32] = {0}; + int start_count = 0; - clusters = volgen_link_bricks_from_list_tail (graph, volinfo, + if (volinfo->tier_info.cur_tier_hot && + volinfo->tier_info.cold_type == GF_CLUSTER_TYPE_REPLICATE) + start_count = volinfo->tier_info.cold_brick_count / + volinfo->tier_info.cold_replica_count; + clusters = volgen_link_bricks_from_list_tail_start (graph, volinfo, replicate_args[0], replicate_args[1], volinfo->brick_count, - volinfo->replica_count); + volinfo->replica_count, + start_count); if (clusters < 0) goto out; @@ -3231,6 +3291,7 @@ volume_volgen_graph_build_clusters (volgen_graph_t *graph, int ret = -1; xlator_t *ec = NULL; xlator_t *client = NULL; + char tmp_volname[GD_VOLUME_NAME_MAX] = {0, }; if (!volinfo->dist_leaf_count) goto out; @@ -3300,9 +3361,17 @@ build_distribute: ret = -1; goto out; } - + if (volinfo->tier_info.hot_brick_count) { + strcpy (tmp_volname, volinfo->volname); + if (volinfo->tier_info.cur_tier_hot) + strcat (volinfo->volname, "-hot"); + else + strcat (volinfo->volname, "-cold"); + } ret = volgen_graph_build_dht_cluster (graph, volinfo, dist_count, is_quotad); + if (volinfo->tier_info.hot_brick_count) + strcpy (volinfo->volname, tmp_volname); if (ret) goto out; @@ -3407,7 +3476,6 @@ volume_volgen_graph_build_clusters_tier (volgen_graph_t *graph, int st_disperse_count = 0; int st_dist_leaf_count = 0; int st_type = 0; - char st_volname[GD_VOLUME_NAME_MAX]; int dist_count = 0; char *decommissioned_children = NULL; @@ -3416,7 +3484,6 @@ volume_volgen_graph_build_clusters_tier (volgen_graph_t *graph, st_disperse_count = volinfo->disperse_count; st_type = volinfo->type; st_dist_leaf_count = volinfo->dist_leaf_count; - strcpy(st_volname, volinfo->volname); volinfo->dist_leaf_count = volinfo->tier_info.cold_dist_leaf_count; volinfo->brick_count = volinfo->tier_info.cold_brick_count; @@ -3424,7 +3491,7 @@ volume_volgen_graph_build_clusters_tier (volgen_graph_t *graph, volinfo->disperse_count = volinfo->tier_info.cold_disperse_count; volinfo->redundancy_count = volinfo->tier_info.cold_redundancy_count; volinfo->type = volinfo->tier_info.cold_type; - sprintf (volinfo->volname, "%s-cold", st_volname); + volinfo->tier_info.cur_tier_hot = 0; ret = volume_volgen_graph_build_clusters (graph, volinfo, is_quotad); if (ret) @@ -3436,28 +3503,29 @@ volume_volgen_graph_build_clusters_tier (volgen_graph_t *graph, volinfo->replica_count = volinfo->tier_info.hot_replica_count; volinfo->dist_leaf_count = glusterd_get_dist_leaf_count(volinfo); volinfo->disperse_count = 0; - - sprintf (volinfo->volname, "%s-hot", st_volname); + volinfo->tier_info.cur_tier_hot = 1; dist_count = volinfo->brick_count / volinfo->dist_leaf_count; if (volinfo->dist_leaf_count != 1) { - ret = volgen_link_bricks_from_list_head + ret = volgen_link_bricks_from_list_head_start (graph, volinfo, "cluster/replicate", "%s-replicate-%d", volinfo->brick_count, - volinfo->replica_count); + volinfo->replica_count, + volinfo->tier_info.cold_brick_count/ + volinfo->tier_info.cold_replica_count); if (ret != -1) volgen_link_bricks_from_list_tail (graph, volinfo, "cluster/distribute", - "%s-dht", + "%s-hot-dht", dist_count, dist_count); } else { ret = volgen_link_bricks_from_list_head (graph, volinfo, "cluster/distribute", - "%s-dht", + "%s-hot-dht", dist_count, dist_count); } @@ -3470,15 +3538,15 @@ volume_volgen_graph_build_clusters_tier (volgen_graph_t *graph, if (!is_quotad) { xl = volgen_graph_add_nolink (graph, "cluster/tier", "%s-%s", - st_volname, "tier-dht"); + volinfo->volname, "tier-dht"); } else { xl = volgen_graph_add_nolink (graph, "cluster/tier", "%s", - st_volname); + volinfo->volname); } if (!xl) goto out; - gf_asprintf(&rule, "%s-hot-dht", st_volname); + gf_asprintf(&rule, "%s-hot-dht", volinfo->volname); ret = xlator_set_option(xl, "rule", rule); if (ret) @@ -3510,7 +3578,7 @@ volume_volgen_graph_build_clusters_tier (volgen_graph_t *graph, volinfo->disperse_count = st_disperse_count; volinfo->type = st_type; volinfo->dist_leaf_count = st_dist_leaf_count; - strcpy(volinfo->volname, st_volname); + volinfo->tier_info.cur_tier_hot = 0; return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index d9b06c3e5da..b6836fbadf8 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -321,6 +321,7 @@ typedef struct tier_info_ { int hot_replica_count; int promoted; int demoted; + uint16_t cur_tier_hot; } gd_tier_info_t; struct glusterd_volinfo_ { @@ -336,7 +337,12 @@ struct glusterd_volinfo_ { the volume which is snapped. In case of a non-snap volume, this field will be initialized as N/A */ - char volname[GD_VOLUME_NAME_MAX]; + char volname[GD_VOLUME_NAME_MAX + 5]; + /* An extra 5 bytes are allocated. + * Reason is, As part of the tiering + * volfile generation code, we are + * temporarily appending either hot + * or cold */ int type; int brick_count; uint64_t snap_count; |