From 73fcf3a874b2049da31d01b8363d1ac85c9488c2 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 17 Apr 2017 15:50:07 +0530 Subject: core: make the per glusterfs_ctx_t timer-wheel refcounted xlators can use a 'global' timer-wheel for scheduling events. This timer-wheel is managed per glusterfs_ctx_t, but does not need to be allocated for every graph. When an xlator wants to use the timer-wheel, it will be instanciated on demand, and provided to xlators that request it later on. By adding a reference counter to the glusterfs_ctx_t for the timer-wheel, the threads and structures can be cleaned up when the last xlator does not have a need for it anymore. In general, the xlators request the timer-wheel in init(), and they should return it in fini(). Because the timer-wheel is managed per glusterfs_ctx_t, the functions can be added to ctx.c and do not need to live in their very minimal tw.[ch] files. Change-Id: I19d225b39aaa272d9005ba7adc3104c3764f1572 BUG: 1442788 Reported-by: Poornima G Signed-off-by: Niels de Vos Reviewed-on: https://review.gluster.org/17068 NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Smoke: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Zhou Zhengping Reviewed-by: Kaleb KEITHLEY --- xlators/performance/nl-cache/src/nl-cache.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'xlators/performance') diff --git a/xlators/performance/nl-cache/src/nl-cache.c b/xlators/performance/nl-cache/src/nl-cache.c index f301b2d06dd..f8d2642be30 100644 --- a/xlators/performance/nl-cache/src/nl-cache.c +++ b/xlators/performance/nl-cache/src/nl-cache.c @@ -12,7 +12,6 @@ #include "nl-cache.h" #include "statedump.h" #include "upcall-utils.h" -#include "tw.h" static void nlc_dentry_op (call_frame_t *frame, xlator_t *this, gf_boolean_t multilink) @@ -627,6 +626,8 @@ nlc_priv_dump (xlator_t *this) void fini (xlator_t *this) { + glusterfs_ctx_tw_put (this->ctx); + return; } @@ -702,17 +703,12 @@ init (xlator_t *this) INIT_LIST_HEAD (&conf->lru); time (&conf->last_child_down); - if (!glusterfs_global_timer_wheel (this)) { - gf_msg_debug (this->name, 0, "Initing the global timer wheel"); - ret = glusterfs_global_timer_wheel_init (this->ctx); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - NLC_MSG_NO_TIMER_WHEEL, - "Initing the global timer wheel failed"); - goto out; - } + conf->timer_wheel = glusterfs_ctx_tw_get (this->ctx); + if (!conf->timer_wheel) { + gf_msg (this->name, GF_LOG_ERROR, 0, NLC_MSG_NO_TIMER_WHEEL, + "Initing the global timer wheel failed"); + goto out; } - conf->timer_wheel = glusterfs_global_timer_wheel (this); this->private = conf; -- cgit