diff options
author | Soumya Koduri <skoduri@redhat.com> | 2015-02-15 23:35:56 +0530 |
---|---|---|
committer | Kaleb KEITHLEY <kkeithle@redhat.com> | 2015-03-17 05:08:07 -0700 |
commit | 2b97b57cd8c71cb07b7002cf3483e9cfc9403c58 (patch) | |
tree | 9fc96451b469e213348f3065ca07e7a7c5a96ec0 /xlators/protocol | |
parent | 79009691c01f2b32b523d91a159aadd0e414f31b (diff) |
Upcall: New xlator to store various states and send cbk events
Framework on the server-side, to handle certain state of the files
accessed and send notifications to the clients connected.
A generic and extensible framework, used to maintain states in
the glusterfsd process for each of the files accessed
(including the clients info doing the fops) and send
notifications to the respective glusterfs clients incase of
any change in that state.
This patch handles "Inode Update/Invalidation" upcall event.
Feature page:
URL: http://www.gluster.org/community/documentation/index.php/Features/Upcall-infrastructure
Below link has a writeup which explains the code changes done -
URL: https://soumyakoduri.wordpress.com/2015/02/25/glusterfs-understanding-upcall-infrastructure-and-cache-invalidation-support/
Change-Id: Ie3d724be9a3419fcf18901a753e8ec2df2ac802f
BUG: 1200262
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
Reviewed-on: http://review.gluster.org/9535
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/server/src/server.c | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index d7eab16bf13..023f2a6234f 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -27,6 +27,12 @@ #include "authenticate.h" #include "event.h" +rpcsvc_cbk_program_t server_cbk_prog = { + .progname = "Gluster Callback", + .prognum = GLUSTER_CBK_PROGRAM, + .progver = GLUSTER_CBK_VERSION, +}; + void grace_time_handler (void *data) { @@ -1093,22 +1099,72 @@ fini (xlator_t *this) int notify (xlator_t *this, int32_t event, void *data, ...) { - int ret = 0; - int32_t val = 0; - dict_t *dict = NULL; - dict_t *output = NULL; - va_list ap; + int ret = 0; + int32_t val = 0; + dict_t *dict = NULL; + dict_t *output = NULL; + va_list ap; + client_t *client = NULL; + char *client_uid = NULL; + struct gf_upcall *upcall_data = NULL; + gfs3_upcall_req up_req; + server_conf_t *conf = NULL; + rpc_transport_t *xprt = NULL; dict = data; va_start (ap, data); output = va_arg (ap, dict_t*); va_end (ap); + conf = this->private; + if (!conf) + return 0; + switch (event) { + case GF_EVENT_UPCALL: + { + if (!data) { + ret = -1; + goto out; + } + + upcall_data = (struct gf_upcall *)data; + + client_uid = upcall_data->client_uid; + + if (!client_uid) { + ret = -1; + goto out; + } + + gf_proto_upcall_from_upcall (&up_req, upcall_data); + + pthread_mutex_lock (&conf->mutex); + { + list_for_each_entry (xprt, &conf->xprt_list, list) { + client = xprt->xl_private; + + if (strcmp(client->client_uid, client_uid)) + continue; + + rpcsvc_request_submit( + conf->rpc, xprt, + &server_cbk_prog, + GF_CBK_UPCALL, + &up_req, + this->ctx, + (xdrproc_t)xdr_gfs3_upcall_req); + break; + } + } + pthread_mutex_unlock (&conf->mutex); + break; + } default: default_notify (this, event, data); break; } +out: return ret; } |