diff options
author | Krishnan Parthasarathi <kparthas@redhat.com> | 2012-07-24 12:44:11 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2012-12-12 00:12:41 -0500 |
commit | c2d72cb5bd9084786ceff03e4df032541461e183 (patch) | |
tree | d18499885ced207bae9453a6323de631f242d1c9 /xlators | |
parent | a383a1e8e6099f1ad5545b1298a750a66c5ae42f (diff) |
glusterd: Persisted hooks friendly user.* keys
- Fixed validation of user.* keys in presence of multiple key, value
pairs in a single volume set command
Change-Id: I5b96de2d009fbc79772121308d9b4c0a552bac52
BUG: 825902
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.com/3715
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/1855
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-hooks.h | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 28 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 44 |
3 files changed, 45 insertions, 33 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-hooks.h b/xlators/mgmt/glusterd/src/glusterd-hooks.h index e717395be40..2584b6bfeb0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-hooks.h +++ b/xlators/mgmt/glusterd/src/glusterd-hooks.h @@ -60,15 +60,13 @@ typedef struct hooks_stub { static inline gf_boolean_t -is_key_glusterd_hooks_friendly (xlator_t *this, char *volname, char *key) +is_key_glusterd_hooks_friendly (char *key) { gf_boolean_t is_friendly = _gf_false; /* This is very specific to hooks friendly behavior */ if (fnmatch (GD_HOOKS_SPECIFIC_KEY, key, FNM_NOESCAPE) == 0) { - gf_log (this->name, GF_LOG_DEBUG, - "user configured key (%s) sent on volume %s", - key, volname); + gf_log (THIS->name, GF_LOG_DEBUG, "user namespace key %s", key); is_friendly = _gf_true; } diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index fedb9458882..79627c637a9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -457,10 +457,8 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) goto out; } - if (is_key_glusterd_hooks_friendly (this, volname, key)) { - ret = 0; - goto out; - } + if (is_key_glusterd_hooks_friendly (key)) + continue; exists = glusterd_check_option_exists (key, &key_fixed); if (exists == -1) { @@ -492,8 +490,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) if (ret) goto out; - ret = glusterd_check_globaloption (key); - if (ret) + if (glusterd_check_globaloption (key)) global_opt = _gf_true; ret = dict_set_str (val_dict, key, value); @@ -1384,20 +1381,17 @@ glusterd_op_set_volume (dict_t *dict) goto out; } - if (is_key_glusterd_hooks_friendly (this, volname, key)) { - ret = 0; - goto out; - } + if (!is_key_glusterd_hooks_friendly (key)) { + ret = glusterd_check_option_exists (key, &key_fixed); + GF_ASSERT (ret); + if (ret <= 0) { + key_fixed = NULL; + 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) + if (glusterd_check_globaloption (key)) global_opt = _gf_true; if (!global_opt) diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index cc7b54a18fc..d13e31fb7ba 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -42,6 +42,7 @@ #include "glusterd-sm.h" #include "glusterd-op-sm.h" #include "glusterd-utils.h" +#include "glusterd-hooks.h" #include "glusterd-store.h" #include "rpc-clnt.h" @@ -545,10 +546,17 @@ void _storeopts (dict_t *this, char *key, data_t *value, void *data) if (!value || !value->data) return; - exists = glusterd_check_option_exists (key, NULL); + if (is_key_glusterd_hooks_friendly (key)) { + exists = 1; + + } else { + exists = glusterd_check_option_exists (key, NULL); + } + if (1 == exists) { gf_log ("", GF_LOG_DEBUG, "Storing in volinfo:key= %s, val=%s", key, value->data); + } else { gf_log ("", GF_LOG_DEBUG, "Discarding:key= %s, val=%s", key, value->data); @@ -2060,27 +2068,39 @@ glusterd_store_retrieve_volume (char *volname) } gf_log ("", GF_LOG_DEBUG, "Parsed as "GEOREP" " " slave:key=%s,value:%s", key, value); + } else { - exists = glusterd_check_option_exists (key, NULL); - if (exists == -1) { + + if (is_key_glusterd_hooks_friendly (key)) { + exists = 1; + + } else { + exists = glusterd_check_option_exists (key, + NULL); + } + + switch (exists) { + case -1: ret = -1; goto out; - } - if (exists) { + + case 0: + gf_log ("", GF_LOG_ERROR, "Unknown key: %s", + key); + break; + + case 1: ret = dict_set_str(volinfo->dict, key, - gf_strdup (value)); + gf_strdup (value)); if (ret) { gf_log ("",GF_LOG_ERROR, "Error in " - "dict_set_str"); + "dict_set_str"); goto out; } gf_log ("", GF_LOG_DEBUG, "Parsed as Volume-" - "set:key=%s,value:%s", - key, value); + "set:key=%s,value:%s", key, value); + break; } - else - gf_log ("", GF_LOG_ERROR, "Unknown key: %s", - key); } GF_FREE (key); |