summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-volgen.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-09-09 09:42:51 +0530
committerVijay Bellur <vijay@gluster.com>2011-09-13 02:10:12 -0700
commit25daa42911d2ff697880ee29c591cac5f2abebed (patch)
tree9555284c052e1e205909e91f578a8b46b522ec56 /xlators/mgmt/glusterd/src/glusterd-volgen.c
parent17e57f27c714c94dd5d9fa91650f83d069f2f4e4 (diff)
support for de-commissioning a node using 'remove-brick'
to achieve this, we now create volume-file with 'decommissioned-nodes' option in distribute volume, then just perform the rebalance set of operations (with 'force' flag set). now onwards, the 'remove-brick' (with 'start' option) operation tries to migrate data from removed bricks to existing bricks. 'remove-brick' also supports similar options as of replace-brick. * (no options) -> works as 'force', will have the current behavior of remove-brick, ie., no data-migration, volume changes. * start (starts remove-brick with data-migration/draining process, which takes care of migrating data and once complete, will commit the changes to volume file) * pause (stop data migration, but keep the volume file intact with extra options whatever is set) * abort (stop data-migration, and fall back to old configuration) * commit (if volume is stopped, commits the changes to volumefile) * force (stops the data-migration and commits the changes to volume file) Change-Id: I3952bcfbe604a0952e68b6accace7014d5e401d3 BUG: 1952 Reviewed-on: http://review.gluster.com/118 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c104
1 files changed, 79 insertions, 25 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index cb198dfb9..d0533b1fc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1811,10 +1811,15 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
char **cluster_args = NULL;
int i = 0;
int j = 0;
- int ret = 0;
+ int ret = -1;
xlator_t *xl = NULL;
xlator_t *txl = NULL;
xlator_t *trav = NULL;
+ int removed_bricks = 0;
+ int index_of_removed_brick = 0;
+ char *removed_bricklist = NULL;
+ char volume_name[1024] = {0,};
+ int idx = 0;
volname = volinfo->volname;
dict = volinfo->dict;
@@ -1824,7 +1829,7 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
gf_log ("", GF_LOG_ERROR,
"volume inconsistency: brick count is 0");
- return -1;
+ goto out;
}
if (volinfo->sub_count && volinfo->sub_count < volinfo->brick_count &&
volinfo->brick_count % volinfo->sub_count != 0) {
@@ -1834,7 +1839,7 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
"number of bricks per cluster (%d) in a multi-cluster "
"setup",
volinfo->brick_count, volinfo->sub_count);
- return -1;
+ goto out;
}
get_transport_type (volinfo, set_dict, transt, _gf_false);
@@ -1844,19 +1849,32 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
i = 0;
list_for_each_entry (brick, &volinfo->bricks, brick_list) {
+ ret = -1;
xl = volgen_graph_add_nolink (graph, "protocol/client",
"%s-client-%d", volname, i);
if (!xl)
- return -1;
+ goto out;
ret = xlator_set_option (xl, "remote-host", brick->hostname);
if (ret)
- return -1;
+ goto out;
ret = xlator_set_option (xl, "remote-subvolume", brick->path);
if (ret)
- return -1;
+ goto out;
ret = xlator_set_option (xl, "transport-type", transt);
if (ret)
- return -1;
+ goto out;
+ if (brick->decommissioned) {
+ if (!removed_bricklist) {
+ removed_bricklist = GF_CALLOC (16 * GF_UNIT_KB,
+ 1, gf_common_mt_char);
+ index_of_removed_brick = i;
+ }
+ if (removed_bricks)
+ strcat (removed_bricklist, ",");
+ snprintf (volume_name, 1024, "%s-client-%d", volname, i);
+ strcat (removed_bricklist, volume_name);
+ removed_bricks++;
+ }
i++;
}
@@ -1866,7 +1884,7 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
"differs from brick count (%d)", i,
volinfo->brick_count);
- return -1;
+ goto out;
}
sub_count = volinfo->sub_count;
@@ -1880,15 +1898,18 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
break;
case GF_CLUSTER_TYPE_STRIPE_REPLICATE:
/* Replicate after the clients, then stripe */
- if (volinfo->replica_count == 0)
- return -1;
+ if (volinfo->replica_count == 0) {
+ ret = -1;
+ goto out;
+ }
sub_count = volinfo->replica_count;
cluster_args = replicate_args;
break;
default:
gf_log ("", GF_LOG_ERROR, "volume inconsistency: "
"unrecognized clustering type");
- return -1;
+ ret = -1;
+ goto out;
}
i = 0;
@@ -1901,14 +1922,16 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
cluster_args[0],
cluster_args[1],
volname, j);
- if (!xl)
- return -1;
+ if (!xl) {
+ ret = -1;
+ goto out;
+ }
j++;
}
ret = volgen_xlator_link (xl, trav);
if (ret)
- return -1;
+ goto out;
if (trav == txl)
break;
@@ -1928,14 +1951,16 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
cluster_args[0],
cluster_args[1],
volname, j);
- if (!xl)
- return -1;
+ if (!xl) {
+ ret = -1;
+ goto out;
+ }
j++;
}
ret = volgen_xlator_link (xl, trav);
if (ret)
- return -1;
+ goto out;
if (trav == txl)
break;
@@ -1953,8 +1978,10 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (dist_count > 1) {
xl = volgen_graph_add_nolink (graph, "cluster/distribute",
"%s-dht", volname);
- if (!xl)
- return -1;
+ if (!xl) {
+ ret = -1;
+ goto out;
+ }
trav = xl;
for (i = 0; i < dist_count; i++)
@@ -1962,28 +1989,50 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
for (; trav != xl; trav = trav->prev) {
ret = volgen_xlator_link (xl, trav);
if (ret)
- return -1;
+ goto out;
+ }
+
+ if (removed_bricks) {
+ if (volinfo->sub_count) {
+ idx = index_of_removed_brick / volinfo->sub_count;
+ if (GF_CLUSTER_TYPE_REPLICATE == volinfo->type) {
+ snprintf (volume_name, 1024, "%s-replicate-%d",
+ volname, idx);
+ strcpy (removed_bricklist, volume_name);
+ } else if (volinfo->type != GF_CLUSTER_TYPE_NONE) {
+ snprintf (volume_name, 1024, "%s-stripe-%d ",
+ volname, idx);
+ strcpy (removed_bricklist, volume_name);
+ }
+ }
+ ret = xlator_set_option (xl, "decommissioned-bricks",
+ removed_bricklist);
+ if (ret)
+ goto out;
}
}
ret = glusterd_volinfo_get_boolean (volinfo, VKEY_FEATURES_QUOTA);
if (ret == -1)
- return -1;
+ goto out;
+
if (ret) {
xl = volgen_graph_add (graph, "features/quota", volname);
- if (!xl)
- return -1;
+ if (!xl) {
+ ret = -1;
+ goto out;
+ }
}
ret = volgen_graph_set_options_generic (graph, set_dict, volname,
&perfxl_option_handler);
if (ret)
- return -1;
+ goto out;
xl = volgen_graph_add_as (graph, "debug/io-stats", volname);
if (!xl)
- return -1;
+ goto out;
ret = volgen_graph_set_options_generic (graph, set_dict, "client",
&loglevel_option_handler);
@@ -1991,6 +2040,11 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (!ret)
ret = volgen_graph_set_options_generic (graph, set_dict, "client",
&sys_loglevel_option_handler);
+
+out:
+ if (removed_bricklist)
+ GF_FREE (removed_bricklist);
+
return ret;
}