summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/src/glfs-fops.c3
-rw-r--r--api/src/glfs-handleops.c4
-rw-r--r--api/src/glfs-internal.h1
-rw-r--r--tests/basic/gfapi/upcall-cache-invalidate.c7
4 files changed, 14 insertions, 1 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index ff1702c6b4b..338bd2f4bc4 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -4265,7 +4265,8 @@ priv_glfs_process_upcall_event (struct glfs *fs, void *data)
{
ctx = fs->ctx;
- if (ctx->cleanup_started) {
+ /* if we're not interested in upcalls (anymore), skip them */
+ if (ctx->cleanup_started || !fs->cache_upcalls) {
pthread_mutex_unlock (&fs->mutex);
goto out;
}
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c
index d09e81ddb1a..f9b4ee90267 100644
--- a/api/src/glfs-handleops.c
+++ b/api/src/glfs-handleops.c
@@ -2028,6 +2028,10 @@ pub_glfs_h_poll_upcall (struct glfs *fs, struct callback_arg *up_arg)
}
fs->pin_refcnt++;
+
+ /* once we call this function, the applications seems to be
+ * interested in events, enable caching them */
+ fs->cache_upcalls = _gf_true;
}
pthread_mutex_unlock (&fs->mutex);
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h
index fe59a3b8eb9..6e99357d651 100644
--- a/api/src/glfs-internal.h
+++ b/api/src/glfs-internal.h
@@ -210,6 +210,7 @@ struct glfs {
gf_boolean_t migration_in_progress;
+ gf_boolean_t cache_upcalls; /* add upcalls to the upcall_list? */
struct list_head upcall_list;
pthread_mutex_t upcall_list_mutex; /* mutex for upcall entry list */
diff --git a/tests/basic/gfapi/upcall-cache-invalidate.c b/tests/basic/gfapi/upcall-cache-invalidate.c
index cc2e6a0fe33..13cca69da89 100644
--- a/tests/basic/gfapi/upcall-cache-invalidate.c
+++ b/tests/basic/gfapi/upcall-cache-invalidate.c
@@ -68,6 +68,13 @@ main (int argc, char *argv[])
ret = glfs_init (fs);
LOG_ERR("glfs_init", ret);
+ /* This does not block, but enables caching of events. Real
+ * applications like NFS-Ganesha run this in a thread before activity
+ * on the fs (through this instance) happens. */
+ ret = glfs_h_poll_upcall(fs_tmp, &cbk);
+ LOG_ERR ("glfs_h_poll_upcall", ret);
+ cbk.reason = 0;
+
fs2 = glfs_new (volname);
if (!fs2) {
fprintf (stderr, "glfs_new fs2: returned NULL\n");