summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-volgen.c
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2019-11-03 15:21:05 +0200
committerAtin Mukherjee <amukherj@redhat.com>2019-11-29 13:38:00 +0000
commitb35f8addc6b582a2498dfae546fbb942964c66b3 (patch)
tree976334ed6816d04c62833fa1c421ef58743017e9 /xlators/mgmt/glusterd/src/glusterd-volgen.c
parent1bfb0a750c6fcd0bbf4d68a1890704f0aefe6337 (diff)
glusterd-op-sm.c (and others) - improve glusterd_op_stage_set_volume()
Multiple changes to the function in the hope to make it somewhat faster. 1. Checking for key length against constant strings before calling strcmp() to save some calls. 2. Verifying if a match was already made against the key to reduce yet more checks. 3. Alignment of error message when they can fit on less lines - just makes 'grep' on the code for error messages easier and it's more readable. 4. Multiple functions where call _gd_get_vmep() one by one. Instead, extracted it to be callable (it was static) and re-used its result, instead of calling it again and again. 5. Removed some unneeded include statement. 6. Removed redundant null checks. Hopefully, no functional changes. Change-Id: Id281224e49adeca6757f96653b4cb13c7c9ba8c9 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.c43
1 files changed, 12 insertions, 31 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index f872c20..2036272 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -6360,13 +6360,16 @@ out:
return ret;
}
-static struct volopt_map_entry *
-_gd_get_vmep(char *key)
+struct volopt_map_entry *
+gd_get_vmep(const char *key)
{
char *completion = NULL;
struct volopt_map_entry *vmep = NULL;
int ret = 0;
+ if (!key)
+ return NULL;
+
COMPLETE_OPTION((char *)key, completion, ret);
for (vmep = glusterd_volopt_map; vmep->key; vmep++) {
if (strcmp(vmep->key, key) == 0)
@@ -6377,13 +6380,8 @@ _gd_get_vmep(char *key)
}
uint32_t
-glusterd_get_op_version_for_key(char *key)
+glusterd_get_op_version_from_vmep(struct volopt_map_entry *vmep)
{
- struct volopt_map_entry *vmep = NULL;
-
- GF_ASSERT(key);
-
- vmep = _gd_get_vmep(key);
if (vmep)
return vmep->op_version;
@@ -6391,13 +6389,8 @@ glusterd_get_op_version_for_key(char *key)
}
gf_boolean_t
-gd_is_client_option(char *key)
+gd_is_client_option(struct volopt_map_entry *vmep)
{
- struct volopt_map_entry *vmep = NULL;
-
- GF_ASSERT(key);
-
- vmep = _gd_get_vmep(key);
if (vmep && (vmep->flags & VOLOPT_FLAG_CLIENT_OPT))
return _gf_true;
@@ -6405,23 +6398,17 @@ gd_is_client_option(char *key)
}
gf_boolean_t
-gd_is_xlator_option(char *key)
+gd_is_xlator_option(struct volopt_map_entry *vmep)
{
- struct volopt_map_entry *vmep = NULL;
-
- GF_ASSERT(key);
-
- vmep = _gd_get_vmep(key);
if (vmep && (vmep->flags & VOLOPT_FLAG_XLATOR_OPT))
return _gf_true;
return _gf_false;
}
-volume_option_type_t
-_gd_get_option_type(char *key)
+static volume_option_type_t
+_gd_get_option_type(struct volopt_map_entry *vmep)
{
- struct volopt_map_entry *vmep = NULL;
void *dl_handle = NULL;
volume_opt_list_t vol_opt_list = {
{0},
@@ -6431,10 +6418,6 @@ _gd_get_option_type(char *key)
char *xlopt_key = NULL;
volume_option_type_t opt_type = GF_OPTION_TYPE_MAX;
- GF_ASSERT(key);
-
- vmep = _gd_get_vmep(key);
-
if (vmep) {
CDS_INIT_LIST_HEAD(&vol_opt_list.list);
ret = xlator_volopt_dynload(vmep->voltype, &dl_handle, &vol_opt_list);
@@ -6461,11 +6444,9 @@ out:
}
gf_boolean_t
-gd_is_boolean_option(char *key)
+gd_is_boolean_option(struct volopt_map_entry *vmep)
{
- GF_ASSERT(key);
-
- if (GF_OPTION_TYPE_BOOL == _gd_get_option_type(key))
+ if (GF_OPTION_TYPE_BOOL == _gd_get_option_type(vmep))
return _gf_true;
return _gf_false;