summaryrefslogtreecommitdiffstats
path: root/api/src/glfs.c
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2015-02-16 11:47:58 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2015-03-17 14:01:21 -0700
commit2a4561ef08b8be3b7d79b951252e87ba8f987120 (patch)
treeed5cc0c87f6532b167ebb2b775389a9a391a3cf4 /api/src/glfs.c
parentd81182cf69a4f188f304fcce6d651ffd56b67aac (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.c')
-rw-r--r--api/src/glfs.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c
index f23481bbb4c..02a8984f450 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -600,6 +600,11 @@ pub_glfs_new (const char *volname)
INIT_LIST_HEAD (&fs->openfds);
+ INIT_LIST_HEAD (&fs->upcall_list);
+ pthread_mutex_init (&fs->upcall_list_mutex, NULL);
+
+ fs->pin_refcnt = 0;
+
return fs;
}
@@ -626,6 +631,11 @@ priv_glfs_new_from_ctx (glusterfs_ctx_t *ctx)
INIT_LIST_HEAD (&fs->openfds);
+ INIT_LIST_HEAD (&fs->upcall_list);
+ pthread_mutex_init (&fs->upcall_list_mutex, NULL);
+
+ fs->pin_refcnt = 0;
+
return fs;
}
@@ -635,9 +645,20 @@ GFAPI_SYMVER_PRIVATE_DEFAULT(glfs_new_from_ctx, 3.7.0);
void
priv_glfs_free_from_ctx (struct glfs *fs)
{
+ upcall_entry *u_list = NULL;
+ upcall_entry *tmp = NULL;
+
if (!fs)
return;
+ /* cleanup upcall structures */
+ list_for_each_entry_safe (u_list, tmp,
+ &fs->upcall_list,
+ upcall_list) {
+ list_del_init (&u_list->upcall_list);
+ }
+ (void) pthread_mutex_destroy (&fs->upcall_list_mutex);
+
(void) pthread_cond_destroy (&fs->cond);
(void) pthread_cond_destroy (&fs->child_down_cond);
@@ -906,6 +927,7 @@ pub_glfs_fini (struct glfs *fs)
int fs_init = 0;
int err = -1;
+
if (!fs) {
errno = EINVAL;
return 0;
@@ -923,10 +945,24 @@ pub_glfs_fini (struct glfs *fs)
while (countdown--) {
/* give some time for background frames to finish */
- if (!call_pool->cnt)
- break;
+ pthread_mutex_lock (&fs->mutex);
+ {
+ /* Do we need to increase countdown? */
+ if ((!call_pool->cnt) && (!fs->pin_refcnt)) {
+ gf_log ("glfs", GF_LOG_ERROR,
+ "call_pool_cnt - %ld,"
+ "pin_refcnt - %d",
+ call_pool->cnt, fs->pin_refcnt);
+
+ ctx->cleanup_started = 1;
+ pthread_mutex_unlock (&fs->mutex);
+ break;
+ }
+ }
+ pthread_mutex_unlock (&fs->mutex);
usleep (100000);
}
+
/* leaked frames may exist, we ignore */
/*We deem glfs_fini as successful if there are no pending frames in the call