summaryrefslogtreecommitdiffstats
path: root/glusterfsd/src
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2012-03-15 14:00:13 +0530
committerVijay Bellur <vijay@gluster.com>2012-03-15 03:33:18 -0700
commit5e50175f56d05ab6c1295b0e0f0c11695e49c277 (patch)
tree9ed89fa4a106939578d271297fbc94e8ead7c32d /glusterfsd/src
parenteb8a9aae19755bc21afe2d8ed4893b788c4e84ff (diff)
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 <amarts@redhat.com> BUG: 799199 Reviewed-on: http://review.gluster.com/2856 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'glusterfsd/src')
-rw-r--r--glusterfsd/src/glusterfsd.c25
-rw-r--r--glusterfsd/src/glusterfsd.h1
2 files changed, 25 insertions, 1 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 57b3f0160..68c511621 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 3c38fbef0..06c23a342 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 {