summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-sm.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-10-03 04:14:19 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-03 02:57:52 -0700
commit53b8c7470f9e40c60c5eebd1fbad5c6d274f7ee5 (patch)
treefb58f75117c2ac2bf08b77b7b6a6c29e0cb5f100 /xlators/mgmt/glusterd/src/glusterd-sm.c
parentc0c419a3572307e71026144b8907a33b464f6066 (diff)
mgmt/glusterd: changes for detach everywhere
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1765 (peer probe on removed-detached bricks) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1765
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-sm.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.c63
1 files changed, 58 insertions, 5 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index fbe8430348a..268ccaff42e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -89,8 +89,58 @@ glusterd_destroy_friend_req_ctx (glusterd_friend_req_ctx_t *ctx)
GF_FREE (ctx);
}
-#define glusterd_destroy_friend_update_ctx(ctx)\
- glusterd_destroy_friend_req_ctx(ctx)
+void
+glusterd_destroy_friend_update_ctx (glusterd_friend_update_ctx_t *ctx)
+{
+ if (!ctx)
+ return;
+ if (ctx->hostname)
+ GF_FREE (ctx->hostname);
+ GF_FREE (ctx);
+}
+
+int
+glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid)
+{
+ int ret = 0;
+ rpc_clnt_procedure_t *proc = NULL;
+ call_frame_t *frame = NULL;
+ glusterd_conf_t *conf = NULL;
+ xlator_t *this = NULL;
+ glusterd_friend_update_ctx_t *ctx = NULL;
+
+ this = THIS;
+ conf = this->private;
+
+ GF_ASSERT (conf);
+ GF_ASSERT (conf->mgmt);
+
+ ctx = GF_CALLOC (1, sizeof (*ctx),
+ gf_gld_mt_friend_update_ctx_t);
+
+ if (!ctx) {
+ ret = -1;
+ goto out;
+ }
+
+ ctx->hostname = gf_strdup (hostname);
+ ctx->op = GD_FRIEND_UPDATE_DEL;
+ proc = &conf->mgmt->proctable[GD_MGMT_FRIEND_UPDATE];
+ if (proc->fn) {
+ frame = create_frame (this, this->ctx->pool);
+ if (!frame) {
+ goto out;
+ }
+ frame->local = ctx;
+ ret = proc->fn (frame, this, ctx);
+ }
+
+out:
+ gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+
+ return ret;
+}
+
static int
glusterd_ac_none (glusterd_friend_sm_event_t *event, void *ctx)
@@ -305,7 +355,7 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
call_frame_t *frame = NULL;
glusterd_conf_t *conf = NULL;
xlator_t *this = NULL;
-
+ glusterd_friend_update_ctx_t *ev_ctx = NULL;
GF_ASSERT (event);
peerinfo = event->peerinfo;
@@ -315,6 +365,9 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
GF_ASSERT (conf);
GF_ASSERT (conf->mgmt);
+ ev_ctx = ctx;
+
+ ev_ctx->op = GD_FRIEND_UPDATE_ADD;
proc = &conf->mgmt->proctable[GD_MGMT_FRIEND_UPDATE];
if (proc->fn) {
@@ -323,7 +376,7 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
goto out;
}
frame->local = ctx;
- ret = proc->fn (frame, this, event);
+ ret = proc->fn (frame, this, ctx);
}
out:
@@ -377,7 +430,6 @@ glusterd_ac_friend_remove (glusterd_friend_sm_event_t *event, void *ctx)
gf_log ("", GF_LOG_ERROR, "Cleanup returned: %d", ret);
}
-
return 0;
}
@@ -444,6 +496,7 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx)
uuid_copy (new_ev_ctx->uuid, ev_ctx->uuid);
new_ev_ctx->hostname = gf_strdup (ev_ctx->hostname);
+ new_ev_ctx->op = GD_FRIEND_UPDATE_ADD;
new_event->ctx = new_ev_ctx;