summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli3_1-cops.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c10
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c39
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h3
5 files changed, 56 insertions, 10 deletions
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index 2c64f115e23..ecf454cbfd0 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -662,20 +662,20 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
cmd = local->u.defrag_vol.cmd;
}
if (cmd == GF_DEFRAG_CMD_START) {
- cli_out ("starting defrag on volume %s has been %s", volname,
+ 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)
- cli_out ("'defrag volume %s stop' failed", volname);
+ cli_out ("rebalance volume %s stop failed", volname);
else
- cli_out ("stopped defrag process of volume %s \n"
+ cli_out ("stopped rebalance process of volume %s \n"
"(after rebalancing %"PRId64" files totaling "
"%"PRId64" bytes)", volname, rsp.files, rsp.size);
}
if (cmd == GF_DEFRAG_CMD_STATUS) {
if (rsp.op_ret == -1)
- cli_out ("failed to get the status of defrag process");
+ cli_out ("failed to get the status of rebalance process");
else {
char *status = "unknown";
if (rsp.op_errno == 0)
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index f66a5b3d28c..439facef0b9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -837,7 +837,7 @@ glusterd_defrag_start (void *data)
volinfo->lookedup_files = defrag->num_files_lookedup;
out:
if (defrag) {
- gf_log ("defrag", GF_LOG_NORMAL, "defrag on %s complete",
+ gf_log ("rebalance", GF_LOG_NORMAL, "rebalance on %s complete",
defrag->mount);
snprintf (cmd_str, 1024, "umount -l %s", defrag->mount);
@@ -931,19 +931,19 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req)
default:
break;
}
- gf_log ("glusterd", GF_LOG_NORMAL, "Received defrag volume on %s",
+ gf_log ("glusterd", GF_LOG_NORMAL, "Received rebalance volume on %s",
cli_req.volname);
rsp.volname = cli_req.volname;
rsp.op_ret = -1;
if (glusterd_volinfo_find(cli_req.volname, &volinfo)) {
- gf_log ("glusterd", GF_LOG_NORMAL, "Received defrag on invalid"
+ gf_log ("glusterd", GF_LOG_NORMAL, "Received rebalance on invalid"
" volname %s", cli_req.volname);
goto out;
}
if (volinfo->status != GLUSTERD_STATUS_STARTED) {
- gf_log ("glusterd", GF_LOG_NORMAL, "Received defrag on stopped"
+ gf_log ("glusterd", GF_LOG_NORMAL, "Received rebalance on stopped"
" volname %s", cli_req.volname);
goto out;
}
@@ -953,7 +953,7 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req)
{
if (volinfo->defrag) {
gf_log ("glusterd", GF_LOG_DEBUG,
- "defrag on volume %s already started",
+ "rebalance on volume %s already started",
cli_req.volname);
goto out;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index e5cf57514db..e3a9777c6c3 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -681,6 +681,14 @@ glusterd_op_stage_add_brick (gd1_mgmt_stage_op_req *req, char **op_errstr)
goto out;
}
+ if (glusterd_is_defrag_on(volinfo)) {
+ snprintf (msg, sizeof(msg), "Volume name %s rebalance is in "
+ "progress. Please retry after completion", volname);
+ gf_log ("glusterd", GF_LOG_ERROR, "%s", msg);
+ *op_errstr = gf_strdup (msg);
+ ret = -1;
+ goto out;
+ }
ret = dict_get_int32 (dict, "count", &count);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to get count");
@@ -844,6 +852,15 @@ glusterd_op_stage_replace_brick (gd1_mgmt_stage_op_req *req, char **op_errstr)
goto out;
}
+ if (glusterd_is_defrag_on(volinfo)) {
+ snprintf (msg, sizeof(msg), "Volume name %s rebalance is in "
+ "progress. Please retry after completion", volname);
+ gf_log ("glusterd", GF_LOG_ERROR, "%s", msg);
+ *op_errstr = gf_strdup (msg);
+ ret = -1;
+ goto out;
+ }
+
ret = glusterd_brickinfo_get (src_brick, volinfo,
&src_brickinfo);
if (ret) {
@@ -1310,6 +1327,27 @@ glusterd_op_stage_remove_brick (gd1_mgmt_stage_op_req *req)
goto out;
}
+ if (glusterd_is_defrag_on(volinfo)) {
+ ctx = glusterd_op_get_ctx (GD_OP_REMOVE_BRICK);
+ errstr = gf_strdup("Rebalance is in progress. Please retry"
+ " after completion");
+ if (!errstr) {
+ ret = -1;
+ goto out;
+ }
+ gf_log ("glusterd", GF_LOG_ERROR, "%s", errstr);
+ ret = dict_set_dynstr (ctx, "errstr", errstr);
+ if (ret) {
+ GF_FREE (errstr);
+ gf_log ("", GF_LOG_DEBUG,
+ "failed to set errstr ctx");
+ goto out;
+ }
+
+ ret = -1;
+ goto out;
+ }
+
if (volinfo->brick_count == 1) {
ctx = glusterd_op_get_ctx (GD_OP_REMOVE_BRICK);
if (!ctx) {
@@ -2851,7 +2889,6 @@ glusterd_op_remove_brick (gd1_mgmt_stage_op_req *req)
goto out;
}
-
ret = dict_get_int32 (dict, "count", &count);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to get count");
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 7072ce1b982..5b5d98750d0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -2118,3 +2118,9 @@ out:
gf_log ("", GF_LOG_DEBUG, "returning %d ", ret);
return ret;
}
+
+int
+glusterd_is_defrag_on (glusterd_volinfo_t *volinfo)
+{
+ return (volinfo->defrag_status == GF_DEFRAG_STATUS_STARTED);
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 4660a26874a..e2736bf1631 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -193,4 +193,7 @@ glusterd_brick_start (glusterd_volinfo_t *volinfo,
int
glusterd_brick_stop (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo);
+
+int
+glusterd_is_defrag_on (glusterd_volinfo_t *volinfo);
#endif