summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 593e32e95d0..b19813cbefb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -3523,8 +3523,9 @@ gd_check_and_update_rebalance_info (glusterd_volinfo_t *old_volinfo,
new = &(new_volinfo->rebal);
//Disconnect from rebalance process
- if (old->defrag && old->defrag->rpc) {
+ if (glusterd_defrag_rpc_get (old->defrag)) {
rpc_transport_disconnect (old->defrag->rpc->conn.trans);
+ glusterd_defrag_rpc_put (old->defrag);
}
if (!gf_uuid_is_null (old->rebalance_id) &&
@@ -3806,6 +3807,39 @@ out:
}
struct rpc_clnt*
+glusterd_defrag_rpc_get (glusterd_defrag_info_t *defrag)
+{
+ struct rpc_clnt *rpc = NULL;
+
+ if (!defrag)
+ return NULL;
+
+ LOCK (&defrag->lock);
+ {
+ rpc = rpc_clnt_ref (defrag->rpc);
+ }
+ UNLOCK (&defrag->lock);
+ return rpc;
+}
+
+struct rpc_clnt*
+glusterd_defrag_rpc_put (glusterd_defrag_info_t *defrag)
+{
+ struct rpc_clnt *rpc = NULL;
+
+ if (!defrag)
+ return NULL;
+
+ LOCK (&defrag->lock);
+ {
+ rpc = rpc_clnt_unref (defrag->rpc);
+ defrag->rpc = rpc;
+ }
+ UNLOCK (&defrag->lock);
+ return rpc;
+}
+
+struct rpc_clnt*
glusterd_pending_node_get_rpc (glusterd_pending_node_t *pending_node)
{
struct rpc_clnt *rpc = NULL;
@@ -3827,8 +3861,8 @@ glusterd_pending_node_get_rpc (glusterd_pending_node_t *pending_node)
rpc = svc->conn.rpc;
} else if (pending_node->type == GD_NODE_REBALANCE) {
volinfo = pending_node->node;
- if (volinfo->rebal.defrag)
- rpc = volinfo->rebal.defrag->rpc;
+ rpc = glusterd_defrag_rpc_get (volinfo->rebal.defrag);
+
} else if (pending_node->type == GD_NODE_SNAPD) {
volinfo = pending_node->node;
rpc = volinfo->snapd.svc.conn.rpc;
@@ -3840,6 +3874,23 @@ out:
return rpc;
}
+void
+glusterd_pending_node_put_rpc (glusterd_pending_node_t *pending_node)
+{
+ glusterd_volinfo_t *volinfo = NULL;
+
+ switch (pending_node->type) {
+ case GD_NODE_REBALANCE:
+ volinfo = pending_node->node;
+ glusterd_defrag_rpc_put (volinfo->rebal.defrag);
+ break;
+
+ default:
+ break;
+ }
+
+}
+
int32_t
glusterd_unlink_file (char *sockfpath)
{