summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.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-utils.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-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index a33f28a80fe..6b44ebd4b13 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -12141,20 +12141,22 @@ glusterd_copy_uuid_to_dict(uuid_t uuid, dict_t *dict, char *key,
return 0;
}
-int
+static int
_update_volume_op_versions(dict_t *this, char *key, data_t *value, void *data)
{
int op_version = 0;
glusterd_volinfo_t *ctx = NULL;
gf_boolean_t enabled = _gf_true;
int ret = -1;
+ struct volopt_map_entry *vmep = NULL;
GF_ASSERT(data);
ctx = data;
- op_version = glusterd_get_op_version_for_key(key);
+ vmep = gd_get_vmep(key);
+ op_version = glusterd_get_op_version_from_vmep(vmep);
- if (gd_is_xlator_option(key) || gd_is_boolean_option(key)) {
+ if (gd_is_xlator_option(vmep) || gd_is_boolean_option(vmep)) {
ret = gf_string2boolean(value->data, &enabled);
if (ret)
return 0;
@@ -12166,7 +12168,7 @@ _update_volume_op_versions(dict_t *this, char *key, data_t *value, void *data)
if (op_version > ctx->op_version)
ctx->op_version = op_version;
- if (gd_is_client_option(key) && (op_version > ctx->client_op_version))
+ if (gd_is_client_option(vmep) && (op_version > ctx->client_op_version))
ctx->client_op_version = op_version;
return 0;