diff options
author | Raghavendra Bhat <raghavendra@redhat.com> | 2015-01-20 17:57:22 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-01-28 06:05:24 -0800 |
commit | c8a6904396142b832ec31c37f43f44b139d24e1f (patch) | |
tree | 897a2ba419752dab93b8b138485914585cbac163 | |
parent | 2f640b3f3ce21c6790c661f53ff39474192b5a21 (diff) |
uss: disable memory accounting for the snapshot daemon
* Bring in option to disable memory accounting for a glusterfs process
This reverses the changes done by the commit
7fba3a88f1ced610eca0c23516a1e720d75160cd.
* Change the key from "memory-accounting" to "no-memory-accounting", as by
default all the glusterfs process enable memory accounting now. So to
disable memory accounting for some process, "no-mem-accounting" argument has
to be passed.
Change-Id: I39c7cefb0fe764ea3e48f4e73e1305b084c5f497
BUG: 1184366
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/9469
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r-- | api/src/glfs-mgmt.c | 2 | ||||
-rw-r--r-- | api/src/glfs.c | 3 | ||||
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 22 | ||||
-rw-r--r-- | libglusterfs/src/ctx.c | 3 | ||||
-rw-r--r-- | libglusterfs/src/globals.c | 14 | ||||
-rw-r--r-- | libglusterfs/src/globals.h | 3 | ||||
-rw-r--r-- | libglusterfs/src/glusterfs.h | 1 | ||||
-rwxr-xr-x | tests/bugs/core/bug-834465.t | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c | 1 |
9 files changed, 47 insertions, 6 deletions
diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c index 1cba1ed1109..86a186e581b 100644 --- a/api/src/glfs-mgmt.c +++ b/api/src/glfs-mgmt.c @@ -820,7 +820,7 @@ glfs_mgmt_init (struct glfs *fs) if (ret) goto out; - rpc = rpc_clnt_new (options, THIS->ctx, THIS->name, 8); + rpc = rpc_clnt_new (options, ctx, THIS->name, 8); if (!rpc) { ret = -1; gf_log (THIS->name, GF_LOG_WARNING, diff --git a/api/src/glfs.c b/api/src/glfs.c index 75dd315f6bd..7542d8b9fcd 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -563,7 +563,8 @@ pub_glfs_new (const char *volname) if (ret) return NULL; - THIS->ctx = ctx; + if (!THIS->ctx) + THIS->ctx = ctx; /* then ctx_defaults_init, for xlator_mem_acct_init(THIS) */ ret = glusterfs_ctx_defaults_init (ctx); diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index e854959daf6..e750d68dd98 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -208,8 +208,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 (enabled by default, obsolete)"}, + {"no-mem-accounting", ARGP_MEM_ACCOUNTING_KEY, 0, OPTION_HIDDEN, + "disable internal memory accounting"}, {"fuse-mountopts", ARGP_FUSE_MOUNTOPTS_KEY, "OPTIONS", OPTION_HIDDEN, "Extra mount options to pass to FUSE"}, {"use-readdirp", ARGP_FUSE_USE_READDIRP_KEY, "BOOL", OPTION_ARG_OPTIONAL, @@ -224,6 +224,7 @@ static struct argp_option gf_options[] = { static struct argp argp = { gf_options, parse_opts, argp_doc, gf_doc }; + int glusterfs_pidfile_cleanup (glusterfs_ctx_t *ctx); int glusterfs_volumes_init (glusterfs_ctx_t *ctx); int glusterfs_mgmt_init (glusterfs_ctx_t *ctx); @@ -1419,6 +1420,9 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) cmd_args->fuse_entry_timeout = -1; cmd_args->fopen_keep_cache = GF_OPTION_DEFERRED; + if (ctx->mem_acct_enable) + cmd_args->mem_acct = 1; + INIT_LIST_HEAD (&cmd_args->xlator_options); INIT_LIST_HEAD (&cmd_args->volfile_servers); @@ -1499,6 +1503,18 @@ logging_init (glusterfs_ctx_t *ctx, const char *progpath) return 0; } +void +gf_check_and_set_mem_acct (int argc, char *argv[]) +{ + int i = 0; + + for (i = 0; i < argc; i++) { + if (strcmp (argv[i], "--no-mem-accounting") == 0) { + gf_global_mem_acct_enable_set (0); + break; + } + } +} int parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx) @@ -1988,6 +2004,8 @@ main (int argc, char *argv[]) int ret = -1; char cmdlinestr[PATH_MAX] = {0,}; + gf_check_and_set_mem_acct (argc, argv); + ctx = glusterfs_ctx_new (); if (!ctx) { gf_msg ("glusterfs", GF_LOG_CRITICAL, 0, glusterfsd_msg_29); diff --git a/libglusterfs/src/ctx.c b/libglusterfs/src/ctx.c index bc704aceacb..aa9d4216fd3 100644 --- a/libglusterfs/src/ctx.c +++ b/libglusterfs/src/ctx.c @@ -14,6 +14,7 @@ #endif /* !_CONFIG_H */ #include <pthread.h> +#include "globals.h" #include "glusterfs.h" @@ -31,7 +32,7 @@ glusterfs_ctx_new () goto out; } - ctx->mem_acct_enable = 1; + ctx->mem_acct_enable = gf_global_mem_acct_enable_get(); INIT_LIST_HEAD (&ctx->graphs); INIT_LIST_HEAD (&ctx->mempool_list); diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 259c5c885f7..cf707c7af4b 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -81,8 +81,22 @@ static pthread_key_t uuid_buf_key; static char global_uuid_buf[GF_UUID_BUF_SIZE]; static pthread_key_t lkowner_buf_key; static char global_lkowner_buf[GF_LKOWNER_BUF_SIZE]; +static int gf_global_mem_acct_enable = 1; +int +gf_global_mem_acct_enable_get (void) +{ + return gf_global_mem_acct_enable; +} + +int +gf_global_mem_acct_enable_set (int val) +{ + gf_global_mem_acct_enable = val; + return 0; +} + void glusterfs_this_destroy (void *ptr) { diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h index 3e2ba870acc..ce1c64475f4 100644 --- a/libglusterfs/src/globals.h +++ b/libglusterfs/src/globals.h @@ -72,4 +72,7 @@ int glusterfs_globals_init (glusterfs_ctx_t *ctx); extern const char *gf_fop_list[]; +/* mem acct enable/disable */ +int gf_global_mem_acct_enable_get (void); +int gf_global_mem_acct_enable_set (int val); #endif /* !_GLOBALS_H */ diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 73945e578fe..8059c976368 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -420,6 +420,7 @@ struct _cmd_args { int background_qlen; int congestion_threshold; char *fuse_mountopts; + int mem_acct; /* key args */ char *mount_point; diff --git a/tests/bugs/core/bug-834465.t b/tests/bugs/core/bug-834465.t index 5bc52a0957e..4bdee83ed2d 100755 --- a/tests/bugs/core/bug-834465.t +++ b/tests/bugs/core/bug-834465.t @@ -16,7 +16,9 @@ TEST $CLI volume start $V0; EXPECT 'Started' volinfo_field $V0 'Status'; MOUNTDIR=$M0; -TEST glusterfs --mem-accounting --volfile-server=$H0 --volfile-id=$V0 $MOUNTDIR; + +#memory-accounting is enabled by default +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $MOUNTDIR; sdump1=$(generate_mount_statedump $V0); nalloc1=0 diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index 33bcf6e7df0..703e5eac66f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -3520,6 +3520,7 @@ glusterd_snapd_start (glusterd_volinfo_t *volinfo, gf_boolean_t wait) runner_add_arg (&runner, "--xlator-option"); runner_argprintf (&runner, "%s-server.listen-port=%d", volname, snapd_port); + runner_add_arg (&runner, "--no-mem-accounting"); snprintf (msg, sizeof (msg), "Starting the snapd service for volume %s", volname); |