core: Global timer-wheel
Instantiate a process wide global instance of the timer wheel data structure. Spawning glusterfs* process with option arg "--global-timer-wheel" instantiates a global instance of timer-wheel under global context (->ctx). Translators can make use of this process wide instance [via a call to glusterfs_global_timer_wheel()] instead of maintaining an instance of their own and possibly consuming more memory. Linux kernel too has a single instance of timer wheel where subsystems such as IO, networking, etc.. make use of. Bitrot daemon would be early consumers of this: bitrot translator instances for multiple volumes would track objects belonging to their respective bricks in this global expiry tracking data structure. This is also a first step to move GlusterFS timer mechanism to use timer-wheel. Change-Id: Ie882df607e07acaced846ea269ebf1ece306d6ae BUG: 1170075 Signed-off-by: Venky Shankar <vshankar@redhat.com> Reviewed-on: http://review.gluster.org/10380 Tested-by: NetBSD Build System Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
This commit is contained in:
parent
7be43338ff
commit
004f64e93d
@ -17,6 +17,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
#include "timer-wheel.h"
|
||||
|
||||
|
@ -74,6 +74,7 @@
|
||||
#include "exports.h"
|
||||
|
||||
#include "daemon.h"
|
||||
#include "tw.h"
|
||||
|
||||
/* process mode definitions */
|
||||
#define GF_SERVER_PROCESS 0
|
||||
@ -184,6 +185,8 @@ static struct argp_option gf_options[] = {
|
||||
"Brick Port to be registered with Gluster portmapper" },
|
||||
{"fopen-keep-cache", ARGP_FOPEN_KEEP_CACHE_KEY, "BOOL", OPTION_ARG_OPTIONAL,
|
||||
"Do not purge the cache on file open"},
|
||||
{"global-timer-wheel", ARGP_GLOBAL_TIMER_WHEEL, "BOOL",
|
||||
OPTION_ARG_OPTIONAL, "Instantiate process global timer-wheel"},
|
||||
|
||||
{0, 0, 0, 0, "Fuse options:"},
|
||||
{"direct-io-mode", ARGP_DIRECT_IO_MODE_KEY, "BOOL", OPTION_ARG_OPTIONAL,
|
||||
@ -1065,6 +1068,10 @@ parse_opts (int key, char *arg, struct argp_state *state)
|
||||
|
||||
break;
|
||||
|
||||
case ARGP_GLOBAL_TIMER_WHEEL:
|
||||
cmd_args->global_timer_wheel = 1;
|
||||
break;
|
||||
|
||||
case ARGP_GID_TIMEOUT_KEY:
|
||||
if (!gf_string2int(arg, &cmd_args->gid_timeout)) {
|
||||
cmd_args->gid_timeout_set = _gf_true;
|
||||
@ -2218,7 +2225,6 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* This is the only legal global pointer */
|
||||
glusterfs_ctx_t *glusterfsd_ctx;
|
||||
|
||||
@ -2306,6 +2312,13 @@ main (int argc, char *argv[])
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* do this _after_ deamonize() */
|
||||
if (cmd->global_timer_wheel) {
|
||||
ret = glusterfs_global_timer_wheel_init (ctx);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = glusterfs_volumes_init (ctx);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
@ -94,6 +94,7 @@ enum argp_option_keys {
|
||||
ARGP_LOG_BUF_SIZE = 170,
|
||||
ARGP_LOG_FLUSH_TIMEOUT = 171,
|
||||
ARGP_SECURE_MGMT_KEY = 172,
|
||||
ARGP_GLOBAL_TIMER_WHEEL = 173,
|
||||
};
|
||||
|
||||
struct _gfd_vol_top_priv_t {
|
||||
|
@ -5,7 +5,7 @@ libglusterfs_la_CPPFLAGS = $(GF_CPPFLAGS) -D__USE_FILE_OFFSET64 \
|
||||
-DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\" \
|
||||
-I$(top_srcdir)/rpc/rpc-lib/src/ -I$(CONTRIBDIR)/rbtree \
|
||||
-I$(CONTRIBDIR)/libexecinfo ${ARGP_STANDALONE_CPPFLAGS} \
|
||||
-DSBIN_DIR=\"$(sbindir)\"
|
||||
-DSBIN_DIR=\"$(sbindir)\" -I$(CONTRIBDIR)/timer-wheel
|
||||
|
||||
libglusterfs_la_LIBADD = @LEXLIB@ $(ZLIB_LIBS) $(MATH_LIB) $(UUID_LIBS)
|
||||
libglusterfs_la_LDFLAGS = -version-info $(LIBGLUSTERFS_LT_VERSION)
|
||||
@ -28,7 +28,7 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \
|
||||
strfd.c parse-utils.c $(CONTRIBDIR)/mount/mntent.c \
|
||||
$(CONTRIBDIR)/libexecinfo/execinfo.c quota-common-utils.c rot-buffs.c \
|
||||
$(CONTRIBDIR)/timer-wheel/timer-wheel.c \
|
||||
$(CONTRIBDIR)/timer-wheel/find_last_bit.c
|
||||
$(CONTRIBDIR)/timer-wheel/find_last_bit.c tw.c
|
||||
|
||||
nodist_libglusterfs_la_SOURCES = y.tab.c graph.lex.c
|
||||
|
||||
@ -47,7 +47,8 @@ noinst_HEADERS = common-utils.h defaults.h dict.h glusterfs.h hashfn.h timespec.
|
||||
$(CONTRIBDIR)/mount/mntent_compat.h lvm-defaults.h \
|
||||
$(CONTRIBDIR)/libexecinfo/execinfo_compat.h \
|
||||
unittest/unittest.h quota-common-utils.h rot-buffs.h \
|
||||
$(CONTRIBDIR)/timer-wheel/timer-wheel.h compat-uuid.h
|
||||
$(CONTRIBDIR)/timer-wheel/timer-wheel.h compat-uuid.h \
|
||||
tw.h
|
||||
|
||||
if !HAVE_LIBUUID
|
||||
# FIXME: unbundle libuuid, see compat-uuid.h.
|
||||
|
@ -434,6 +434,10 @@ struct _cmd_args {
|
||||
int gid_timeout;
|
||||
char gid_timeout_set;
|
||||
int aux_gfid_mount;
|
||||
|
||||
/* need a process wide timer-wheel? */
|
||||
int global_timer_wheel;
|
||||
|
||||
struct list_head xlator_options; /* list of xlator_option_t */
|
||||
|
||||
/* fuse options */
|
||||
@ -496,6 +500,8 @@ typedef enum {
|
||||
MGMT_SSL_ALWAYS
|
||||
} mgmt_ssl_t;
|
||||
|
||||
struct tvec_base;
|
||||
|
||||
struct _glusterfs_ctx {
|
||||
cmd_args_t cmd_args;
|
||||
char *process_uuid;
|
||||
@ -570,6 +576,8 @@ struct _glusterfs_ctx {
|
||||
pthread_cond_t notify_cond;
|
||||
int notifying;
|
||||
|
||||
struct tvec_base *timer_wheel; /* global timer-wheel instance */
|
||||
|
||||
};
|
||||
typedef struct _glusterfs_ctx glusterfs_ctx_t;
|
||||
|
||||
|
25
libglusterfs/src/tw.c
Normal file
25
libglusterfs/src/tw.c
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
Copyright (c) 2008-2015 Red Hat, Inc. <http://www.redhat.com>
|
||||
This file is part of GlusterFS.
|
||||
|
||||
This file is licensed to you under your choice of the GNU Lesser
|
||||
General Public License, version 3 or any later version (LGPLv3 or
|
||||
later), or the GNU General Public License, version 2 (GPLv2), in all
|
||||
cases as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include "tw.h"
|
||||
#include "timer-wheel.h"
|
||||
|
||||
int
|
||||
glusterfs_global_timer_wheel_init (glusterfs_ctx_t *ctx)
|
||||
{
|
||||
ctx->timer_wheel = gf_tw_init_timers();
|
||||
return ctx->timer_wheel ? 0 : -1;
|
||||
}
|
||||
|
||||
struct tvec_base *
|
||||
glusterfs_global_timer_wheel (xlator_t *this)
|
||||
{
|
||||
return this->ctx->timer_wheel;
|
||||
}
|
23
libglusterfs/src/tw.h
Normal file
23
libglusterfs/src/tw.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
Copyright (c) 2008-2015 Red Hat, Inc. <http://www.redhat.com>
|
||||
This file is part of GlusterFS.
|
||||
|
||||
This file is licensed to you under your choice of the GNU Lesser
|
||||
General Public License, version 3 or any later version (LGPLv3 or
|
||||
later), or the GNU General Public License, version 2 (GPLv2), in all
|
||||
cases as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef __TW_H__
|
||||
#define __TW_H__
|
||||
|
||||
#include "xlator.h"
|
||||
#include "glusterfs.h"
|
||||
|
||||
int
|
||||
glusterfs_global_timer_wheel_init (glusterfs_ctx_t *);
|
||||
|
||||
struct tvec_base *
|
||||
glusterfs_global_timer_wheel (xlator_t *);
|
||||
|
||||
#endif /* __TW_H__ */
|
Loading…
x
Reference in New Issue
Block a user