diff options
author | Amar Tumballi <amarts@redhat.com> | 2012-03-15 14:00:13 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-03-15 03:33:18 -0700 |
commit | 5e50175f56d05ab6c1295b0e0f0c11695e49c277 (patch) | |
tree | 9ed89fa4a106939578d271297fbc94e8ead7c32d /xlators/mgmt/glusterd/src/glusterd-op-sm.c | |
parent | eb8a9aae19755bc21afe2d8ed4893b788c4e84ff (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 'xlators/mgmt/glusterd/src/glusterd-op-sm.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index f9813db12f5..d96d6717eeb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -391,11 +391,25 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) global_opt = _gf_false; sprintf (str, "key%d", count); ret = dict_get_str (dict, str, &key); - - if (ret) break; + sprintf (str, "value%d", count); + ret = dict_get_str (dict, str, &value); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "invalid key,value pair in 'volume set'"); + ret = -1; + goto out; + } + + if (strcmp (key, "memory-accounting") == 0) { + gf_log (this->name, GF_LOG_INFO, + "enabling memory accounting for volume %s", + volname); + ret = 0; + goto out; + } exists = glusterd_check_option_exists (key, &key_fixed); if (exists == -1) { ret = -1; @@ -416,16 +430,6 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) goto out; } - sprintf (str, "value%d", count); - ret = dict_get_str (dict, str, &value); - - if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "invalid key,value pair in 'volume set'"); - ret = -1; - goto out; - } - if (key_fixed) key = key_fixed; @@ -1008,24 +1012,9 @@ glusterd_op_set_volume (dict_t *dict) global_opt = _gf_false; sprintf (str, "key%d", count); ret = dict_get_str (dict, str, &key); - if (ret) break; - if (!ret) { - ret = glusterd_check_option_exists (key, &key_fixed); - GF_ASSERT (ret); - if (ret == -1) { - key_fixed = NULL; - goto out; - } - ret = 0; - } - - ret = glusterd_check_globaloption (key); - if (ret) - global_opt = _gf_true; - sprintf (str, "value%d", count); ret = dict_get_str (dict, str, &value); if (ret) { @@ -1035,6 +1024,22 @@ glusterd_op_set_volume (dict_t *dict) goto out; } + if (strcmp (key, "memory-accounting") == 0) { + ret = gf_string2boolean (value, + &volinfo->memory_accounting); + goto out; + } + ret = glusterd_check_option_exists (key, &key_fixed); + GF_ASSERT (ret); + if (ret == -1) { + key_fixed = NULL; + goto out; + } + + ret = glusterd_check_globaloption (key); + if (ret) + global_opt = _gf_true; + if (!global_opt) value = gf_strdup (value); @@ -1067,7 +1072,7 @@ glusterd_op_set_volume (dict_t *dict) } } - if ( count == 1 ) { + if (count == 1) { gf_log (this->name, GF_LOG_ERROR, "No options received "); ret = -1; goto out; |