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 --- libglusterfs/src/glusterfs.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'libglusterfs/src/glusterfs.h') diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 4d5ca839cd3..839a1d47d2a 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -36,6 +36,7 @@ #include "logging.h" #include "lkowner.h" #include "compat-uuid.h" +#include "refcount.h" #define GF_YES 1 #define GF_NO 0 @@ -438,6 +439,12 @@ typedef enum { struct tvec_base; +/* reference counting for the global (per ctx) timer-wheel */ +struct gf_ctx_tw { + GF_REF_DECL; + struct tvec_base *timer_wheel; /* global timer-wheel instance */ +}; + struct _glusterfs_ctx { cmd_args_t cmd_args; char *process_uuid; @@ -506,14 +513,13 @@ struct _glusterfs_ctx { */ mgmt_ssl_t secure_srvr; /* Buffer to 'save' backtrace even under OOM-kill like situations*/ - char btbuf[GF_BACKTRACE_LEN]; + char btbuf[GF_BACKTRACE_LEN]; - pthread_mutex_t notify_lock; - pthread_cond_t notify_cond; - int notifying; - - struct tvec_base *timer_wheel; /* global timer-wheel instance */ + pthread_mutex_t notify_lock; + pthread_cond_t notify_cond; + int notifying; + struct gf_ctx_tw *tw; /* refcounted timer_wheel */ }; typedef struct _glusterfs_ctx glusterfs_ctx_t; -- cgit