summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-03-01 03:37:12 +0000
committerAnand V. Avati <avati@dev.gluster.com>2011-03-01 15:10:40 -0800
commit4175d3e8e2ca1afc0e9f3404ca04fe29d522c81f (patch)
tree11f8beb46de58f68002dc7780c0c62e26937f4b5 /cli
parentae578f0c6518afd22cf13c21eebca203352774d3 (diff)
gluster rebalance: give option to split the command
the 'gluster volume rebalance <VOLNAME> start' is enhanced with two more options: * 'gluster volume rebalance <VOLNAME> fix-layout start' (for fixing layout only) * 'gluster volume rebalance <VOLNAME> migrate-data start' (for migrating data only) Also the old way of running rebalance in one shot will still work fine * 'gluster volume rebalance <VOLNAME> start' Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 2258 (enhance gluster volume rebalance) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2258
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-volume.c20
-rw-r--r--cli/src/cli-rpc-ops.c44
2 files changed, 51 insertions, 13 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 9e93d4e97..a790b326e 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -476,7 +476,7 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (!dict)
goto out;
- if (wordcount != 4) {
+ if (!((wordcount == 4) || (wordcount == 5))) {
cli_usage_out (word->pattern);
parse_error = 1;
goto out;
@@ -486,9 +486,19 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (ret)
goto out;
- ret = dict_set_str (dict, "command", (char *)words[3]);
- if (ret)
- goto out;
+ if (wordcount == 4) {
+ ret = dict_set_str (dict, "command", (char *)words[3]);
+ if (ret)
+ goto out;
+ }
+ if (wordcount == 5) {
+ ret = dict_set_str (dict, "start-type", (char *)words[3]);
+ if (ret)
+ goto out;
+ ret = dict_set_str (dict, "command", (char *)words[4]);
+ if (ret)
+ goto out;
+ }
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_DEFRAG_VOLUME];
@@ -962,7 +972,7 @@ struct cli_cmd volume_cmds[] = {
cli_cmd_volume_remove_brick_cbk,
"remove brick from volume <VOLNAME>"},
- { "volume rebalance <VOLNAME> {start|stop|status}",
+ { "volume rebalance <VOLNAME> [fix-layout|migrate-data] {start|stop|status}",
cli_cmd_volume_defrag_cbk,
"rebalance operations"},
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 4e713eef5..d95c91bbe 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -803,7 +803,9 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
volname = local->u.defrag_vol.volname;
cmd = local->u.defrag_vol.cmd;
}
- if (cmd == GF_DEFRAG_CMD_START) {
+ if ((cmd == GF_DEFRAG_CMD_START) ||
+ (cmd == GF_DEFRAG_CMD_START_LAYOUT_FIX) ||
+ (cmd == GF_DEFRAG_CMD_START_MIGRATE_DATA)) {
if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
cli_out (rsp.op_errstr);
else
@@ -845,21 +847,34 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
status = "completed";
if (rsp.op_errno == 5)
status = "failed";
+ if (rsp.op_errno == 6)
+ status = "step 1: layout fix complete";
+ if (rsp.op_errno == 7)
+ status = "step 2: data migration complete";
if (rsp.files && (rsp.op_errno == 1)) {
cli_out ("rebalance %s: fixed layout %"PRId64,
status, rsp.files);
- } else if (rsp.files) {
+ goto done;
+ }
+ if (rsp.files && (rsp.op_errno == 6)) {
+ cli_out ("rebalance %s: fixed layout %"PRId64,
+ status, rsp.files);
+ goto done;
+ }
+ if (rsp.files) {
cli_out ("rebalance %s: rebalanced %"PRId64
" files of size %"PRId64" (total files"
" scanned %"PRId64")", status,
rsp.files, rsp.size, rsp.lookedup_files);
- } else {
- cli_out ("rebalance %s", status);
+ goto done;
}
+
+ cli_out ("rebalance %s", status);
}
}
+done:
if (volname)
GF_FREE (volname);
@@ -1723,15 +1738,28 @@ gf_cli3_1_defrag_volume (call_frame_t *frame, xlator_t *this,
goto out;
}
- if (strncasecmp (cmd_str, "start", 6) == 0) {
+ if (strcmp (cmd_str, "start") == 0) {
req.cmd = GF_DEFRAG_CMD_START;
- } else if (strncasecmp (cmd_str, "stop", 5) == 0) {
+ ret = dict_get_str (dict, "start-type", &cmd_str);
+ if (!ret) {
+ if (strcmp (cmd_str, "fix-layout") == 0) {
+ req.cmd = GF_DEFRAG_CMD_START_LAYOUT_FIX;
+ }
+ if (strcmp (cmd_str, "migrate-data") == 0) {
+ req.cmd = GF_DEFRAG_CMD_START_MIGRATE_DATA;
+ }
+ }
+ goto done;
+ }
+ if (strcmp (cmd_str, "stop") == 0) {
req.cmd = GF_DEFRAG_CMD_STOP;
- } else if (strncasecmp (cmd_str, "status", 7) == 0) {
+ goto done;
+ }
+ if (strcmp (cmd_str, "status") == 0) {
req.cmd = GF_DEFRAG_CMD_STATUS;
}
-
+done:
local = cli_local_get ();
if (local) {