diff --git a/configure b/configure index 62ec6e5..84085f0 100755 --- a/configure +++ b/configure @@ -19,35 +19,55 @@ SCRIPTPATH=`realpath $SCRIPTPATH` CONFIG_FILES=`ls $SCRIPTPATH/configure.d/*.conf | sort` FILES_COUNT=`echo $CONFIG_FILES | wc -w` +CONFIG_FILE="config.out" + generate_config() { - rm -f config.out - progress=0 - for file in $CONFIG_FILES; do - progress=$((progress+1)) - echo -ne "Generating configuration: $progress/$FILES_COUNT\033[0K\r" - CONF="$(/bin/bash $file "check")" - echo "$(basename $file) $CONF" >> config.out - done - echo "" + rm -f ${CONFIG_FILE} + touch ${CONFIG_FILE} + declare -a pid_list + progress=0 + + # Compile each test module in backgorund + echo "Preparing configuration" + for file in $CONFIG_FILES; do + progress=$((progress+1)) + # $1 - Action to be performed + # $2 - File with stored configuration + # $3 - Name of called script (since script is running as subprocess + # it has to be passed explicitly + source $file "check" "${SCRIPTPATH}/${CONFIG_FILE}" "$file" & + pid_list+=($!) + done + + # Wait for all compilation processes to finish + for i in "${pid_list[@]}"; do + wait $i &> /dev/null + done + + grep "X" ${SCRIPTPATH}/${CONFIG_FILE} &> /dev/null + if [ $? -eq 0 ] ; then + echo "ERROR! Following steps failed while preparing config:" + grep "X" ${SCRIPTPATH}/${CONFIG_FILE} | cut -f1 -d ' ' + exit 1 + fi } generate_header() { - rm -f $SCRIPTPATH/modules/generated_defines.h - progress=0 - for file in $CONFIG_FILES; do - progress=$((progress+1)) - echo -ne "Configuring OpenCAS: $progress/$FILES_COUNT\033[0K\r" - CONF=$(cat config.out | awk -v file=$(basename $file) '{ if ($1 == file) print $2 }') - /bin/bash $file "apply" "$CONF" - done - echo "" + rm -f $SCRIPTPATH/modules/generated_defines.h + progress=0 + for file in $CONFIG_FILES; do + progress=$((progress+1)) + echo -ne "Configuring OpenCAS: $progress/$FILES_COUNT\033[0K\r" + CONF=$(cat ${CONFIG_FILE} | awk -v file=$(basename $file) '{ if ($1 == file) print $2 }') + /bin/bash $file "apply" "$CONF" "$file" + done + echo "" } if [ -z "$1" ]; then - generate_config - CONFIG_FILE="config.out" + generate_config else - CONFIG_FILE="$1" + CONFIG_FILE="$1" fi generate_header diff --git a/configure.d/1_append_bio.conf b/configure.d/1_append_bio.conf index 64b9de9..903a709 100644 --- a/configure.d/1_append_bio.conf +++ b/configure.d/1_append_bio.conf @@ -4,14 +4,17 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework + check() { - if compile_module "struct bio *b;blk_rq_append_bio(NULL, &b)" "linux/blkdev.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct bio *b;blk_rq_append_bio(NULL, &b)" "linux/blkdev.h" then - echo "1" + echo $cur_name 1 >> $config_file_path else - echo "2" + echo $cur_name 2 >> $config_file_path fi } diff --git a/configure.d/1_bdev_lookup.conf b/configure.d/1_bdev_lookup.conf index 5d08334..037d00c 100644 --- a/configure.d/1_bdev_lookup.conf +++ b/configure.d/1_bdev_lookup.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "lookup_bdev(\"some_path\")" "linux/fs.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "lookup_bdev(\"some_path\")" "linux/fs.h" then - echo "1" - elif compile_module "lookup_bdev(\"some_path\", 0)" "linux/fs.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "lookup_bdev(\"some_path\", 0)" "linux/fs.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_bio_clone.conf b/configure.d/1_bio_clone.conf index 9a00cf2..aa0c5a9 100644 --- a/configure.d/1_bio_clone.conf +++ b/configure.d/1_bio_clone.conf @@ -4,20 +4,22 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "bio_clone(NULL, 0)" "linux/bio.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "bio_clone(NULL, 0)" "linux/bio.h" then - echo "1" - elif compile_module "bio_clone_kmalloc(NULL, 0)" "linux/bio.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "bio_clone_kmalloc(NULL, 0)" "linux/bio.h" then - echo "2" - elif compile_module "bio_clone_fast(NULL, 0, NULL)" "linux/bio.h" + echo $cur_name "2" >> $config_file_path + elif compile_module $cur_name "bio_clone_fast(NULL, 0, NULL)" "linux/bio.h" then - echo "3" + echo $cur_name "3" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_bio_cmpl.conf b/configure.d/1_bio_cmpl.conf index 90c79de..71100f6 100644 --- a/configure.d/1_bio_cmpl.conf +++ b/configure.d/1_bio_cmpl.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "struct bio b;b.bi_end_io(NULL, 0)" "linux/bio.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct bio b;b.bi_end_io(NULL, 0)" "linux/bio.h" then - echo "1" - elif compile_module "struct bio b;b.bi_end_io(NULL)" "linux/bio.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "struct bio b;b.bi_end_io(NULL)" "linux/bio.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_bio_discard.conf b/configure.d/1_bio_discard.conf index 9fa2d7a..56c87c2 100644 --- a/configure.d/1_bio_discard.conf +++ b/configure.d/1_bio_discard.conf @@ -4,22 +4,25 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework + check() { - if compile_module "bio_op(NULL)" "linux/bio.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "bio_op(NULL)" "linux/bio.h" then - echo "1" - elif compile_module "REQ_OP_MASK" "linux/blk_types.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "REQ_OP_MASK" "linux/blk_types.h" then - echo "2" - elif compile_module "REQ_OP_DISCARD" "linux/blk_types.h" + echo $cur_name "2" >> $config_file_path + elif compile_module $cur_name "REQ_OP_DISCARD" "linux/blk_types.h" then - echo "3" - elif compile_module "REQ_DISCARD" "linux/blk_types.h" + echo $cur_name "3" >> $config_file_path + elif compile_module $cur_name "REQ_DISCARD" "linux/blk_types.h" then - echo "4" + echo $cur_name "4" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_bio_err.conf b/configure.d/1_bio_err.conf index 5adf64e..da764cf 100644 --- a/configure.d/1_bio_err.conf +++ b/configure.d/1_bio_err.conf @@ -4,17 +4,17 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "struct bio b;b.bi_status" "linux/bio.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct bio b;b.bi_status" "linux/bio.h" then - echo "1" - elif compile_module "struct bio b;b.bi_error" "linux/bio.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "struct bio b;b.bi_error" "linux/bio.h" then - echo "2" - else - echo "X" + echo $cur_name "2" >> $config_file_path fi } diff --git a/configure.d/1_bio_flags.conf b/configure.d/1_bio_flags.conf index 0c04f0d..f0e35ad 100644 --- a/configure.d/1_bio_flags.conf +++ b/configure.d/1_bio_flags.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "struct bio b;b.bi_opf" "linux/bio.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct bio b;b.bi_opf" "linux/bio.h" then - echo "1" - elif compile_module "struct bio b;b.bi_rw" "linux/bio.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "struct bio b;b.bi_rw" "linux/bio.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_bio_iter.conf b/configure.d/1_bio_iter.conf index 855e83e..4efbda7 100644 --- a/configure.d/1_bio_iter.conf +++ b/configure.d/1_bio_iter.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "struct bio b;b.bi_iter.bi_size" "linux/bio.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct bio b;b.bi_iter.bi_size" "linux/bio.h" then - echo "1" - elif compile_module "struct bio b;b.bi_size" "linux/bio.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "struct bio b;b.bi_size" "linux/bio.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_biovec.conf b/configure.d/1_biovec.conf index c75a33b..ceb30db 100644 --- a/configure.d/1_biovec.conf +++ b/configure.d/1_biovec.conf @@ -4,14 +4,16 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "struct bio b;&bio_iovec(&b)" "linux/bio.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct bio b;&bio_iovec(&b)" "linux/bio.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi } diff --git a/configure.d/1_block_pc.conf b/configure.d/1_block_pc.conf index 49de88c..d12e27e 100644 --- a/configure.d/1_block_pc.conf +++ b/configure.d/1_block_pc.conf @@ -4,14 +4,16 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "blk_rq_set_block_pc(NULL)" "linux/blkdev.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "blk_rq_set_block_pc(NULL)" "linux/blkdev.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi } diff --git a/configure.d/1_deamonize.conf b/configure.d/1_deamonize.conf index 1f5db26..0e40cbb 100644 --- a/configure.d/1_deamonize.conf +++ b/configure.d/1_deamonize.conf @@ -4,14 +4,16 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "deamonize(\"some_name\", NULL)" "linux/sched.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "deamonize(\"some_name\", NULL)" "linux/sched.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi } diff --git a/configure.d/1_dentry.conf b/configure.d/1_dentry.conf index 0c285c0..bcf8c9f 100644 --- a/configure.d/1_dentry.conf +++ b/configure.d/1_dentry.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "struct dentry dentry;dentry.d_u.d_alias" "linux/dcache.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct dentry dentry;dentry.d_u.d_alias" "linux/dcache.h" then - echo "1" - elif compile_module "struct dentry dentry;dentry.d_alias" "linux/dcache.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "struct dentry dentry;dentry.d_alias" "linux/dcache.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_discard_zeros.conf b/configure.d/1_discard_zeros.conf index b28e50a..a2b9333 100644 --- a/configure.d/1_discard_zeros.conf +++ b/configure.d/1_discard_zeros.conf @@ -4,14 +4,16 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "struct queue_limits q;q.discard_zeroes_data" "linux/blkdev.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct queue_limits q;q.discard_zeroes_data" "linux/blkdev.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi } diff --git a/configure.d/1_flush_flag.conf b/configure.d/1_flush_flag.conf index 83f677d..688ace5 100644 --- a/configure.d/1_flush_flag.conf +++ b/configure.d/1_flush_flag.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "REQ_PREFLUSH" "linux/blk_types.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "REQ_PREFLUSH" "linux/blk_types.h" then - echo "1" - elif compile_module "REQ_FLUSH" "linux/blk_types.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "REQ_FLUSH" "linux/blk_types.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_generic_acct.conf b/configure.d/1_generic_acct.conf index 2525ded..cb4515f 100644 --- a/configure.d/1_generic_acct.conf +++ b/configure.d/1_generic_acct.conf @@ -4,23 +4,25 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "generic_start_io_acct(NULL, 0, 0, NULL)" "linux/bio.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "generic_start_io_acct(NULL, 0, 0, NULL)" "linux/bio.h" then - echo "1" - elif compile_module "generic_start_io_acct(0, 0, NULL)" "linux/bio.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "generic_start_io_acct(0, 0, NULL)" "linux/bio.h" then - echo "2" - elif compile_module "part_round_stats(1, 1)" "linux/genhd.h" + echo $cur_name "2" >> $config_file_path + elif compile_module $cur_name "part_round_stats(1, 1)" "linux/genhd.h" then - echo "3" - elif compile_module "part_round_stats(NULL, 1, 1)" "linux/genhd.h" + echo $cur_name "3" >> $config_file_path + elif compile_module $cur_name "part_round_stats(NULL, 1, 1)" "linux/genhd.h" then - echo "4" + echo $cur_name "4" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_global_page_state.conf b/configure.d/1_global_page_state.conf index 5332cc2..d4d6901 100644 --- a/configure.d/1_global_page_state.conf +++ b/configure.d/1_global_page_state.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "global_zone_page_state(1)" "linux/mm.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "global_zone_page_state(1)" "linux/mm.h" then - echo "1" - elif compile_module "global_page_state(1)" "linux/mm.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "global_page_state(1)" "linux/mm.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_hlist.conf b/configure.d/1_hlist.conf index d60e19e..f888b03 100644 --- a/configure.d/1_hlist.conf +++ b/configure.d/1_hlist.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "struct hlist_node list" "linux/types.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct hlist_node list" "linux/types.h" then - echo "1" - elif compile_module "struct list_head list" "linux/list.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "struct list_head list" "linux/list.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_inode.conf b/configure.d/1_inode.conf index e89bfa1..ca06a83 100644 --- a/configure.d/1_inode.conf +++ b/configure.d/1_inode.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "struct file file;file.f_inode" "linux/fs.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct file file;file.f_inode" "linux/fs.h" then - echo "1" - elif compile_module "struct file file;file->f_dentry->d_inode" "linux/fs.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "struct file file;file->f_dentry->d_inode" "linux/fs.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_munmap.conf b/configure.d/1_munmap.conf index 895dadf..b6cff97 100644 --- a/configure.d/1_munmap.conf +++ b/configure.d/1_munmap.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "vm_munmap(0, 0)" "linux/mm.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "vm_munmap(0, 0)" "linux/mm.h" then - echo "1" - elif compile_module "do_munmap(NULL, 0)" "linux/mm.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "do_munmap(NULL, 0)" "linux/mm.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_queue_bounce.conf b/configure.d/1_queue_bounce.conf index 4aee459..88d5c6a 100644 --- a/configure.d/1_queue_bounce.conf +++ b/configure.d/1_queue_bounce.conf @@ -4,14 +4,16 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "blk_queue_bounce(NULL, NULL);" "linux/blkdev.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "blk_queue_bounce(NULL, NULL);" "linux/blkdev.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi } diff --git a/configure.d/1_queue_chunk_sectors.conf b/configure.d/1_queue_chunk_sectors.conf index a04187b..be9c5ab 100644 --- a/configure.d/1_queue_chunk_sectors.conf +++ b/configure.d/1_queue_chunk_sectors.conf @@ -4,14 +4,16 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "struct request_queue q;q.limits.chunk_sectors" "linux/blkdev.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct request_queue q;q.limits.chunk_sectors" "linux/blkdev.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi } diff --git a/configure.d/1_queue_flag_set.conf b/configure.d/1_queue_flag_set.conf index 1388e13..9308474 100644 --- a/configure.d/1_queue_flag_set.conf +++ b/configure.d/1_queue_flag_set.conf @@ -4,14 +4,16 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "blk_queue_flag_set(0, NULL)" "linux/blkdev.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "blk_queue_flag_set(0, NULL)" "linux/blkdev.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi } diff --git a/configure.d/1_queue_limits.conf b/configure.d/1_queue_limits.conf index 06cf53d..3827547 100644 --- a/configure.d/1_queue_limits.conf +++ b/configure.d/1_queue_limits.conf @@ -4,21 +4,23 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework # RHEL 7.3 check() { - if compile_module "struct queue_limits q;q.limits_aux" "linux/blkdev.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct queue_limits q;q.limits_aux" "linux/blkdev.h" then - echo "1" - elif compile_module "struct queue_limits q;q.max_write_zeroes_sectors" "linux/blkdev.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "struct queue_limits q;q.max_write_zeroes_sectors" "linux/blkdev.h" then - echo "2" - elif compile_module "struct queue_limits q;q.max_write_same_sectors" "linux/blkdev.h" + echo $cur_name "2" >> $config_file_path + elif compile_module $cur_name "struct queue_limits q;q.max_write_same_sectors" "linux/blkdev.h" then - echo "3" + echo $cur_name "3" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_req_fs.conf b/configure.d/1_req_fs.conf index ba95802..8faf779 100644 --- a/configure.d/1_req_fs.conf +++ b/configure.d/1_req_fs.conf @@ -4,14 +4,16 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "REQ_TYPE_FS" "linux/blkdev.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "REQ_TYPE_FS" "linux/blkdev.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi } diff --git a/configure.d/1_submit_bio.conf b/configure.d/1_submit_bio.conf index 867ee94..42c911e 100644 --- a/configure.d/1_submit_bio.conf +++ b/configure.d/1_submit_bio.conf @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework # submit_bio() can be defined in "bio.h" or in "fs.h" # If it is defind in fs.h, three possibilities are available: @@ -12,20 +12,22 @@ # * it takes two arguments and returns non-void # * it takse two arguments and is void-type check() { - if compile_module "submit_bio(NULL)" "linux/bio.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "submit_bio(NULL)" "linux/bio.h" then - echo "1" - elif compile_module "submit_bio(NULL)" "linux/fs.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "submit_bio(NULL)" "linux/fs.h" then - echo "2" - elif compile_module "void *t=submit_bio(0, NULL)" "linux/fs.h" + echo $cur_name "2" >> $config_file_path + elif compile_module $cur_name "void *t=submit_bio(0, NULL)" "linux/fs.h" then - echo "3" - elif compile_module "submit_bio(0, NULL)" "linux/fs.h" + echo $cur_name "4" >> $config_file_path + elif compile_module $cur_name "submit_bio(0, NULL)" "linux/fs.h" then - echo "4" + echo $cur_name "4" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_whlt.conf b/configure.d/1_whlt.conf deleted file mode 100644 index d4bc1ee..0000000 --- a/configure.d/1_whlt.conf +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# Copyright(c) 2012-2019 Intel Corporation -# SPDX-License-Identifier: BSD-3-Clause-Clear -# - -. `dirname $0`/conf_framework - -check() { - if compile_module "struct bio b;b.bi_write_hint" "linux/bio.h" - then - echo "1" - else - echo "X" - fi -} - -apply() { - case "$1" in - "1") - add_define "CAS_WLTH_SUPPORT \\ - 1" ;; - esac -} - -conf_run $@ diff --git a/configure.d/1_write_flag.conf b/configure.d/1_write_flag.conf index 94db6fc..db9ab62 100644 --- a/configure.d/1_write_flag.conf +++ b/configure.d/1_write_flag.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "WRITE" "linux/blk_types.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "WRITE" "linux/blk_types.h" then - echo "1" - elif compile_module "REQ_WRITE" "linux/blk_types.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "REQ_WRITE" "linux/blk_types.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/1_write_fua.conf b/configure.d/1_write_fua.conf index 1a51e8e..e32de73 100644 --- a/configure.d/1_write_fua.conf +++ b/configure.d/1_write_fua.conf @@ -4,22 +4,24 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "WRITE_FUA" "linux/fs.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "WRITE_FUA" "linux/fs.h" then - if compile_module "BIO_FUA" "linux/bio.h" + if compile_module $cur_name "BIO_FUA" "linux/bio.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi - elif compile_module "REQ_FUA" "linux/blk_types.h" + elif compile_module $cur_name "REQ_FUA" "linux/blk_types.h" then - echo "3" + echo $cur_name "3" >> $config_file_path else - echo "4" + echo $cur_name "4" >> $config_file_path fi } diff --git a/configure.d/1_wtlh.conf b/configure.d/1_wtlh.conf new file mode 100644 index 0000000..1589d34 --- /dev/null +++ b/configure.d/1_wtlh.conf @@ -0,0 +1,28 @@ +#!/bin/bash +# +# Copyright(c) 2012-2019 Intel Corporation +# SPDX-License-Identifier: BSD-3-Clause-Clear +# + +. $(dirname $3)/conf_framework + +check() { + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "struct bio b;b.bi_write_hint" "linux/bio.h" + then + echo $cur_name "1" >> $config_file_path + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_WLTH_SUPPORT \\ + 1" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/2_bio_barrier.conf b/configure.d/2_bio_barrier.conf index 94288a3..cfa1921 100644 --- a/configure.d/2_bio_barrier.conf +++ b/configure.d/2_bio_barrier.conf @@ -4,20 +4,22 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "RQF_SOFTBARRIER" "linux/blkdev.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "RQF_SOFTBARRIER" "linux/blkdev.h" then - echo "1" - elif compile_module "REQ_SOFTBARRIER" "linux/blk_types.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "REQ_SOFTBARRIER" "linux/blk_types.h" then - echo "2" - elif compile_module "BIO_RW_BARRIER" "linux/fs.h" + echo $cur_name "2" >> $config_file_path + elif compile_module $cur_name "BIO_RW_BARRIER" "linux/fs.h" then - echo "3" + echo $cur_name "3" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/2_flush_fua.conf b/configure.d/2_flush_fua.conf index 6d90825..3ee5bd7 100644 --- a/configure.d/2_flush_fua.conf +++ b/configure.d/2_flush_fua.conf @@ -4,22 +4,24 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "WRITE_FLUSH_FUA" "linux/fs.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "WRITE_FLUSH_FUA" "linux/fs.h" then - if compile_module "BIO_FUA" "linux/bio.h" + if compile_module $cur_name "BIO_FUA" "linux/bio.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi - elif compile_module "REQ_PREFLUSH" "linux/blk_types.h" + elif compile_module $cur_name "REQ_PREFLUSH" "linux/blk_types.h" then - echo "3" + echo $cur_name "3" >> $config_file_path else - echo "4" + echo $cur_name "4" >> $config_file_path fi } diff --git a/configure.d/2_make_req.conf b/configure.d/2_make_req.conf index a6ae16e..b604615 100644 --- a/configure.d/2_make_req.conf +++ b/configure.d/2_make_req.conf @@ -4,14 +4,16 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "blk_make_request(NULL, NULL, 0)" "linux/blkdev.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "blk_make_request(NULL, NULL, 0)" "linux/blkdev.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi } diff --git a/configure.d/2_queue_write.conf b/configure.d/2_queue_write.conf index 586ead2..b70510f 100644 --- a/configure.d/2_queue_write.conf +++ b/configure.d/2_queue_write.conf @@ -4,17 +4,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "blk_queue_write_cache(NULL, 0, 0)" "linux/blkdev.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "blk_queue_write_cache(NULL, 0, 0)" "linux/blkdev.h" then - echo "1" - elif compile_module "struct request_queue rq;rq.flush_flags" "linux/blkdev.h" + echo $cur_name "1" >> $config_file_path + elif compile_module $cur_name "struct request_queue rq;rq.flush_flags" "linux/blkdev.h" then - echo "2" + echo $cur_name "2" >> $config_file_path else - echo "X" + echo $cur_name "X" >> $config_file_path fi } diff --git a/configure.d/2_write_flush.conf b/configure.d/2_write_flush.conf index bf0c3d6..28556b4 100644 --- a/configure.d/2_write_flush.conf +++ b/configure.d/2_write_flush.conf @@ -4,22 +4,24 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -. `dirname $0`/conf_framework +. $(dirname $3)/conf_framework check() { - if compile_module "WRITE_FLUSH" "linux/fs.h" + cur_name=$(basename $2) + config_file_path=$1 + if compile_module $cur_name "WRITE_FLUSH" "linux/fs.h" then - if compile_module "BIO_FLUSH" "linux/bio.h" + if compile_module $cur_name "BIO_FLUSH" "linux/bio.h" then - echo "1" + echo $cur_name "1" >> $config_file_path else - echo "2" + echo $cur_name "2" >> $config_file_path fi - elif compile_module "REQ_PREFLUSH" "linux/blk_types.h" + elif compile_module $cur_name "REQ_PREFLUSH" "linux/blk_types.h" then - echo "3" + echo $cur_name "3" >> $config_file_path else - echo "4" + echo $cur_name "4" >> $config_file_path fi } diff --git a/configure.d/conf_framework b/configure.d/conf_framework index eb99cb7..d7be5e9 100644 --- a/configure.d/conf_framework +++ b/configure.d/conf_framework @@ -6,8 +6,6 @@ SCRIPTPATH=`dirname $0` SCRIPTPATH=`realpath $SCRIPTPATH` -MODULE_FILE=$SCRIPTPATH/test_mod.c -OBJ_MOD=$SCRIPTPATH/test_mod.o KERNEL_DIR="${KERNEL_DIR:-/lib/modules/$(uname -r)/build/}" KERNEL_VER="$(cd $KERNEL_DIR; make kernelversion)" NPROC=`nproc` @@ -23,48 +21,58 @@ add_function() { } compile_module(){ - if [ $# -gt 1 ] + if [ $# -gt 2 ] then - INCLUDE="#include <$2>" + INCLUDE="#include <$3>" else INCLUDE="" fi + config_file=$1 + test_module_dir=$SCRIPTPATH/configure.d/${config_file}_dir + test_module_file=$test_module_dir/test_mod.c + test_module_obj=$test_module_dir/test_mod.o + + mkdir -p $test_module_dir + cp -f $SCRIPTPATH/configure.d/Makefile $test_module_dir + ############# TEST MODULE ############# - cat > $MODULE_FILE <<- EOF + cat > $test_module_file <<- EOF #include #include $INCLUDE int init_module(void) { - $1; + $2; return 0; } void cleanup_module(void) {}; EOF ####################################### - make -C $SCRIPTPATH KERNEL_DIR=${KERNEL_DIR} &> /dev/null + make -C $test_module_dir KERNEL_DIR=${KERNEL_DIR} &> /dev/null local ret=$? - if [ $ret -eq 0 ]; then - make -C $SCRIPTPATH clean &> /dev/null - fi + + rm -Rf $test_module_dir return $ret } kernel_not_supp_fail() { - echo "Current kernel is not supported!" - rm $DEFINE_FILE - exit 1 + echo "Current kernel is not supported!" + rm $DEFINE_FILE + exit 1 } +# $1 - name of function to be called +# $2 - path to file with valid configs +# $3 - name of processed template file conf_run() { - case "$1" in - "check") check ;; - "apply") apply $2 ;; - esac + case "$1" in + "check") check $2 $3;; + "apply") apply $2 ;; + esac } IFS='?'