summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2012-04-24 10:39:31 +0530
committerVijay Bellur <vijay@gluster.com>2012-04-25 04:06:11 -0700
commit8be3e656aa58e790c301c9078afdbd4bd4909d92 (patch)
tree3ece1b9a977df9040b68a0cd69f6748155b54aa1 /xlators
parentbd892b972eb5df5d3f48637cc473f9622684087d (diff)
glusterd/rebalance: Remove state dependency on rpc event
Status is updated by event_notify handshake by the rebalance process. If there is disconnect, before rebalance process, only then the state is moved to failure. Change-Id: I334055397c3d38688dbef653826bc07ac47a1911 BUG: 813167 Signed-off-by: shishir gowda <shishirng@gluster.com> Reviewed-on: http://review.gluster.com/3165 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c29
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c48
2 files changed, 36 insertions, 41 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index b3787f5cbe7..bcc9fd6aec3 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -1480,6 +1480,12 @@ gf_defrag_start_crawl (void *data)
}
ret = gf_defrag_fix_layout (this, defrag, &loc, fix_layout,
migrate_data);
+ if ((defrag->defrag_status != GF_DEFRAG_STATUS_STOPPED) &&
+ (defrag->defrag_status != GF_DEFRAG_STATUS_FAILED)) {
+ defrag->defrag_status = GF_DEFRAG_STATUS_COMPLETE;
+ }
+
+
out:
LOCK (&defrag->lock);
@@ -1557,6 +1563,7 @@ gf_defrag_status_get (gf_defrag_info_t *defrag, dict_t *dict)
uint64_t size = 0;
uint64_t lookup = 0;
uint64_t failures = 0;
+ char *status = "";
if (!defrag)
goto out;
@@ -1595,6 +1602,25 @@ gf_defrag_status_get (gf_defrag_info_t *defrag, dict_t *dict)
ret = dict_set_uint64 (dict, "failures", failures);
log:
+ switch (defrag->defrag_status) {
+ case GF_DEFRAG_STATUS_NOT_STARTED:
+ status = "not started";
+ break;
+ case GF_DEFRAG_STATUS_STARTED:
+ status = "in progress";
+ break;
+ case GF_DEFRAG_STATUS_STOPPED:
+ status = "stopped";
+ break;
+ case GF_DEFRAG_STATUS_COMPLETE:
+ status = "completed";
+ break;
+ case GF_DEFRAG_STATUS_FAILED:
+ status = "failed";
+ break;
+ }
+
+ gf_log (THIS->name, GF_LOG_INFO, "Rebalance is %s", status);
gf_log (THIS->name, GF_LOG_INFO, "Files migrated: %"PRIu64", size: %"
PRIu64", lookups: %"PRIu64", failures: %"PRIu64, files, size,
lookup, failures);
@@ -1616,12 +1642,13 @@ gf_defrag_stop (gf_defrag_info_t *defrag, dict_t *output)
goto out;
}
+ gf_log ("", GF_LOG_INFO, "Recieved stop command on rebalance");
defrag->defrag_status = GF_DEFRAG_STATUS_STOPPED;
if (output)
gf_defrag_status_get (defrag, output);
ret = 0;
out:
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index 9ed6af66741..7e35f06dd12 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -51,38 +51,6 @@ int32_t
glusterd3_1_brick_op_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe);
-int
-glusterd_defrag_update_state (glusterd_volinfo_t *volinfo,
- glusterd_defrag_info_t *defrag)
-{
- int ret = -1;
- int cmd = 0;
-
- GF_ASSERT (volinfo);
- GF_ASSERT (defrag);
-
- if (volinfo->defrag_status == GF_DEFRAG_STATUS_NOT_STARTED) {
- goto out;
- }
-
- LOCK (&defrag->lock);
- {
- cmd = defrag->cmd;
- if ((cmd == GF_DEFRAG_CMD_START) || (cmd ==
- GF_DEFRAG_CMD_START_FORCE) || (cmd ==
- GF_DEFRAG_CMD_START_LAYOUT_FIX))
- volinfo->defrag_status = GF_DEFRAG_STATUS_COMPLETE;
- else if (cmd == GF_DEFRAG_CMD_STOP)
- volinfo->defrag_status = GF_DEFRAG_STATUS_STOPPED;
- }
- UNLOCK (&defrag->lock);
-
- ret = 0;
-out:
- gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
- return ret;
-}
-
void
glusterd_rebalance_cmd_attempted_log (int cmd, char *volname)
{
@@ -213,14 +181,14 @@ glusterd_defrag_notify (struct rpc_clnt *rpc, void *mydata,
UNLOCK (&defrag->lock);
if (!glusterd_is_service_running (pidfile, NULL)) {
- glusterd_defrag_update_state (volinfo, defrag);
- } else {
- volinfo->defrag_status = GF_DEFRAG_STATUS_FAILED;
- }
-
- /* Success or failure, Reset cmd in volinfo */
-
- volinfo->defrag_cmd = 0;
+ if (volinfo->defrag_status ==
+ GF_DEFRAG_STATUS_STARTED) {
+ volinfo->defrag_status =
+ GF_DEFRAG_STATUS_FAILED;
+ } else {
+ volinfo->defrag_cmd = 0;
+ }
+ }
glusterd_store_volinfo (volinfo,
GLUSTERD_VOLINFO_VER_AC_INCREMENT);