From 599c6b472869cfaf0058e7b169de204450a41948 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Tue, 30 Apr 2013 13:03:08 +0530 Subject: glusterd-volgen: Improve volume op-versions calculation Volume op-versions calculations now take into account if an option, a. enables/disables an xlator, or b. is a boolean option. This prevents op-versions from being updated when a feature is disabled. Also, correctly close the dynamically loaded xlators in xlator_volopt_dynload() and prevent leaks. Change-Id: I895ddeeec6f6a33e509325f0ce6f01b7aad3cf5c BUG: 954256 Signed-off-by: Kaushal M Reviewed-on: http://review.gluster.org/4952 Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/options.c | 3 +-- libglusterfs/src/options.h | 3 +++ libglusterfs/src/xlator.c | 29 +++++------------------------ 3 files changed, 9 insertions(+), 26 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c index 5d436bab..842b6413 100644 --- a/libglusterfs/src/options.c +++ b/libglusterfs/src/options.c @@ -761,7 +761,7 @@ out: } -static volume_option_t * +volume_option_t * xlator_volume_option_get_list (volume_opt_list_t *vol_list, const char *key) { volume_option_t *opt = NULL; @@ -1098,7 +1098,6 @@ pc_or_size (char *in, double *out) return ret; } - DEFINE_INIT_OPT(char *, str, pass); DEFINE_INIT_OPT(uint64_t, uint64, gf_string2uint64); DEFINE_INIT_OPT(int64_t, int64, gf_string2int64); diff --git a/libglusterfs/src/options.h b/libglusterfs/src/options.h index 64c2c64e..e2a25baa 100644 --- a/libglusterfs/src/options.h +++ b/libglusterfs/src/options.h @@ -93,6 +93,9 @@ int xlator_options_validate (xlator_t *xl, dict_t *options, char **errstr); volume_option_t * xlator_volume_option_get (xlator_t *xl, const char *key); +volume_option_t * +xlator_volume_option_get_list (volume_opt_list_t *vol_list, const char *key); + #define DECLARE_INIT_OPT(type_t, type) \ int \ diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 348f48c4..d8997bc7 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -119,18 +119,9 @@ xlator_volopt_dynload (char *xlator_type, void **dl_handle, int ret = -1; char *name = NULL; void *handle = NULL; - volume_opt_list_t *vol_opt = NULL; GF_VALIDATE_OR_GOTO ("xlator", xlator_type, out); - GF_ASSERT (dl_handle); - - if (*dl_handle) - if (dlclose (*dl_handle)) - gf_log ("xlator", GF_LOG_WARNING, "Unable to close " - "previously opened handle( may be stale)." - "Ignoring the invalid handle"); - ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, xlator_type); if (-1 == ret) { gf_log ("xlator", GF_LOG_ERROR, "asprintf failed"); @@ -146,25 +137,15 @@ xlator_volopt_dynload (char *xlator_type, void **dl_handle, gf_log ("xlator", GF_LOG_WARNING, "%s", dlerror ()); goto out; } - *dl_handle = handle; - - vol_opt = GF_CALLOC (1, sizeof (volume_opt_list_t), - gf_common_mt_volume_opt_list_t); - - if (!vol_opt) { - goto out; - } - - if (!(vol_opt->given_opt = dlsym (handle, "options"))) { + if (!(opt_list->given_opt = dlsym (handle, "options"))) { dlerror (); - gf_log ("xlator", GF_LOG_DEBUG, - "Strict option validation not enforced -- neglecting"); + gf_log ("xlator", GF_LOG_ERROR, + "Failed to load xlator opt table"); + goto out; } - opt_list->given_opt = vol_opt->given_opt; - INIT_LIST_HEAD (&vol_opt->list); - list_add_tail (&vol_opt->list, &opt_list->list); + *dl_handle = handle; ret = 0; out: -- cgit