From 7ba1e1ed45cee56ef51b9c04df99c976546d5d04 Mon Sep 17 00:00:00 2001 From: shishirng Date: Wed, 18 Jan 2012 15:29:15 +0530 Subject: cluster/dht: Rebalance will be a new glusterfs process rebalance will not use any maintainance clients. It is replaced by syncops, with the volfile. Brickop (communication between glusterd<->glusterfs process) is used for status and stop commands. Dept-first traversal of dir is maintained, but data is migrated as and when encounterd. fix-layout (dir) do Complete migrate-data of dir fix-layout (subdir) done Rebalance state is saved in the vol file, for restart-ability. A disconnect event and pidfile state determine the defrag-status Signed-off-by: shishirng Change-Id: Iec6c80c84bbb2142d840242c28db3d5f5be94d01 BUG: 763844 Reviewed-on: http://review.gluster.com/2540 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi --- cli/src/cli-cmd-volume.c | 30 ++++++++------------ cli/src/cli-rpc-ops.c | 71 ++++++++++++++---------------------------------- 2 files changed, 31 insertions(+), 70 deletions(-) (limited to 'cli/src') diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 6bea948e968..6ab1515e302 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -731,7 +731,7 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word, if (!dict) goto out; - if (!((wordcount == 4) || (wordcount == 5) || (wordcount == 6))) { + if (!((wordcount == 4) || (wordcount == 5))) { cli_usage_out (word->pattern); parse_error = 1; goto out; @@ -741,7 +741,7 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word, index = 3; } else { if (strcmp (words[3], "fix-layout") && - strcmp (words[3], "migrate-data")) { + strcmp (words[3], "start")) { cli_usage_out (word->pattern); parse_error = 1; goto out; @@ -750,7 +750,7 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word, } if (strcmp (words[index], "start") && strcmp (words[index], "stop") && - strcmp (words[index], "status")) { + strcmp (words[index], "status") && strcmp (words[index], "force")) { cli_usage_out (word->pattern); parse_error = 1; goto out; @@ -766,27 +766,19 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word, 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; - } - - /* 'force' option is valid only for the 'migrate-data' key */ - if (wordcount == 6) { - if (strcmp (words[3], "migrate-data") || - strcmp (words[4], "start") || - strcmp (words[5], "force")) { + if ((strcmp (words[3], "fix-layout") || + strcmp (words[4], "start")) && + (strcmp (words[3], "start") || + strcmp (words[4], "force"))) { cli_usage_out (word->pattern); parse_error = 1; goto out; } - ret = dict_set_str (dict, "start-type", "migrate-data-force"); + + ret = dict_set_str (dict, "option", (char *)words[4]); if (ret) goto out; - ret = dict_set_str (dict, "command", (char *)words[4]); + ret = dict_set_str (dict, "command", (char *)words[3]); if (ret) goto out; } @@ -1776,7 +1768,7 @@ struct cli_cmd volume_cmds[] = { cli_cmd_volume_remove_brick_cbk, "remove brick from volume "}, - { "volume rebalance [fix-layout|migrate-data] {start|stop|status} [force]", + { "volume rebalance [fix-layout] {start|stop|status} [force]", cli_cmd_volume_defrag_cbk, "rebalance operations"}, diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 6ed380bffa8..d1888415cef 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -1052,9 +1052,9 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, volname); } else { snprintf (msg, sizeof (msg), - "stopped rebalance process of volume %s \n" - "(after rebalancing %"PRId64" files totaling" - " %"PRId64" bytes)", volname, files, size); + "Stopped rebalance process on volume %s \n" + "(after rebalancing %"PRId64" bytes - " + "%"PRId64" files)", volname, size, files); } goto done; } @@ -1065,7 +1065,7 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, "%s", rsp.op_errstr); else snprintf (msg, sizeof (msg), - "failed to get the status of " + "Failed to get the status of " "rebalance process"); goto done; } @@ -1074,11 +1074,8 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, case GF_DEFRAG_STATUS_NOT_STARTED: status = "not started"; break; - case GF_DEFRAG_STATUS_LAYOUT_FIX_STARTED: - status = "step 1: layout fix in progress"; - break; - case GF_DEFRAG_STATUS_MIGRATE_DATA_STARTED: - status = "step 2: data migration in progress"; + case GF_DEFRAG_STATUS_STARTED: + status = "in progress"; break; case GF_DEFRAG_STATUS_STOPPED: status = "stopped"; @@ -1089,38 +1086,17 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, case GF_DEFRAG_STATUS_FAILED: status = "failed"; break; - case GF_DEFRAG_STATUS_LAYOUT_FIX_COMPLETE: - status = "step 1: layout fix complete"; - break; - case GF_DEFRAG_STATUS_MIGRATE_DATA_COMPLETE: - status = "step 2: data migration complete"; - break; - case GF_DEFRAG_STATUS_PAUSED: - status = "paused"; - break; } - if (files && (rsp.op_errno == 1)) { - snprintf (msg, sizeof (msg), - "rebalance %s: fixed layout %"PRId64, - status, files); - goto done; - } - if (files && (rsp.op_errno == 6)) { - snprintf (msg, sizeof (msg), - "rebalance %s: fixed layout %"PRId64, - status, files); - goto done; - } - if (files) { - snprintf (msg, sizeof (msg), - "rebalance %s: rebalanced %"PRId64 + if (files || size || lookup) { + snprintf (msg, sizeof(msg), + "Rebalance %s: rebalanced %"PRId64 " files of size %"PRId64" (total files" " scanned %"PRId64")", status, files, size, lookup); goto done; } - snprintf (msg, sizeof (msg), "rebalance %s", status); + snprintf (msg, sizeof (msg), "Rebalance %s", status); goto done; } @@ -1129,7 +1105,7 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); else snprintf (msg, sizeof (msg), - "starting rebalance on volume %s has been %s", + "Starting rebalance on volume %s has been %s", volname, (rsp.op_ret) ? "unsuccessful": "successful"); @@ -1398,24 +1374,18 @@ gf_cli3_remove_brick_status_cbk (struct rpc_req *req, struct iovec *iov, case GF_DEFRAG_STATUS_NOT_STARTED: status = "not started"; break; - case GF_DEFRAG_STATUS_LAYOUT_FIX_STARTED: - case GF_DEFRAG_STATUS_MIGRATE_DATA_STARTED: - case GF_DEFRAG_STATUS_LAYOUT_FIX_COMPLETE: + case GF_DEFRAG_STATUS_STARTED: status = "in progress"; break; case GF_DEFRAG_STATUS_STOPPED: status = "stopped"; break; case GF_DEFRAG_STATUS_COMPLETE: - case GF_DEFRAG_STATUS_MIGRATE_DATA_COMPLETE: status = "completed"; break; case GF_DEFRAG_STATUS_FAILED: status = "failed"; break; - case GF_DEFRAG_STATUS_PAUSED: - status = "paused"; - break; } if (rsp.dict.dict_len) { @@ -2479,20 +2449,19 @@ gf_cli3_1_defrag_volume (call_frame_t *frame, xlator_t *this, if (strcmp (cmd_str, "start") == 0) { cmd = GF_DEFRAG_CMD_START; - ret = dict_get_str (dict, "start-type", &cmd_str); + ret = dict_get_str (dict, "option", &cmd_str); if (!ret) { - if (strcmp (cmd_str, "fix-layout") == 0) { - cmd = GF_DEFRAG_CMD_START_LAYOUT_FIX; - } - if (strcmp (cmd_str, "migrate-data") == 0) { - cmd = GF_DEFRAG_CMD_START_MIGRATE_DATA; - } - if (strcmp (cmd_str, "migrate-data-force") == 0) { - cmd = GF_DEFRAG_CMD_START_MIGRATE_DATA_FORCE; + if (strcmp (cmd_str, "force") == 0) { + cmd = GF_DEFRAG_CMD_START_FORCE; } } goto done; } + + if (strcmp (cmd_str, "fix-layout") == 0) { + cmd = GF_DEFRAG_CMD_START_LAYOUT_FIX; + goto done; + } if (strcmp (cmd_str, "stop") == 0) { cmd = GF_DEFRAG_CMD_STOP; goto done; -- cgit