From 13c51041ff408ecf9f2c5d1b575116d5d7f5cc90 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Wed, 10 Jul 2019 14:57:12 +0200 Subject: [PATCH] Generate and apply config Allows for faster configuration in known environments Signed-off-by: Robert Baldyga Signed-off-by: Michal Mielewczyk --- configure | 50 +++++-- configure.d/1_append_bio.conf | 31 +++-- configure.d/1_bdev_lookup.conf | 35 +++-- configure.d/1_bio_clone.conf | 57 +++++--- configure.d/1_bio_cmpl.conf | 62 +++++---- configure.d/1_bio_discard.conf | 70 ++++++---- configure.d/1_bio_err.conf | 36 +++-- configure.d/1_bio_flags.conf | 39 ++++-- configure.d/1_bio_iter.conf | 51 +++++--- configure.d/1_biovec.conf | 31 +++-- configure.d/1_block_pc.conf | 31 +++-- configure.d/1_deamonize.conf | 31 +++-- configure.d/1_dentry.conf | 35 +++-- configure.d/1_discard_zeros.conf | 31 +++-- configure.d/1_flush_flag.conf | 43 ++++-- configure.d/1_generic_acct.conf | 174 ++++++++++++++----------- configure.d/1_global_page_state.conf | 62 +++++---- configure.d/1_hlist.conf | 51 +++++--- configure.d/1_inode.conf | 35 +++-- configure.d/1_munmap.conf | 75 ++++++----- configure.d/1_queue_bounce.conf | 31 +++-- configure.d/1_queue_chunk_sectors.conf | 31 +++-- configure.d/1_queue_flag_set.conf | 31 +++-- configure.d/1_queue_limits.conf | 107 ++++++++------- configure.d/1_req_fs.conf | 59 +++++---- configure.d/1_submit_bio.conf | 83 +++++++----- configure.d/1_whlt.conf | 23 +++- configure.d/1_write_flag.conf | 35 +++-- configure.d/1_write_fua.conf | 67 ++++++---- configure.d/2_bio_barrier.conf | 45 +++++-- configure.d/2_flush_fua.conf | 67 ++++++---- configure.d/2_make_req.conf | 75 ++++++----- configure.d/2_queue_write.conf | 75 ++++++----- configure.d/2_write_flush.conf | 81 +++++++----- configure.d/conf_framework | 7 + 35 files changed, 1224 insertions(+), 623 deletions(-) diff --git a/configure b/configure index c27bf7e..62ec6e5 100755 --- a/configure +++ b/configure @@ -3,23 +3,51 @@ # Copyright(c) 2012-2019 Intel Corporation # SPDX-License-Identifier: BSD-3-Clause-Clear # -which dirname 2>&1 > /dev/null || { echo >&2 "Eror: missing 'dirname' utility"; exit 1; } -which realpath 2>&1 > /dev/null || { echo >&2 "Eror: missing 'realpath' utility"; exit 1; } + +check_util() { + which $1 2>&1 > /dev/null || { echo >&2 "Error: missing '$1' utility"; exit 1; } +} + +check_util dirname +check_util realpath +check_util basename +check_util awk SCRIPTPATH=`dirname $0` SCRIPTPATH=`realpath $SCRIPTPATH` CONFIG_FILES=`ls $SCRIPTPATH/configure.d/*.conf | sort` +FILES_COUNT=`echo $CONFIG_FILES | wc -w` -rm -f $SCRIPTPATH/modules/generated_defines.h +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 "" +} -files_count=`echo $CONFIG_FILES | wc -w` -progress=0 +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 "" +} -for file in $CONFIG_FILES; do - progress=$((progress+1)) - echo -ne "Configuring OpenCAS: $progress/$files_count\033[0K\r" - /bin/bash $file -done -echo -ne " \033[0K\r" +if [ -z "$1" ]; then + generate_config + CONFIG_FILE="config.out" +else + CONFIG_FILE="$1" +fi +generate_header diff --git a/configure.d/1_append_bio.conf b/configure.d/1_append_bio.conf index 81be684..64b9de9 100644 --- a/configure.d/1_append_bio.conf +++ b/configure.d/1_append_bio.conf @@ -6,11 +6,26 @@ . `dirname $0`/conf_framework -if compile_module "struct bio *b;blk_rq_append_bio(NULL, &b)" "linux/blkdev.h" -then - add_define "cas_blk_rq_append_bio(rq, bounce_bio) \\ - blk_rq_append_bio(rq, &bounce_bio)" -else - add_define "cas_blk_rq_append_bio(rq, bounce_bio) \\ - blk_rq_append_bio(rq, bounce_bio)" -fi +check() { + if compile_module "struct bio *b;blk_rq_append_bio(NULL, &b)" "linux/blkdev.h" + then + echo "1" + else + echo "2" + fi +} + +apply() { + case "$1" in + "1") + add_define "cas_blk_rq_append_bio(rq, bounce_bio) \\ + blk_rq_append_bio(rq, &bounce_bio)" ;; + "2") + add_define "cas_blk_rq_append_bio(rq, bounce_bio) \\ + blk_rq_append_bio(rq, bounce_bio)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_bdev_lookup.conf b/configure.d/1_bdev_lookup.conf index 60c52bd..5d08334 100644 --- a/configure.d/1_bdev_lookup.conf +++ b/configure.d/1_bdev_lookup.conf @@ -6,12 +6,29 @@ . `dirname $0`/conf_framework -if compile_module "lookup_bdev(\"some_path\")" "linux/fs.h" -then - add_define "CAS_LOOKUP_BDEV(PATH) \\ - lookup_bdev(PATH)" -elif compile_module "lookup_bdev(\"some_path\", 0)" "linux/fs.h" -then - add_define "CAS_LOOKUP_BDEV(PATH) \\ - lookup_bdev(PATH, 0)" -fi +check() { + if compile_module "lookup_bdev(\"some_path\")" "linux/fs.h" + then + echo "1" + elif compile_module "lookup_bdev(\"some_path\", 0)" "linux/fs.h" + then + echo "2" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_LOOKUP_BDEV(PATH) \\ + lookup_bdev(PATH)" ;; + "2") + add_define "CAS_LOOKUP_BDEV(PATH) \\ + lookup_bdev(PATH, 0)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_bio_clone.conf b/configure.d/1_bio_clone.conf index cda76c6..9a00cf2 100644 --- a/configure.d/1_bio_clone.conf +++ b/configure.d/1_bio_clone.conf @@ -6,22 +6,41 @@ . `dirname $0`/conf_framework -if compile_module "bio_clone(NULL, 0)" "linux/bio.h" -then - add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask) - { - return bio_clone(bio, gfp_mask); - }" -elif compile_module "bio_clone_kmalloc(NULL, 0)" "linux/bio.h" -then - add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask) - { - return bio_clone_kmalloc(bio, gfp_mask); - }" -elif compile_module "bio_clone_fast(NULL, 0, NULL)" "linux/bio.h" -then - add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask) - { - return bio_clone_fast(bio, gfp_mask, NULL); - }" -fi +check() { + if compile_module "bio_clone(NULL, 0)" "linux/bio.h" + then + echo "1" + elif compile_module "bio_clone_kmalloc(NULL, 0)" "linux/bio.h" + then + echo "2" + elif compile_module "bio_clone_fast(NULL, 0, NULL)" "linux/bio.h" + then + echo "3" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask) + { + return bio_clone(bio, gfp_mask); + }" ;; + "2") + add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask) + { + return bio_clone_kmalloc(bio, gfp_mask); + }" ;; + "3") + add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask) + { + return bio_clone_fast(bio, gfp_mask, NULL); + }" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_bio_cmpl.conf b/configure.d/1_bio_cmpl.conf index 0ee2a0d..90c79de 100644 --- a/configure.d/1_bio_cmpl.conf +++ b/configure.d/1_bio_cmpl.conf @@ -6,26 +6,42 @@ . `dirname $0`/conf_framework -if compile_module "struct bio b;b.bi_end_io(NULL, 0)" "linux/bio.h" -then - add_define "CAS_BIO_ENDIO(BIO, BYTES_DONE, ERROR) \\ - bio_endio(BIO, ERROR)" - add_define "CAS_DECLARE_BLOCK_CALLBACK(name, BIO, BYTES_DONE, ERROR) \\ - void name##_callback(BIO, ERROR)" - add_define "CAS_BLOCK_CALLBACK_ERROR(BIO, ERROR) \\ - ERROR" -elif compile_module "struct bio b;b.bi_end_io(NULL)" "linux/bio.h" -then - add_define "CAS_BIO_ENDIO(BIO, BYTES_DONE, ERROR) \\ - ({ CAS_BIO_OP_STATUS(BIO) = ERROR; bio_endio(BIO); })" - add_define "CAS_DECLARE_BLOCK_CALLBACK(name, BIO, BYTES_DONE, ERROR) \\ - void name##_callback(BIO)" - add_define "CAS_BLOCK_CALLBACK_ERROR(BIO, ERROR) \\ - CAS_BIO_OP_STATUS(BIO)" -fi -add_define "CAS_REFER_BLOCK_CALLBACK(name) \\ - name##_callback" -add_define "CAS_BLOCK_CALLBACK_INIT(BIO) \\ - {; }" -add_define "CAS_BLOCK_CALLBACK_RETURN(BIO) \\ - { return; }" +check() { + if compile_module "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" + then + echo "2" + else + echo "X" + fi +} + +apply() { + add_define "CAS_REFER_BLOCK_CALLBACK(name) \\ + name##_callback" + add_define "CAS_BLOCK_CALLBACK_INIT(BIO) \\ + {; }" + add_define "CAS_BLOCK_CALLBACK_RETURN(BIO) \\ + { return; }" + + case "$1" in + "1") + add_define "CAS_BIO_ENDIO(BIO, BYTES_DONE, ERROR) \\ + bio_endio(BIO, ERROR)" + add_define "CAS_DECLARE_BLOCK_CALLBACK(name, BIO, BYTES_DONE, ERROR) \\ + void name##_callback(BIO, ERROR)" + add_define "CAS_BLOCK_CALLBACK_ERROR(BIO, ERROR) \\ + ERROR" ;; + "2") + add_define "CAS_BIO_ENDIO(BIO, BYTES_DONE, ERROR) \\ + ({ CAS_BIO_OP_STATUS(BIO) = ERROR; bio_endio(BIO); })" + add_define "CAS_DECLARE_BLOCK_CALLBACK(name, BIO, BYTES_DONE, ERROR) \\ + void name##_callback(BIO)" + add_define "CAS_BLOCK_CALLBACK_ERROR(BIO, ERROR) \\ + CAS_BIO_OP_STATUS(BIO)" ;; + esac +} + +conf_run $@ diff --git a/configure.d/1_bio_discard.conf b/configure.d/1_bio_discard.conf index 0d128b9..9fa2d7a 100644 --- a/configure.d/1_bio_discard.conf +++ b/configure.d/1_bio_discard.conf @@ -5,29 +5,49 @@ # . `dirname $0`/conf_framework +check() { + if compile_module "bio_op(NULL)" "linux/bio.h" + then + echo "1" + elif compile_module "REQ_OP_MASK" "linux/blk_types.h" + then + echo "2" + elif compile_module "REQ_OP_DISCARD" "linux/blk_types.h" + then + echo "3" + elif compile_module "REQ_DISCARD" "linux/blk_types.h" + then + echo "4" + else + echo "X" + fi +} -if compile_module "bio_op(NULL)" "linux/bio.h" -then - add_define "CAS_IS_DISCARD(bio) \\ - (bio_op(bio) == REQ_OP_DISCARD)" - add_define "CAS_BIO_DISCARD \\ - (REQ_OP_DISCARD)" -elif compile_module "REQ_OP_MASK" "linux/blk_types.h" -then - add_define "CAS_IS_DISCARD(bio) \\ - (((CAS_BIO_OP_FLAGS(bio)) & REQ_OP_MASK) == REQ_OP_DISCARD)" - add_define "CAS_BIO_DISCARD \\ - ((REQ_OP_WRITE | REQ_OP_DISCARD))" -elif compile_module "REQ_OP_DISCARD" "linux/blk_types.h" -then - add_define "CAS_IS_DISCARD(bio) \\ - ((CAS_BIO_OP_FLAGS(bio)) & REQ_OP_DISCARD)" - add_define "CAS_BIO_DISCARD \\ - ((REQ_OP_WRITE | REQ_OP_DISCARD))" -elif compile_module "REQ_DISCARD" "linux/blk_types.h" -then - add_define "CAS_IS_DISCARD(bio) \\ - ((CAS_BIO_OP_FLAGS(bio)) & REQ_DISCARD)" - add_define "CAS_BIO_DISCARD \\ - (REQ_WRITE | REQ_DISCARD)" -fi +apply() { + case "$1" in + "1") + add_define "CAS_IS_DISCARD(bio) \\ + (bio_op(bio) == REQ_OP_DISCARD)" + add_define "CAS_BIO_DISCARD \\ + (REQ_OP_DISCARD)" ;; + "2") + add_define "CAS_IS_DISCARD(bio) \\ + (((CAS_BIO_OP_FLAGS(bio)) & REQ_OP_MASK) == REQ_OP_DISCARD)" + add_define "CAS_BIO_DISCARD \\ + ((REQ_OP_WRITE | REQ_OP_DISCARD))" ;; + "3") + add_define "CAS_IS_DISCARD(bio) \\ + ((CAS_BIO_OP_FLAGS(bio)) & REQ_OP_DISCARD)" + add_define "CAS_BIO_DISCARD \\ + ((REQ_OP_WRITE | REQ_OP_DISCARD))" ;; + "4") + add_define "CAS_IS_DISCARD(bio) \\ + ((CAS_BIO_OP_FLAGS(bio)) & REQ_DISCARD)" + add_define "CAS_BIO_DISCARD \\ + (REQ_WRITE | REQ_DISCARD)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_bio_err.conf b/configure.d/1_bio_err.conf index b980a83..5adf64e 100644 --- a/configure.d/1_bio_err.conf +++ b/configure.d/1_bio_err.conf @@ -6,12 +6,30 @@ . `dirname $0`/conf_framework -if compile_module "struct bio b;b.bi_status" "linux/bio.h" -then - add_define "CAS_BIO_OP_STATUS(bio) \\ - bio->bi_status" -elif compile_module "struct bio b;b.bi_error" "linux/bio.h" -then - add_define "CAS_BIO_OP_STATUS(bio) \\ - bio->bi_error" -fi +check() { + if compile_module "struct bio b;b.bi_status" "linux/bio.h" + then + echo "1" + elif compile_module "struct bio b;b.bi_error" "linux/bio.h" + then + echo "2" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_BIO_OP_STATUS(bio) \\ + bio->bi_status" ;; + "2") + add_define "CAS_BIO_OP_STATUS(bio) \\ + bio->bi_error" ;; + *) + exit 1 + esac +} + +conf_run $@ + diff --git a/configure.d/1_bio_flags.conf b/configure.d/1_bio_flags.conf index 70f9083..0c04f0d 100644 --- a/configure.d/1_bio_flags.conf +++ b/configure.d/1_bio_flags.conf @@ -6,14 +6,31 @@ . `dirname $0`/conf_framework -if compile_module "struct bio b;b.bi_opf" "linux/bio.h" -then - add_define "CAS_BIO_OP_FLAGS_FORMAT \"0x%016X\"" - add_define "CAS_BIO_OP_FLAGS(bio) \\ - (bio)->bi_opf" -elif compile_module "struct bio b;b.bi_rw" "linux/bio.h" -then - add_define "CAS_BIO_OP_FLAGS_FORMAT \"0x%016lX\"" - add_define "CAS_BIO_OP_FLAGS(bio) \\ - (bio)->bi_rw" -fi +check() { + if compile_module "struct bio b;b.bi_opf" "linux/bio.h" + then + echo "1" + elif compile_module "struct bio b;b.bi_rw" "linux/bio.h" + then + echo "2" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_BIO_OP_FLAGS_FORMAT \"0x%016X\"" + add_define "CAS_BIO_OP_FLAGS(bio) \\ + (bio)->bi_opf" ;; + "2") + add_define "CAS_BIO_OP_FLAGS_FORMAT \"0x%016lX\"" + add_define "CAS_BIO_OP_FLAGS(bio) \\ + (bio)->bi_rw" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_bio_iter.conf b/configure.d/1_bio_iter.conf index 54c3d05..855e83e 100644 --- a/configure.d/1_bio_iter.conf +++ b/configure.d/1_bio_iter.conf @@ -6,20 +6,37 @@ . `dirname $0`/conf_framework -if compile_module "struct bio b;b.bi_iter.bi_size" "linux/bio.h" -then - add_define "CAS_BIO_BISIZE(bio) \\ - bio->bi_iter.bi_size" - add_define "CAS_BIO_BIIDX(bio) \\ - bio->bi_iter.bi_idx" - add_define "CAS_BIO_BISECTOR(bio) \\ - bio->bi_iter.bi_sector" -elif compile_module "struct bio b;b.bi_size" "linux/bio.h" -then - add_define "CAS_BIO_BISIZE(bio) \\ - bio->bi_size" - add_define "CAS_BIO_BIIDX(bio) \\ - bio->bi_idx" - add_define "CAS_BIO_BISECTOR(bio) \\ - bio->bi_sector" -fi +check() { + if compile_module "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" + then + echo "2" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_BIO_BISIZE(bio) \\ + bio->bi_iter.bi_size" + add_define "CAS_BIO_BIIDX(bio) \\ + bio->bi_iter.bi_idx" + add_define "CAS_BIO_BISECTOR(bio) \\ + bio->bi_iter.bi_sector" ;; + "2") + add_define "CAS_BIO_BISIZE(bio) \\ + bio->bi_size" + add_define "CAS_BIO_BIIDX(bio) \\ + bio->bi_idx" + add_define "CAS_BIO_BISECTOR(bio) \\ + bio->bi_sector" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_biovec.conf b/configure.d/1_biovec.conf index 758bcbe..c75a33b 100644 --- a/configure.d/1_biovec.conf +++ b/configure.d/1_biovec.conf @@ -6,11 +6,26 @@ . `dirname $0`/conf_framework -if compile_module "struct bio b;&bio_iovec(&b)" "linux/bio.h" -then - add_define "CAS_SEGMENT_BVEC(vec) \\ - (&(vec))" -else - add_define "CAS_SEGMENT_BVEC(vec) \\ - (vec)" -fi +check() { + if compile_module "struct bio b;&bio_iovec(&b)" "linux/bio.h" + then + echo "1" + else + echo "2" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_SEGMENT_BVEC(vec) \\ + (&(vec))" ;; + "2") + add_define "CAS_SEGMENT_BVEC(vec) \\ + (vec)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_block_pc.conf b/configure.d/1_block_pc.conf index 5cb4074..49de88c 100644 --- a/configure.d/1_block_pc.conf +++ b/configure.d/1_block_pc.conf @@ -6,11 +6,26 @@ . `dirname $0`/conf_framework -if compile_module "blk_rq_set_block_pc(NULL)" "linux/blkdev.h" -then - add_define "cas_blk_rq_set_block_pc(rq) \\ - blk_rq_set_block_pc(rq)" -else - add_define "cas_blk_rq_set_block_pc(rq) \\ - {}" -fi +check() { + if compile_module "blk_rq_set_block_pc(NULL)" "linux/blkdev.h" + then + echo "1" + else + echo "2" + fi +} + +apply() { + case "$1" in + "1") + add_define "cas_blk_rq_set_block_pc(rq) \\ + blk_rq_set_block_pc(rq)" ;; + "2") + add_define "cas_blk_rq_set_block_pc(rq) \\ + {}" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_deamonize.conf b/configure.d/1_deamonize.conf index 36f7570..1f5db26 100644 --- a/configure.d/1_deamonize.conf +++ b/configure.d/1_deamonize.conf @@ -6,11 +6,26 @@ . `dirname $0`/conf_framework -if compile_module "deamonize(\"some_name\", NULL)" "linux/sched.h" -then - add_define "CAS_DAEMONIZE(name, arg...) \\ - daemonize(name, ##arg)" -else - add_define "CAS_DAEMONIZE(name, arg...) \\ - do { } while (0)" -fi +check() { + if compile_module "deamonize(\"some_name\", NULL)" "linux/sched.h" + then + echo "1" + else + echo "2" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_DAEMONIZE(name, arg...) \\ + daemonize(name, ##arg)" ;; + "2") + add_define "CAS_DAEMONIZE(name, arg...) \\ + do { } while (0)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_dentry.conf b/configure.d/1_dentry.conf index ef3f6fe..0c285c0 100644 --- a/configure.d/1_dentry.conf +++ b/configure.d/1_dentry.conf @@ -6,12 +6,29 @@ . `dirname $0`/conf_framework -if compile_module "struct dentry dentry;dentry.d_u.d_alias" "linux/dcache.h" -then - add_define "CAS_ALIAS_NODE_TO_DENTRY(alias) \\ - container_of(alias, struct dentry, d_u.d_alias)" -elif compile_module "struct dentry dentry;dentry.d_alias" "linux/dcache.h" -then - add_define "CAS_ALIAS_NODE_TO_DENTRY(alias) \\ - container_of(alias, struct dentry, d_alias)" -fi +check() { + if compile_module "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" + then + echo "2" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_ALIAS_NODE_TO_DENTRY(alias) \\ + container_of(alias, struct dentry, d_u.d_alias)" ;; + "2") + add_define "CAS_ALIAS_NODE_TO_DENTRY(alias) \\ + container_of(alias, struct dentry, d_alias)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_discard_zeros.conf b/configure.d/1_discard_zeros.conf index eb80767..b28e50a 100644 --- a/configure.d/1_discard_zeros.conf +++ b/configure.d/1_discard_zeros.conf @@ -6,11 +6,26 @@ . `dirname $0`/conf_framework -if compile_module "struct queue_limits q;q.discard_zeroes_data" "linux/blkdev.h" -then - add_define "CAS_SET_DISCARD_ZEROES_DATA(queue_limits, val) \\ - queue_limits.discard_zeroes_data = val" -else - add_define "CAS_SET_DISCARD_ZEROES_DATA(queue_limits, val) \\ - ({})" -fi +check() { + if compile_module "struct queue_limits q;q.discard_zeroes_data" "linux/blkdev.h" + then + echo "1" + else + echo "2" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_SET_DISCARD_ZEROES_DATA(queue_limits, val) \\ + queue_limits.discard_zeroes_data = val" ;; + "2") + add_define "CAS_SET_DISCARD_ZEROES_DATA(queue_limits, val) \\ + ({})" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_flush_flag.conf b/configure.d/1_flush_flag.conf index f7973e1..83f677d 100644 --- a/configure.d/1_flush_flag.conf +++ b/configure.d/1_flush_flag.conf @@ -6,16 +6,33 @@ . `dirname $0`/conf_framework -if compile_module "REQ_PREFLUSH" "linux/blk_types.h" -then - add_define "CAS_REQ_FLUSH \\ - REQ_PREFLUSH" - add_define "CAS_FLUSH_SUPPORTED \\ - 1" -elif compile_module "REQ_FLUSH" "linux/blk_types.h" -then - add_define "CAS_REQ_FLUSH \\ - REQ_FLUSH" - add_define "CAS_FLUSH_SUPPORTED \\ - 1" -fi +check() { + if compile_module "REQ_PREFLUSH" "linux/blk_types.h" + then + echo "1" + elif compile_module "REQ_FLUSH" "linux/blk_types.h" + then + echo "2" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_REQ_FLUSH \\ + REQ_PREFLUSH" + add_define "CAS_FLUSH_SUPPORTED \\ + 1" ;; + "2") + add_define "CAS_REQ_FLUSH \\ + REQ_FLUSH" + add_define "CAS_FLUSH_SUPPORTED \\ + 1" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_generic_acct.conf b/configure.d/1_generic_acct.conf index 2f1da4a..2525ded 100644 --- a/configure.d/1_generic_acct.conf +++ b/configure.d/1_generic_acct.conf @@ -6,80 +6,100 @@ . `dirname $0`/conf_framework -if -compile_module "generic_start_io_acct(NULL, 0, 0, NULL)" "linux/bio.h" -then - add_function " -static inline void cas_generic_start_io_acct(struct request_queue *q, - int rw, unsigned long sectors, struct hd_struct *part) { - generic_start_io_acct(q, rw, sectors, part); -}" - add_function " -static inline void cas_generic_end_io_acct(struct request_queue *q, - int rw, struct hd_struct *part, unsigned long start_time) -{ - generic_end_io_acct(q, rw, part, start_time); -}" -elif compile_module "generic_start_io_acct(0, 0, NULL)" "linux/bio.h" -then - add_function " -static inline void cas_generic_start_io_acct(struct request_queue *q, - int rw, unsigned long sectors, struct hd_struct *part) -{ - generic_start_io_acct(rw, sectors, part); -}" - add_function " -static inline void cas_generic_end_io_acct(struct request_queue *q, - int rw, struct hd_struct *part, unsigned long start_time) -{ - generic_end_io_acct(rw, part, start_time); -}" -elif compile_module "part_round_stats(1, 1)" "linux/genhd.h" -then - add_function " -static inline void cas_generic_start_io_acct(struct request_queue *q, - int rw, unsigned long sectors, struct hd_struct *part) -{ - int cpu = part_stat_lock(); - part_round_stats(cpu, part); - part_stat_inc(cpu, part, ios[rw]); - part_stat_add(cpu, part, sectors[rw], sectors); - part_inc_in_flight(part, rw); - part_stat_unlock(); -}" - add_function " -static inline void cas_generic_end_io_acct(struct request_queue *q, - int rw, struct hd_struct *part, unsigned long start_time) -{ - unsigned long duration = jiffies - start_time; - int cpu = part_stat_lock(); - part_stat_add(cpu, part, ticks[rw], duration); - part_round_stats(cpu, part); - part_dec_in_flight(part, rw); - part_stat_unlock(); -}" -elif compile_module "part_round_stats(NULL, 1, 1)" "linux/genhd.h" -then - add_function " -static inline void cas_generic_start_io_acct(struct request_queue *q, - int rw, unsigned long sectors, struct hd_struct *part) -{ - int cpu = part_stat_lock(); - part_round_stats(NULL, cpu, part); - part_stat_inc(cpu, part, ios[rw]); - part_stat_add(cpu, part, sectors[rw], sectors); - part_inc_in_flight(NULL, part, rw); - part_stat_unlock(); -}" - add_function " -static inline void cas_generic_end_io_acct(struct request_queue *q, - int rw, struct hd_struct *part, unsigned long start_time) -{ - unsigned long duration = jiffies - start_time; - int cpu = part_stat_lock(); - part_stat_add(cpu, part, ticks[rw], duration); - part_round_stats(NULL, cpu, part); - part_dec_in_flight(NULL, part, rw); - part_stat_unlock(); -}" -fi +check() { + if compile_module "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" + then + echo "2" + elif compile_module "part_round_stats(1, 1)" "linux/genhd.h" + then + echo "3" + elif compile_module "part_round_stats(NULL, 1, 1)" "linux/genhd.h" + then + echo "4" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_function " + static inline void cas_generic_start_io_acct(struct request_queue *q, + int rw, unsigned long sectors, struct hd_struct *part) { + generic_start_io_acct(q, rw, sectors, part); + }" + add_function " + static inline void cas_generic_end_io_acct(struct request_queue *q, + int rw, struct hd_struct *part, unsigned long start_time) + { + generic_end_io_acct(q, rw, part, start_time); + }" ;; + "2") + add_function " + static inline void cas_generic_start_io_acct(struct request_queue *q, + int rw, unsigned long sectors, struct hd_struct *part) + { + generic_start_io_acct(rw, sectors, part); + }" + add_function " + static inline void cas_generic_end_io_acct(struct request_queue *q, + int rw, struct hd_struct *part, unsigned long start_time) + { + generic_end_io_acct(rw, part, start_time); + }" ;; + "3") + add_function " + static inline void cas_generic_start_io_acct(struct request_queue *q, + int rw, unsigned long sectors, struct hd_struct *part) + { + int cpu = part_stat_lock(); + part_round_stats(cpu, part); + part_stat_inc(cpu, part, ios[rw]); + part_stat_add(cpu, part, sectors[rw], sectors); + part_inc_in_flight(part, rw); + part_stat_unlock(); + }" + add_function " + static inline void cas_generic_end_io_acct(struct request_queue *q, + int rw, struct hd_struct *part, unsigned long start_time) + { + unsigned long duration = jiffies - start_time; + int cpu = part_stat_lock(); + part_stat_add(cpu, part, ticks[rw], duration); + part_round_stats(cpu, part); + part_dec_in_flight(part, rw); + part_stat_unlock(); + }" ;; + "4") + add_function " + static inline void cas_generic_start_io_acct(struct request_queue *q, + int rw, unsigned long sectors, struct hd_struct *part) + { + int cpu = part_stat_lock(); + part_round_stats(NULL, cpu, part); + part_stat_inc(cpu, part, ios[rw]); + part_stat_add(cpu, part, sectors[rw], sectors); + part_inc_in_flight(NULL, part, rw); + part_stat_unlock(); + }" + add_function " + static inline void cas_generic_end_io_acct(struct request_queue *q, + int rw, struct hd_struct *part, unsigned long start_time) + { + unsigned long duration = jiffies - start_time; + int cpu = part_stat_lock(); + part_stat_add(cpu, part, ticks[rw], duration); + part_round_stats(NULL, cpu, part); + part_dec_in_flight(NULL, part, rw); + part_stat_unlock(); + }" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_global_page_state.conf b/configure.d/1_global_page_state.conf index 386375d..5332cc2 100644 --- a/configure.d/1_global_page_state.conf +++ b/configure.d/1_global_page_state.conf @@ -6,27 +6,43 @@ . `dirname $0`/conf_framework +check() { + if compile_module "global_zone_page_state(1)" "linux/mm.h" + then + echo "1" + elif compile_module "global_page_state(1)" "linux/mm.h" + then + echo "2" + else + echo "X" + fi +} -if compile_module "global_zone_page_state(1)" "linux/mm.h" -then - add_function " -static inline unsigned long cas_global_zone_page_state(enum zone_stat_item item) - { - return global_zone_page_state(item); - }" - add_define "CAS_BIO_SET_DEV(bio, bdev) \\ - bio_set_dev(bio, bdev)" - add_define "CAS_BIO_GET_DEV(bio) \\ - bio->bi_disk" -elif compile_module "global_page_state(1)" "linux/mm.h" -then - add_function " -static inline unsigned long cas_global_zone_page_state(enum zone_stat_item item) - { - return global_page_state(item); - }" - add_define "CAS_BIO_SET_DEV(bio, bdev) \\ - bio->bi_bdev = bdev" - add_define "CAS_BIO_GET_DEV(bio) \\ - bio->bi_bdev->bd_disk" -fi +apply() { + case "$1" in + "1") + add_function " + static inline unsigned long cas_global_zone_page_state(enum zone_stat_item item) + { + return global_zone_page_state(item); + }" + add_define "CAS_BIO_SET_DEV(bio, bdev) \\ + bio_set_dev(bio, bdev)" + add_define "CAS_BIO_GET_DEV(bio) \\ + bio->bi_disk" ;; + "2") + add_function " + static inline unsigned long cas_global_zone_page_state(enum zone_stat_item item) + { + return global_page_state(item); + }" + add_define "CAS_BIO_SET_DEV(bio, bdev) \\ + bio->bi_bdev = bdev" + add_define "CAS_BIO_GET_DEV(bio) \\ + bio->bi_bdev->bd_disk" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_hlist.conf b/configure.d/1_hlist.conf index 6d1f45c..d60e19e 100644 --- a/configure.d/1_hlist.conf +++ b/configure.d/1_hlist.conf @@ -6,20 +6,37 @@ . `dirname $0`/conf_framework -if compile_module "struct hlist_node list" "linux/types.h" -then - add_define "CAS_ALIAS_NODE_TYPE \\ - struct hlist_node" - add_define "CAS_DENTRY_LIST_EMPTY(head) \\ - hlist_empty(head)" - add_define "CAS_INODE_FOR_EACH_DENTRY(pos, head) \\ - hlist_for_each(pos, head)" -elif compile_module "struct list_head list" "linux/list.h" -then - add_define "CAS_ALIAS_NODE_TYPE \\ - struct list_head" - add_define "CAS_DENTRY_LIST_EMPTY(head) \\ - list_empty(head)" - add_define "CAS_INODE_FOR_EACH_DENTRY(pos, head) \\ - list_for_each(pos, head)" -fi +check() { + if compile_module "struct hlist_node list" "linux/types.h" + then + echo "1" + elif compile_module "struct list_head list" "linux/list.h" + then + echo "2" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_ALIAS_NODE_TYPE \\ + struct hlist_node" + add_define "CAS_DENTRY_LIST_EMPTY(head) \\ + hlist_empty(head)" + add_define "CAS_INODE_FOR_EACH_DENTRY(pos, head) \\ + hlist_for_each(pos, head)" ;; + "2") + add_define "CAS_ALIAS_NODE_TYPE \\ + struct list_head" + add_define "CAS_DENTRY_LIST_EMPTY(head) \\ + list_empty(head)" + add_define "CAS_INODE_FOR_EACH_DENTRY(pos, head) \\ + list_for_each(pos, head)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_inode.conf b/configure.d/1_inode.conf index a925287..e89bfa1 100644 --- a/configure.d/1_inode.conf +++ b/configure.d/1_inode.conf @@ -6,12 +6,29 @@ . `dirname $0`/conf_framework -if compile_module "struct file file;file.f_inode" "linux/fs.h" -then - add_define "CAS_FILE_INODE(file) \\ - file->f_inode" -elif compile_module "struct file file;file->f_dentry->d_inode" "linux/fs.h" -then - add_define "CAS_FILE_INODE(file) \\ - file->f_dentry->d_inode" -fi +check() { + if compile_module "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" + then + echo "2" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_FILE_INODE(file) \\ + file->f_inode" ;; + "2") + add_define "CAS_FILE_INODE(file) \\ + file->f_dentry->d_inode" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_munmap.conf b/configure.d/1_munmap.conf index 2201a8b..895dadf 100644 --- a/configure.d/1_munmap.conf +++ b/configure.d/1_munmap.conf @@ -6,34 +6,51 @@ . `dirname $0`/conf_framework -if compile_module "vm_munmap(0, 0)" "linux/mm.h" -then - add_function " +check() { + if compile_module "vm_munmap(0, 0)" "linux/mm.h" + then + echo "1" + elif compile_module "do_munmap(NULL, 0)" "linux/mm.h" + then + echo "2" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_function " #include -static inline unsigned long cas_vm_mmap(struct file *file, - unsigned long addr, unsigned long len) -{ - return vm_mmap(file, addr, len, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, 0); -}" - add_function " -static inline int cas_vm_munmap(unsigned long start, size_t len) -{ - return vm_munmap(start, len); -}" -elif compile_module "do_munmap(NULL, 0)" "linux/mm.h" -then - add_function " + static inline unsigned long cas_vm_mmap(struct file *file, + unsigned long addr, unsigned long len) + { + return vm_mmap(file, addr, len, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, 0); + }" + add_function " + static inline int cas_vm_munmap(unsigned long start, size_t len) + { + return vm_munmap(start, len); + }" ;; + "2") + add_function " #include -static inline unsigned long cas_vm_mmap(struct file *file, - unsigned long addr, unsigned long len) -{ - return do_mmap_pgoff(file, addr, len, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, 0); -}" - add_function " -static inline int cas_vm_munmap(unsigned long start, size_t len) -{ - return do_munmap(current->mm, start, len); -}" -fi + static inline unsigned long cas_vm_mmap(struct file *file, + unsigned long addr, unsigned long len) + { + return do_mmap_pgoff(file, addr, len, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, 0); + }" + add_function " + static inline int cas_vm_munmap(unsigned long start, size_t len) + { + return do_munmap(current->mm, start, len); + }" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_queue_bounce.conf b/configure.d/1_queue_bounce.conf index 0c20524..4aee459 100644 --- a/configure.d/1_queue_bounce.conf +++ b/configure.d/1_queue_bounce.conf @@ -6,11 +6,26 @@ . `dirname $0`/conf_framework -if compile_module "blk_queue_bounce(NULL, NULL);" "linux/blkdev.h" -then - add_define "cas_blk_queue_bounce(q, bounce_bio) \\ - blk_queue_bounce(q, bounce_bio)" -else - add_define "cas_blk_queue_bounce(q, bounce_bio) \\ - ({})" -fi +check() { + if compile_module "blk_queue_bounce(NULL, NULL);" "linux/blkdev.h" + then + echo "1" + else + echo "2" + fi +} + +apply() { + case "$1" in + "1") + add_define "cas_blk_queue_bounce(q, bounce_bio) \\ + blk_queue_bounce(q, bounce_bio)" ;; + "2") + add_define "cas_blk_queue_bounce(q, bounce_bio) \\ + ({})" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_queue_chunk_sectors.conf b/configure.d/1_queue_chunk_sectors.conf index 84a2bf8..a04187b 100644 --- a/configure.d/1_queue_chunk_sectors.conf +++ b/configure.d/1_queue_chunk_sectors.conf @@ -6,11 +6,26 @@ . `dirname $0`/conf_framework -if compile_module "struct request_queue q;q.limits.chunk_sectors" "linux/blkdev.h" -then - add_define "CAS_SET_QUEUE_CHUNK_SECTORS(queue, chunk_size) \\ - queue->limits.chunk_sectors = chunk_size" -else - add_define "CAS_SET_QUEUE_CHUNK_SECTORS(queue, chunk_size) \\ - {;}" -fi +check() { + if compile_module "struct request_queue q;q.limits.chunk_sectors" "linux/blkdev.h" + then + echo "1" + else + echo "2" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_SET_QUEUE_CHUNK_SECTORS(queue, chunk_size) \\ + queue->limits.chunk_sectors = chunk_size" ;; + "2") + add_define "CAS_SET_QUEUE_CHUNK_SECTORS(queue, chunk_size) \\ + {;}" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_queue_flag_set.conf b/configure.d/1_queue_flag_set.conf index 0dcbcb4..1388e13 100644 --- a/configure.d/1_queue_flag_set.conf +++ b/configure.d/1_queue_flag_set.conf @@ -6,11 +6,26 @@ . `dirname $0`/conf_framework -if compile_module "blk_queue_flag_set(0, NULL)" "linux/blkdev.h" -then - add_define "cas_queue_flag_set_unlocked(flag, request_queue) \\ - blk_queue_flag_set(flag, request_queue)" -else - add_define "cas_queue_flag_set_unlocked(flag, request_queue) \\ - queue_flag_set_unlocked(flag, request_queue)" -fi +check() { + if compile_module "blk_queue_flag_set(0, NULL)" "linux/blkdev.h" + then + echo "1" + else + echo "2" + fi +} + +apply() { + case "$1" in + "1") + add_define "cas_queue_flag_set_unlocked(flag, request_queue) \\ + blk_queue_flag_set(flag, request_queue)" ;; + "2") + add_define "cas_queue_flag_set_unlocked(flag, request_queue) \\ + queue_flag_set_unlocked(flag, request_queue)" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_queue_limits.conf b/configure.d/1_queue_limits.conf index 0b55921..06cf53d 100644 --- a/configure.d/1_queue_limits.conf +++ b/configure.d/1_queue_limits.conf @@ -7,47 +7,66 @@ . `dirname $0`/conf_framework # RHEL 7.3 -if compile_module "struct queue_limits q;q.limits_aux" "linux/blkdev.h" -then - add_function " -static inline void cas_copy_queue_limits(struct request_queue *exp_q, - struct request_queue *cache_q, struct request_queue *core_q) -{ - struct queue_limits_aux *l_aux = exp_q->limits.limits_aux; - exp_q->limits = cache_q->limits; - exp_q->limits.limits_aux = l_aux; - if (exp_q->limits.limits_aux && cache_q->limits.limits_aux) - *exp_q->limits.limits_aux = *cache_q->limits.limits_aux; - exp_q->limits.max_sectors = core_q->limits.max_sectors; - exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors; - exp_q->limits.max_segments = core_q->limits.max_segments; - exp_q->limits.max_write_same_sectors = 0; - if (queue_virt_boundary(cache_q)) - queue_flag_set(QUEUE_FLAG_NOMERGES, cache_q); -}" -elif compile_module "struct queue_limits q;q.max_write_zeroes_sectors" "linux/blkdev.h" -then - add_function " -static inline void cas_copy_queue_limits(struct request_queue *exp_q, - struct request_queue *cache_q, struct request_queue *core_q) -{ - exp_q->limits = cache_q->limits; - exp_q->limits.max_sectors = core_q->limits.max_sectors; - exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors; - exp_q->limits.max_segments = core_q->limits.max_segments; - exp_q->limits.max_write_same_sectors = 0; - exp_q->limits.max_write_zeroes_sectors = 0; -}" -elif compile_module "struct queue_limits q;q.max_write_same_sectors" "linux/blkdev.h" -then - add_function " -static inline void cas_copy_queue_limits(struct request_queue *exp_q, - struct request_queue *cache_q, struct request_queue *core_q) -{ - exp_q->limits = cache_q->limits; - exp_q->limits.max_sectors = core_q->limits.max_sectors; - exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors; - exp_q->limits.max_segments = core_q->limits.max_segments; - exp_q->limits.max_write_same_sectors = 0; -}" -fi +check() { + if compile_module "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" + then + echo "2" + elif compile_module "struct queue_limits q;q.max_write_same_sectors" "linux/blkdev.h" + then + echo "3" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_function " + static inline void cas_copy_queue_limits(struct request_queue *exp_q, + struct request_queue *cache_q, struct request_queue *core_q) + { + struct queue_limits_aux *l_aux = exp_q->limits.limits_aux; + exp_q->limits = cache_q->limits; + exp_q->limits.limits_aux = l_aux; + if (exp_q->limits.limits_aux && cache_q->limits.limits_aux) + *exp_q->limits.limits_aux = *cache_q->limits.limits_aux; + exp_q->limits.max_sectors = core_q->limits.max_sectors; + exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors; + exp_q->limits.max_segments = core_q->limits.max_segments; + exp_q->limits.max_write_same_sectors = 0; + if (queue_virt_boundary(cache_q)) + queue_flag_set(QUEUE_FLAG_NOMERGES, cache_q); + }" ;; + "2") + add_function " + static inline void cas_copy_queue_limits(struct request_queue *exp_q, + struct request_queue *cache_q, struct request_queue *core_q) + { + exp_q->limits = cache_q->limits; + exp_q->limits.max_sectors = core_q->limits.max_sectors; + exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors; + exp_q->limits.max_segments = core_q->limits.max_segments; + exp_q->limits.max_write_same_sectors = 0; + exp_q->limits.max_write_zeroes_sectors = 0; + }" ;; + "3") + add_function " + static inline void cas_copy_queue_limits(struct request_queue *exp_q, + struct request_queue *cache_q, struct request_queue *core_q) + { + exp_q->limits = cache_q->limits; + exp_q->limits.max_sectors = core_q->limits.max_sectors; + exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors; + exp_q->limits.max_segments = core_q->limits.max_segments; + exp_q->limits.max_write_same_sectors = 0; + }" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_req_fs.conf b/configure.d/1_req_fs.conf index 92d9f9d..ba95802 100644 --- a/configure.d/1_req_fs.conf +++ b/configure.d/1_req_fs.conf @@ -6,25 +6,40 @@ . `dirname $0`/conf_framework -if compile_module "REQ_TYPE_FS" "linux/blkdev.h" -then - add_function " -static inline int cas_is_rq_type_fs(struct request *rq) -{ - return rq->cmd_type == REQ_TYPE_FS; -}" -else - add_function " -static inline int cas_is_rq_type_fs(struct request *rq) -{ - switch (req_op(rq)){ - case REQ_OP_READ: - case REQ_OP_WRITE: - case REQ_OP_FLUSH: - case REQ_OP_DISCARD: - return true; - default: - return false; - } -}" -fi +check() { + if compile_module "REQ_TYPE_FS" "linux/blkdev.h" + then + echo "1" + else + echo "2" + fi +} + +apply() { + case "$1" in + "1") + add_function " + static inline int cas_is_rq_type_fs(struct request *rq) + { + return rq->cmd_type == REQ_TYPE_FS; + }" ;; + "2") + add_function " + static inline int cas_is_rq_type_fs(struct request *rq) + { + switch (req_op(rq)){ + case REQ_OP_READ: + case REQ_OP_WRITE: + case REQ_OP_FLUSH: + case REQ_OP_DISCARD: + return true; + default: + return false; + } + }" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_submit_bio.conf b/configure.d/1_submit_bio.conf index 4652f26..867ee94 100644 --- a/configure.d/1_submit_bio.conf +++ b/configure.d/1_submit_bio.conf @@ -11,34 +11,55 @@ # * it takes one argument and retuns non-void # * it takes two arguments and returns non-void # * it takse two arguments and is void-type -if compile_module "submit_bio(NULL)" "linux/bio.h" -then - add_function " -static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio) -{ - CAS_BIO_OP_FLAGS(bio) |= rw; - return submit_bio(bio); -}" -elif compile_module "submit_bio(NULL)" "linux/fs.h" -then - add_function " -static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio) -{ - CAS_BIO_OP_FLAGS(bio) |= rw; - return submit_bio(bio); -}" -elif compile_module "void *t=submit_bio(0, NULL)" "linux/fs.h" -then - add_function " -static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio) -{ - return submit_bio(rw, bio); -}" -elif compile_module "submit_bio(0, NULL)" "linux/fs.h" -then - add_function " -static inline void cas_submit_bio(int rw, struct bio *bio) -{ - submit_bio(rw, bio); -}" -fi +check() { + if compile_module "submit_bio(NULL)" "linux/bio.h" + then + echo "1" + elif compile_module "submit_bio(NULL)" "linux/fs.h" + then + echo "2" + elif compile_module "void *t=submit_bio(0, NULL)" "linux/fs.h" + then + echo "3" + elif compile_module "submit_bio(0, NULL)" "linux/fs.h" + then + echo "4" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_function " + static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio) + { + CAS_BIO_OP_FLAGS(bio) |= rw; + return submit_bio(bio); + }" ;; + "2") + add_function " + static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio) + { + CAS_BIO_OP_FLAGS(bio) |= rw; + return submit_bio(bio); + }" ;; + "3") + add_function " + static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio) + { + return submit_bio(rw, bio); + }" ;; + "4") + add_function " + static inline void cas_submit_bio(int rw, struct bio *bio) + { + submit_bio(rw, bio); + }" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_whlt.conf b/configure.d/1_whlt.conf index 1a4e26e..d4bc1ee 100644 --- a/configure.d/1_whlt.conf +++ b/configure.d/1_whlt.conf @@ -6,8 +6,21 @@ . `dirname $0`/conf_framework -if compile_module "struct bio b;b.bi_write_hint" "linux/bio.h" -then - add_define "CAS_WLTH_SUPPORT \\ - 1" -fi +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 db41dff..94db6fc 100644 --- a/configure.d/1_write_flag.conf +++ b/configure.d/1_write_flag.conf @@ -6,12 +6,29 @@ . `dirname $0`/conf_framework -if compile_module "WRITE" "linux/blk_types.h" -then - add_define "CAS_RQ_DATA_DIR_WR \\ - WRITE" -elif compile_module "REQ_WRITE" "linux/blk_types.h" -then - add_define "CAS_RQ_DATA_DIR_WR \\ - REQ_WRITE" -fi +check() { + if compile_module "WRITE" "linux/blk_types.h" + then + echo "1" + elif compile_module "REQ_WRITE" "linux/blk_types.h" + then + echo "2" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_RQ_DATA_DIR_WR \\ + WRITE" ;; + "2") + add_define "CAS_RQ_DATA_DIR_WR \\ + REQ_WRITE" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/1_write_fua.conf b/configure.d/1_write_fua.conf index 98f7589..1a51e8e 100644 --- a/configure.d/1_write_fua.conf +++ b/configure.d/1_write_fua.conf @@ -6,27 +6,48 @@ . `dirname $0`/conf_framework -if compile_module "WRITE_FUA" "linux/fs.h" -then - add_define "CAS_WRITE_FUA \\ - WRITE_FUA" - if compile_module "BIO_FUA" "linux/bio.h" - then - add_define "CAS_IS_WRITE_FUA(flags) \\ - ((flags) & BIO_FUA)" - else - add_define "CAS_IS_WRITE_FUA(flags) \\ - ((flags) & REQ_FUA)" +check() { + if compile_module "WRITE_FUA" "linux/fs.h" + then + if compile_module "BIO_FUA" "linux/bio.h" + then + echo "1" + else + echo "2" + fi + elif compile_module "REQ_FUA" "linux/blk_types.h" + then + echo "3" + else + echo "4" fi -elif compile_module "REQ_FUA" "linux/blk_types.h" -then - add_define "CAS_IS_WRITE_FUA(flags) \\ - ((flags) & REQ_FUA)" - add_define "CAS_WRITE_FUA \\ - REQ_FUA" -else - add_define "CAS_IS_WRITE_FUA(flags) \\ - 0" - add_define "CAS_WRITE_FUA \\ - WRITE_BARRIER" -fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_WRITE_FUA \\ + WRITE_FUA" + add_define "CAS_IS_WRITE_FUA(flags) \\ + ((flags) & BIO_FUA)" ;; + "2") + add_define "CAS_WRITE_FUA \\ + WRITE_FUA" + add_define "CAS_IS_WRITE_FUA(flags) \\ + ((flags) & REQ_FUA)" ;; + "3") + add_define "CAS_IS_WRITE_FUA(flags) \\ + ((flags) & REQ_FUA)" + add_define "CAS_WRITE_FUA \\ + REQ_FUA" ;; + "4") + add_define "CAS_IS_WRITE_FUA(flags) \\ + 0" + add_define "CAS_WRITE_FUA \\ + WRITE_BARRIER" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/2_bio_barrier.conf b/configure.d/2_bio_barrier.conf index a2ec759..94288a3 100644 --- a/configure.d/2_bio_barrier.conf +++ b/configure.d/2_bio_barrier.conf @@ -6,16 +6,35 @@ . `dirname $0`/conf_framework -if compile_module "RQF_SOFTBARRIER" "linux/blkdev.h" -then - add_define "CAS_CHECK_BARRIER(bio) \\ - ((CAS_BIO_OP_FLAGS(bio) & RQF_SOFTBARRIER) != 0)" -elif compile_module "REQ_SOFTBARRIER" "linux/blk_types.h" -then - add_define "CAS_CHECK_BARRIER(bio) \\ - ((CAS_BIO_OP_FLAGS(bio) & REQ_SOFTBARRIER) != 0)" -elif compile_module "BIO_RW_BARRIER" "linux/fs.h" -then - add_define "CAS_CHECK_BARRIER(bio) \\ - (bio_rw_flagged((bio), BIO_RW_BARRIER))" -fi +check() { + if compile_module "RQF_SOFTBARRIER" "linux/blkdev.h" + then + echo "1" + elif compile_module "REQ_SOFTBARRIER" "linux/blk_types.h" + then + echo "2" + elif compile_module "BIO_RW_BARRIER" "linux/fs.h" + then + echo "3" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_CHECK_BARRIER(bio) \\ + ((CAS_BIO_OP_FLAGS(bio) & RQF_SOFTBARRIER) != 0)" ;; + "2") + add_define "CAS_CHECK_BARRIER(bio) \\ + ((CAS_BIO_OP_FLAGS(bio) & REQ_SOFTBARRIER) != 0)" ;; + "3") + add_define "CAS_CHECK_BARRIER(bio) \\ + (bio_rw_flagged((bio), BIO_RW_BARRIER))" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/2_flush_fua.conf b/configure.d/2_flush_fua.conf index 9365906..6d90825 100644 --- a/configure.d/2_flush_fua.conf +++ b/configure.d/2_flush_fua.conf @@ -6,27 +6,48 @@ . `dirname $0`/conf_framework -if compile_module "WRITE_FLUSH_FUA" "linux/fs.h" -then - add_define "CAS_WRITE_FLUSH_FUA \\ - WRITE_FLUSH_FUA" - if compile_module "BIO_FUA" "linux/bio.h" - then - add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\ - ((BIO_FUA | BIO_FLUSH) == ((flags) & (BIO_FUA | BIO_FLUSH)))" - else - add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\ - ((REQ_FUA | CAS_REQ_FLUSH) == ((flags) & (REQ_FUA | CAS_REQ_FLUSH)))" +check() { + if compile_module "WRITE_FLUSH_FUA" "linux/fs.h" + then + if compile_module "BIO_FUA" "linux/bio.h" + then + echo "1" + else + echo "2" + fi + elif compile_module "REQ_PREFLUSH" "linux/blk_types.h" + then + echo "3" + else + echo "4" fi -elif compile_module "REQ_PREFLUSH" "linux/blk_types.h" -then - add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\ - ((REQ_PREFLUSH | REQ_FUA) == ((flags) & (REQ_PREFLUSH |REQ_FUA)))" - add_define "CAS_WRITE_FLUSH_FUA \\ - (REQ_PREFLUSH | REQ_FUA)" -else - add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\ - 0" - add_define "CAS_WRITE_FLUSH_FUA \\ - WRITE_BARRIER" -fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_WRITE_FLUSH_FUA \\ + WRITE_FLUSH_FUA" + add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\ + ((BIO_FUA | BIO_FLUSH) == ((flags) & (BIO_FUA | BIO_FLUSH)))" ;; + "2") + add_define "CAS_WRITE_FLUSH_FUA \\ + WRITE_FLUSH_FUA" + add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\ + ((REQ_FUA | CAS_REQ_FLUSH) == ((flags) & (REQ_FUA | CAS_REQ_FLUSH)))" ;; + "3") + add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\ + ((REQ_PREFLUSH | REQ_FUA) == ((flags) & (REQ_PREFLUSH |REQ_FUA)))" + add_define "CAS_WRITE_FLUSH_FUA \\ + (REQ_PREFLUSH | REQ_FUA)" ;; + "4") + add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\ + 0" + add_define "CAS_WRITE_FLUSH_FUA \\ + WRITE_BARRIER" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/2_make_req.conf b/configure.d/2_make_req.conf index b294d4a..a6ae16e 100644 --- a/configure.d/2_make_req.conf +++ b/configure.d/2_make_req.conf @@ -6,34 +6,49 @@ . `dirname $0`/conf_framework -if compile_module "blk_make_request(NULL, NULL, 0)" "linux/blkdev.h" -then - add_function " -static inline struct request *cas_blk_make_request(struct request_queue *q, - struct bio *bio, gfp_t gfp_mask) -{ - return blk_make_request(q, bio, gfp_mask); -}" -else - add_function " -static inline struct request *cas_blk_make_request(struct request_queue *q, - struct bio *bio, gfp_t gfp_mask) -{ - struct request *rq = blk_get_request(q, bio_data_dir(bio), gfp_mask); - if (IS_ERR(rq)) - return rq; - cas_blk_rq_set_block_pc(rq); - rq->q = q; - for_each_bio(bio) { - struct bio *bounce_bio = bio; - int ret; - cas_blk_queue_bounce(q, &bounce_bio); - ret = cas_blk_rq_append_bio(rq, bounce_bio); - if (unlikely(ret)) { - blk_put_request(rq); - return ERR_PTR(ret); +check() { + if compile_module "blk_make_request(NULL, NULL, 0)" "linux/blkdev.h" + then + echo "1" + else + echo "2" + fi +} + +apply() { + case "$1" in + "1") + add_function " + static inline struct request *cas_blk_make_request(struct request_queue *q, + struct bio *bio, gfp_t gfp_mask) + { + return blk_make_request(q, bio, gfp_mask); + }" ;; + "2") + add_function " + static inline struct request *cas_blk_make_request(struct request_queue *q, + struct bio *bio, gfp_t gfp_mask) + { + struct request *rq = blk_get_request(q, bio_data_dir(bio), gfp_mask); + if (IS_ERR(rq)) + return rq; + cas_blk_rq_set_block_pc(rq); + rq->q = q; + for_each_bio(bio) { + struct bio *bounce_bio = bio; + int ret; + cas_blk_queue_bounce(q, &bounce_bio); + ret = cas_blk_rq_append_bio(rq, bounce_bio); + if (unlikely(ret)) { + blk_put_request(rq); + return ERR_PTR(ret); + } } - } - return rq; -}" -fi + return rq; + }" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/2_queue_write.conf b/configure.d/2_queue_write.conf index 34a6596..586ead2 100644 --- a/configure.d/2_queue_write.conf +++ b/configure.d/2_queue_write.conf @@ -6,33 +6,50 @@ . `dirname $0`/conf_framework -if compile_module "blk_queue_write_cache(NULL, 0, 0)" "linux/blkdev.h" -then - add_define "CAS_CHECK_QUEUE_FLUSH(q) \\ - test_bit(QUEUE_FLAG_WC, &(q)->queue_flags)" - add_define "CAS_CHECK_QUEUE_FUA(q) \\ - test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags)" - add_function " -static inline void cas_set_queue_flush_fua(struct request_queue *q, - bool flush, bool fua) -{ - blk_queue_write_cache(q, flush, fua); -}" -elif compile_module "struct request_queue rq;rq.flush_flags" "linux/blkdev.h" -then - add_define "CAS_CHECK_QUEUE_FLUSH(q) \\ - ((q)->flush_flags & CAS_REQ_FLUSH)" - add_define "CAS_CHECK_QUEUE_FUA(q) \\ - ((q)->flush_flags & REQ_FUA)" - add_function "static inline void cas_set_queue_flush_fua(struct request_queue *q, +check() { + if compile_module "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" + then + echo "2" + else + echo "X" + fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_CHECK_QUEUE_FLUSH(q) \\ + test_bit(QUEUE_FLAG_WC, &(q)->queue_flags)" + add_define "CAS_CHECK_QUEUE_FUA(q) \\ + test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags)" + add_function " + static inline void cas_set_queue_flush_fua(struct request_queue *q, bool flush, bool fua) -{ - unsigned int flags = 0; - if (flush) - flags |= CAS_REQ_FLUSH; - if (fua) - flags |= REQ_FUA; - if (flags) - blk_queue_flush(q, flags); -}" -fi + { + blk_queue_write_cache(q, flush, fua); + }" ;; + "2") + add_define "CAS_CHECK_QUEUE_FLUSH(q) \\ + ((q)->flush_flags & CAS_REQ_FLUSH)" + add_define "CAS_CHECK_QUEUE_FUA(q) \\ + ((q)->flush_flags & REQ_FUA)" + add_function "static inline void cas_set_queue_flush_fua(struct request_queue *q, + bool flush, bool fua) + { + unsigned int flags = 0; + if (flush) + flags |= CAS_REQ_FLUSH; + if (fua) + flags |= REQ_FUA; + if (flags) + blk_queue_flush(q, flags); + }" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/2_write_flush.conf b/configure.d/2_write_flush.conf index d689669..bf0c3d6 100644 --- a/configure.d/2_write_flush.conf +++ b/configure.d/2_write_flush.conf @@ -6,33 +6,56 @@ . `dirname $0`/conf_framework -if compile_module "WRITE_FLUSH" "linux/fs.h" -then - add_define "CAS_RQ_IS_FLUSH(rq) \\ - ((rq)->cmd_flags & CAS_REQ_FLUSH)" - add_define "CAS_WRITE_FLUSH \\ - WRITE_FLUSH" - if compile_module "BIO_FLUSH" "linux/bio.h" - then - add_define "CAS_IS_WRITE_FLUSH(flags) \\ - ((flags) & BIO_FLUSH)" - else - add_define "CAS_IS_WRITE_FLUSH(flags) \\ - ((flags) & CAS_REQ_FLUSH)" +check() { + if compile_module "WRITE_FLUSH" "linux/fs.h" + then + if compile_module "BIO_FLUSH" "linux/bio.h" + then + echo "1" + else + echo "2" + fi + elif compile_module "REQ_PREFLUSH" "linux/blk_types.h" + then + echo "3" + else + echo "4" fi -elif compile_module "REQ_PREFLUSH" "linux/blk_types.h" -then - add_define "CAS_RQ_IS_FLUSH(rq) \\ - ((rq)->cmd_flags & REQ_PREFLUSH)" - add_define "CAS_WRITE_FLUSH \\ - (REQ_OP_WRITE | REQ_PREFLUSH)" - add_define "CAS_IS_WRITE_FLUSH(flags) \\ - (CAS_WRITE_FLUSH == ((flags) & CAS_WRITE_FLUSH))" -else - add_define "CAS_RQ_IS_FLUSH(rq) \\ - 0" - add_define "CAS_IS_WRITE_FLUSH(flags) \\ - (WRITE_BARRIER == ((flags) & WRITE_BARRIER))" - add_define "CAS_WRITE_FLUSH \\ - WRITE_BARRIER" -fi +} + +apply() { + case "$1" in + "1") + add_define "CAS_RQ_IS_FLUSH(rq) \\ + ((rq)->cmd_flags & CAS_REQ_FLUSH)" + add_define "CAS_WRITE_FLUSH \\ + WRITE_FLUSH" + add_define "CAS_IS_WRITE_FLUSH(flags) \\ + ((flags) & BIO_FLUSH)" ;; + "2") + add_define "CAS_RQ_IS_FLUSH(rq) \\ + ((rq)->cmd_flags & CAS_REQ_FLUSH)" + add_define "CAS_WRITE_FLUSH \\ + WRITE_FLUSH" + add_define "CAS_IS_WRITE_FLUSH(flags) \\ + ((flags) & CAS_REQ_FLUSH)" ;; + "3") + add_define "CAS_RQ_IS_FLUSH(rq) \\ + ((rq)->cmd_flags & REQ_PREFLUSH)" + add_define "CAS_WRITE_FLUSH \\ + (REQ_OP_WRITE | REQ_PREFLUSH)" + add_define "CAS_IS_WRITE_FLUSH(flags) \\ + (CAS_WRITE_FLUSH == ((flags) & CAS_WRITE_FLUSH))" ;; + "4") + add_define "CAS_RQ_IS_FLUSH(rq) \\ + 0" + add_define "CAS_IS_WRITE_FLUSH(flags) \\ + (WRITE_BARRIER == ((flags) & WRITE_BARRIER))" + add_define "CAS_WRITE_FLUSH \\ + WRITE_BARRIER" ;; + *) + exit 1 + esac +} + +conf_run $@ diff --git a/configure.d/conf_framework b/configure.d/conf_framework index 48b29e3..eb99cb7 100644 --- a/configure.d/conf_framework +++ b/configure.d/conf_framework @@ -60,4 +60,11 @@ kernel_not_supp_fail() { exit 1 } +conf_run() { + case "$1" in + "check") check ;; + "apply") apply $2 ;; + esac +} + IFS='?'