summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2016-01-29 16:24:02 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-02-24 19:49:27 -0800
commitd9cc672719b96168c46bc82334f44efc010adad5 (patch)
tree76fec07bf2f2c282826c501caad0c3f29aecd6d8 /xlators/mgmt/glusterd
parent4777f12ba5a930016faa6ef9114d8ffc8304c77b (diff)
glusterd/rebalance: initialize defrag variable after glusterd restart
During reblance restart after glusterd restarted, we are not connecting to rebalance process from glusterd, because the defrag variable in volinfo will be null. Initializing the variable will connect the rpc Back port of> >Change-Id: Id820cad6a3634a9fc976427fbe1c45844d3d4b9b >BUG: 1303028 >Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> >Reviewed-on: http://review.gluster.org/13319 >Smoke: Gluster Build System <jenkins@build.gluster.com> >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> >Reviewed-by: Dan Lambright <dlambrig@redhat.com> >CentOS-regression: Gluster Build System <jenkins@build.gluster.com> (cherry picked from commit a67331f3f79e827ffa4f7a547f6898e12407bbf9) Change-Id: Ieec82a798da937002e09fb9325c93678a5eefca8 BUG: 1311041 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: http://review.gluster.org/13494 Smoke: Gluster Build System <jenkins@build.gluster.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c34
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h3
3 files changed, 47 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index 2ceab6d6d24..356cc909e17 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -331,6 +331,40 @@ out:
return ret;
}
+int
+glusterd_rebalance_defrag_init (glusterd_volinfo_t *volinfo,
+ defrag_cbk_fn_t cbk)
+
+{
+ glusterd_defrag_info_t *defrag = NULL;
+ int ret = -1;
+
+ if (!volinfo->rebal.defrag) {
+ volinfo->rebal.defrag =
+ GF_CALLOC (1, sizeof (*volinfo->rebal.defrag),
+ gf_gld_mt_defrag_info);
+ } else {
+ /*
+ * if defrag variable is already initialized,
+ * we skip the initialization.
+ */
+ ret = 0;
+ goto out;
+ }
+
+ if (!volinfo->rebal.defrag)
+ goto out;
+ defrag = volinfo->rebal.defrag;
+
+ defrag->cmd = volinfo->rebal.defrag_cmd;
+ LOCK_INIT (&defrag->lock);
+ if (cbk)
+ defrag->cbk_fn = cbk;
+ ret = 0;
+out:
+ return ret;
+
+}
int
glusterd_rebalance_rpc_create (glusterd_volinfo_t *volinfo,
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 11fe0481b77..a4d6ec592d9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -7133,6 +7133,15 @@ glusterd_volume_defrag_restart (glusterd_volinfo_t *volinfo, char *op_errstr,
case GF_DEFRAG_STATUS_STARTED:
GLUSTERD_GET_DEFRAG_PID_FILE(pidfile, volinfo, priv);
if (gf_is_service_running (pidfile, &pid)) {
+ ret = glusterd_rebalance_defrag_init (volinfo, cbk);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_REBALANCE_START_FAIL,
+ "Failed to initialize defrag."
+ "Not starting rebalance process for "
+ "%s.", volinfo->volname);
+ goto out;
+ }
ret = glusterd_rebalance_rpc_create (volinfo, _gf_true);
break;
}
@@ -7148,7 +7157,7 @@ glusterd_volume_defrag_restart (glusterd_volinfo_t *volinfo, char *op_errstr,
volinfo->rebal.defrag_status, volinfo->volname);
break;
}
-
+out:
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 3b7c82faab2..c872cd2339c 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -1004,6 +1004,9 @@ int
glusterd_rebalance_rpc_create (glusterd_volinfo_t *volinfo,
gf_boolean_t reconnect);
+int glusterd_rebalance_defrag_init (glusterd_volinfo_t *volinfo,
+ defrag_cbk_fn_t cbk);
+
int glusterd_handle_cli_heal_volume (rpcsvc_request_t *req);
int glusterd_handle_cli_list_volume (rpcsvc_request_t *req);