summaryrefslogtreecommitdiffstats
path: root/xlators/features/upcall/src/upcall.c
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2015-04-22 15:48:52 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2015-05-04 16:27:41 -0700
commit86fb4828f5566e455a12ac2207999120275b61a7 (patch)
tree8d5806d43b1f16024dc38f31847a76b2c07a879c /xlators/features/upcall/src/upcall.c
parentf8bb9ac26aad8c0068bcc45a34ecb4a73cc06e7a (diff)
Upcall: Cleanup expired client entries
To cleanup expired client entries (with access_time > 2*CACHE_INVALIDATION_TIMEOUT), have * defined a global list to contain all the upcall_inode_ctx allocated * Every time a upcall_inode_ctx is allocated, it is added to the global list * during inode_forget, that upcall_inode_ctx is marked for destroy * created a reaper thread which scans through that list * cleans up expired client entries * frees the inode_ctx with destroy_mode set. Note: This reaper thread is initialized only when features.cache_invalidation option is enabled. Change-Id: Iea2a63eb31b8e08d5709e7e090cf26fd13d01265 BUG: 1200267 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/10342 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'xlators/features/upcall/src/upcall.c')
-rw-r--r--xlators/features/upcall/src/upcall.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c
index ad86567aa7c..c68c0258fb8 100644
--- a/xlators/features/upcall/src/upcall.c
+++ b/xlators/features/upcall/src/upcall.c
@@ -1615,6 +1615,20 @@ reconfigure (xlator_t *this, dict_t *options)
options, int32, out);
ret = 0;
+
+ if (priv->cache_invalidation_enabled &&
+ !priv->reaper_init_done) {
+ ret = upcall_reaper_thread_init (this);
+
+ if (ret) {
+ gf_msg ("upcall", GF_LOG_WARNING, 0,
+ UPCALL_MSG_INTERNAL_ERROR,
+ "reaper_thread creation failed (%s)."
+ " Disabling cache_invalidation",
+ strerror(errno));
+ }
+ }
+
out:
return ret;
}
@@ -1639,10 +1653,27 @@ init (xlator_t *this)
GF_OPTION_INIT ("cache-invalidation-timeout",
priv->cache_invalidation_timeout, int32, out);
+ LOCK_INIT (&priv->inode_ctx_lk);
+ INIT_LIST_HEAD (&priv->inode_ctx_list);
+
this->private = priv;
+ priv->fini = 0;
+ priv->reaper_init_done = 0;
+
this->local_pool = mem_pool_new (upcall_local_t, 512);
ret = 0;
+ if (priv->cache_invalidation_enabled) {
+ ret = upcall_reaper_thread_init (this);
+
+ if (ret) {
+ gf_msg ("upcall", GF_LOG_WARNING, 0,
+ UPCALL_MSG_INTERNAL_ERROR,
+ "reaper_thread creation failed (%s)."
+ " Disabling cache_invalidation",
+ strerror(errno));
+ }
+ }
out:
if (ret) {
GF_FREE (priv);
@@ -1662,6 +1693,15 @@ fini (xlator_t *this)
}
this->private = NULL;
+ priv->fini = 1;
+
+ pthread_join (priv->reaper_thr, NULL);
+
+ LOCK_DESTROY (&priv->inode_ctx_lk);
+
+ /* Do we need to cleanup the inode_ctxs? IMO not required
+ * as inode_forget would have been done on all the inodes
+ * before calling xlator_fini */
GF_FREE (priv);
return 0;