diff --git a/configure.d/1_module_mutex.conf b/configure.d/1_module_mutex.conf new file mode 100644 index 0000000..d8cc307 --- /dev/null +++ b/configure.d/1_module_mutex.conf @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Copyright(c) 2022 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause +# + +. $(dirname $3)/conf_framework + + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "mutex_lock(&module_mutex);" "linux/module.h" + then + echo $cur_name 1 >> $config_file_path + else + echo $cur_name 2 >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_define "MODULE_MUTEX_SUPPORTED 1" ;; + "2") + ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/modules/cas_cache/main.c b/modules/cas_cache/main.c index 2b4a4fd..3bebeb7 100644 --- a/modules/cas_cache/main.c +++ b/modules/cas_cache/main.c @@ -46,7 +46,7 @@ MODULE_PARM_DESC(seq_cut_off_mb, ocf_ctx_t cas_ctx; struct casdsk_functions_mapper casdisk_functions; -#ifdef SYMBOL_LOOKUP_SUPPORTED +#if defined(SYMBOL_LOOKUP_SUPPORTED) && defined(MODULE_MUTEX_SUPPORTED) struct exported_symbol { char *name; @@ -83,7 +83,9 @@ int static cas_find_symbol(void *data, const char *namebuf, int static cas_casdisk_lookup_funtions(void) { +#ifdef MODULE_MUTEX_SUPPORTED mutex_lock(&module_mutex); +#endif cas_lookup_symbol(casdsk_disk_detach); cas_lookup_symbol(casdsk_exp_obj_destroy); cas_lookup_symbol(casdsk_exp_obj_create); @@ -105,7 +107,9 @@ int static cas_casdisk_lookup_funtions(void) cas_lookup_symbol(casdsk_disk_open); cas_lookup_symbol(casdsk_disk_clear_pt); cas_lookup_symbol(casdsk_exp_obj_get_gendisk); +#ifdef MODULE_MUTEX_SUPPORTED mutex_unlock(&module_mutex); +#endif return 0; }