From dfcafa47b514154bd3ff714f8bc16eda1c6df6f4 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 30 Aug 2016 10:54:37 +0200 Subject: gfapi: do not cache upcalls if the application is not interested When the volume option 'features.cache-invalidation' is enabled, upcall events are sent from the brick process to the client. Even if the client is not interested in upcall events itself, md-cache or other xlators may benefit from them. By adding a new 'cache_upcalls' boolean in the 'struct glfs', we can enable the caching of upcalls when the application called glfs_h_poll_upcall(). NFS-Ganesha sets up a thread for handling upcalls in the initialization phase, and calls glfs_h_poll_upcall() before any NFS-client accesses the NFS-export. In the future there will be a more flexible registration API for enabling certain kind of upcall events. Until that is available, this should work just fine. Verificatio of this change is not trivial within our current regression test framework. The bug report contains a description on how to reliably reproduce the problem with the glusterfs-coreutils. Cherry picked from commit 218c9b033fa44eacbc27d87491abd830548b362e: > Change-Id: I818595c92db50e6e48f7bfe287ee05103a4a30a2 > BUG: 1368842 > Signed-off-by: Niels de Vos > Reviewed-on: http://review.gluster.org/15191 > Smoke: Gluster Build System > Reviewed-by: Poornima G > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System > Reviewed-by: soumya k > Reviewed-by: Kaleb KEITHLEY Change-Id: I818595c92db50e6e48f7bfe287ee05103a4a30a2 BUG: 1368843 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/15347 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Poornima G Reviewed-by: soumya k --- api/src/glfs-fops.c | 3 ++- api/src/glfs-handleops.c | 4 ++++ api/src/glfs-internal.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'api/src') 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 */ -- cgit