diff options
author | Soumya Koduri <skoduri@redhat.com> | 2015-02-16 11:47:58 +0530 |
---|---|---|
committer | Kaleb KEITHLEY <kkeithle@redhat.com> | 2015-03-17 14:01:21 -0700 |
commit | 2a4561ef08b8be3b7d79b951252e87ba8f987120 (patch) | |
tree | ed5cc0c87f6532b167ebb2b775389a9a391a3cf4 /api/src/glfs-fops.c | |
parent | d81182cf69a4f188f304fcce6d651ffd56b67aac (diff) |
gfapi: APIs to store and process upcall notifications received
In case of any upcall cbk events received by the protocol/client,
gfapi will be notified which queues them up in a list (<gfapi_cbk_upcall>).
Applicatons are responsible to provide APIs to process & notify them in case
of any such upcall events queued.
Added a new API which will be used by Ganesha to repeatedly poll for any
such upcall event notified (<glfs_h_poll_upcall>).
A new test-file has been added to test the cache_invalidation upcall events.
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: Iafc6880000c865fd4da22d0cfc388ec135b5a1c5
BUG: 1200262
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
Reviewed-on: http://review.gluster.org/9536
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'api/src/glfs-fops.c')
-rw-r--r-- | api/src/glfs-fops.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index 182317fa41a..f0c769def29 100644 --- a/api/src/glfs-fops.c +++ b/api/src/glfs-fops.c @@ -16,6 +16,7 @@ #include "glfs.h" #include "compat-errno.h" #include <limits.h> +#include "glusterfs3.h" #ifdef NAME_MAX #define GF_NAME_MAX NAME_MAX @@ -3495,3 +3496,87 @@ out: GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_dup, 3.4.0); +/* + * This routine is called in case of any notification received + * from the server. All the upcall events are queued up in a list + * to be read by the applications. + * + * XXX: Applications may register a cbk function for each 'fs' + * which then needs to be called by this routine incase of any + * event received. The cbk fn is responsible for notifying the + * applications the way it desires for each event queued (for eg., + * can raise a signal or broadcast a cond variable etc.) + */ +void +priv_glfs_process_upcall_event (struct glfs *fs, void *data) +{ + int ret = -1; + inode_t *inode = NULL; + uuid_t gfid; + upcall_entry *u_list = NULL; + glusterfs_ctx_t *ctx = NULL; + struct gf_upcall *upcall_data = NULL; + struct glfs_object *object = NULL; + + gf_log (THIS->name, GF_LOG_DEBUG, + "Upcall gfapi callback is called"); + + if (!fs || !data) + goto out; + + /* Unlike in I/O path, "glfs_fini" would not have freed + * 'fs' by the time we take lock as it waits for all epoll + * threads to exit including this + */ + pthread_mutex_lock (&fs->mutex); + { + ctx = fs->ctx; + + if (ctx->cleanup_started) { + pthread_mutex_unlock (&fs->mutex); + goto out; + } + + fs->pin_refcnt++; + } + pthread_mutex_unlock (&fs->mutex); + + upcall_data = (struct gf_upcall *)data; + + gf_log (THIS->name, GF_LOG_DEBUG, "Upcall gfapi gfid = %s" + "ret = %d", (char *)(upcall_data->gfid), ret); + + memcpy(gfid, (char *)(upcall_data->gfid), 16); + u_list = GF_CALLOC (1, sizeof(*u_list), + glfs_mt_upcall_entry_t); + + if (!u_list) { + gf_log (THIS->name, GF_LOG_ERROR, "Upcall entry allocation" + "failed."); + goto out; + } + + INIT_LIST_HEAD (&u_list->upcall_list); + + uuid_copy (u_list->gfid, gfid); + u_list->event_type = upcall_data->event_type; + u_list->flags = (uint32_t)(upcall_data->flags); + u_list->expire_time_attr = upcall_data->expire_time_attr; + + pthread_mutex_lock (&fs->upcall_list_mutex); + { + list_add_tail (&u_list->upcall_list, + &fs->upcall_list); + } + pthread_mutex_unlock (&fs->upcall_list_mutex); + + pthread_mutex_lock (&fs->mutex); + { + fs->pin_refcnt--; + } + pthread_mutex_unlock (&fs->mutex); +out: + return; +} + +GFAPI_SYMVER_PRIVATE_DEFAULT(glfs_process_upcall_event, 3.7.0); |