diff options
author | Yaniv Kaul <ykaul@redhat.com> | 2019-11-05 18:05:38 +0200 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2019-11-18 01:13:45 +0000 |
commit | 515d1b4577d989fa99f236d9e344a71db7d001a0 (patch) | |
tree | 1f22c700a77469aae355d32124a55f7f7cb017df /xlators/mgmt/glusterd/src/glusterd-volgen.c | |
parent | d1842d97b22419a8b73c2da07caa5f346ee6f7a7 (diff) |
glusterd-volgen.c: improve volgen_graph_set_options_generic()
Skip fetching "skip-CLIOT" unconditionally on every
invocation of volgen_graph_set_options_generic().
Instead, fetch only if the vme->key matches to it.
We calculate the length of vme->key (but we would have
done it anyway in dict_get() later on, so now we can use
dict_getn() instead and re-use that key length) and check
if the lengths match before doing a strcmp() between them.
Lastly, if they match, we actually do the fetch.
Change-Id: I9d9a7104f9e920bf81477128adb5fc87f5d30627
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 4dbc78a8e02..b93c7b84c90 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -459,7 +459,7 @@ struct opthandler_data { void *param; }; -static int +static void process_option(char *key, data_t *value, void *param) { struct opthandler_data *odt = param; @@ -468,7 +468,7 @@ process_option(char *key, data_t *value, void *param) }; if (odt->rv) - return 0; + return; odt->found = _gf_true; vme.key = key; @@ -489,7 +489,7 @@ process_option(char *key, data_t *value, void *param) vme.value = value->data; odt->rv = odt->handler(odt->graph, &vme, odt->param); - return 0; + return; } static int @@ -501,7 +501,7 @@ volgen_graph_set_options_generic(volgen_graph_t *graph, dict_t *dict, 0, }; data_t *data = NULL; - const int skip_cliot = dict_get_str_boolean(dict, "skip-CLIOT", _gf_false); + int keylen; odt.graph = graph; odt.handler = handler; @@ -509,16 +509,17 @@ volgen_graph_set_options_generic(volgen_graph_t *graph, dict_t *dict, (void)data; for (vme = glusterd_volopt_map; vme->key; vme++) { - odt.vme = vme; - odt.found = _gf_false; - odt.data_t_fake = _gf_false; - - data = dict_get(dict, vme->key); - if (skip_cliot == _gf_true && - !strcmp(vme->key, "performance.client-io-threads")) { + keylen = strlen(vme->key); + if (keylen == SLEN("performance.client-io-threads") && + !strcmp(vme->key, "performance.client-io-threads") && + dict_get_str_boolean(dict, "skip-CLIOT", _gf_false) == _gf_true) { continue; } + odt.vme = vme; + odt.found = _gf_false; + odt.data_t_fake = _gf_false; + data = dict_getn(dict, vme->key, keylen); if (data) process_option(vme->key, data, &odt); if (odt.rv) |