From 5e50175f56d05ab6c1295b0e0f0c11695e49c277 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Thu, 15 Mar 2012 14:00:13 +0530 Subject: core: bring a cmdline option to set memory-accounting currently this is implemented as a command line option, and not as an easier translator option. this is because as of now, before even the volume files are parsed, we would need memory accounting enabled. there is scope for improving this behavior, but for now, this approach solves the problem. Also, this feature's major consumers are the testers who are looking for leaks, hence option is hidden from usage output. Change-Id: I09a5b13743ae43ff42c251989f921319e94cabe3 Signed-off-by: Amar Tumballi BUG: 799199 Reviewed-on: http://review.gluster.com/2856 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- glusterfsd/src/glusterfsd.c | 25 ++++++++++++++++++++++++- glusterfsd/src/glusterfsd.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'glusterfsd') diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 57b3f0160bd..68c51162101 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -185,6 +185,8 @@ static struct argp_option gf_options[] = { "Dump fuse traffic to PATH"}, {"volfile-check", ARGP_VOLFILE_CHECK_KEY, 0, 0, "Enable strict volume file checking"}, + {"mem-accounting", ARGP_MEM_ACCOUNTING_KEY, 0, OPTION_HIDDEN, + "Enable internal memory accounting"}, {0, 0, 0, 0, "Miscellaneous Options:"}, {0, } }; @@ -501,6 +503,7 @@ out: static error_t parse_opts (int key, char *arg, struct argp_state *state) { + glusterfs_ctx_t *ctx = NULL; cmd_args_t *cmd_args = NULL; uint32_t n = 0; double d = 0.0; @@ -763,6 +766,12 @@ parse_opts (int key, char *arg, struct argp_state *state) argp_failure (state, -1, 0, "unknown brick (listen) port %s", arg); break; + + case ARGP_MEM_ACCOUNTING_KEY: + /* TODO: it should have got handled much earlier */ + ctx = glusterfs_ctx_get (); + ctx->mem_accounting = 1; + break; } return 0; @@ -1102,6 +1111,17 @@ logging_init (glusterfs_ctx_t *ctx) return 0; } +void +gf_check_and_set_mem_acct (int argc, char *argv[], glusterfs_ctx_t *ctx) +{ + int i = 0; + for (i = 0; i < argc; i++) { + if (strcmp (argv[i], "--mem-accounting") == 0) { + ctx->mem_accounting = 1; + break; + } + } +} int parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx) @@ -1582,7 +1602,10 @@ main (int argc, char *argv[]) "ERROR: glusterfs context not initialized"); return ENOMEM; } - +#ifndef DEBUG + /* Enable memory accounting on the fly based on argument */ + gf_check_and_set_mem_acct (argc, argv, ctx); +#endif ret = glusterfs_ctx_defaults_init (ctx); if (ret) goto out; diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h index 3c38fbef065..06c23a34233 100644 --- a/glusterfsd/src/glusterfsd.h +++ b/glusterfsd/src/glusterfsd.h @@ -80,6 +80,7 @@ enum argp_option_keys { ARGP_ACL_KEY = 154, ARGP_WORM_KEY = 155, ARGP_USER_MAP_ROOT_KEY = 156, + ARGP_MEM_ACCOUNTING_KEY = 157, }; struct _gfd_vol_top_priv_t { -- cgit