From ed561b78d9837b9f799ebb410bcc26b7e5413f33 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 7 Sep 2010 09:30:29 +0000 Subject: glusterd: rebalance fixes Signed-off-by: Amar Tumballi Signed-off-by: Vijay Bellur BUG: 1481 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1481 --- cli/src/cli3_1-cops.c | 11 +++++++--- xlators/mgmt/glusterd/src/glusterd-handler.c | 30 +++++++++++++++++----------- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 5 +++-- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c index 064845087b8..a88d0c6957f 100644 --- a/cli/src/cli3_1-cops.c +++ b/cli/src/cli3_1-cops.c @@ -611,9 +611,14 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, if (rsp.op_errno == 4) status = "failed"; - cli_out ("rebalance %s: rebalanced %"PRId64" files of size %"PRId64 - " (total files scanned %"PRId64")", status, - rsp.files, rsp.size, rsp.lookedup_files); + 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); + } } } diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index a2563865acd..6dee0355d3d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -765,16 +765,17 @@ glusterd_defrag_start (void *data) char cmd_str[1024] = {0,}; int ret = -1; struct stat stbuf = {0,}; + char value[128] = {0,}; defrag = volinfo->defrag; if (!defrag) goto out; - sleep (5); + sleep (1); ret = stat (defrag->mount, &stbuf); if ((ret == -1) && (errno == ENOTCONN)) { /* Wait for some more time before starting rebalance */ - sleep (7); + sleep (2); ret = stat (defrag->mount, &stbuf); if (ret == -1) { volinfo->defrag_status = GF_DEFRAG_STATUS_FAILED; @@ -785,6 +786,9 @@ glusterd_defrag_start (void *data) } } + /* Fix the root ('/') first */ + getxattr (defrag->mount, "trusted.distribute.fix.layout", &value, 128); + ret = glusterd_check_and_rebalance (volinfo, defrag->mount); /* TODO: This should run in a thread, and finish the thread when @@ -869,7 +873,6 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req) glusterd_volinfo_t *volinfo = NULL; glusterd_defrag_info_t *defrag = NULL; gf1_cli_defrag_vol_rsp rsp = {0,}; - char operation[8]; GF_ASSERT (req); @@ -881,17 +884,17 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req) } switch (cli_req.cmd) { - case GF_DEFRAG_CMD_START: strcpy (operation, "start"); - break; - case GF_DEFRAG_CMD_STOP: strcpy (operation, "stop"); + case GF_DEFRAG_CMD_START: + gf_cmd_log ("Volume rebalance"," on volname: %s " + "cmd: start, attempted", cli_req.volname); break; - case GF_DEFRAG_CMD_STATUS: strcpy (operation, "status"); + case GF_DEFRAG_CMD_STOP: + gf_cmd_log ("Volume rebalance"," on volname: %s " + "cmd: stop, attempted", cli_req.volname); break; - default: strcpy (operation, "unknown"); + default: break; } - gf_cmd_log ("Volume rebalance"," on volname: %s cmd:%s attempted", cli_req.volname, - operation); gf_log ("glusterd", GF_LOG_NORMAL, "Received defrag volume on %s", cli_req.volname); @@ -975,8 +978,11 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req) if (ret) gf_log("glusterd", GF_LOG_DEBUG, "command: %s failed",cmd_str); - gf_cmd_log ("volume rebalance"," on volname: %s %d %s",cli_req.volname, - cli_req.cmd, ((ret)?"FAILED":"SUCCESS")); + if (cli_req.cmd != GF_DEFRAG_CMD_STATUS) { + gf_cmd_log ("volume rebalance"," on volname: %s %d %s", + cli_req.volname, + cli_req.cmd, ((ret)?"FAILED":"SUCCESS")); + } out: diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 512ebdc8558..9e37383f5ff 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1136,6 +1136,7 @@ glusterd_op_create_volume (gd1_mgmt_stage_op_req *req) } list_add_tail (&volinfo->vol_list, &priv->volumes); volinfo->version++; + volinfo->defrag_status = 0; ret = glusterd_store_create_volume (volinfo); @@ -1290,7 +1291,7 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req) } volinfo->version++; - + volinfo->defrag_status = 0; ret = glusterd_store_update_volume (volinfo); @@ -2283,7 +2284,7 @@ glusterd_op_remove_brick (gd1_mgmt_stage_op_req *req) goto out; volinfo->version++; - + volinfo->defrag_status = 0; ret = glusterd_store_update_volume (volinfo); -- cgit