summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-rpc-ops.c
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r--cli/src/cli-rpc-ops.c100
1 files changed, 52 insertions, 48 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 366d8742b..8fc73032a 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -791,6 +791,7 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
cli_local_t *local = NULL;
char *volname = NULL;
call_frame_t *frame = NULL;
+ char *status = "unknown";
int cmd = 0;
int ret = 0;
@@ -813,16 +814,7 @@ 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) ||
- (cmd == GF_DEFRAG_CMD_START_LAYOUT_FIX) ||
- (cmd == GF_DEFRAG_CMD_START_MIGRATE_DATA)) {
- if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
- cli_out ("%s", rsp.op_errstr);
- else
- cli_out ("starting rebalance on volume %s has been %s",
- volname, (rsp.op_ret) ? "unsuccessful":
- "successful");
- }
+
if (cmd == GF_DEFRAG_CMD_STOP) {
if (rsp.op_ret == -1) {
if (strcmp (rsp.op_errstr, ""))
@@ -835,6 +827,7 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
"(after rebalancing %"PRId64" files totaling "
"%"PRId64" bytes)", volname, rsp.files, rsp.size);
}
+ goto done;
}
if (cmd == GF_DEFRAG_CMD_STATUS) {
if (rsp.op_ret == -1) {
@@ -843,47 +836,55 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
else
cli_out ("failed to get the status of "
"rebalance process");
- } else {
- char *status = "unknown";
- if (rsp.op_errno == 0)
- status = "not started";
- if (rsp.op_errno == 1)
- status = "step 1: layout fix in progress";
- if (rsp.op_errno == 2)
- status = "step 2: data migration in progress";
- if (rsp.op_errno == 3)
- status = "stopped";
- if (rsp.op_errno == 4)
- 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);
- 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);
- goto done;
- }
-
- cli_out ("rebalance %s", status);
+ goto done;
+ }
+ if (rsp.op_errno == 0)
+ status = "not started";
+ if (rsp.op_errno == 1)
+ status = "step 1: layout fix in progress";
+ if (rsp.op_errno == 2)
+ status = "step 2: data migration in progress";
+ if (rsp.op_errno == 3)
+ status = "stopped";
+ if (rsp.op_errno == 4)
+ 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);
+ 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);
+ goto done;
+ }
+
+ cli_out ("rebalance %s", status);
+ goto done;
}
+ /* All other possibility is about starting a volume */
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
+ cli_out ("%s", rsp.op_errstr);
+ else
+ cli_out ("starting rebalance on volume %s has been %s",
+ volname, (rsp.op_ret) ? "unsuccessful":
+ "successful");
+
done:
if (volname)
GF_FREE (volname);
@@ -1906,6 +1907,9 @@ gf_cli3_1_defrag_volume (call_frame_t *frame, xlator_t *this,
if (strcmp (cmd_str, "migrate-data") == 0) {
req.cmd = GF_DEFRAG_CMD_START_MIGRATE_DATA;
}
+ if (strcmp (cmd_str, "migrate-data-force") == 0) {
+ req.cmd = GF_DEFRAG_CMD_START_MIGRATE_DATA_FORCE;
+ }
}
goto done;
}