summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
diff options
context:
space:
mode:
authorDan Lambright <dlambrig@redhat.com>2015-04-13 02:42:12 +0100
committerKaleb KEITHLEY <kkeithle@redhat.com>2015-04-22 07:51:03 -0700
commit86b02afab780e559e82399b9e96381d8df594ed6 (patch)
treee59242b087191dfb6af7b302b18a59206a9cd17c /xlators/mgmt/glusterd/src/glusterd-brick-ops.c
parentabbc525dd3cbe142753c5b44a2717c1ed6b26723 (diff)
glusterd: support for tier volumes 'detach start' and 'detach commit'
These commands work in a manner analagous to rebalancing when removing a brick. The existing migration daemon detects "detach start" and switches to moving data off the hot tier. While in this state all lookups are directed to the cold tier. gluster v detach-tier <vol> start gluster v detach-tier <vol> commit The status and stop cli commands shall be submitted separately. Change-Id: I24fda5cc3ba74f5fb8aa9a3234ad51f18b80a8a0 BUG: 1205540 Signed-off-by: Dan Lambright <dlambrig@redhat.com> Signed-off-by: root <root@localhost.localdomain> Signed-off-by: Dan Lambright <dlambrig@redhat.com> Reviewed-on: http://review.gluster.org/10108 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: NetBSD Build System
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-brick-ops.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index 165622f87ef..c69d2ada238 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -1604,6 +1604,7 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr)
ret = 0;
goto out;
+ case GF_OP_CMD_DETACH_START:
case GF_OP_CMD_START:
{
if ((volinfo->type == GF_CLUSTER_TYPE_REPLICATE) &&
@@ -1736,7 +1737,8 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr)
break;
- case GF_OP_CMD_DETACH:
+ case GF_OP_CMD_DETACH_COMMIT:
+ case GF_OP_CMD_DETACH_COMMIT_FORCE:
case GF_OP_CMD_COMMIT_FORCE:
break;
}
@@ -1961,7 +1963,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
xlator_t *this = NULL;
dict_t *bricks_dict = NULL;
char *brick_tmpstr = NULL;
-
+ int start_remove = 0;
this = THIS;
GF_ASSERT (this);
@@ -1985,10 +1987,15 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
}
cmd = flag;
+ if ((GF_OP_CMD_START == cmd) ||
+ (GF_OP_CMD_DETACH_START == cmd))
+ start_remove = 1;
+
/* Set task-id, if available, in ctx dict for operations other than
* start
*/
- if (is_origin_glusterd (dict) && (cmd != GF_OP_CMD_START)) {
+
+ if (is_origin_glusterd (dict) && (!start_remove)) {
if (!gf_uuid_is_null (volinfo->rebal.rebalance_id)) {
ret = glusterd_copy_uuid_to_dict
(volinfo->rebal.rebalance_id, dict,
@@ -2003,7 +2010,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
/* Clear task-id, rebal.op and stored bricks on commmitting/stopping
* remove-brick */
- if ((cmd != GF_OP_CMD_START) || (cmd != GF_OP_CMD_STATUS)) {
+ if ((!start_remove) && (cmd != GF_OP_CMD_STATUS)) {
gf_uuid_clear (volinfo->rebal.rebalance_id);
volinfo->rebal.op = GD_OP_NONE;
dict_unref (volinfo->rebal.dict);
@@ -2047,6 +2054,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
goto out;
}
+ case GF_OP_CMD_DETACH_START:
case GF_OP_CMD_START:
/* Reset defrag status to 'NOT STARTED' whenever a
* remove-brick/rebalance command is issued to remove
@@ -2069,7 +2077,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
force = 1;
break;
- case GF_OP_CMD_DETACH:
+ case GF_OP_CMD_DETACH_COMMIT:
+ case GF_OP_CMD_DETACH_COMMIT_FORCE:
glusterd_op_perform_detach_tier (volinfo);
/* fall through */
@@ -2105,7 +2114,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
* remove-brick. Right now this is required for displaying the task
* parameters with task status in volume status.
*/
- if (GF_OP_CMD_START == cmd) {
+ if (start_remove) {
bricks_dict = dict_new ();
if (!bricks_dict) {
ret = -1;
@@ -2118,6 +2127,10 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
goto out;
}
}
+
+ if (volinfo->type == GF_CLUSTER_TYPE_TIER)
+ count = glusterd_set_detach_bricks(dict, volinfo);
+
while ( i <= count) {
snprintf (key, 256, "brick%d", i);
ret = dict_get_str (dict, key, &brick);
@@ -2127,7 +2140,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
goto out;
}
- if (GF_OP_CMD_START == cmd) {
+ if (start_remove) {
brick_tmpstr = gf_strdup (brick);
if (!brick_tmpstr) {
ret = -1;
@@ -2150,7 +2163,7 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
goto out;
i++;
}
- if (GF_OP_CMD_START == cmd)
+ if (start_remove)
volinfo->rebal.dict = dict_ref (bricks_dict);
volinfo->subvol_count = (volinfo->brick_count /
@@ -2170,7 +2183,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
* volumes undergoing a detach operation, they should not
* be modified here.
*/
- if ((replica_count == 1) && (cmd != GF_OP_CMD_DETACH)) {
+ if ((replica_count == 1) && (cmd != GF_OP_CMD_DETACH_COMMIT) &&
+ (cmd != GF_OP_CMD_DETACH_COMMIT_FORCE)) {
if (volinfo->type == GF_CLUSTER_TYPE_REPLICATE) {
volinfo->type = GF_CLUSTER_TYPE_NONE;
/* backward compatibility */
@@ -2195,8 +2209,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
goto out;
}
- if (GF_OP_CMD_START == cmd &&
- volinfo->status == GLUSTERD_STATUS_STARTED) {
+ if (start_remove &&
+ volinfo->status == GLUSTERD_STATUS_STARTED) {
ret = glusterd_svcs_reconfigure (volinfo);
if (ret) {
gf_log (this->name, GF_LOG_WARNING,