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 --- api/src/glfs.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'api/src') diff --git a/api/src/glfs.c b/api/src/glfs.c index 01b3bc83..6b3c2113 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -365,15 +365,18 @@ glfs_new (const char *volname) int ret = -1; glusterfs_ctx_t *ctx = NULL; - /* first globals init, for gf_mem_acct_enable_set () */ - ret = glusterfs_globals_init (); - if (ret) - return NULL; - ctx = glusterfs_ctx_new (); if (!ctx) { return NULL; } + + gf_mem_acct_enable_set (ctx); + + /* first globals init, for gf_mem_acct_enable_set () */ + ret = glusterfs_globals_init (ctx); + if (ret) + return NULL; + THIS->ctx = ctx; /* then ctx_defaults_init, for xlator_mem_acct_init(THIS) */ @@ -440,7 +443,7 @@ glfs_set_logging (struct glfs *fs, const char *logfile, int loglevel) { int ret = -1; - ret = gf_log_init (logfile); + ret = gf_log_init (fs->ctx, logfile); if (ret) return ret; -- cgit