From af7e957b4954bd84b8f7df6bfbd59c939092ead2 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Thu, 6 Dec 2018 16:24:52 +0530 Subject: xlator: make 'xlator_api' mandatory * Remove the options to load old symbol. * keep only 'xlator_api' symbol from being exported using xlator.sym * add xlator_api to all the xlators where its missing NOTE: This covers all the xlators which has at least a test case to validate its loading. If there is a translator, which doesn't have any test, then we should probably remove that from codebase. fixes: #164 Change-Id: Ibcdc8c9844cda6b4463d907a15813745d14c1ebb Signed-off-by: Amar Tumballi --- libglusterfs/src/glusterfs/xlator.h | 7 -- libglusterfs/src/xlator.c | 154 ++++-------------------------------- 2 files changed, 16 insertions(+), 145 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/glusterfs/xlator.h b/libglusterfs/src/glusterfs/xlator.h index 12d507bc021..0c39f4bd3cc 100644 --- a/libglusterfs/src/glusterfs/xlator.h +++ b/libglusterfs/src/glusterfs/xlator.h @@ -866,13 +866,6 @@ struct _xlator { uint32_t notify_down; }; -typedef struct { - int32_t (*init)(xlator_t *this); - void (*fini)(xlator_t *this); - int32_t (*reconfigure)(xlator_t *this, dict_t *options); - event_notify_fn_t notify; -} class_methods_t; - /* This would be the only structure which needs to be exported by the translators. For the backward compatibility, in 4.x series even the old exported fields will be supported */ diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 13213d55994..3dc0c648177 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -214,26 +214,16 @@ xlator_volopt_dynload(char *xlator_type, void **dl_handle, /* check new struct first, and then check this */ xlapi = dlsym(handle, "xlator_api"); if (!xlapi) { - gf_msg("xlator", GF_LOG_DEBUG, 0, LG_MSG_DLSYM_ERROR, - "dlsym(xlator_api) on %s. " - "Fall back to old symbols", - dlerror()); - /* This case is not an error for now, so allow it - to fall back to old methods. */ - opt_list->given_opt = dlsym(handle, "options"); - if (!opt_list->given_opt) { - dlerror(); - gf_msg("xlator", GF_LOG_ERROR, 0, LG_MSG_LOAD_FAILED, - "Failed to load xlator opt table"); - goto out; - } - } else { - opt_list->given_opt = xlapi->options; - if (!opt_list->given_opt) { - gf_msg("xlator", GF_LOG_ERROR, 0, LG_MSG_LOAD_FAILED, - "Failed to load xlator options table"); - goto out; - } + gf_msg("xlator", GF_LOG_ERROR, 0, LG_MSG_DLSYM_ERROR, + "dlsym(xlator_api) missing: %s", dlerror()); + goto out; + } + + opt_list->given_opt = xlapi->options; + if (!opt_list->given_opt) { + gf_msg("xlator", GF_LOG_ERROR, 0, LG_MSG_LOAD_FAILED, + "Failed to load xlator options table"); + goto out; } *dl_handle = handle; @@ -249,110 +239,8 @@ out: return ret; } -int -xlator_dynload_oldway(xlator_t *xl) -{ - int i = 0; - int ret = -1; - void *handle = NULL; - volume_opt_list_t *vol_opt = NULL; - class_methods_t *vtbl = NULL; - - handle = xl->dlhandle; - - xl->fops = dlsym(handle, "fops"); - if (!xl->fops) { - gf_msg("xlator", GF_LOG_WARNING, 0, LG_MSG_DLSYM_ERROR, - "dlsym(fops) on %s", dlerror()); - goto out; - } - - xl->cbks = dlsym(handle, "cbks"); - if (!xl->cbks) { - gf_msg("xlator", GF_LOG_WARNING, 0, LG_MSG_DLSYM_ERROR, - "dlsym(cbks) on %s", dlerror()); - goto out; - } - - /* - * If class_methods exists, its contents override any definitions of - * init or fini for that translator. Otherwise, we fall back to the - * older method of looking for init and fini directly. - */ - vtbl = dlsym(handle, "class_methods"); - if (vtbl) { - xl->init = vtbl->init; - xl->fini = vtbl->fini; - xl->reconfigure = vtbl->reconfigure; - xl->notify = vtbl->notify; - } else { - if (!(*VOID(&xl->init) = dlsym(handle, "init"))) { - gf_msg("xlator", GF_LOG_WARNING, 0, LG_MSG_DLSYM_ERROR, - "dlsym(init) on %s", dlerror()); - goto out; - } - - if (!(*VOID(&(xl->fini)) = dlsym(handle, "fini"))) { - gf_msg("xlator", GF_LOG_WARNING, 0, LG_MSG_DLSYM_ERROR, - "dlsym(fini) on %s", dlerror()); - goto out; - } - if (!(*VOID(&(xl->reconfigure)) = dlsym(handle, "reconfigure"))) { - gf_msg_trace("xlator", 0, - "dlsym(reconfigure) on %s " - "-- neglecting", - dlerror()); - } - if (!(*VOID(&(xl->notify)) = dlsym(handle, "notify"))) { - gf_msg_trace("xlator", 0, - "dlsym(notify) on %s -- " - "neglecting", - dlerror()); - } - } - - if (!(xl->dumpops = dlsym(handle, "dumpops"))) { - gf_msg_trace("xlator", 0, - "dlsym(dumpops) on %s -- " - "neglecting", - dlerror()); - } - - if (!(*VOID(&(xl->mem_acct_init)) = dlsym(handle, "mem_acct_init"))) { - gf_msg_trace(xl->name, 0, - "dlsym(mem_acct_init) on %s -- " - "neglecting", - dlerror()); - } - - vol_opt = GF_CALLOC(1, sizeof(volume_opt_list_t), - gf_common_mt_volume_opt_list_t); - - if (!vol_opt) { - goto out; - } - - INIT_LIST_HEAD(&vol_opt->list); - vol_opt->given_opt = dlsym(handle, "options"); - if (!vol_opt->given_opt) { - vol_opt->given_opt = default_options; - } - list_add_tail(&vol_opt->list, &xl->volume_options); - - /* make sure 'min' is set to high value, so it would be - properly set later */ - for (i = 0; i < GF_FOP_MAXVALUE; i++) { - xl->stats.interval.latencies[i].min = 0xffffffff; - } - - ret = 0; - -out: - return ret; -} - -int -xlator_dynload_newway(xlator_t *xl) +static int +xlator_dynload_apis(xlator_t *xl) { int ret = -1; void *handle = NULL; @@ -363,13 +251,9 @@ xlator_dynload_newway(xlator_t *xl) xlapi = dlsym(handle, "xlator_api"); if (!xlapi) { - gf_msg("xlator", GF_LOG_INFO, 0, LG_MSG_DLSYM_ERROR, - "dlsym(xlator_api) on %s. " - "Fall back to old symbols", - dlerror()); - /* This case is not an error for now, so allow it - to fall back to old methods. */ - ret = 1; + gf_msg("xlator", GF_LOG_ERROR, 0, LG_MSG_DLSYM_ERROR, + "dlsym(xlator_api) missing: %s", dlerror()); + ret = -1; goto out; } @@ -492,15 +376,9 @@ xlator_dynload(xlator_t *xl) } xl->dlhandle = handle; - ret = xlator_dynload_newway(xl); + ret = xlator_dynload_apis(xl); if (-1 == ret) goto out; - if (1 == ret) { - /* it means we don't find the new symbol in xlator code */ - ret = xlator_dynload_oldway(xl); - if (-1 == ret) - goto out; - } fill_defaults(xl); -- cgit