summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2010-09-23 08:29:15 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-24 03:53:41 -0700
commitad9c5f801ebffb0993d5f764b27e12b01beba2ce (patch)
tree49dd25cad320cb3277528a0bde5ec71275c40642 /xlators/mgmt
parent7e1b8bb370b4082e66ebe6e458fc45aa653ab3f1 (diff)
mgmt/glusterd: cleanup generate_perf_xlator_list ()
Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1670 (Volume set enable disable support) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1670
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c152
1 files changed, 52 insertions, 100 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 120cef0c210..bf0e8c5f94a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1768,126 +1768,78 @@ __write_perf_xlator (char *xlator_name, FILE *file,
}
-static gf_boolean_t
-is_perf_xlator_enabled (char *status)
-{
- gf_boolean_t ret = _gf_false;
-
- if (strcmp (status, "enable") == 0)
- ret = _gf_true;
-
- return ret;
-}
-
-static int
-generate_perf_xlator_list (dict_t *dict, char *perf_xlator_list[])
+static
+int
+add_perf_xlator_list_item (dict_t *dict, char **perf_xlator_list,
+ char *xlator_name, int *idx)
{
- char *status = NULL;
- int i = 0;
- int dict_ret = 0;
- int ret = 0;
-
- GF_ASSERT (dict);
-
- dict_ret = dict_get_str (dict, "write-behind", &status);
- if (dict_ret || is_perf_xlator_enabled (status)) {
- gf_log ("", GF_LOG_DEBUG,
- "Write behind is enabled");
- perf_xlator_list[i] = gf_strdup ("write-behind");
- if (!perf_xlator_list[i]) {
- gf_log ("", GF_LOG_ERROR,
- "Out of memory");
- ret = -1;
- goto out;
- }
-
- i++;
+ int ret = 0;
- } else {
+ ret = dict_get_str_boolean (dict, xlator_name, 1);
+ switch (ret) {
+ case -1:
+ goto out;
+ case 1:
gf_log ("", GF_LOG_DEBUG,
- "write-behind option is disabled");
- }
-
+ "%s is enabled", xlator_name);
+ perf_xlator_list[*idx] = gf_strdup (xlator_name);
+ if (!perf_xlator_list[*idx]) {
+ gf_log ("", GF_LOG_ERROR, "Out of memory");
- dict_ret = dict_get_str (dict, "read-ahead", &status);
- if (dict_ret || is_perf_xlator_enabled (status)) {
- gf_log ("", GF_LOG_DEBUG,
- "read-ahead is enabled");
- perf_xlator_list[i] = gf_strdup ("read-ahead");
- if (!perf_xlator_list[i]) {
- gf_log ("", GF_LOG_ERROR,
- "Out of memory");
- ret = -1;
- goto out;
+ return -1;
}
- i++;
+ (*idx)++;
- } else {
- gf_log ("", GF_LOG_DEBUG,
- "read-ahead option is disabled");
+ break;
+ case 0:
+ gf_log ("", GF_LOG_DEBUG, "%s option is disabled", xlator_name);
+ break;
+ default:
+ GF_ASSERT (!"Biohazard!");
}
- dict_ret = dict_get_str (dict, "io-cache", &status);
- if (dict_ret || is_perf_xlator_enabled (status)) {
- gf_log ("", GF_LOG_DEBUG,
- "io-cache is enabled");
- perf_xlator_list[i] = gf_strdup ("io-cache");
- if (!perf_xlator_list[i]) {
- gf_log ("", GF_LOG_ERROR,
- "Out of memory");
- ret = -1;
- goto out;
- }
+ ret = 0;
- i++;
+out:
+ return ret;
+}
- } else {
- gf_log ("", GF_LOG_DEBUG,
- "io-cache option is disabled");
- }
+static int
+generate_perf_xlator_list (dict_t *dict, char *perf_xlator_list[])
+{
+ int i = 0;
+ int ret = 0;
- dict_ret = dict_get_str (dict, "quick-read", &status);
- if (dict_ret || is_perf_xlator_enabled (status)) {
- gf_log ("", GF_LOG_DEBUG,
- "quick-read is enabled");
- perf_xlator_list[i] = gf_strdup ("quick-read");
- if (!perf_xlator_list[i]) {
- gf_log ("", GF_LOG_ERROR,
- "Out of memory");
- ret = -1;
- goto out;
- }
+ GF_ASSERT (dict);
- i++;
+ ret = add_perf_xlator_list_item (dict, perf_xlator_list,
+ "write-behind", &i);
+ if (ret == -1)
+ goto out;
- } else {
- gf_log ("", GF_LOG_DEBUG,
- "quick-read option is disabled");
- }
+ ret = add_perf_xlator_list_item (dict, perf_xlator_list,
+ "read-ahead", &i);
+ if (ret == -1)
+ goto out;
- dict_ret = dict_get_str (dict, "stat-prefetch", &status);
- if (dict_ret || is_perf_xlator_enabled (status)) {
- gf_log ("", GF_LOG_DEBUG,
- "stat-prefetch is enabled");
- perf_xlator_list[i] = gf_strdup ("stat-prefetch");
- if (!perf_xlator_list[i]) {
- gf_log ("", GF_LOG_ERROR,
- "Out of memory");
- ret = -1;
- goto out;
- }
+ ret = add_perf_xlator_list_item (dict, perf_xlator_list,
+ "io-cache", &i);
+ if (ret == -1)
+ goto out;
- i++;
+ ret = add_perf_xlator_list_item (dict, perf_xlator_list,
+ "quick-read", &i);
+ if (ret == -1)
+ goto out;
- } else {
- gf_log ("", GF_LOG_DEBUG,
- "stat-prefetch option is disabled");
- }
+ ret = add_perf_xlator_list_item (dict, perf_xlator_list,
+ "stat-prefetch", &i);
+ if (ret == -1)
+ goto out;
out:
return ret;
-
}
static int