diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-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 fa652ac60c1..74e5aba7e1c 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -2323,7 +2323,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); @@ -2447,6 +2448,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: @@ -2536,6 +2538,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); @@ -2629,9 +2638,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 38cc609eab7..ad63e533243 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -2827,11 +2827,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; @@ -2866,6 +2866,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, @@ -2875,6 +2919,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) ; @@ -2882,7 +2929,7 @@ volgen_link_bricks_from_list_tail (volgen_graph_t *graph, xl_type, xl_namefmt, child_count, - sub_count, + sub_count, 0, trav); } @@ -2901,7 +2948,7 @@ volgen_link_bricks_from_list_head (volgen_graph_t *graph, xl_type, xl_namefmt, child_count, - sub_count, + sub_count, 0, trav); } @@ -3104,7 +3151,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, @@ -3145,12 +3192,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; @@ -3180,12 +3234,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; @@ -3226,6 +3286,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; @@ -3295,9 +3356,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; @@ -3402,7 +3471,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; @@ -3411,7 +3479,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; @@ -3419,7 +3486,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) @@ -3431,28 +3498,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); } @@ -3465,15 +3533,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) @@ -3505,7 +3573,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 59a1919e2c1..e9098a227d2 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -316,6 +316,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_ { @@ -331,7 +332,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; |