From ed4b76ba9c545f577287c0e70ae3cc853a0d5f3f Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Thu, 2 Aug 2012 13:14:25 +0530 Subject: core: reduce the usage of global variables * move all the 'logging' related global variables into ctx * make gf_fop_list a 'const' global array, hence no init(), no edits. * make sure ctx is allocated without any dependancy on memory-accounting infrastructure, so it can be the first one to get allocated * globals_init() should happen with ctx as argument not yet fixed below in this patchset: * anything with 'THIS' related globals * anything related to compat_errno related globals as its one time init'd and not changed later on. * statedump related globals Change-Id: Iab8fc30d4bfdbded6741d66ff1ed670fdc7b7ad2 Signed-off-by: Amar Tumballi BUG: 764890 Reviewed-on: http://review.gluster.com/3767 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/glusterfs.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'libglusterfs/src/glusterfs.h') diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index ad3bae14b..70a50af6a 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -33,9 +33,9 @@ #include #include - #include "list.h" #include "logging.h" +#include "lkowner.h" #define GF_YES 1 #define GF_NO 0 @@ -134,6 +134,8 @@ * we have to add aux-gid in payload of actors */ #define GF_MAX_AUX_GROUPS 200 +#define GF_UUID_BUF_SIZE 50 + /* NOTE: add members ONLY at the end (just before _MAXVALUE) */ typedef enum { GF_FOP_NULL = 0, @@ -379,14 +381,21 @@ struct _glusterfs_ctx { glusterfsd_mgmt_event_notify_fn_t notify; /* Used for xlators to make call to fsd-mgmt */ + gf_log_handle_t log; /* all logging related variables */ + + pthread_key_t synctask_key; + pthread_key_t uuid_buf_key; + char uuid_buf[GF_UUID_BUF_SIZE]; + pthread_key_t lkowner_buf_key; + char lkowner_buf[GF_LKOWNER_BUF_SIZE]; + + int mem_acct_enable; + }; typedef struct _glusterfs_ctx glusterfs_ctx_t; glusterfs_ctx_t *glusterfs_ctx_new (void); -/* If you edit this structure then, make a corresponding change in - * globals.c in the eventstring. - */ typedef enum { GF_EVENT_PARENT_UP = 1, GF_EVENT_POLLIN, @@ -408,9 +417,6 @@ typedef enum { GF_EVENT_MAXVAL, } glusterfs_event_t; -/* gf_lkowner_t is defined in lkowner.h */ -#include "lkowner.h" - struct gf_flock { short l_type; short l_whence; @@ -420,8 +426,6 @@ struct gf_flock { gf_lkowner_t l_owner; }; -extern char *glusterfs_strevent (glusterfs_event_t ev); - #define GF_MUST_CHECK __attribute__((warn_unused_result)) /* * Some macros (e.g. ALLOC_OR_GOTO) set variables in function scope, but the -- cgit