summaryrefslogtreecommitdiffstats
path: root/xlators/features/upcall/src/upcall-internal.c
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2015-03-24 10:30:31 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2015-03-31 11:16:26 -0700
commit25f97b2788a33efcb0714ad639f8db380b864982 (patch)
tree9720bdd09e04239dcd75bdb88ddc97623ec6fb44 /xlators/features/upcall/src/upcall-internal.c
parente6f5ace08ad0a068cb49d3ca1274a27aa031992b (diff)
Upcall: Added xlator options to enable cache-invalidation
Added two xlator options to enable cache-invalidation and set cache-invalidation-timeout. In addition, made few minor changes in the upcall processing code in gfapi. Change-Id: Ie0b32ca8348e34e3fe4f1e7df30cc925fa4aad31 BUG: 1200271 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/9975 Reviewed-by: Meghana M <mmadhusu@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/upcall/src/upcall-internal.c')
-rw-r--r--xlators/features/upcall/src/upcall-internal.c68
1 files changed, 64 insertions, 4 deletions
diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c
index 26473e2a7bd..ef7743c9083 100644
--- a/xlators/features/upcall/src/upcall-internal.c
+++ b/xlators/features/upcall/src/upcall-internal.c
@@ -34,6 +34,62 @@
#include "defaults.h"
/*
+ * Check if any of the upcall options are enabled:
+ * - cache_invalidation
+ * - XXX: lease_lk
+ */
+gf_boolean_t
+is_upcall_enabled(xlator_t *this) {
+ upcall_private_t *priv = NULL;
+ gf_boolean_t is_enabled = _gf_false;
+
+ if (this->private) {
+ priv = (upcall_private_t *)this->private;
+
+ if (priv->cache_invalidation_enabled) {
+ is_enabled = _gf_true;
+ }
+ }
+
+ return is_enabled;
+}
+
+/*
+ * Check if any of cache_invalidation is enabled
+ */
+gf_boolean_t
+is_cache_invalidation_enabled(xlator_t *this) {
+ upcall_private_t *priv = NULL;
+ gf_boolean_t is_enabled = _gf_false;
+
+ if (this->private) {
+ priv = (upcall_private_t *)this->private;
+
+ if (priv->cache_invalidation_enabled) {
+ is_enabled = _gf_true;
+ }
+ }
+
+ return is_enabled;
+}
+
+/*
+ * Get the cache_invalidation_timeout
+ */
+int32_t
+get_cache_invalidation_timeout(xlator_t *this) {
+ upcall_private_t *priv = NULL;
+ int32_t timeout = 0;
+
+ if (this->private) {
+ priv = (upcall_private_t *)this->private;
+ timeout = priv->cache_invalidation_timeout;
+ }
+
+ return timeout;
+}
+
+/*
* Allocate and add a new client entry to the given upcall entry
*/
upcall_client_t*
@@ -73,7 +129,8 @@ __add_upcall_client (call_frame_t *frame, uuid_t gfid,
INIT_LIST_HEAD (&up_client_entry->client_list);
up_client_entry->client_uid = gf_strdup(client->client_uid);
up_client_entry->access_time = time(NULL);
- up_client_entry->expire_time_attr = CACHE_INVALIDATION_PERIOD;
+ up_client_entry->expire_time_attr =
+ get_cache_invalidation_timeout(frame->this);
list_add_tail (&up_client_entry->client_list,
&up_inode_ctx->client_list);
@@ -349,7 +406,7 @@ upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client,
/*
* If the upcall_client_t has recently accessed the file (i.e, within
- * CACHE_INVALIDATION_PERIOD), send a upcall notification.
+ * priv->cache_invalidation_timeout), send a upcall notification.
*/
void
upcall_client_cache_invalidate (xlator_t *this, uuid_t gfid,
@@ -357,9 +414,12 @@ upcall_client_cache_invalidate (xlator_t *this, uuid_t gfid,
uint32_t flags)
{
notify_event_data_t n_event_data;
+ time_t timeout = 0;
time_t t_expired = time(NULL) - up_client_entry->access_time;
- if (t_expired < CACHE_INVALIDATION_PERIOD) {
+ timeout = get_cache_invalidation_timeout(this);
+
+ if (t_expired < timeout) {
/* Send notify call */
uuid_copy(n_event_data.gfid, gfid);
n_event_data.client_entry = up_client_entry;
@@ -374,7 +434,7 @@ upcall_client_cache_invalidate (xlator_t *this, uuid_t gfid,
up_client_entry->client_uid);
} else {
- if (t_expired > (2*CACHE_INVALIDATION_PERIOD)) {
+ if (t_expired > (2*timeout)) {
/* Cleanup the entry */
__upcall_cleanup_client_entry (up_client_entry);
}